babylon.module.d.ts 7.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815155816155817155818155819155820155821155822155823155824155825155826155827155828155829155830155831155832155833155834155835155836155837155838155839155840155841155842155843155844155845155846155847155848155849155850155851155852155853155854155855155856155857155858155859155860155861155862155863155864155865155866155867155868155869155870155871155872155873155874155875155876155877155878155879155880155881155882155883155884155885155886155887155888155889155890155891155892155893155894155895155896155897155898155899155900155901155902155903155904155905155906155907155908155909155910155911155912155913155914155915155916155917155918155919155920155921155922155923155924155925155926155927155928155929155930155931155932155933155934155935155936155937155938155939155940155941155942155943155944155945155946155947155948155949155950155951155952155953155954155955155956155957155958155959155960155961155962155963155964155965155966155967155968155969155970155971155972155973155974155975155976155977155978155979155980155981155982155983155984155985155986155987155988155989155990155991155992155993155994155995155996155997155998155999156000156001156002156003156004156005156006156007156008156009156010156011156012156013156014156015156016156017156018156019156020156021156022156023156024156025156026156027156028156029156030156031156032156033156034156035156036156037156038156039156040156041156042156043156044156045156046156047156048156049156050156051156052156053156054156055156056156057156058156059156060156061156062156063156064156065156066156067156068156069156070156071156072156073156074156075156076156077156078156079156080156081156082156083156084156085156086156087156088156089156090156091156092156093156094156095156096156097156098156099156100156101156102156103156104156105156106156107156108156109156110156111156112156113156114156115156116156117156118156119156120156121156122156123156124156125156126156127156128156129156130156131156132156133156134156135156136156137156138156139156140156141156142156143156144156145156146156147156148156149156150156151156152156153156154156155156156156157156158156159156160156161156162156163156164156165156166156167156168156169156170156171156172156173156174156175156176156177156178156179156180156181156182156183156184156185156186156187156188156189156190156191156192156193156194156195156196156197156198156199156200156201156202156203156204156205156206156207156208156209156210156211156212156213156214156215156216156217156218156219156220156221156222156223156224156225156226156227156228156229156230156231156232156233156234156235156236156237156238156239156240156241156242156243156244156245156246156247156248156249156250156251156252156253156254156255156256156257156258156259156260156261156262156263156264156265156266156267156268156269156270156271156272156273156274156275156276156277156278156279156280156281156282156283156284156285156286156287156288156289156290156291156292156293156294156295156296156297156298156299156300156301156302156303156304156305156306156307156308156309156310156311156312156313156314156315156316156317156318156319156320156321156322156323156324156325156326156327156328156329156330156331156332156333156334156335156336156337156338156339156340156341156342156343156344156345156346156347156348156349156350156351156352156353156354156355156356156357156358156359156360156361156362156363156364156365156366156367156368156369156370156371156372156373156374156375156376156377156378156379156380156381156382156383156384156385156386156387156388156389156390156391156392156393156394156395156396156397156398156399156400156401156402156403156404156405156406156407156408156409156410156411156412156413156414156415156416156417156418156419156420156421156422156423156424156425156426156427156428156429156430156431156432156433156434156435156436156437156438156439156440156441156442156443156444156445156446156447156448156449156450156451156452156453156454156455156456156457156458156459156460156461156462156463156464156465156466156467156468156469156470156471156472156473156474156475156476156477156478156479156480156481156482156483156484156485156486156487156488156489156490156491156492156493156494156495156496156497156498156499156500156501156502156503156504156505156506156507156508156509156510156511156512156513156514156515156516156517156518156519156520156521156522156523156524156525156526156527156528156529156530156531156532156533156534156535156536156537156538156539156540156541156542156543156544156545156546156547156548156549156550156551156552156553156554156555156556156557156558156559156560156561156562156563156564156565156566156567156568156569156570156571156572156573156574156575156576156577156578156579156580156581156582156583156584156585156586156587156588156589156590156591156592156593156594156595156596156597156598156599156600156601156602156603156604156605156606156607156608156609156610156611156612156613156614156615156616156617156618156619156620156621156622156623156624156625156626156627156628156629156630156631156632156633156634156635156636156637156638156639156640156641156642156643156644156645156646156647156648156649156650156651156652156653156654156655156656156657156658156659156660156661156662156663156664156665156666156667156668156669156670156671156672156673156674156675156676156677156678156679156680156681156682156683156684156685156686156687156688156689156690156691156692156693156694156695156696156697156698156699156700156701156702156703156704156705156706156707156708156709156710156711156712156713156714156715156716156717156718156719156720156721156722156723156724156725156726156727156728156729156730156731156732156733156734156735156736156737156738156739156740156741156742156743156744156745156746156747156748156749156750156751156752156753156754156755156756156757156758156759156760156761156762156763156764156765156766156767156768156769156770156771156772156773156774156775156776156777156778156779156780156781156782156783156784156785156786156787156788156789156790156791156792156793156794156795156796156797156798156799156800156801156802156803156804156805156806156807156808156809156810156811156812156813156814156815156816156817156818156819156820156821156822156823156824156825156826156827156828156829156830156831156832156833156834156835156836156837156838156839156840156841156842156843156844156845156846156847156848156849156850156851156852156853156854156855156856156857156858156859156860156861156862156863156864156865156866156867156868156869156870156871156872156873156874156875156876156877156878156879156880156881156882156883156884156885156886156887156888156889156890156891156892156893156894156895156896156897156898156899156900156901156902156903156904156905156906156907156908156909156910156911156912156913156914156915156916156917156918156919156920156921156922156923156924156925156926156927156928156929156930156931156932156933156934156935156936156937156938156939156940156941156942156943156944156945156946156947156948156949156950156951156952156953156954156955156956156957156958156959156960156961156962156963156964156965156966156967156968156969156970156971156972156973156974156975156976156977156978156979156980156981156982156983156984156985156986156987156988156989156990156991156992156993156994156995156996156997156998156999157000157001157002157003157004157005157006157007157008157009157010157011157012157013157014157015157016157017157018157019157020157021157022157023157024157025157026157027157028157029157030157031157032157033157034157035157036157037157038157039157040157041157042157043157044157045157046157047157048157049157050157051157052157053157054157055157056157057157058157059157060157061157062157063157064157065157066157067157068157069157070157071157072157073157074157075157076157077157078157079157080157081157082157083157084157085157086157087157088157089157090157091157092157093157094157095157096157097157098157099157100157101157102157103157104157105157106157107157108157109157110157111157112157113157114157115157116157117157118157119157120157121157122157123157124157125157126157127157128157129157130157131157132157133157134157135157136157137157138157139157140157141157142157143157144157145157146157147157148157149157150157151157152157153157154157155157156157157157158157159157160157161157162157163157164157165157166157167157168157169157170157171157172157173157174157175157176157177157178157179157180157181157182157183157184157185157186157187157188157189157190157191157192157193157194157195157196157197157198157199157200157201157202157203157204157205157206157207157208157209157210157211157212157213157214157215157216157217157218157219157220157221157222157223157224157225157226157227157228157229157230157231157232157233157234157235157236157237157238157239157240157241157242157243157244157245157246157247157248157249157250157251157252157253157254157255157256157257157258157259157260157261157262157263157264157265157266157267157268157269157270157271157272157273157274157275157276157277157278157279157280157281157282157283157284157285157286157287157288157289157290157291157292157293157294157295157296157297157298157299157300157301157302157303157304157305157306157307157308157309157310157311157312157313157314157315157316157317157318157319157320157321157322157323157324157325157326157327157328157329157330157331157332157333157334157335157336157337157338157339157340157341157342157343157344157345157346157347157348157349157350157351157352157353157354157355157356157357157358157359157360157361157362157363157364157365157366157367157368157369157370157371157372157373157374157375157376157377157378157379157380157381157382157383157384157385157386157387157388157389157390157391157392157393157394157395157396157397157398157399157400157401157402157403157404157405157406157407157408157409157410157411157412157413157414157415157416157417157418157419157420157421157422157423157424157425157426157427157428157429157430157431157432157433157434157435157436157437157438157439157440157441157442157443157444157445157446157447157448157449157450157451157452157453157454157455157456157457157458157459157460157461157462157463157464157465157466157467157468157469157470157471157472157473157474157475157476157477157478157479157480157481157482157483157484157485157486157487157488157489157490157491157492157493157494157495157496157497157498157499157500157501157502157503157504157505157506157507157508157509157510157511157512157513157514157515157516157517157518157519157520157521157522157523157524157525157526157527157528157529157530157531157532157533157534157535157536157537157538157539157540157541157542157543157544157545157546157547157548157549157550157551157552157553157554157555157556157557157558157559157560157561157562157563157564157565157566157567157568157569157570157571157572157573157574157575157576157577157578157579157580157581157582157583157584157585157586157587157588157589157590157591157592157593157594157595157596157597157598157599157600157601157602157603157604157605157606157607157608157609157610157611157612157613157614157615157616157617157618157619157620157621157622157623157624157625157626157627157628157629157630157631157632157633157634157635157636157637157638157639157640157641157642157643157644157645157646157647157648157649157650157651157652157653157654157655157656157657157658157659157660157661157662157663157664157665157666157667157668157669157670157671157672157673157674157675157676157677157678157679157680157681157682157683157684157685157686157687157688157689157690157691157692157693157694157695157696157697157698157699157700157701157702157703157704157705157706157707157708157709157710157711157712157713157714157715157716157717157718157719157720157721157722157723157724157725157726157727157728157729157730157731157732157733157734157735157736157737157738157739157740157741157742157743157744157745157746157747157748157749157750157751157752157753157754157755157756157757157758157759157760157761157762157763157764157765157766157767157768157769157770157771157772157773157774157775157776157777157778157779157780157781157782157783157784157785157786157787157788157789157790157791157792157793157794157795157796157797157798157799157800157801157802157803157804157805157806157807157808157809157810157811157812157813157814157815157816157817157818157819157820157821157822157823157824157825157826157827157828157829157830157831157832157833157834157835157836157837157838157839157840157841157842157843157844157845157846157847157848157849157850157851157852157853157854157855157856157857157858157859157860157861157862157863157864157865157866157867157868157869157870157871157872157873157874157875157876157877157878157879157880157881157882157883157884157885157886157887157888157889157890157891157892157893157894157895157896157897157898157899157900157901157902157903157904157905157906157907157908157909157910157911157912157913157914157915157916157917157918157919157920157921157922157923157924157925157926157927157928157929157930157931157932157933157934157935157936157937157938157939157940157941157942157943157944157945157946157947157948157949157950157951157952157953157954157955157956157957157958157959157960157961157962157963157964157965157966157967157968157969157970157971157972157973157974157975157976157977157978157979157980157981157982157983157984157985157986157987157988157989157990157991157992157993157994157995157996157997157998157999158000158001158002158003158004158005158006158007158008158009158010158011158012158013158014158015158016158017158018158019158020158021158022158023158024158025158026158027158028158029158030158031158032158033158034158035158036158037158038158039158040158041158042158043158044158045158046158047158048158049158050158051158052158053158054158055158056158057158058158059158060158061158062158063158064158065158066158067158068158069158070158071158072158073158074158075158076158077158078158079158080158081158082158083158084158085158086158087158088158089158090158091158092158093158094158095158096158097158098158099158100158101158102158103158104158105158106158107158108158109158110158111158112158113158114158115158116158117158118158119158120158121158122158123158124158125158126158127158128158129158130158131158132158133158134158135158136158137158138158139158140158141158142158143158144158145158146158147158148158149158150158151158152158153158154158155158156158157158158158159158160158161158162158163158164158165158166158167158168158169158170158171158172158173158174158175158176158177158178158179158180158181158182158183158184158185158186158187158188158189158190158191158192158193158194158195158196158197158198158199158200158201158202158203158204158205158206158207158208158209158210158211158212158213158214158215158216158217158218158219158220158221158222158223158224158225158226158227158228158229158230158231158232158233158234158235158236158237158238158239158240158241158242158243158244158245158246158247158248158249158250158251158252158253158254158255158256158257158258158259158260158261158262158263158264158265158266158267158268158269158270158271158272158273158274158275158276158277158278158279158280158281158282158283158284158285158286158287158288158289158290158291158292158293158294158295158296158297158298158299158300158301158302158303158304158305158306158307158308158309158310158311158312158313158314158315158316158317158318158319158320158321158322158323158324158325158326158327158328158329158330158331158332158333158334158335158336158337158338158339158340158341158342158343158344158345158346158347158348158349158350158351158352158353158354158355158356158357158358158359158360158361158362158363158364158365158366158367158368158369158370158371158372158373158374158375158376158377158378158379158380158381158382158383158384158385158386158387158388158389158390158391158392158393158394158395158396158397158398158399158400158401158402158403158404158405158406158407158408158409158410158411158412158413158414158415158416158417158418158419158420158421158422158423158424158425158426158427158428158429158430158431158432158433158434158435158436158437158438158439158440158441158442158443158444158445158446158447158448158449158450158451158452158453158454158455158456158457158458158459158460158461158462158463158464158465158466158467158468158469158470158471158472158473158474158475158476158477158478158479158480158481158482158483158484158485158486158487158488158489158490158491158492158493158494158495158496158497158498158499158500158501158502158503158504158505158506158507158508158509158510158511158512158513158514158515158516158517158518158519158520158521158522158523158524158525158526158527158528158529158530158531158532158533158534158535158536158537158538158539158540158541158542158543158544158545158546158547158548158549158550158551158552158553158554158555158556158557158558158559158560158561158562158563158564158565158566158567158568158569158570158571158572158573158574158575158576158577158578158579158580158581158582158583158584158585158586158587158588158589158590158591158592158593158594158595158596158597158598158599158600158601158602158603158604158605158606158607158608158609158610158611158612158613158614158615158616158617158618158619158620158621158622158623158624158625158626158627158628158629158630158631158632158633158634158635158636158637158638158639158640158641158642158643158644158645158646158647158648158649158650158651158652158653158654158655158656158657158658158659158660158661158662158663158664158665158666158667158668158669158670158671158672158673158674158675158676158677158678158679158680158681158682158683158684158685158686158687158688158689158690158691158692158693158694158695158696158697158698158699158700158701158702158703158704158705158706158707158708158709158710158711158712158713158714158715158716158717158718158719158720158721158722158723158724158725158726158727158728158729158730158731158732158733158734158735158736158737158738158739158740158741158742158743158744158745158746158747158748158749158750158751158752158753158754158755158756158757158758158759158760158761158762158763158764158765158766158767158768158769158770158771158772158773158774158775158776158777158778158779158780158781158782158783158784158785158786158787158788158789158790158791158792158793158794158795158796158797158798158799158800158801158802158803158804158805158806158807158808158809158810158811158812158813158814158815158816158817158818158819158820158821158822158823158824158825158826158827158828158829158830158831158832158833158834158835158836158837158838158839158840158841158842158843158844158845158846158847158848158849158850158851158852158853158854158855158856158857158858158859158860158861158862158863158864158865158866158867158868158869158870158871158872158873158874158875158876158877158878158879158880158881158882158883158884158885158886158887158888158889158890158891158892158893158894158895158896158897158898158899158900158901158902158903158904158905158906158907158908158909158910158911158912158913158914158915158916158917158918158919158920158921158922158923158924158925158926158927158928158929158930158931158932158933158934158935158936158937158938158939158940158941158942158943158944158945158946158947158948158949158950158951158952158953158954158955158956158957158958158959158960158961158962158963158964158965158966158967158968158969158970158971158972158973158974158975158976158977158978158979158980158981158982158983158984158985158986158987158988158989158990158991158992158993158994158995158996158997158998158999159000159001159002159003159004159005159006159007159008159009159010159011159012159013159014159015159016159017159018159019159020159021159022159023159024159025159026159027159028159029159030159031159032159033159034159035159036159037159038159039159040159041159042159043159044159045159046159047159048159049159050159051159052159053159054159055159056159057159058159059159060159061159062159063159064159065159066159067159068159069159070159071159072159073159074159075159076159077159078159079159080159081159082159083159084159085159086159087159088159089159090159091159092159093159094159095159096159097159098159099159100159101159102159103159104159105159106159107159108159109159110159111159112159113159114159115159116159117159118159119159120159121159122159123159124159125159126159127159128159129159130159131159132159133159134159135159136159137159138159139159140159141159142159143159144159145159146159147159148159149159150159151159152159153159154159155159156159157159158159159159160159161159162159163159164159165159166159167159168159169159170159171159172159173159174159175159176159177159178159179159180159181159182159183159184159185159186159187159188159189159190159191159192159193159194159195159196159197159198159199159200159201159202159203159204159205159206159207159208159209159210159211159212159213159214159215159216159217159218159219159220159221159222159223159224159225159226159227159228159229159230159231159232159233159234159235159236159237159238159239159240159241159242159243159244159245159246159247159248159249159250159251159252159253159254159255159256159257159258159259159260159261159262159263159264159265159266159267159268159269159270159271159272159273159274159275159276159277159278159279159280159281159282159283159284159285159286159287159288159289159290159291159292159293159294159295159296159297159298159299159300159301159302159303159304159305159306159307159308159309159310159311159312159313159314159315159316159317159318159319159320159321159322159323159324159325159326159327159328159329159330159331159332159333159334159335159336159337159338159339159340159341159342159343159344159345159346159347159348159349159350159351159352159353159354159355159356159357159358159359159360159361159362159363159364159365159366159367159368159369159370159371159372159373159374159375159376159377159378159379159380159381159382159383159384159385159386159387159388159389159390159391159392159393159394159395159396159397159398159399159400159401159402159403159404159405159406159407159408159409159410159411159412159413159414159415159416159417159418159419159420159421159422159423159424159425159426159427159428159429159430159431159432159433159434159435159436159437159438159439159440159441159442159443159444159445159446159447159448159449159450159451159452159453159454159455159456159457159458159459159460159461159462159463159464159465159466159467159468159469159470159471159472159473159474159475159476159477159478159479159480159481159482159483159484159485159486159487159488159489159490159491159492159493159494159495159496159497159498159499159500159501159502159503159504159505159506159507159508159509159510159511159512159513159514159515159516159517159518159519159520159521159522159523159524159525159526159527159528159529159530159531159532159533159534159535159536159537159538159539159540159541159542159543159544159545159546159547159548159549159550159551159552159553159554159555159556159557159558159559159560159561159562159563159564159565159566159567159568159569159570159571159572159573159574159575159576159577159578159579159580159581159582159583159584159585159586159587159588159589159590159591159592159593159594159595159596159597159598159599159600159601159602159603159604159605159606159607159608159609159610159611159612159613159614159615159616159617159618159619159620159621159622159623159624159625159626159627159628159629159630159631159632159633159634159635159636159637159638159639159640159641159642159643159644159645159646159647159648159649159650159651159652159653159654159655159656159657159658159659159660159661159662159663159664159665159666159667159668159669159670159671159672159673159674159675159676159677159678159679159680159681159682159683159684159685159686159687159688159689159690159691159692159693159694159695159696159697159698159699159700159701159702159703159704159705159706159707159708159709159710159711159712159713159714159715159716159717159718159719159720159721159722159723159724159725159726159727159728159729159730159731159732159733159734159735159736159737159738159739159740159741159742159743159744159745159746159747159748159749159750159751159752159753159754159755159756159757159758159759159760159761159762159763159764159765159766159767159768159769159770159771159772159773159774159775159776159777159778159779159780159781159782159783159784159785159786159787159788159789159790159791159792159793159794159795159796159797159798159799159800159801159802159803159804159805159806159807159808159809159810159811159812159813159814159815159816159817159818159819159820159821159822159823159824159825159826159827159828159829159830159831159832159833159834159835159836159837159838159839159840159841159842159843159844159845159846159847159848159849159850159851159852159853159854159855159856159857159858159859159860159861159862159863159864159865159866159867159868159869159870159871159872159873159874159875159876159877159878159879159880159881159882159883159884159885159886159887159888159889159890159891159892159893159894159895159896159897159898159899159900159901159902159903159904159905159906159907159908159909159910159911159912159913159914159915159916159917159918159919159920159921159922159923159924159925159926159927159928159929159930159931159932159933159934159935159936159937159938159939159940159941159942159943159944159945159946159947159948159949159950159951159952159953159954159955159956159957159958159959159960159961159962159963159964159965159966159967159968159969159970159971159972159973159974159975159976159977159978159979159980159981159982159983159984159985159986159987159988159989159990159991159992159993159994159995159996159997159998159999160000160001160002160003160004160005160006160007160008160009160010160011160012160013160014160015160016160017160018160019160020160021160022160023160024160025160026160027160028160029160030160031160032160033160034160035160036160037160038160039160040160041160042160043160044160045160046160047160048160049160050160051160052160053160054160055160056160057160058160059160060160061160062160063160064160065160066160067160068160069160070160071160072160073160074160075160076160077160078160079160080160081160082160083160084160085160086160087160088160089160090160091160092160093160094160095160096160097160098160099160100160101160102160103160104160105160106160107160108160109160110160111160112160113160114160115160116160117160118160119160120160121160122160123160124160125160126160127160128160129160130160131160132160133160134160135160136160137160138160139160140160141160142160143160144160145160146160147160148160149160150160151160152160153160154160155160156160157160158160159160160160161160162160163160164160165160166160167160168160169160170160171160172160173160174160175160176160177160178160179160180160181160182160183160184160185160186160187160188160189160190160191160192160193160194160195160196160197160198160199160200160201160202160203160204160205160206160207160208160209160210160211160212160213160214160215160216160217160218160219160220160221160222160223160224160225160226160227160228160229160230160231160232160233160234160235160236160237160238160239160240160241160242160243160244160245160246160247160248160249160250160251160252160253160254160255160256160257160258160259160260160261160262160263160264160265160266160267160268160269160270160271160272160273160274160275160276160277160278160279160280160281160282160283160284160285160286160287160288160289160290160291160292160293160294160295160296160297160298160299160300160301160302160303160304160305160306160307160308160309160310160311160312160313160314160315160316160317160318160319160320160321160322160323160324160325160326160327160328160329160330160331160332160333160334160335160336160337160338160339160340160341160342160343160344160345160346160347160348160349160350160351160352160353160354160355160356160357160358160359160360160361160362160363160364160365160366160367160368160369160370160371160372160373160374160375160376160377160378160379160380160381160382160383160384160385160386160387160388160389160390160391160392160393160394160395160396160397160398160399160400160401160402160403160404160405160406160407160408160409160410160411160412160413160414160415160416160417160418160419160420160421160422160423160424160425160426160427160428160429160430160431160432160433160434160435160436160437160438160439160440160441160442160443160444160445160446160447160448160449160450160451160452160453160454160455160456160457160458160459160460160461160462160463160464160465160466160467160468160469160470160471160472160473160474160475160476160477160478160479160480160481160482160483160484160485160486160487160488160489160490160491160492160493160494160495160496160497160498160499160500160501160502160503160504160505160506160507160508160509160510160511160512160513160514160515160516160517160518160519160520160521160522160523160524160525160526160527160528160529160530160531160532160533160534160535160536160537160538160539160540160541160542160543160544160545160546160547160548160549160550160551160552160553160554160555160556160557160558160559160560160561160562160563160564160565160566160567160568160569160570160571160572160573160574160575160576160577160578160579160580160581160582160583160584160585160586160587160588160589160590160591160592160593160594160595160596160597160598160599160600160601160602160603160604160605160606160607160608160609160610160611160612160613160614160615160616160617160618160619160620160621160622160623160624160625160626160627160628160629160630160631160632160633160634160635160636160637160638160639160640160641160642160643160644160645160646160647160648160649160650160651160652160653160654160655160656160657160658160659160660160661160662160663160664160665160666160667160668160669160670160671160672160673160674160675160676160677160678160679160680160681160682160683160684160685160686160687160688160689160690160691160692160693160694160695160696160697160698160699160700160701160702160703160704160705160706160707160708160709160710160711160712160713160714160715160716160717160718160719160720160721160722160723160724160725160726160727160728160729160730160731160732160733160734160735160736160737160738160739160740160741160742160743160744160745160746160747160748160749160750160751160752160753160754160755160756160757160758160759160760160761160762160763160764160765160766160767160768160769160770160771160772160773160774160775160776160777160778160779160780160781160782160783160784160785160786160787160788160789160790160791160792160793160794160795160796160797160798160799160800160801160802160803160804160805160806160807160808160809160810160811160812160813160814160815160816160817160818160819160820160821160822160823160824160825160826160827160828160829160830160831160832160833160834160835160836160837160838160839160840160841160842160843160844160845160846160847160848160849160850160851160852160853160854160855160856160857160858160859160860160861160862160863160864160865160866160867160868160869160870160871160872160873160874160875160876160877160878160879160880160881160882160883160884160885160886160887160888160889160890160891160892160893160894160895160896160897160898160899160900160901160902160903160904160905160906160907160908160909160910160911160912160913160914160915160916160917160918160919160920160921160922160923160924160925160926160927160928160929160930160931160932160933160934160935160936160937160938160939160940160941160942160943160944160945160946160947160948160949160950160951160952160953160954160955160956160957160958160959160960160961160962160963160964160965160966160967160968160969160970160971160972160973160974160975160976160977160978160979160980160981160982160983160984160985160986160987160988160989160990160991160992160993160994160995160996160997160998160999161000161001161002161003161004161005161006161007161008161009161010161011161012161013161014161015161016161017161018161019161020161021161022161023161024161025161026161027161028161029161030161031161032161033161034161035161036161037161038161039161040161041161042161043161044161045161046161047161048161049161050161051161052161053161054161055161056161057161058161059161060161061161062161063161064161065161066161067161068161069161070161071161072161073161074161075161076161077161078161079161080161081161082161083161084161085161086161087161088161089161090161091161092161093161094161095161096161097161098161099161100161101161102161103161104161105161106161107161108161109161110161111161112161113161114161115161116161117161118161119161120161121161122161123161124161125161126161127161128161129161130161131161132161133161134161135161136161137161138161139161140161141161142161143161144161145161146161147161148161149161150161151161152161153161154161155161156161157161158161159161160161161161162161163161164161165161166161167161168161169161170161171161172161173161174161175161176161177161178161179161180161181161182161183161184161185161186161187161188161189161190161191161192161193161194161195161196161197161198161199161200161201161202161203161204161205161206161207161208161209161210161211161212161213161214161215161216161217161218161219161220161221161222161223161224161225161226161227161228161229161230161231161232161233161234161235161236161237161238161239161240161241161242161243161244161245161246161247161248161249161250161251161252161253161254161255161256161257161258161259161260161261161262161263161264161265161266161267161268161269161270161271161272161273161274161275161276161277161278161279161280161281161282161283161284161285161286161287161288161289161290161291161292161293161294161295161296161297161298161299161300161301161302161303161304161305161306161307161308161309161310161311161312161313161314161315161316161317161318161319161320161321161322161323161324161325161326161327161328161329161330161331161332161333161334161335161336161337161338161339161340161341161342161343161344161345161346161347161348161349161350161351161352161353161354161355161356161357161358161359161360161361161362161363161364161365161366161367161368161369161370161371161372161373161374161375161376161377161378161379161380161381161382161383161384161385161386161387161388161389161390161391161392161393161394161395161396161397161398161399161400161401161402161403161404161405161406161407161408161409161410161411161412161413161414161415161416161417161418161419161420161421161422161423161424161425161426161427161428161429161430161431161432161433161434161435161436161437161438161439161440161441161442161443161444161445161446161447161448161449161450161451161452161453161454161455161456161457161458161459161460161461161462161463161464161465161466161467161468161469161470161471161472161473161474161475161476161477161478161479161480161481161482161483161484161485161486161487161488161489161490161491161492161493161494161495161496161497161498161499161500161501161502161503161504161505161506161507161508161509161510161511161512161513161514161515161516161517161518161519161520161521161522161523161524161525161526161527161528161529161530161531161532161533161534161535161536161537161538161539161540161541161542161543161544161545161546161547161548161549161550161551161552161553161554161555161556161557161558161559161560161561161562161563161564161565161566161567161568161569161570161571161572161573161574161575161576161577161578161579161580161581161582161583161584161585161586161587161588161589161590161591161592161593161594161595161596161597161598161599161600161601161602161603161604161605161606161607161608161609161610161611161612161613161614161615161616161617161618161619161620161621161622161623161624161625161626161627161628161629161630161631161632161633161634161635161636161637161638161639161640161641161642161643161644161645161646161647161648161649161650161651161652161653161654161655161656161657161658161659161660161661161662161663161664161665161666161667161668161669161670161671161672161673161674161675161676161677161678161679161680161681161682161683161684161685161686161687161688161689161690161691161692161693161694161695161696161697161698161699161700161701161702161703161704161705161706161707161708161709161710161711161712161713161714161715161716161717161718161719161720161721161722161723161724161725161726161727161728161729161730161731161732161733161734161735161736161737161738161739161740161741161742161743161744161745161746161747161748161749161750161751161752161753161754161755161756161757161758161759161760161761161762161763161764161765161766161767161768161769161770161771161772161773161774161775161776161777161778161779161780161781161782161783161784161785161786161787161788161789161790161791161792161793161794161795161796161797161798161799161800161801161802161803161804161805161806161807161808161809161810161811161812161813161814161815161816161817161818161819161820161821161822161823161824161825161826161827161828161829161830161831161832161833161834161835161836161837161838161839161840161841161842161843161844161845161846161847161848161849161850161851161852161853161854161855161856161857161858161859161860161861161862161863161864161865161866161867161868161869161870161871161872161873161874161875161876161877161878161879161880161881161882161883161884161885161886161887161888161889161890161891161892161893161894161895161896161897161898161899161900161901161902161903161904161905161906161907161908161909161910161911161912161913161914161915161916161917161918161919161920161921161922161923161924161925161926161927161928161929161930161931161932161933161934161935161936161937161938161939161940161941161942161943161944161945161946161947161948161949161950161951161952161953161954161955161956161957161958161959161960161961161962161963161964161965161966161967161968161969161970161971161972161973161974161975161976161977161978161979161980161981161982161983161984161985161986161987161988161989161990161991161992161993161994161995161996161997161998161999162000162001162002162003162004162005162006162007162008162009162010162011162012162013162014162015162016162017162018162019162020162021162022162023162024162025162026162027162028162029162030162031162032162033162034162035162036162037162038162039162040162041162042162043162044162045162046162047162048162049162050162051162052162053162054162055162056162057162058162059162060162061162062162063162064162065162066162067162068162069162070162071162072162073162074162075162076162077162078162079162080162081162082162083162084162085162086162087162088162089162090162091162092162093162094162095162096162097162098162099162100162101162102162103162104162105162106162107162108162109162110162111162112162113162114162115162116162117162118162119162120162121162122162123162124162125162126162127162128162129162130162131162132162133162134162135162136162137162138162139162140162141162142162143162144162145162146162147162148162149162150162151162152162153162154162155162156162157162158162159162160162161162162162163162164162165162166162167162168162169162170162171162172162173162174162175162176162177162178162179162180162181162182162183162184162185162186162187162188162189162190162191162192162193162194162195162196162197162198162199162200162201162202162203162204162205162206162207162208162209162210162211162212162213162214162215162216162217162218162219162220162221162222162223162224162225162226162227162228162229162230162231162232162233162234162235162236162237162238162239162240162241162242162243162244162245162246162247162248162249162250162251162252162253162254162255162256162257162258162259162260162261162262162263162264162265162266162267162268162269162270162271162272162273162274162275162276162277162278162279162280162281162282162283162284162285162286162287162288162289162290162291162292162293162294162295162296162297162298162299162300162301162302162303162304162305162306162307162308162309162310162311162312162313162314162315162316162317162318162319162320162321162322162323162324162325162326162327162328162329162330162331162332162333162334162335162336162337162338162339162340162341162342162343162344162345162346162347162348162349162350162351162352162353162354162355162356162357162358162359162360162361162362162363162364162365162366162367162368162369162370162371162372162373162374162375162376162377162378162379162380162381162382162383162384162385162386162387162388162389162390162391162392162393162394162395162396162397162398162399162400162401162402162403162404162405162406162407162408162409162410162411162412162413162414162415162416162417162418162419162420162421162422162423162424162425162426162427162428162429162430162431162432162433162434162435162436162437162438162439162440162441162442162443162444162445162446162447162448162449162450162451162452162453162454162455162456162457162458162459162460162461162462162463162464162465162466162467162468162469162470162471162472162473162474162475162476162477162478162479162480162481162482162483162484162485162486162487162488162489162490162491162492162493162494162495162496162497162498162499162500162501162502162503162504162505162506162507162508162509162510162511162512162513162514162515162516162517162518162519162520162521162522162523162524162525162526162527162528162529162530162531162532162533162534162535162536162537162538162539162540162541162542162543162544162545162546162547162548162549162550162551162552162553162554162555162556162557162558162559162560162561162562162563162564162565162566162567162568162569162570162571162572162573162574162575162576162577162578162579162580162581162582162583162584162585162586162587162588162589162590162591162592162593162594162595162596162597162598162599162600162601162602162603162604162605162606162607162608162609162610162611162612162613162614162615162616162617162618162619162620162621162622162623162624162625162626162627162628162629162630162631162632162633162634162635162636162637162638162639162640162641162642162643162644162645162646162647162648162649162650162651162652162653162654162655162656162657162658162659162660162661162662162663162664162665162666162667162668162669162670162671162672162673162674162675162676162677162678162679162680162681162682162683162684162685162686162687162688162689162690162691162692162693162694162695162696162697162698162699162700162701162702162703162704162705162706162707162708162709162710162711162712162713162714162715162716162717162718162719162720162721162722162723162724162725162726162727162728162729162730162731162732162733162734162735162736162737162738162739162740162741162742162743162744162745162746162747162748162749162750162751162752162753162754162755162756162757162758162759162760162761162762162763162764162765162766162767162768162769162770162771162772162773162774162775162776162777162778162779162780162781162782162783162784162785162786162787162788162789162790162791162792162793162794162795162796162797162798162799162800162801162802162803162804162805162806162807162808162809162810162811162812162813162814162815162816162817162818162819162820162821162822162823162824162825162826162827162828162829162830162831162832162833162834162835162836162837162838162839162840162841162842162843162844162845162846162847162848162849162850162851162852162853162854162855162856162857162858162859162860162861162862162863162864162865162866162867162868162869162870162871162872162873162874162875162876162877162878162879162880162881162882162883162884162885162886162887162888162889162890162891162892162893162894162895162896162897162898162899162900162901162902162903162904162905162906162907162908162909162910162911162912162913162914162915162916162917162918162919162920162921162922162923162924162925162926162927162928162929162930162931162932162933162934162935162936162937162938162939162940162941162942162943162944162945162946162947162948162949162950162951162952162953162954162955162956162957162958162959162960162961162962162963162964162965162966162967162968162969162970162971162972162973162974162975162976162977162978162979162980162981162982162983162984162985162986162987162988162989162990162991162992162993162994162995162996162997162998162999163000163001163002163003163004163005163006163007163008163009163010163011163012163013163014163015163016163017163018163019163020163021163022163023163024163025163026163027163028163029163030163031163032163033163034163035163036163037163038163039163040163041163042163043163044163045163046163047163048163049163050163051163052163053163054163055163056163057163058163059163060163061163062163063163064163065163066163067163068163069163070163071163072163073163074163075163076163077163078163079163080163081163082163083163084163085163086163087163088163089163090163091163092163093163094163095163096163097163098163099163100163101163102163103163104163105163106163107163108163109163110163111163112163113163114163115163116163117163118163119163120163121163122163123163124163125163126163127163128163129163130163131163132163133163134163135163136163137163138163139163140163141163142163143163144163145163146163147163148163149163150163151163152163153163154163155163156163157163158163159163160163161163162163163163164163165163166163167163168163169163170163171163172163173163174163175163176163177163178163179163180163181163182163183163184163185163186163187163188163189163190163191163192163193163194163195163196163197163198163199163200163201163202163203163204163205163206163207163208163209163210163211163212163213163214163215163216163217163218163219163220163221163222163223163224163225163226163227163228163229163230163231163232163233163234163235163236163237163238163239163240163241163242163243163244163245163246163247163248163249163250163251163252163253163254163255163256163257163258163259163260163261163262163263163264163265163266163267163268163269163270163271163272163273163274163275163276163277163278163279163280163281163282163283163284163285163286163287163288163289163290163291163292163293163294163295163296163297163298163299163300163301163302163303163304163305163306163307163308163309163310163311163312163313163314163315163316163317163318163319163320163321163322163323163324163325163326163327163328163329163330163331163332163333163334163335163336163337163338163339163340163341163342163343163344163345163346163347163348163349163350163351163352163353163354163355163356163357163358163359163360163361163362163363163364163365163366163367163368163369163370163371163372163373163374163375163376163377163378163379163380163381163382163383163384163385163386163387163388163389163390163391163392163393163394163395163396163397163398163399163400163401163402163403163404163405163406163407163408163409163410163411163412163413163414163415163416163417163418163419163420163421163422163423163424163425163426163427163428163429163430163431163432163433163434163435163436163437163438163439163440163441163442163443163444163445163446163447163448163449163450163451163452163453163454163455163456163457163458163459163460163461163462163463163464163465163466163467163468163469163470163471163472163473163474163475163476163477163478163479163480163481163482163483163484163485163486163487163488163489163490163491163492163493163494163495163496163497163498163499163500163501163502163503163504163505163506163507163508163509163510163511163512163513163514163515163516163517163518163519163520163521163522163523163524163525163526163527163528163529163530163531163532163533163534163535163536163537163538163539163540163541163542163543163544163545163546163547163548163549163550163551163552163553163554163555163556163557163558163559163560163561163562163563163564163565163566163567163568163569163570163571163572163573163574163575163576163577163578163579163580163581163582163583163584163585163586163587163588163589163590163591163592163593163594163595163596163597163598163599163600163601163602163603163604163605163606163607163608163609163610163611163612163613163614163615163616163617163618163619163620163621163622163623163624163625163626163627163628163629163630163631163632163633163634163635163636163637163638163639163640163641163642163643163644163645163646163647163648163649163650163651163652163653163654163655163656163657163658163659163660163661163662163663163664163665163666163667163668163669163670163671163672163673163674163675163676163677163678163679163680163681163682163683163684163685163686163687163688163689163690163691163692163693163694163695163696163697163698163699163700163701163702163703163704163705163706163707163708163709163710163711163712163713163714163715163716163717163718163719163720163721163722163723163724163725163726163727163728163729163730163731163732163733163734163735163736163737163738163739163740163741163742163743163744163745163746163747163748163749163750163751163752163753163754163755163756163757163758163759163760163761163762163763163764163765163766163767163768163769163770163771163772163773163774163775163776163777163778163779163780163781163782163783163784163785163786163787163788163789163790163791163792163793163794163795163796163797163798163799163800163801163802163803163804163805163806163807163808163809163810163811163812163813163814163815163816163817163818163819163820163821163822163823163824163825163826163827163828163829163830163831163832163833163834163835163836163837163838163839163840163841163842163843163844163845163846163847163848163849163850163851163852163853163854163855163856163857163858163859163860163861163862163863163864163865163866163867163868163869163870163871163872163873163874163875163876163877163878163879163880163881163882163883163884163885163886163887163888163889163890163891163892163893163894163895163896163897163898163899163900163901163902163903163904163905163906163907163908163909163910163911163912163913163914163915163916163917163918163919163920163921163922163923163924163925163926163927163928163929163930163931163932163933163934163935163936163937163938163939163940163941163942163943163944163945163946163947163948163949163950163951163952163953163954163955163956163957163958163959163960163961163962163963163964163965163966163967163968163969163970163971163972163973163974163975163976163977163978163979163980163981163982163983163984163985163986163987163988163989163990163991163992163993163994163995163996163997163998163999164000164001164002164003164004164005164006164007164008164009164010164011164012164013164014164015164016164017164018164019164020164021164022164023164024164025164026164027164028164029164030164031164032164033164034164035164036164037164038164039164040164041164042164043164044164045164046164047164048164049164050164051164052164053164054164055164056164057164058164059164060164061164062164063164064164065164066164067164068164069164070164071164072164073164074164075164076164077164078164079164080164081164082164083164084164085164086164087164088164089164090164091164092164093164094164095164096164097164098164099164100164101164102164103164104164105164106164107164108164109164110164111164112164113164114164115164116164117164118164119164120164121164122164123164124164125164126164127164128164129164130164131164132164133164134164135164136164137164138164139164140164141164142164143164144164145164146164147164148164149164150164151164152164153164154164155164156164157164158164159164160164161164162164163164164164165164166164167164168164169164170164171164172164173164174164175164176164177164178164179164180164181164182164183164184164185164186164187164188164189164190164191164192164193164194164195164196164197164198164199164200164201164202164203164204164205164206164207164208164209164210164211164212164213164214164215164216164217164218164219164220164221164222164223164224164225164226164227164228164229164230164231164232164233164234164235164236164237164238164239164240164241164242164243164244164245164246164247164248164249164250164251164252164253164254164255164256164257164258164259164260164261164262164263164264164265164266164267164268164269164270164271164272164273164274164275164276164277164278164279164280164281164282164283164284164285164286164287164288164289164290164291164292164293164294164295164296164297164298164299164300164301164302164303164304164305164306164307164308164309164310164311164312164313164314164315164316164317164318164319164320164321164322164323164324164325164326164327164328164329164330164331164332164333164334164335164336164337164338164339164340164341164342164343164344164345164346164347164348164349164350164351164352164353164354164355164356164357164358164359164360164361164362164363164364164365164366164367164368164369164370164371164372164373164374164375164376164377164378164379164380164381164382164383164384164385164386164387164388164389164390164391164392164393164394164395164396164397164398164399164400164401164402164403164404164405164406164407164408164409164410164411164412164413164414164415164416164417164418164419164420164421164422164423164424164425164426164427164428164429164430164431164432164433164434164435164436164437164438164439164440164441164442164443164444164445164446164447164448164449164450164451164452164453164454164455164456164457164458164459164460164461164462164463164464164465164466164467164468164469164470164471164472164473164474164475164476164477164478164479164480164481164482164483164484164485164486164487164488164489164490164491164492164493164494164495164496164497164498164499164500164501164502164503164504164505164506164507164508164509164510164511164512164513164514164515164516164517164518164519164520164521164522164523164524164525164526164527164528164529164530164531164532164533164534164535164536164537164538164539164540164541164542164543164544164545164546164547164548164549164550164551164552164553164554164555164556164557164558164559164560164561164562164563164564164565164566164567164568164569164570164571164572164573164574164575164576164577164578164579164580164581164582164583164584164585164586164587164588164589164590164591164592164593164594164595164596164597164598164599164600164601164602164603164604164605164606164607164608164609164610164611164612164613164614164615164616164617164618164619164620164621164622164623164624164625164626164627164628164629164630164631164632164633164634164635164636164637164638164639164640164641164642164643164644164645164646164647164648164649164650164651164652164653164654164655164656164657164658164659164660164661164662164663164664164665164666164667164668164669164670164671164672164673164674164675164676164677164678164679164680164681164682164683164684164685164686164687164688164689164690164691164692164693164694164695164696164697164698164699164700164701164702164703164704164705164706164707164708164709164710164711164712164713164714164715164716164717164718164719164720164721164722164723164724164725164726164727164728164729164730164731164732164733164734164735164736164737164738164739164740164741164742164743164744164745164746164747164748164749164750164751164752164753164754164755164756164757164758164759164760164761164762164763164764164765164766164767164768164769164770164771164772164773164774164775164776164777164778164779164780164781164782164783164784164785164786164787164788164789164790164791164792164793164794164795164796164797164798164799164800164801164802164803164804164805164806164807164808164809164810164811164812164813164814164815164816164817164818164819164820164821164822164823164824164825164826164827164828164829164830164831164832164833164834164835164836164837164838164839164840164841164842164843164844164845164846164847164848164849164850164851164852164853164854164855164856164857164858164859164860164861164862164863164864164865164866164867164868164869164870164871164872164873164874164875164876164877164878164879164880164881164882164883164884164885164886164887164888164889164890164891164892164893164894164895164896164897164898164899164900164901164902164903164904164905164906164907164908164909164910164911164912164913164914164915164916164917164918164919164920164921164922164923164924164925164926164927164928164929164930164931164932164933164934164935164936164937164938164939164940164941164942164943164944164945164946164947164948164949164950164951164952164953164954164955164956164957164958164959164960164961164962164963164964164965164966164967164968164969164970164971164972164973164974164975164976164977164978164979164980164981164982164983164984164985164986164987164988164989164990164991164992164993164994164995164996164997164998164999165000165001165002165003165004165005165006165007165008165009165010165011165012165013165014165015165016165017165018165019165020165021165022165023165024165025165026165027165028165029165030165031165032165033165034165035165036165037165038165039165040165041165042165043165044165045165046165047165048165049165050165051165052165053165054165055165056165057165058165059165060165061165062165063165064165065165066165067165068165069165070165071165072165073165074165075165076165077165078165079165080165081165082165083165084165085165086165087165088165089165090165091165092165093165094165095165096165097165098165099165100165101165102165103165104165105165106165107165108165109165110165111165112165113165114165115165116165117165118165119165120165121165122165123165124165125165126165127165128165129165130165131165132165133165134165135165136165137165138165139165140165141165142165143165144165145165146165147165148165149165150165151165152165153165154165155165156165157165158165159165160165161165162165163165164165165165166165167165168165169165170165171165172165173165174165175165176165177165178165179165180165181165182165183165184165185165186165187165188165189165190165191165192165193165194165195165196165197165198165199165200165201165202165203165204165205165206165207165208165209165210165211165212165213165214165215165216165217165218165219165220165221165222165223165224165225165226165227165228165229165230165231165232165233165234165235165236165237165238165239165240165241165242165243165244165245165246165247165248165249165250165251165252165253165254165255165256165257165258165259165260165261165262165263165264165265165266165267165268165269165270165271165272165273165274165275165276165277165278165279165280165281165282165283165284165285165286165287165288165289165290165291165292165293165294165295165296165297165298165299165300165301165302165303165304165305165306165307165308165309165310165311165312165313165314165315165316165317165318165319165320165321165322165323165324165325165326165327165328165329165330165331165332165333165334165335165336165337165338165339165340165341165342165343165344165345165346165347165348165349165350165351165352165353165354165355165356165357165358165359165360165361165362165363165364165365165366165367165368165369165370165371165372165373165374165375165376165377165378165379165380165381165382165383165384165385165386165387165388165389165390165391165392165393165394165395165396165397165398165399165400165401165402165403165404165405165406165407165408165409165410165411165412165413165414165415165416165417165418165419165420165421165422165423165424165425165426165427165428165429165430165431165432165433165434165435165436165437165438165439165440165441165442165443165444165445165446165447165448165449165450165451165452165453165454165455165456165457165458165459165460165461165462165463165464165465165466165467165468165469165470165471165472165473165474165475165476165477165478165479165480165481165482165483165484165485165486165487165488165489165490165491165492165493165494165495165496165497165498165499165500165501165502165503165504165505165506165507165508165509165510165511165512165513165514165515165516165517165518165519165520165521165522165523165524165525165526165527165528165529165530165531165532165533165534165535165536165537165538165539165540165541165542165543165544165545165546165547165548165549165550165551165552165553165554165555165556165557165558165559165560165561165562165563165564165565165566165567165568165569165570165571165572165573165574165575165576165577165578165579165580165581165582165583165584165585165586165587165588165589165590165591165592165593165594165595165596165597165598165599165600165601165602165603165604165605165606165607165608165609165610165611165612165613165614165615165616165617165618165619165620165621165622165623165624165625165626165627165628165629165630165631165632165633165634165635165636165637165638165639165640165641165642165643165644165645165646165647165648165649165650165651165652165653165654165655165656165657165658165659165660165661165662165663165664165665165666165667165668165669165670165671165672165673165674165675165676165677165678165679165680165681165682165683165684165685165686165687165688165689165690165691165692165693165694165695165696165697165698165699165700165701165702165703165704165705165706165707165708165709165710165711165712165713165714165715165716165717165718165719165720165721165722165723165724165725165726165727165728165729165730165731165732165733165734165735165736165737165738165739165740165741165742165743165744165745165746165747165748165749165750165751165752165753165754165755165756165757165758165759165760165761165762165763165764165765165766165767165768165769165770165771165772165773165774165775165776165777165778165779165780165781165782165783165784165785165786165787165788165789165790165791165792165793165794165795165796165797165798165799165800165801165802165803165804165805165806165807165808165809165810165811165812165813165814165815165816165817165818165819165820165821165822165823165824165825165826165827165828165829165830165831165832165833165834165835165836165837165838165839165840165841165842165843165844165845165846165847165848165849165850165851165852165853165854165855165856165857165858165859165860165861165862165863165864165865165866165867165868165869165870165871165872165873165874165875165876165877165878165879165880165881165882165883165884165885165886165887165888165889165890165891165892165893165894165895165896165897165898165899165900165901165902165903165904165905165906165907165908165909165910165911165912165913165914165915165916165917165918165919165920165921165922165923165924165925165926165927165928165929165930165931165932165933165934165935165936165937165938165939165940165941165942165943165944165945165946165947165948165949165950165951165952165953165954165955165956165957165958165959165960165961165962165963165964165965165966165967165968165969165970165971165972165973165974165975165976165977165978165979165980165981165982165983165984165985165986165987165988165989165990165991165992165993165994165995165996165997165998165999166000166001166002166003166004166005166006166007166008166009166010166011166012166013166014166015166016166017166018166019166020166021166022166023166024166025166026166027166028166029166030166031166032166033166034166035166036166037166038166039166040166041166042166043166044166045166046166047166048166049166050166051166052166053166054166055166056166057166058166059166060166061166062166063166064166065166066166067166068166069166070166071166072166073166074166075166076166077166078166079166080166081166082166083166084166085166086166087166088166089166090166091166092166093166094166095166096166097166098166099166100166101166102166103166104166105166106166107166108166109166110166111166112166113166114166115166116166117166118166119166120166121166122166123166124166125166126166127166128166129166130166131166132166133166134166135166136166137166138166139166140166141166142166143166144166145166146166147166148166149166150166151166152166153166154166155166156166157166158166159166160166161166162166163166164166165166166166167166168166169166170166171166172166173166174166175166176166177166178166179166180166181166182166183166184166185166186166187166188166189166190166191166192166193166194166195166196166197166198166199166200166201166202166203166204166205166206166207166208166209166210166211166212166213166214166215166216166217166218166219166220166221166222166223166224166225166226166227166228166229166230166231166232166233166234166235166236166237166238166239166240166241166242166243166244166245166246166247166248166249166250166251166252166253166254166255166256166257166258166259166260166261166262166263166264166265166266166267166268166269166270166271166272166273166274166275166276166277166278166279166280166281166282166283166284166285166286166287166288166289166290166291166292166293166294166295166296166297166298166299166300166301166302166303166304166305166306166307166308166309166310166311166312166313166314166315166316166317166318166319166320166321166322166323166324166325166326166327166328166329166330166331166332166333166334166335166336166337166338166339166340166341166342166343166344166345166346166347166348166349166350166351166352166353166354166355166356166357166358166359166360166361166362166363166364166365166366166367166368166369166370166371166372166373166374166375166376166377166378166379166380166381166382166383166384166385166386166387166388166389166390166391166392166393166394166395166396166397166398166399166400166401166402166403166404166405166406166407166408166409166410166411166412166413166414166415
  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. set hasAlpha(value: boolean);
  7831. get hasAlpha(): 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 { IColor4Like } from "babylonjs/Maths/math.like";
  18736. import { Nullable } from "babylonjs/types";
  18737. module "babylonjs/Engines/thinEngine" {
  18738. interface ThinEngine {
  18739. /**
  18740. * Unbind a list of render target textures from the webGL context
  18741. * This is used only when drawBuffer extension or webGL2 are active
  18742. * @param textures defines the render target textures to unbind
  18743. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  18744. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  18745. */
  18746. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  18747. /**
  18748. * Create a multi render target texture
  18749. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  18750. * @param size defines the size of the texture
  18751. * @param options defines the creation options
  18752. * @returns the cube texture as an InternalTexture
  18753. */
  18754. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  18755. /**
  18756. * Update the sample count for a given multiple render target texture
  18757. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  18758. * @param textures defines the textures to update
  18759. * @param samples defines the sample count to set
  18760. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  18761. */
  18762. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  18763. /**
  18764. * Select a subsets of attachments to draw to.
  18765. * @param attachments gl attachments
  18766. */
  18767. bindAttachments(attachments: number[]): void;
  18768. /**
  18769. * Creates a layout object to draw/clear on specific textures in a MRT
  18770. * @param textureStatus textureStatus[i] indicates if the i-th is active
  18771. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  18772. */
  18773. buildTextureLayout(textureStatus: boolean[]): number[];
  18774. /**
  18775. * Restores the webgl state to only draw on the main color attachment
  18776. */
  18777. restoreSingleAttachment(): void;
  18778. /**
  18779. * Clears a list of attachments
  18780. * @param attachments list of the attachments
  18781. * @param colorMain clear color for the main attachment (the first one)
  18782. * @param colorOthers clear color for the other attachments
  18783. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  18784. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  18785. */
  18786. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  18787. }
  18788. }
  18789. }
  18790. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  18791. import { Scene } from "babylonjs/scene";
  18792. import { Engine } from "babylonjs/Engines/engine";
  18793. import { Texture } from "babylonjs/Materials/Textures/texture";
  18794. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18795. import "babylonjs/Engines/Extensions/engine.multiRender";
  18796. /**
  18797. * Creation options of the multi render target texture.
  18798. */
  18799. export interface IMultiRenderTargetOptions {
  18800. /**
  18801. * Define if the texture needs to create mip maps after render.
  18802. */
  18803. generateMipMaps?: boolean;
  18804. /**
  18805. * Define the types of all the draw buffers we want to create
  18806. */
  18807. types?: number[];
  18808. /**
  18809. * Define the sampling modes of all the draw buffers we want to create
  18810. */
  18811. samplingModes?: number[];
  18812. /**
  18813. * Define if a depth buffer is required
  18814. */
  18815. generateDepthBuffer?: boolean;
  18816. /**
  18817. * Define if a stencil buffer is required
  18818. */
  18819. generateStencilBuffer?: boolean;
  18820. /**
  18821. * Define if a depth texture is required instead of a depth buffer
  18822. */
  18823. generateDepthTexture?: boolean;
  18824. /**
  18825. * Define the number of desired draw buffers
  18826. */
  18827. textureCount?: number;
  18828. /**
  18829. * Define if aspect ratio should be adapted to the texture or stay the scene one
  18830. */
  18831. doNotChangeAspectRatio?: boolean;
  18832. /**
  18833. * Define the default type of the buffers we are creating
  18834. */
  18835. defaultType?: number;
  18836. }
  18837. /**
  18838. * A multi render target, like a render target provides the ability to render to a texture.
  18839. * Unlike the render target, it can render to several draw buffers in one draw.
  18840. * This is specially interesting in deferred rendering or for any effects requiring more than
  18841. * just one color from a single pass.
  18842. */
  18843. export class MultiRenderTarget extends RenderTargetTexture {
  18844. private _internalTextures;
  18845. private _textures;
  18846. private _multiRenderTargetOptions;
  18847. private _count;
  18848. /**
  18849. * Get if draw buffers are currently supported by the used hardware and browser.
  18850. */
  18851. get isSupported(): boolean;
  18852. /**
  18853. * Get the list of textures generated by the multi render target.
  18854. */
  18855. get textures(): Texture[];
  18856. /**
  18857. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  18858. */
  18859. get count(): number;
  18860. /**
  18861. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  18862. */
  18863. get depthTexture(): Texture;
  18864. /**
  18865. * Set the wrapping mode on U of all the textures we are rendering to.
  18866. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18867. */
  18868. set wrapU(wrap: number);
  18869. /**
  18870. * Set the wrapping mode on V of all the textures we are rendering to.
  18871. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18872. */
  18873. set wrapV(wrap: number);
  18874. /**
  18875. * Instantiate a new multi render target texture.
  18876. * A multi render target, like a render target provides the ability to render to a texture.
  18877. * Unlike the render target, it can render to several draw buffers in one draw.
  18878. * This is specially interesting in deferred rendering or for any effects requiring more than
  18879. * just one color from a single pass.
  18880. * @param name Define the name of the texture
  18881. * @param size Define the size of the buffers to render to
  18882. * @param count Define the number of target we are rendering into
  18883. * @param scene Define the scene the texture belongs to
  18884. * @param options Define the options used to create the multi render target
  18885. */
  18886. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  18887. private _initTypes;
  18888. /** @hidden */
  18889. _rebuild(forceFullRebuild?: boolean): void;
  18890. private _createInternalTextures;
  18891. private _createTextures;
  18892. /**
  18893. * Replaces a texture within the MRT.
  18894. * @param texture The new texture to insert in the MRT
  18895. * @param index The index of the texture to replace
  18896. */
  18897. replaceTexture(texture: Texture, index: number): void;
  18898. /**
  18899. * Define the number of samples used if MSAA is enabled.
  18900. */
  18901. get samples(): number;
  18902. set samples(value: number);
  18903. /**
  18904. * Resize all the textures in the multi render target.
  18905. * Be careful as it will recreate all the data in the new texture.
  18906. * @param size Define the new size
  18907. */
  18908. resize(size: any): void;
  18909. /**
  18910. * Changes the number of render targets in this MRT
  18911. * Be careful as it will recreate all the data in the new texture.
  18912. * @param count new texture count
  18913. * @param options Specifies texture types and sampling modes for new textures
  18914. */
  18915. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  18916. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18917. /**
  18918. * Dispose the render targets and their associated resources
  18919. */
  18920. dispose(): void;
  18921. /**
  18922. * Release all the underlying texture used as draw buffers.
  18923. */
  18924. releaseInternalTextures(): void;
  18925. }
  18926. }
  18927. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  18928. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  18929. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  18930. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  18931. /** @hidden */
  18932. export var imageProcessingPixelShader: {
  18933. name: string;
  18934. shader: string;
  18935. };
  18936. }
  18937. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  18938. import { Nullable } from "babylonjs/types";
  18939. import { Color4 } from "babylonjs/Maths/math.color";
  18940. import { Camera } from "babylonjs/Cameras/camera";
  18941. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18942. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  18943. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  18944. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  18945. import { Engine } from "babylonjs/Engines/engine";
  18946. import "babylonjs/Shaders/imageProcessing.fragment";
  18947. import "babylonjs/Shaders/postprocess.vertex";
  18948. /**
  18949. * ImageProcessingPostProcess
  18950. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  18951. */
  18952. export class ImageProcessingPostProcess extends PostProcess {
  18953. /**
  18954. * Default configuration related to image processing available in the PBR Material.
  18955. */
  18956. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  18957. /**
  18958. * Gets the image processing configuration used either in this material.
  18959. */
  18960. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  18961. /**
  18962. * Sets the Default image processing configuration used either in the this material.
  18963. *
  18964. * If sets to null, the scene one is in use.
  18965. */
  18966. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  18967. /**
  18968. * Keep track of the image processing observer to allow dispose and replace.
  18969. */
  18970. private _imageProcessingObserver;
  18971. /**
  18972. * Attaches a new image processing configuration to the PBR Material.
  18973. * @param configuration
  18974. */
  18975. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  18976. /**
  18977. * If the post process is supported.
  18978. */
  18979. get isSupported(): boolean;
  18980. /**
  18981. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18982. */
  18983. get colorCurves(): Nullable<ColorCurves>;
  18984. /**
  18985. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18986. */
  18987. set colorCurves(value: Nullable<ColorCurves>);
  18988. /**
  18989. * Gets wether the color curves effect is enabled.
  18990. */
  18991. get colorCurvesEnabled(): boolean;
  18992. /**
  18993. * Sets wether the color curves effect is enabled.
  18994. */
  18995. set colorCurvesEnabled(value: boolean);
  18996. /**
  18997. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18998. */
  18999. get colorGradingTexture(): Nullable<BaseTexture>;
  19000. /**
  19001. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  19002. */
  19003. set colorGradingTexture(value: Nullable<BaseTexture>);
  19004. /**
  19005. * Gets wether the color grading effect is enabled.
  19006. */
  19007. get colorGradingEnabled(): boolean;
  19008. /**
  19009. * Gets wether the color grading effect is enabled.
  19010. */
  19011. set colorGradingEnabled(value: boolean);
  19012. /**
  19013. * Gets exposure used in the effect.
  19014. */
  19015. get exposure(): number;
  19016. /**
  19017. * Sets exposure used in the effect.
  19018. */
  19019. set exposure(value: number);
  19020. /**
  19021. * Gets wether tonemapping is enabled or not.
  19022. */
  19023. get toneMappingEnabled(): boolean;
  19024. /**
  19025. * Sets wether tonemapping is enabled or not
  19026. */
  19027. set toneMappingEnabled(value: boolean);
  19028. /**
  19029. * Gets the type of tone mapping effect.
  19030. */
  19031. get toneMappingType(): number;
  19032. /**
  19033. * Sets the type of tone mapping effect.
  19034. */
  19035. set toneMappingType(value: number);
  19036. /**
  19037. * Gets contrast used in the effect.
  19038. */
  19039. get contrast(): number;
  19040. /**
  19041. * Sets contrast used in the effect.
  19042. */
  19043. set contrast(value: number);
  19044. /**
  19045. * Gets Vignette stretch size.
  19046. */
  19047. get vignetteStretch(): number;
  19048. /**
  19049. * Sets Vignette stretch size.
  19050. */
  19051. set vignetteStretch(value: number);
  19052. /**
  19053. * Gets Vignette centre X Offset.
  19054. */
  19055. get vignetteCentreX(): number;
  19056. /**
  19057. * Sets Vignette centre X Offset.
  19058. */
  19059. set vignetteCentreX(value: number);
  19060. /**
  19061. * Gets Vignette centre Y Offset.
  19062. */
  19063. get vignetteCentreY(): number;
  19064. /**
  19065. * Sets Vignette centre Y Offset.
  19066. */
  19067. set vignetteCentreY(value: number);
  19068. /**
  19069. * Gets Vignette weight or intensity of the vignette effect.
  19070. */
  19071. get vignetteWeight(): number;
  19072. /**
  19073. * Sets Vignette weight or intensity of the vignette effect.
  19074. */
  19075. set vignetteWeight(value: number);
  19076. /**
  19077. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  19078. * if vignetteEnabled is set to true.
  19079. */
  19080. get vignetteColor(): Color4;
  19081. /**
  19082. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  19083. * if vignetteEnabled is set to true.
  19084. */
  19085. set vignetteColor(value: Color4);
  19086. /**
  19087. * Gets Camera field of view used by the Vignette effect.
  19088. */
  19089. get vignetteCameraFov(): number;
  19090. /**
  19091. * Sets Camera field of view used by the Vignette effect.
  19092. */
  19093. set vignetteCameraFov(value: number);
  19094. /**
  19095. * Gets the vignette blend mode allowing different kind of effect.
  19096. */
  19097. get vignetteBlendMode(): number;
  19098. /**
  19099. * Sets the vignette blend mode allowing different kind of effect.
  19100. */
  19101. set vignetteBlendMode(value: number);
  19102. /**
  19103. * Gets wether the vignette effect is enabled.
  19104. */
  19105. get vignetteEnabled(): boolean;
  19106. /**
  19107. * Sets wether the vignette effect is enabled.
  19108. */
  19109. set vignetteEnabled(value: boolean);
  19110. private _fromLinearSpace;
  19111. /**
  19112. * Gets wether the input of the processing is in Gamma or Linear Space.
  19113. */
  19114. get fromLinearSpace(): boolean;
  19115. /**
  19116. * Sets wether the input of the processing is in Gamma or Linear Space.
  19117. */
  19118. set fromLinearSpace(value: boolean);
  19119. /**
  19120. * Defines cache preventing GC.
  19121. */
  19122. private _defines;
  19123. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  19124. /**
  19125. * "ImageProcessingPostProcess"
  19126. * @returns "ImageProcessingPostProcess"
  19127. */
  19128. getClassName(): string;
  19129. /**
  19130. * @hidden
  19131. */
  19132. _updateParameters(): void;
  19133. dispose(camera?: Camera): void;
  19134. }
  19135. }
  19136. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  19137. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19138. /**
  19139. * Interface for defining prepass effects in the prepass post-process pipeline
  19140. */
  19141. export interface PrePassEffectConfiguration {
  19142. /**
  19143. * Name of the effect
  19144. */
  19145. name: string;
  19146. /**
  19147. * Post process to attach for this effect
  19148. */
  19149. postProcess?: PostProcess;
  19150. /**
  19151. * Textures required in the MRT
  19152. */
  19153. texturesRequired: number[];
  19154. /**
  19155. * Is the effect enabled
  19156. */
  19157. enabled: boolean;
  19158. /**
  19159. * Disposes the effect configuration
  19160. */
  19161. dispose?: () => void;
  19162. /**
  19163. * Creates the associated post process
  19164. */
  19165. createPostProcess?: () => PostProcess;
  19166. }
  19167. }
  19168. declare module "babylonjs/Materials/fresnelParameters" {
  19169. import { DeepImmutable } from "babylonjs/types";
  19170. import { Color3 } from "babylonjs/Maths/math.color";
  19171. /**
  19172. * Options to be used when creating a FresnelParameters.
  19173. */
  19174. export type IFresnelParametersCreationOptions = {
  19175. /**
  19176. * Define the color used on edges (grazing angle)
  19177. */
  19178. leftColor?: Color3;
  19179. /**
  19180. * Define the color used on center
  19181. */
  19182. rightColor?: Color3;
  19183. /**
  19184. * Define bias applied to computed fresnel term
  19185. */
  19186. bias?: number;
  19187. /**
  19188. * Defined the power exponent applied to fresnel term
  19189. */
  19190. power?: number;
  19191. /**
  19192. * Define if the fresnel effect is enable or not.
  19193. */
  19194. isEnabled?: boolean;
  19195. };
  19196. /**
  19197. * Serialized format for FresnelParameters.
  19198. */
  19199. export type IFresnelParametersSerialized = {
  19200. /**
  19201. * Define the color used on edges (grazing angle) [as an array]
  19202. */
  19203. leftColor: number[];
  19204. /**
  19205. * Define the color used on center [as an array]
  19206. */
  19207. rightColor: number[];
  19208. /**
  19209. * Define bias applied to computed fresnel term
  19210. */
  19211. bias: number;
  19212. /**
  19213. * Defined the power exponent applied to fresnel term
  19214. */
  19215. power?: number;
  19216. /**
  19217. * Define if the fresnel effect is enable or not.
  19218. */
  19219. isEnabled: boolean;
  19220. };
  19221. /**
  19222. * This represents all the required information to add a fresnel effect on a material:
  19223. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19224. */
  19225. export class FresnelParameters {
  19226. private _isEnabled;
  19227. /**
  19228. * Define if the fresnel effect is enable or not.
  19229. */
  19230. get isEnabled(): boolean;
  19231. set isEnabled(value: boolean);
  19232. /**
  19233. * Define the color used on edges (grazing angle)
  19234. */
  19235. leftColor: Color3;
  19236. /**
  19237. * Define the color used on center
  19238. */
  19239. rightColor: Color3;
  19240. /**
  19241. * Define bias applied to computed fresnel term
  19242. */
  19243. bias: number;
  19244. /**
  19245. * Defined the power exponent applied to fresnel term
  19246. */
  19247. power: number;
  19248. /**
  19249. * Creates a new FresnelParameters object.
  19250. *
  19251. * @param options provide your own settings to optionally to override defaults
  19252. */
  19253. constructor(options?: IFresnelParametersCreationOptions);
  19254. /**
  19255. * Clones the current fresnel and its valuues
  19256. * @returns a clone fresnel configuration
  19257. */
  19258. clone(): FresnelParameters;
  19259. /**
  19260. * Determines equality between FresnelParameters objects
  19261. * @param otherFresnelParameters defines the second operand
  19262. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  19263. */
  19264. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  19265. /**
  19266. * Serializes the current fresnel parameters to a JSON representation.
  19267. * @return the JSON serialization
  19268. */
  19269. serialize(): IFresnelParametersSerialized;
  19270. /**
  19271. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  19272. * @param parsedFresnelParameters Define the JSON representation
  19273. * @returns the parsed parameters
  19274. */
  19275. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  19276. }
  19277. }
  19278. declare module "babylonjs/Materials/materialFlags" {
  19279. /**
  19280. * This groups all the flags used to control the materials channel.
  19281. */
  19282. export class MaterialFlags {
  19283. private static _DiffuseTextureEnabled;
  19284. /**
  19285. * Are diffuse textures enabled in the application.
  19286. */
  19287. static get DiffuseTextureEnabled(): boolean;
  19288. static set DiffuseTextureEnabled(value: boolean);
  19289. private static _DetailTextureEnabled;
  19290. /**
  19291. * Are detail textures enabled in the application.
  19292. */
  19293. static get DetailTextureEnabled(): boolean;
  19294. static set DetailTextureEnabled(value: boolean);
  19295. private static _AmbientTextureEnabled;
  19296. /**
  19297. * Are ambient textures enabled in the application.
  19298. */
  19299. static get AmbientTextureEnabled(): boolean;
  19300. static set AmbientTextureEnabled(value: boolean);
  19301. private static _OpacityTextureEnabled;
  19302. /**
  19303. * Are opacity textures enabled in the application.
  19304. */
  19305. static get OpacityTextureEnabled(): boolean;
  19306. static set OpacityTextureEnabled(value: boolean);
  19307. private static _ReflectionTextureEnabled;
  19308. /**
  19309. * Are reflection textures enabled in the application.
  19310. */
  19311. static get ReflectionTextureEnabled(): boolean;
  19312. static set ReflectionTextureEnabled(value: boolean);
  19313. private static _EmissiveTextureEnabled;
  19314. /**
  19315. * Are emissive textures enabled in the application.
  19316. */
  19317. static get EmissiveTextureEnabled(): boolean;
  19318. static set EmissiveTextureEnabled(value: boolean);
  19319. private static _SpecularTextureEnabled;
  19320. /**
  19321. * Are specular textures enabled in the application.
  19322. */
  19323. static get SpecularTextureEnabled(): boolean;
  19324. static set SpecularTextureEnabled(value: boolean);
  19325. private static _BumpTextureEnabled;
  19326. /**
  19327. * Are bump textures enabled in the application.
  19328. */
  19329. static get BumpTextureEnabled(): boolean;
  19330. static set BumpTextureEnabled(value: boolean);
  19331. private static _LightmapTextureEnabled;
  19332. /**
  19333. * Are lightmap textures enabled in the application.
  19334. */
  19335. static get LightmapTextureEnabled(): boolean;
  19336. static set LightmapTextureEnabled(value: boolean);
  19337. private static _RefractionTextureEnabled;
  19338. /**
  19339. * Are refraction textures enabled in the application.
  19340. */
  19341. static get RefractionTextureEnabled(): boolean;
  19342. static set RefractionTextureEnabled(value: boolean);
  19343. private static _ColorGradingTextureEnabled;
  19344. /**
  19345. * Are color grading textures enabled in the application.
  19346. */
  19347. static get ColorGradingTextureEnabled(): boolean;
  19348. static set ColorGradingTextureEnabled(value: boolean);
  19349. private static _FresnelEnabled;
  19350. /**
  19351. * Are fresnels enabled in the application.
  19352. */
  19353. static get FresnelEnabled(): boolean;
  19354. static set FresnelEnabled(value: boolean);
  19355. private static _ClearCoatTextureEnabled;
  19356. /**
  19357. * Are clear coat textures enabled in the application.
  19358. */
  19359. static get ClearCoatTextureEnabled(): boolean;
  19360. static set ClearCoatTextureEnabled(value: boolean);
  19361. private static _ClearCoatBumpTextureEnabled;
  19362. /**
  19363. * Are clear coat bump textures enabled in the application.
  19364. */
  19365. static get ClearCoatBumpTextureEnabled(): boolean;
  19366. static set ClearCoatBumpTextureEnabled(value: boolean);
  19367. private static _ClearCoatTintTextureEnabled;
  19368. /**
  19369. * Are clear coat tint textures enabled in the application.
  19370. */
  19371. static get ClearCoatTintTextureEnabled(): boolean;
  19372. static set ClearCoatTintTextureEnabled(value: boolean);
  19373. private static _SheenTextureEnabled;
  19374. /**
  19375. * Are sheen textures enabled in the application.
  19376. */
  19377. static get SheenTextureEnabled(): boolean;
  19378. static set SheenTextureEnabled(value: boolean);
  19379. private static _AnisotropicTextureEnabled;
  19380. /**
  19381. * Are anisotropic textures enabled in the application.
  19382. */
  19383. static get AnisotropicTextureEnabled(): boolean;
  19384. static set AnisotropicTextureEnabled(value: boolean);
  19385. private static _ThicknessTextureEnabled;
  19386. /**
  19387. * Are thickness textures enabled in the application.
  19388. */
  19389. static get ThicknessTextureEnabled(): boolean;
  19390. static set ThicknessTextureEnabled(value: boolean);
  19391. }
  19392. }
  19393. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  19394. /** @hidden */
  19395. export var defaultFragmentDeclaration: {
  19396. name: string;
  19397. shader: string;
  19398. };
  19399. }
  19400. declare module "babylonjs/Shaders/ShadersInclude/sceneUboDeclaration" {
  19401. /** @hidden */
  19402. export var sceneUboDeclaration: {
  19403. name: string;
  19404. shader: string;
  19405. };
  19406. }
  19407. declare module "babylonjs/Shaders/ShadersInclude/meshUboDeclaration" {
  19408. /** @hidden */
  19409. export var meshUboDeclaration: {
  19410. name: string;
  19411. shader: string;
  19412. };
  19413. }
  19414. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  19415. import "babylonjs/Shaders/ShadersInclude/sceneUboDeclaration";
  19416. import "babylonjs/Shaders/ShadersInclude/meshUboDeclaration";
  19417. /** @hidden */
  19418. export var defaultUboDeclaration: {
  19419. name: string;
  19420. shader: string;
  19421. };
  19422. }
  19423. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  19424. /** @hidden */
  19425. export var prePassDeclaration: {
  19426. name: string;
  19427. shader: string;
  19428. };
  19429. }
  19430. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  19431. /** @hidden */
  19432. export var lightFragmentDeclaration: {
  19433. name: string;
  19434. shader: string;
  19435. };
  19436. }
  19437. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  19438. /** @hidden */
  19439. export var lightUboDeclaration: {
  19440. name: string;
  19441. shader: string;
  19442. };
  19443. }
  19444. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  19445. /** @hidden */
  19446. export var lightsFragmentFunctions: {
  19447. name: string;
  19448. shader: string;
  19449. };
  19450. }
  19451. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  19452. /** @hidden */
  19453. export var shadowsFragmentFunctions: {
  19454. name: string;
  19455. shader: string;
  19456. };
  19457. }
  19458. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  19459. /** @hidden */
  19460. export var fresnelFunction: {
  19461. name: string;
  19462. shader: string;
  19463. };
  19464. }
  19465. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  19466. /** @hidden */
  19467. export var bumpFragmentMainFunctions: {
  19468. name: string;
  19469. shader: string;
  19470. };
  19471. }
  19472. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  19473. /** @hidden */
  19474. export var bumpFragmentFunctions: {
  19475. name: string;
  19476. shader: string;
  19477. };
  19478. }
  19479. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  19480. /** @hidden */
  19481. export var logDepthDeclaration: {
  19482. name: string;
  19483. shader: string;
  19484. };
  19485. }
  19486. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  19487. /** @hidden */
  19488. export var fogFragmentDeclaration: {
  19489. name: string;
  19490. shader: string;
  19491. };
  19492. }
  19493. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  19494. /** @hidden */
  19495. export var bumpFragment: {
  19496. name: string;
  19497. shader: string;
  19498. };
  19499. }
  19500. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  19501. /** @hidden */
  19502. export var depthPrePass: {
  19503. name: string;
  19504. shader: string;
  19505. };
  19506. }
  19507. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  19508. /** @hidden */
  19509. export var lightFragment: {
  19510. name: string;
  19511. shader: string;
  19512. };
  19513. }
  19514. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  19515. /** @hidden */
  19516. export var logDepthFragment: {
  19517. name: string;
  19518. shader: string;
  19519. };
  19520. }
  19521. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  19522. /** @hidden */
  19523. export var fogFragment: {
  19524. name: string;
  19525. shader: string;
  19526. };
  19527. }
  19528. declare module "babylonjs/Shaders/default.fragment" {
  19529. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  19530. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  19531. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  19532. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  19533. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  19534. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  19535. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  19536. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  19537. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  19538. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  19539. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  19540. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  19541. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  19542. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  19543. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19544. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  19545. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  19546. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19547. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  19548. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  19549. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  19550. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  19551. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  19552. /** @hidden */
  19553. export var defaultPixelShader: {
  19554. name: string;
  19555. shader: string;
  19556. };
  19557. }
  19558. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  19559. /** @hidden */
  19560. export var defaultVertexDeclaration: {
  19561. name: string;
  19562. shader: string;
  19563. };
  19564. }
  19565. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  19566. /** @hidden */
  19567. export var bonesDeclaration: {
  19568. name: string;
  19569. shader: string;
  19570. };
  19571. }
  19572. declare module "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration" {
  19573. /** @hidden */
  19574. export var prePassVertexDeclaration: {
  19575. name: string;
  19576. shader: string;
  19577. };
  19578. }
  19579. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  19580. /** @hidden */
  19581. export var bumpVertexDeclaration: {
  19582. name: string;
  19583. shader: string;
  19584. };
  19585. }
  19586. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  19587. /** @hidden */
  19588. export var fogVertexDeclaration: {
  19589. name: string;
  19590. shader: string;
  19591. };
  19592. }
  19593. declare module "babylonjs/Shaders/ShadersInclude/lightVxFragmentDeclaration" {
  19594. /** @hidden */
  19595. export var lightVxFragmentDeclaration: {
  19596. name: string;
  19597. shader: string;
  19598. };
  19599. }
  19600. declare module "babylonjs/Shaders/ShadersInclude/lightVxUboDeclaration" {
  19601. /** @hidden */
  19602. export var lightVxUboDeclaration: {
  19603. name: string;
  19604. shader: string;
  19605. };
  19606. }
  19607. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  19608. /** @hidden */
  19609. export var morphTargetsVertexGlobalDeclaration: {
  19610. name: string;
  19611. shader: string;
  19612. };
  19613. }
  19614. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  19615. /** @hidden */
  19616. export var morphTargetsVertexDeclaration: {
  19617. name: string;
  19618. shader: string;
  19619. };
  19620. }
  19621. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  19622. /** @hidden */
  19623. export var morphTargetsVertex: {
  19624. name: string;
  19625. shader: string;
  19626. };
  19627. }
  19628. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  19629. /** @hidden */
  19630. export var instancesVertex: {
  19631. name: string;
  19632. shader: string;
  19633. };
  19634. }
  19635. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  19636. /** @hidden */
  19637. export var bonesVertex: {
  19638. name: string;
  19639. shader: string;
  19640. };
  19641. }
  19642. declare module "babylonjs/Shaders/ShadersInclude/prePassVertex" {
  19643. /** @hidden */
  19644. export var prePassVertex: {
  19645. name: string;
  19646. shader: string;
  19647. };
  19648. }
  19649. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  19650. /** @hidden */
  19651. export var bumpVertex: {
  19652. name: string;
  19653. shader: string;
  19654. };
  19655. }
  19656. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  19657. /** @hidden */
  19658. export var fogVertex: {
  19659. name: string;
  19660. shader: string;
  19661. };
  19662. }
  19663. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  19664. /** @hidden */
  19665. export var shadowsVertex: {
  19666. name: string;
  19667. shader: string;
  19668. };
  19669. }
  19670. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  19671. /** @hidden */
  19672. export var pointCloudVertex: {
  19673. name: string;
  19674. shader: string;
  19675. };
  19676. }
  19677. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  19678. /** @hidden */
  19679. export var logDepthVertex: {
  19680. name: string;
  19681. shader: string;
  19682. };
  19683. }
  19684. declare module "babylonjs/Shaders/default.vertex" {
  19685. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  19686. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  19687. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  19688. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19689. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  19690. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  19691. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19692. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  19693. import "babylonjs/Shaders/ShadersInclude/lightVxFragmentDeclaration";
  19694. import "babylonjs/Shaders/ShadersInclude/lightVxUboDeclaration";
  19695. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  19696. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  19697. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  19698. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  19699. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19700. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19701. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  19702. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  19703. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19704. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  19705. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  19706. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  19707. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  19708. /** @hidden */
  19709. export var defaultVertexShader: {
  19710. name: string;
  19711. shader: string;
  19712. };
  19713. }
  19714. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  19715. import { Nullable } from "babylonjs/types";
  19716. import { Scene } from "babylonjs/scene";
  19717. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19718. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19719. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  19720. /**
  19721. * @hidden
  19722. */
  19723. export interface IMaterialDetailMapDefines {
  19724. DETAIL: boolean;
  19725. DETAILDIRECTUV: number;
  19726. DETAIL_NORMALBLENDMETHOD: number;
  19727. /** @hidden */
  19728. _areTexturesDirty: boolean;
  19729. }
  19730. /**
  19731. * Define the code related to the detail map parameters of a material
  19732. *
  19733. * Inspired from:
  19734. * 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
  19735. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  19736. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  19737. */
  19738. export class DetailMapConfiguration {
  19739. private _texture;
  19740. /**
  19741. * The detail texture of the material.
  19742. */
  19743. texture: Nullable<BaseTexture>;
  19744. /**
  19745. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  19746. * Bigger values mean stronger blending
  19747. */
  19748. diffuseBlendLevel: number;
  19749. /**
  19750. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  19751. * Bigger values mean stronger blending. Only used with PBR materials
  19752. */
  19753. roughnessBlendLevel: number;
  19754. /**
  19755. * Defines how strong the bump effect from the detail map is
  19756. * Bigger values mean stronger effect
  19757. */
  19758. bumpLevel: number;
  19759. private _normalBlendMethod;
  19760. /**
  19761. * The method used to blend the bump and detail normals together
  19762. */
  19763. normalBlendMethod: number;
  19764. private _isEnabled;
  19765. /**
  19766. * Enable or disable the detail map on this material
  19767. */
  19768. isEnabled: boolean;
  19769. /** @hidden */
  19770. private _internalMarkAllSubMeshesAsTexturesDirty;
  19771. /** @hidden */
  19772. _markAllSubMeshesAsTexturesDirty(): void;
  19773. /**
  19774. * Instantiate a new detail map
  19775. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19776. */
  19777. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19778. /**
  19779. * Gets whether the submesh is ready to be used or not.
  19780. * @param defines the list of "defines" to update.
  19781. * @param scene defines the scene the material belongs to.
  19782. * @returns - boolean indicating that the submesh is ready or not.
  19783. */
  19784. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  19785. /**
  19786. * Update the defines for detail map usage
  19787. * @param defines the list of "defines" to update.
  19788. * @param scene defines the scene the material belongs to.
  19789. */
  19790. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  19791. /**
  19792. * Binds the material data.
  19793. * @param uniformBuffer defines the Uniform buffer to fill in.
  19794. * @param scene defines the scene the material belongs to.
  19795. * @param isFrozen defines whether the material is frozen or not.
  19796. */
  19797. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  19798. /**
  19799. * Checks to see if a texture is used in the material.
  19800. * @param texture - Base texture to use.
  19801. * @returns - Boolean specifying if a texture is used in the material.
  19802. */
  19803. hasTexture(texture: BaseTexture): boolean;
  19804. /**
  19805. * Returns an array of the actively used textures.
  19806. * @param activeTextures Array of BaseTextures
  19807. */
  19808. getActiveTextures(activeTextures: BaseTexture[]): void;
  19809. /**
  19810. * Returns the animatable textures.
  19811. * @param animatables Array of animatable textures.
  19812. */
  19813. getAnimatables(animatables: IAnimatable[]): void;
  19814. /**
  19815. * Disposes the resources of the material.
  19816. * @param forceDisposeTextures - Forces the disposal of all textures.
  19817. */
  19818. dispose(forceDisposeTextures?: boolean): void;
  19819. /**
  19820. * Get the current class name useful for serialization or dynamic coding.
  19821. * @returns "DetailMap"
  19822. */
  19823. getClassName(): string;
  19824. /**
  19825. * Add the required uniforms to the current list.
  19826. * @param uniforms defines the current uniform list.
  19827. */
  19828. static AddUniforms(uniforms: string[]): void;
  19829. /**
  19830. * Add the required samplers to the current list.
  19831. * @param samplers defines the current sampler list.
  19832. */
  19833. static AddSamplers(samplers: string[]): void;
  19834. /**
  19835. * Add the required uniforms to the current buffer.
  19836. * @param uniformBuffer defines the current uniform buffer.
  19837. */
  19838. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19839. /**
  19840. * Makes a duplicate of the current instance into another one.
  19841. * @param detailMap define the instance where to copy the info
  19842. */
  19843. copyTo(detailMap: DetailMapConfiguration): void;
  19844. /**
  19845. * Serializes this detail map instance
  19846. * @returns - An object with the serialized instance.
  19847. */
  19848. serialize(): any;
  19849. /**
  19850. * Parses a detail map setting from a serialized object.
  19851. * @param source - Serialized object.
  19852. * @param scene Defines the scene we are parsing for
  19853. * @param rootUrl Defines the rootUrl to load from
  19854. */
  19855. parse(source: any, scene: Scene, rootUrl: string): void;
  19856. }
  19857. }
  19858. declare module "babylonjs/Materials/standardMaterial" {
  19859. import { SmartArray } from "babylonjs/Misc/smartArray";
  19860. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  19861. import { Nullable } from "babylonjs/types";
  19862. import { Scene } from "babylonjs/scene";
  19863. import { Matrix } from "babylonjs/Maths/math.vector";
  19864. import { Color3 } from "babylonjs/Maths/math.color";
  19865. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19866. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19867. import { Mesh } from "babylonjs/Meshes/mesh";
  19868. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  19869. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  19870. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  19871. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  19872. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  19873. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  19874. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19875. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19876. import "babylonjs/Shaders/default.fragment";
  19877. import "babylonjs/Shaders/default.vertex";
  19878. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  19879. /** @hidden */
  19880. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  19881. MAINUV1: boolean;
  19882. MAINUV2: boolean;
  19883. DIFFUSE: boolean;
  19884. DIFFUSEDIRECTUV: number;
  19885. DETAIL: boolean;
  19886. DETAILDIRECTUV: number;
  19887. DETAIL_NORMALBLENDMETHOD: number;
  19888. AMBIENT: boolean;
  19889. AMBIENTDIRECTUV: number;
  19890. OPACITY: boolean;
  19891. OPACITYDIRECTUV: number;
  19892. OPACITYRGB: boolean;
  19893. REFLECTION: boolean;
  19894. EMISSIVE: boolean;
  19895. EMISSIVEDIRECTUV: number;
  19896. SPECULAR: boolean;
  19897. SPECULARDIRECTUV: number;
  19898. BUMP: boolean;
  19899. BUMPDIRECTUV: number;
  19900. PARALLAX: boolean;
  19901. PARALLAXOCCLUSION: boolean;
  19902. SPECULAROVERALPHA: boolean;
  19903. CLIPPLANE: boolean;
  19904. CLIPPLANE2: boolean;
  19905. CLIPPLANE3: boolean;
  19906. CLIPPLANE4: boolean;
  19907. CLIPPLANE5: boolean;
  19908. CLIPPLANE6: boolean;
  19909. ALPHATEST: boolean;
  19910. DEPTHPREPASS: boolean;
  19911. ALPHAFROMDIFFUSE: boolean;
  19912. POINTSIZE: boolean;
  19913. FOG: boolean;
  19914. SPECULARTERM: boolean;
  19915. DIFFUSEFRESNEL: boolean;
  19916. OPACITYFRESNEL: boolean;
  19917. REFLECTIONFRESNEL: boolean;
  19918. REFRACTIONFRESNEL: boolean;
  19919. EMISSIVEFRESNEL: boolean;
  19920. FRESNEL: boolean;
  19921. NORMAL: boolean;
  19922. UV1: boolean;
  19923. UV2: boolean;
  19924. VERTEXCOLOR: boolean;
  19925. VERTEXALPHA: boolean;
  19926. NUM_BONE_INFLUENCERS: number;
  19927. BonesPerMesh: number;
  19928. BONETEXTURE: boolean;
  19929. BONES_VELOCITY_ENABLED: boolean;
  19930. INSTANCES: boolean;
  19931. THIN_INSTANCES: boolean;
  19932. GLOSSINESS: boolean;
  19933. ROUGHNESS: boolean;
  19934. EMISSIVEASILLUMINATION: boolean;
  19935. LINKEMISSIVEWITHDIFFUSE: boolean;
  19936. REFLECTIONFRESNELFROMSPECULAR: boolean;
  19937. LIGHTMAP: boolean;
  19938. LIGHTMAPDIRECTUV: number;
  19939. OBJECTSPACE_NORMALMAP: boolean;
  19940. USELIGHTMAPASSHADOWMAP: boolean;
  19941. REFLECTIONMAP_3D: boolean;
  19942. REFLECTIONMAP_SPHERICAL: boolean;
  19943. REFLECTIONMAP_PLANAR: boolean;
  19944. REFLECTIONMAP_CUBIC: boolean;
  19945. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  19946. REFLECTIONMAP_PROJECTION: boolean;
  19947. REFLECTIONMAP_SKYBOX: boolean;
  19948. REFLECTIONMAP_EXPLICIT: boolean;
  19949. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  19950. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  19951. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  19952. INVERTCUBICMAP: boolean;
  19953. LOGARITHMICDEPTH: boolean;
  19954. REFRACTION: boolean;
  19955. REFRACTIONMAP_3D: boolean;
  19956. REFLECTIONOVERALPHA: boolean;
  19957. TWOSIDEDLIGHTING: boolean;
  19958. SHADOWFLOAT: boolean;
  19959. MORPHTARGETS: boolean;
  19960. MORPHTARGETS_NORMAL: boolean;
  19961. MORPHTARGETS_TANGENT: boolean;
  19962. MORPHTARGETS_UV: boolean;
  19963. NUM_MORPH_INFLUENCERS: number;
  19964. NONUNIFORMSCALING: boolean;
  19965. PREMULTIPLYALPHA: boolean;
  19966. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  19967. ALPHABLEND: boolean;
  19968. PREPASS: boolean;
  19969. PREPASS_IRRADIANCE: boolean;
  19970. PREPASS_IRRADIANCE_INDEX: number;
  19971. PREPASS_ALBEDO: boolean;
  19972. PREPASS_ALBEDO_INDEX: number;
  19973. PREPASS_DEPTHNORMAL: boolean;
  19974. PREPASS_DEPTHNORMAL_INDEX: number;
  19975. PREPASS_POSITION: boolean;
  19976. PREPASS_POSITION_INDEX: number;
  19977. PREPASS_VELOCITY: boolean;
  19978. PREPASS_VELOCITY_INDEX: number;
  19979. PREPASS_REFLECTIVITY: boolean;
  19980. PREPASS_REFLECTIVITY_INDEX: number;
  19981. SCENE_MRT_COUNT: number;
  19982. RGBDLIGHTMAP: boolean;
  19983. RGBDREFLECTION: boolean;
  19984. RGBDREFRACTION: boolean;
  19985. IMAGEPROCESSING: boolean;
  19986. VIGNETTE: boolean;
  19987. VIGNETTEBLENDMODEMULTIPLY: boolean;
  19988. VIGNETTEBLENDMODEOPAQUE: boolean;
  19989. TONEMAPPING: boolean;
  19990. TONEMAPPING_ACES: boolean;
  19991. CONTRAST: boolean;
  19992. COLORCURVES: boolean;
  19993. COLORGRADING: boolean;
  19994. COLORGRADING3D: boolean;
  19995. SAMPLER3DGREENDEPTH: boolean;
  19996. SAMPLER3DBGRMAP: boolean;
  19997. IMAGEPROCESSINGPOSTPROCESS: boolean;
  19998. MULTIVIEW: boolean;
  19999. /**
  20000. * If the reflection texture on this material is in linear color space
  20001. * @hidden
  20002. */
  20003. IS_REFLECTION_LINEAR: boolean;
  20004. /**
  20005. * If the refraction texture on this material is in linear color space
  20006. * @hidden
  20007. */
  20008. IS_REFRACTION_LINEAR: boolean;
  20009. EXPOSURE: boolean;
  20010. constructor();
  20011. setReflectionMode(modeToEnable: string): void;
  20012. }
  20013. /**
  20014. * This is the default material used in Babylon. It is the best trade off between quality
  20015. * and performances.
  20016. * @see https://doc.babylonjs.com/babylon101/materials
  20017. */
  20018. export class StandardMaterial extends PushMaterial {
  20019. private _diffuseTexture;
  20020. /**
  20021. * The basic texture of the material as viewed under a light.
  20022. */
  20023. diffuseTexture: Nullable<BaseTexture>;
  20024. private _ambientTexture;
  20025. /**
  20026. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  20027. */
  20028. ambientTexture: Nullable<BaseTexture>;
  20029. private _opacityTexture;
  20030. /**
  20031. * Define the transparency of the material from a texture.
  20032. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  20033. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  20034. */
  20035. opacityTexture: Nullable<BaseTexture>;
  20036. private _reflectionTexture;
  20037. /**
  20038. * Define the texture used to display the reflection.
  20039. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  20040. */
  20041. reflectionTexture: Nullable<BaseTexture>;
  20042. private _emissiveTexture;
  20043. /**
  20044. * Define texture of the material as if self lit.
  20045. * This will be mixed in the final result even in the absence of light.
  20046. */
  20047. emissiveTexture: Nullable<BaseTexture>;
  20048. private _specularTexture;
  20049. /**
  20050. * Define how the color and intensity of the highlight given by the light in the material.
  20051. */
  20052. specularTexture: Nullable<BaseTexture>;
  20053. private _bumpTexture;
  20054. /**
  20055. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  20056. * 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.
  20057. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  20058. */
  20059. bumpTexture: Nullable<BaseTexture>;
  20060. private _lightmapTexture;
  20061. /**
  20062. * Complex lighting can be computationally expensive to compute at runtime.
  20063. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  20064. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  20065. */
  20066. lightmapTexture: Nullable<BaseTexture>;
  20067. private _refractionTexture;
  20068. /**
  20069. * Define the texture used to display the refraction.
  20070. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  20071. */
  20072. refractionTexture: Nullable<BaseTexture>;
  20073. /**
  20074. * The color of the material lit by the environmental background lighting.
  20075. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  20076. */
  20077. ambientColor: Color3;
  20078. /**
  20079. * The basic color of the material as viewed under a light.
  20080. */
  20081. diffuseColor: Color3;
  20082. /**
  20083. * Define how the color and intensity of the highlight given by the light in the material.
  20084. */
  20085. specularColor: Color3;
  20086. /**
  20087. * Define the color of the material as if self lit.
  20088. * This will be mixed in the final result even in the absence of light.
  20089. */
  20090. emissiveColor: Color3;
  20091. /**
  20092. * Defines how sharp are the highlights in the material.
  20093. * The bigger the value the sharper giving a more glossy feeling to the result.
  20094. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  20095. */
  20096. specularPower: number;
  20097. private _useAlphaFromDiffuseTexture;
  20098. /**
  20099. * Does the transparency come from the diffuse texture alpha channel.
  20100. */
  20101. useAlphaFromDiffuseTexture: boolean;
  20102. private _useEmissiveAsIllumination;
  20103. /**
  20104. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  20105. */
  20106. useEmissiveAsIllumination: boolean;
  20107. private _linkEmissiveWithDiffuse;
  20108. /**
  20109. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  20110. * the emissive level when the final color is close to one.
  20111. */
  20112. linkEmissiveWithDiffuse: boolean;
  20113. private _useSpecularOverAlpha;
  20114. /**
  20115. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  20116. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  20117. */
  20118. useSpecularOverAlpha: boolean;
  20119. private _useReflectionOverAlpha;
  20120. /**
  20121. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  20122. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  20123. */
  20124. useReflectionOverAlpha: boolean;
  20125. private _disableLighting;
  20126. /**
  20127. * Does lights from the scene impacts this material.
  20128. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  20129. */
  20130. disableLighting: boolean;
  20131. private _useObjectSpaceNormalMap;
  20132. /**
  20133. * Allows using an object space normal map (instead of tangent space).
  20134. */
  20135. useObjectSpaceNormalMap: boolean;
  20136. private _useParallax;
  20137. /**
  20138. * Is parallax enabled or not.
  20139. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  20140. */
  20141. useParallax: boolean;
  20142. private _useParallaxOcclusion;
  20143. /**
  20144. * Is parallax occlusion enabled or not.
  20145. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  20146. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  20147. */
  20148. useParallaxOcclusion: boolean;
  20149. /**
  20150. * 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.
  20151. */
  20152. parallaxScaleBias: number;
  20153. private _roughness;
  20154. /**
  20155. * Helps to define how blurry the reflections should appears in the material.
  20156. */
  20157. roughness: number;
  20158. /**
  20159. * In case of refraction, define the value of the index of refraction.
  20160. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  20161. */
  20162. indexOfRefraction: number;
  20163. /**
  20164. * Invert the refraction texture alongside the y axis.
  20165. * It can be useful with procedural textures or probe for instance.
  20166. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  20167. */
  20168. invertRefractionY: boolean;
  20169. /**
  20170. * Defines the alpha limits in alpha test mode.
  20171. */
  20172. alphaCutOff: number;
  20173. private _useLightmapAsShadowmap;
  20174. /**
  20175. * In case of light mapping, define whether the map contains light or shadow informations.
  20176. */
  20177. useLightmapAsShadowmap: boolean;
  20178. private _diffuseFresnelParameters;
  20179. /**
  20180. * Define the diffuse fresnel parameters of the material.
  20181. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  20182. */
  20183. diffuseFresnelParameters: FresnelParameters;
  20184. private _opacityFresnelParameters;
  20185. /**
  20186. * Define the opacity fresnel parameters of the material.
  20187. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  20188. */
  20189. opacityFresnelParameters: FresnelParameters;
  20190. private _reflectionFresnelParameters;
  20191. /**
  20192. * Define the reflection fresnel parameters of the material.
  20193. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  20194. */
  20195. reflectionFresnelParameters: FresnelParameters;
  20196. private _refractionFresnelParameters;
  20197. /**
  20198. * Define the refraction fresnel parameters of the material.
  20199. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  20200. */
  20201. refractionFresnelParameters: FresnelParameters;
  20202. private _emissiveFresnelParameters;
  20203. /**
  20204. * Define the emissive fresnel parameters of the material.
  20205. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  20206. */
  20207. emissiveFresnelParameters: FresnelParameters;
  20208. private _useReflectionFresnelFromSpecular;
  20209. /**
  20210. * If true automatically deducts the fresnels values from the material specularity.
  20211. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  20212. */
  20213. useReflectionFresnelFromSpecular: boolean;
  20214. private _useGlossinessFromSpecularMapAlpha;
  20215. /**
  20216. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  20217. */
  20218. useGlossinessFromSpecularMapAlpha: boolean;
  20219. private _maxSimultaneousLights;
  20220. /**
  20221. * Defines the maximum number of lights that can be used in the material
  20222. */
  20223. maxSimultaneousLights: number;
  20224. private _invertNormalMapX;
  20225. /**
  20226. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  20227. */
  20228. invertNormalMapX: boolean;
  20229. private _invertNormalMapY;
  20230. /**
  20231. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  20232. */
  20233. invertNormalMapY: boolean;
  20234. private _twoSidedLighting;
  20235. /**
  20236. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  20237. */
  20238. twoSidedLighting: boolean;
  20239. /**
  20240. * Default configuration related to image processing available in the standard Material.
  20241. */
  20242. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  20243. /**
  20244. * Gets the image processing configuration used either in this material.
  20245. */
  20246. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  20247. /**
  20248. * Sets the Default image processing configuration used either in the this material.
  20249. *
  20250. * If sets to null, the scene one is in use.
  20251. */
  20252. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  20253. /**
  20254. * Keep track of the image processing observer to allow dispose and replace.
  20255. */
  20256. private _imageProcessingObserver;
  20257. /**
  20258. * Attaches a new image processing configuration to the Standard Material.
  20259. * @param configuration
  20260. */
  20261. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  20262. /**
  20263. * Defines additionnal PrePass parameters for the material.
  20264. */
  20265. readonly prePassConfiguration: PrePassConfiguration;
  20266. /**
  20267. * Gets wether the color curves effect is enabled.
  20268. */
  20269. get cameraColorCurvesEnabled(): boolean;
  20270. /**
  20271. * Sets wether the color curves effect is enabled.
  20272. */
  20273. set cameraColorCurvesEnabled(value: boolean);
  20274. /**
  20275. * Gets wether the color grading effect is enabled.
  20276. */
  20277. get cameraColorGradingEnabled(): boolean;
  20278. /**
  20279. * Gets wether the color grading effect is enabled.
  20280. */
  20281. set cameraColorGradingEnabled(value: boolean);
  20282. /**
  20283. * Gets wether tonemapping is enabled or not.
  20284. */
  20285. get cameraToneMappingEnabled(): boolean;
  20286. /**
  20287. * Sets wether tonemapping is enabled or not
  20288. */
  20289. set cameraToneMappingEnabled(value: boolean);
  20290. /**
  20291. * The camera exposure used on this material.
  20292. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  20293. * This corresponds to a photographic exposure.
  20294. */
  20295. get cameraExposure(): number;
  20296. /**
  20297. * The camera exposure used on this material.
  20298. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  20299. * This corresponds to a photographic exposure.
  20300. */
  20301. set cameraExposure(value: number);
  20302. /**
  20303. * Gets The camera contrast used on this material.
  20304. */
  20305. get cameraContrast(): number;
  20306. /**
  20307. * Sets The camera contrast used on this material.
  20308. */
  20309. set cameraContrast(value: number);
  20310. /**
  20311. * Gets the Color Grading 2D Lookup Texture.
  20312. */
  20313. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  20314. /**
  20315. * Sets the Color Grading 2D Lookup Texture.
  20316. */
  20317. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  20318. /**
  20319. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  20320. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  20321. * 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;
  20322. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  20323. */
  20324. get cameraColorCurves(): Nullable<ColorCurves>;
  20325. /**
  20326. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  20327. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  20328. * 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;
  20329. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  20330. */
  20331. set cameraColorCurves(value: Nullable<ColorCurves>);
  20332. /**
  20333. * Can this material render to several textures at once
  20334. */
  20335. get canRenderToMRT(): boolean;
  20336. /**
  20337. * Defines the detail map parameters for the material.
  20338. */
  20339. readonly detailMap: DetailMapConfiguration;
  20340. protected _renderTargets: SmartArray<RenderTargetTexture>;
  20341. protected _worldViewProjectionMatrix: Matrix;
  20342. protected _globalAmbientColor: Color3;
  20343. protected _useLogarithmicDepth: boolean;
  20344. protected _rebuildInParallel: boolean;
  20345. /**
  20346. * Instantiates a new standard material.
  20347. * This is the default material used in Babylon. It is the best trade off between quality
  20348. * and performances.
  20349. * @see https://doc.babylonjs.com/babylon101/materials
  20350. * @param name Define the name of the material in the scene
  20351. * @param scene Define the scene the material belong to
  20352. */
  20353. constructor(name: string, scene: Scene);
  20354. /**
  20355. * Gets a boolean indicating that current material needs to register RTT
  20356. */
  20357. get hasRenderTargetTextures(): boolean;
  20358. /**
  20359. * Gets the current class name of the material e.g. "StandardMaterial"
  20360. * Mainly use in serialization.
  20361. * @returns the class name
  20362. */
  20363. getClassName(): string;
  20364. /**
  20365. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  20366. * You can try switching to logarithmic depth.
  20367. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  20368. */
  20369. get useLogarithmicDepth(): boolean;
  20370. set useLogarithmicDepth(value: boolean);
  20371. /**
  20372. * Specifies if the material will require alpha blending
  20373. * @returns a boolean specifying if alpha blending is needed
  20374. */
  20375. needAlphaBlending(): boolean;
  20376. /**
  20377. * Specifies if this material should be rendered in alpha test mode
  20378. * @returns a boolean specifying if an alpha test is needed.
  20379. */
  20380. needAlphaTesting(): boolean;
  20381. /**
  20382. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  20383. */
  20384. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  20385. /**
  20386. * Specifies whether or not there is a usable alpha channel for transparency.
  20387. */
  20388. protected _hasAlphaChannel(): boolean;
  20389. /**
  20390. * Get the texture used for alpha test purpose.
  20391. * @returns the diffuse texture in case of the standard material.
  20392. */
  20393. getAlphaTestTexture(): Nullable<BaseTexture>;
  20394. /**
  20395. * Get if the submesh is ready to be used and all its information available.
  20396. * Child classes can use it to update shaders
  20397. * @param mesh defines the mesh to check
  20398. * @param subMesh defines which submesh to check
  20399. * @param useInstances specifies that instances should be used
  20400. * @returns a boolean indicating that the submesh is ready or not
  20401. */
  20402. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  20403. /**
  20404. * Builds the material UBO layouts.
  20405. * Used internally during the effect preparation.
  20406. */
  20407. buildUniformLayout(): void;
  20408. /**
  20409. * Unbinds the material from the mesh
  20410. */
  20411. unbind(): void;
  20412. /**
  20413. * Binds the submesh to this material by preparing the effect and shader to draw
  20414. * @param world defines the world transformation matrix
  20415. * @param mesh defines the mesh containing the submesh
  20416. * @param subMesh defines the submesh to bind the material to
  20417. */
  20418. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20419. /**
  20420. * Get the list of animatables in the material.
  20421. * @returns the list of animatables object used in the material
  20422. */
  20423. getAnimatables(): IAnimatable[];
  20424. /**
  20425. * Gets the active textures from the material
  20426. * @returns an array of textures
  20427. */
  20428. getActiveTextures(): BaseTexture[];
  20429. /**
  20430. * Specifies if the material uses a texture
  20431. * @param texture defines the texture to check against the material
  20432. * @returns a boolean specifying if the material uses the texture
  20433. */
  20434. hasTexture(texture: BaseTexture): boolean;
  20435. /**
  20436. * Disposes the material
  20437. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20438. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20439. */
  20440. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  20441. /**
  20442. * Makes a duplicate of the material, and gives it a new name
  20443. * @param name defines the new name for the duplicated material
  20444. * @returns the cloned material
  20445. */
  20446. clone(name: string): StandardMaterial;
  20447. /**
  20448. * Serializes this material in a JSON representation
  20449. * @returns the serialized material object
  20450. */
  20451. serialize(): any;
  20452. /**
  20453. * Creates a standard material from parsed material data
  20454. * @param source defines the JSON representation of the material
  20455. * @param scene defines the hosting scene
  20456. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20457. * @returns a new standard material
  20458. */
  20459. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  20460. /**
  20461. * Are diffuse textures enabled in the application.
  20462. */
  20463. static get DiffuseTextureEnabled(): boolean;
  20464. static set DiffuseTextureEnabled(value: boolean);
  20465. /**
  20466. * Are detail textures enabled in the application.
  20467. */
  20468. static get DetailTextureEnabled(): boolean;
  20469. static set DetailTextureEnabled(value: boolean);
  20470. /**
  20471. * Are ambient textures enabled in the application.
  20472. */
  20473. static get AmbientTextureEnabled(): boolean;
  20474. static set AmbientTextureEnabled(value: boolean);
  20475. /**
  20476. * Are opacity textures enabled in the application.
  20477. */
  20478. static get OpacityTextureEnabled(): boolean;
  20479. static set OpacityTextureEnabled(value: boolean);
  20480. /**
  20481. * Are reflection textures enabled in the application.
  20482. */
  20483. static get ReflectionTextureEnabled(): boolean;
  20484. static set ReflectionTextureEnabled(value: boolean);
  20485. /**
  20486. * Are emissive textures enabled in the application.
  20487. */
  20488. static get EmissiveTextureEnabled(): boolean;
  20489. static set EmissiveTextureEnabled(value: boolean);
  20490. /**
  20491. * Are specular textures enabled in the application.
  20492. */
  20493. static get SpecularTextureEnabled(): boolean;
  20494. static set SpecularTextureEnabled(value: boolean);
  20495. /**
  20496. * Are bump textures enabled in the application.
  20497. */
  20498. static get BumpTextureEnabled(): boolean;
  20499. static set BumpTextureEnabled(value: boolean);
  20500. /**
  20501. * Are lightmap textures enabled in the application.
  20502. */
  20503. static get LightmapTextureEnabled(): boolean;
  20504. static set LightmapTextureEnabled(value: boolean);
  20505. /**
  20506. * Are refraction textures enabled in the application.
  20507. */
  20508. static get RefractionTextureEnabled(): boolean;
  20509. static set RefractionTextureEnabled(value: boolean);
  20510. /**
  20511. * Are color grading textures enabled in the application.
  20512. */
  20513. static get ColorGradingTextureEnabled(): boolean;
  20514. static set ColorGradingTextureEnabled(value: boolean);
  20515. /**
  20516. * Are fresnels enabled in the application.
  20517. */
  20518. static get FresnelEnabled(): boolean;
  20519. static set FresnelEnabled(value: boolean);
  20520. }
  20521. }
  20522. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  20523. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  20524. /** @hidden */
  20525. export var rgbdDecodePixelShader: {
  20526. name: string;
  20527. shader: string;
  20528. };
  20529. }
  20530. declare module "babylonjs/Shaders/pass.fragment" {
  20531. /** @hidden */
  20532. export var passPixelShader: {
  20533. name: string;
  20534. shader: string;
  20535. };
  20536. }
  20537. declare module "babylonjs/Shaders/passCube.fragment" {
  20538. /** @hidden */
  20539. export var passCubePixelShader: {
  20540. name: string;
  20541. shader: string;
  20542. };
  20543. }
  20544. declare module "babylonjs/PostProcesses/passPostProcess" {
  20545. import { Nullable } from "babylonjs/types";
  20546. import { Camera } from "babylonjs/Cameras/camera";
  20547. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  20548. import { Engine } from "babylonjs/Engines/engine";
  20549. import "babylonjs/Shaders/pass.fragment";
  20550. import "babylonjs/Shaders/passCube.fragment";
  20551. import { Scene } from "babylonjs/scene";
  20552. /**
  20553. * PassPostProcess which produces an output the same as it's input
  20554. */
  20555. export class PassPostProcess extends PostProcess {
  20556. /**
  20557. * Gets a string identifying the name of the class
  20558. * @returns "PassPostProcess" string
  20559. */
  20560. getClassName(): string;
  20561. /**
  20562. * Creates the PassPostProcess
  20563. * @param name The name of the effect.
  20564. * @param options The required width/height ratio to downsize to before computing the render pass.
  20565. * @param camera The camera to apply the render pass to.
  20566. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20567. * @param engine The engine which the post process will be applied. (default: current engine)
  20568. * @param reusable If the post process can be reused on the same frame. (default: false)
  20569. * @param textureType The type of texture to be used when performing the post processing.
  20570. * @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)
  20571. */
  20572. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  20573. /** @hidden */
  20574. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  20575. }
  20576. /**
  20577. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  20578. */
  20579. export class PassCubePostProcess extends PostProcess {
  20580. private _face;
  20581. /**
  20582. * Gets or sets the cube face to display.
  20583. * * 0 is +X
  20584. * * 1 is -X
  20585. * * 2 is +Y
  20586. * * 3 is -Y
  20587. * * 4 is +Z
  20588. * * 5 is -Z
  20589. */
  20590. get face(): number;
  20591. set face(value: number);
  20592. /**
  20593. * Gets a string identifying the name of the class
  20594. * @returns "PassCubePostProcess" string
  20595. */
  20596. getClassName(): string;
  20597. /**
  20598. * Creates the PassCubePostProcess
  20599. * @param name The name of the effect.
  20600. * @param options The required width/height ratio to downsize to before computing the render pass.
  20601. * @param camera The camera to apply the render pass to.
  20602. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20603. * @param engine The engine which the post process will be applied. (default: current engine)
  20604. * @param reusable If the post process can be reused on the same frame. (default: false)
  20605. * @param textureType The type of texture to be used when performing the post processing.
  20606. * @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)
  20607. */
  20608. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  20609. /** @hidden */
  20610. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  20611. }
  20612. }
  20613. declare module "babylonjs/Misc/textureTools" {
  20614. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20615. import { Texture } from "babylonjs/Materials/Textures/texture";
  20616. import { Scene } from "babylonjs/scene";
  20617. /**
  20618. * Class used to host texture specific utilities
  20619. */
  20620. export class TextureTools {
  20621. /**
  20622. * Uses the GPU to create a copy texture rescaled at a given size
  20623. * @param texture Texture to copy from
  20624. * @param width defines the desired width
  20625. * @param height defines the desired height
  20626. * @param useBilinearMode defines if bilinear mode has to be used
  20627. * @return the generated texture
  20628. */
  20629. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  20630. /**
  20631. * Apply a post process to a texture
  20632. * @param postProcessName name of the fragment post process
  20633. * @param internalTexture the texture to encode
  20634. * @param scene the scene hosting the texture
  20635. * @param type type of the output texture. If not provided, use the one from internalTexture
  20636. * @param samplingMode sampling moode to use to sample the source texture. If not provided, use the one from internalTexture
  20637. * @param format format of the output texture. If not provided, use the one from internalTexture
  20638. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  20639. */
  20640. static ApplyPostProcess(postProcessName: string, internalTexture: InternalTexture, scene: Scene, type?: number, samplingMode?: number, format?: number): Promise<InternalTexture>;
  20641. }
  20642. }
  20643. declare module "babylonjs/Misc/rgbdTextureTools" {
  20644. import "babylonjs/Shaders/rgbdDecode.fragment";
  20645. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20646. import { Texture } from "babylonjs/Materials/Textures/texture";
  20647. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20648. import { Scene } from "babylonjs/scene";
  20649. /**
  20650. * Class used to host RGBD texture specific utilities
  20651. */
  20652. export class RGBDTextureTools {
  20653. /**
  20654. * Expand the RGBD Texture from RGBD to Half Float if possible.
  20655. * @param texture the texture to expand.
  20656. */
  20657. static ExpandRGBDTexture(texture: Texture): void;
  20658. /**
  20659. * Encode the texture to RGBD if possible.
  20660. * @param internalTexture the texture to encode
  20661. * @param scene the scene hosting the texture
  20662. * @param outputTextureType type of the texture in which the encoding is performed
  20663. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  20664. */
  20665. static EncodeTextureToRGBD(internalTexture: InternalTexture, scene: Scene, outputTextureType?: number): Promise<InternalTexture>;
  20666. }
  20667. }
  20668. declare module "babylonjs/Misc/brdfTextureTools" {
  20669. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20670. import { Scene } from "babylonjs/scene";
  20671. /**
  20672. * Class used to host texture specific utilities
  20673. */
  20674. export class BRDFTextureTools {
  20675. /**
  20676. * Prevents texture cache collision
  20677. */
  20678. private static _instanceNumber;
  20679. /**
  20680. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  20681. * @param scene defines the hosting scene
  20682. * @returns the environment BRDF texture
  20683. */
  20684. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  20685. private static _environmentBRDFBase64Texture;
  20686. }
  20687. }
  20688. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  20689. import { Nullable } from "babylonjs/types";
  20690. import { Color3 } from "babylonjs/Maths/math.color";
  20691. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20692. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20693. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20694. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20695. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20696. import { Engine } from "babylonjs/Engines/engine";
  20697. import { Scene } from "babylonjs/scene";
  20698. /**
  20699. * @hidden
  20700. */
  20701. export interface IMaterialClearCoatDefines {
  20702. CLEARCOAT: boolean;
  20703. CLEARCOAT_DEFAULTIOR: boolean;
  20704. CLEARCOAT_TEXTURE: boolean;
  20705. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  20706. CLEARCOAT_TEXTUREDIRECTUV: number;
  20707. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  20708. CLEARCOAT_BUMP: boolean;
  20709. CLEARCOAT_BUMPDIRECTUV: number;
  20710. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20711. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20712. CLEARCOAT_REMAP_F0: boolean;
  20713. CLEARCOAT_TINT: boolean;
  20714. CLEARCOAT_TINT_TEXTURE: boolean;
  20715. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  20716. /** @hidden */
  20717. _areTexturesDirty: boolean;
  20718. }
  20719. /**
  20720. * Define the code related to the clear coat parameters of the pbr material.
  20721. */
  20722. export class PBRClearCoatConfiguration {
  20723. /**
  20724. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20725. * The default fits with a polyurethane material.
  20726. * @hidden
  20727. */
  20728. static readonly _DefaultIndexOfRefraction: number;
  20729. private _isEnabled;
  20730. /**
  20731. * Defines if the clear coat is enabled in the material.
  20732. */
  20733. isEnabled: boolean;
  20734. /**
  20735. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  20736. */
  20737. intensity: number;
  20738. /**
  20739. * Defines the clear coat layer roughness.
  20740. */
  20741. roughness: number;
  20742. private _indexOfRefraction;
  20743. /**
  20744. * Defines the index of refraction of the clear coat.
  20745. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20746. * The default fits with a polyurethane material.
  20747. * Changing the default value is more performance intensive.
  20748. */
  20749. indexOfRefraction: number;
  20750. private _texture;
  20751. /**
  20752. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  20753. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  20754. * if textureRoughness is not empty, else no texture roughness is used
  20755. */
  20756. texture: Nullable<BaseTexture>;
  20757. private _useRoughnessFromMainTexture;
  20758. /**
  20759. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  20760. * If false, the green channel from textureRoughness is used for roughness
  20761. */
  20762. useRoughnessFromMainTexture: boolean;
  20763. private _textureRoughness;
  20764. /**
  20765. * Stores the clear coat roughness in a texture (green channel)
  20766. * Not used if useRoughnessFromMainTexture is true
  20767. */
  20768. textureRoughness: Nullable<BaseTexture>;
  20769. private _remapF0OnInterfaceChange;
  20770. /**
  20771. * Defines if the F0 value should be remapped to account for the interface change in the material.
  20772. */
  20773. remapF0OnInterfaceChange: boolean;
  20774. private _bumpTexture;
  20775. /**
  20776. * Define the clear coat specific bump texture.
  20777. */
  20778. bumpTexture: Nullable<BaseTexture>;
  20779. private _isTintEnabled;
  20780. /**
  20781. * Defines if the clear coat tint is enabled in the material.
  20782. */
  20783. isTintEnabled: boolean;
  20784. /**
  20785. * Defines the clear coat tint of the material.
  20786. * This is only use if tint is enabled
  20787. */
  20788. tintColor: Color3;
  20789. /**
  20790. * Defines the distance at which the tint color should be found in the
  20791. * clear coat media.
  20792. * This is only use if tint is enabled
  20793. */
  20794. tintColorAtDistance: number;
  20795. /**
  20796. * Defines the clear coat layer thickness.
  20797. * This is only use if tint is enabled
  20798. */
  20799. tintThickness: number;
  20800. private _tintTexture;
  20801. /**
  20802. * Stores the clear tint values in a texture.
  20803. * rgb is tint
  20804. * a is a thickness factor
  20805. */
  20806. tintTexture: Nullable<BaseTexture>;
  20807. /** @hidden */
  20808. private _internalMarkAllSubMeshesAsTexturesDirty;
  20809. /** @hidden */
  20810. _markAllSubMeshesAsTexturesDirty(): void;
  20811. /**
  20812. * Instantiate a new istance of clear coat configuration.
  20813. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20814. */
  20815. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20816. /**
  20817. * Gets wehter the submesh is ready to be used or not.
  20818. * @param defines the list of "defines" to update.
  20819. * @param scene defines the scene the material belongs to.
  20820. * @param engine defines the engine the material belongs to.
  20821. * @param disableBumpMap defines wether the material disables bump or not.
  20822. * @returns - boolean indicating that the submesh is ready or not.
  20823. */
  20824. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  20825. /**
  20826. * Checks to see if a texture is used in the material.
  20827. * @param defines the list of "defines" to update.
  20828. * @param scene defines the scene to the material belongs to.
  20829. */
  20830. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  20831. /**
  20832. * Binds the material data.
  20833. * @param uniformBuffer defines the Uniform buffer to fill in.
  20834. * @param scene defines the scene the material belongs to.
  20835. * @param engine defines the engine the material belongs to.
  20836. * @param disableBumpMap defines wether the material disables bump or not.
  20837. * @param isFrozen defines wether the material is frozen or not.
  20838. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  20839. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  20840. * @param subMesh the submesh to bind data for
  20841. */
  20842. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  20843. /**
  20844. * Checks to see if a texture is used in the material.
  20845. * @param texture - Base texture to use.
  20846. * @returns - Boolean specifying if a texture is used in the material.
  20847. */
  20848. hasTexture(texture: BaseTexture): boolean;
  20849. /**
  20850. * Returns an array of the actively used textures.
  20851. * @param activeTextures Array of BaseTextures
  20852. */
  20853. getActiveTextures(activeTextures: BaseTexture[]): void;
  20854. /**
  20855. * Returns the animatable textures.
  20856. * @param animatables Array of animatable textures.
  20857. */
  20858. getAnimatables(animatables: IAnimatable[]): void;
  20859. /**
  20860. * Disposes the resources of the material.
  20861. * @param forceDisposeTextures - Forces the disposal of all textures.
  20862. */
  20863. dispose(forceDisposeTextures?: boolean): void;
  20864. /**
  20865. * Get the current class name of the texture useful for serialization or dynamic coding.
  20866. * @returns "PBRClearCoatConfiguration"
  20867. */
  20868. getClassName(): string;
  20869. /**
  20870. * Add fallbacks to the effect fallbacks list.
  20871. * @param defines defines the Base texture to use.
  20872. * @param fallbacks defines the current fallback list.
  20873. * @param currentRank defines the current fallback rank.
  20874. * @returns the new fallback rank.
  20875. */
  20876. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20877. /**
  20878. * Add the required uniforms to the current list.
  20879. * @param uniforms defines the current uniform list.
  20880. */
  20881. static AddUniforms(uniforms: string[]): void;
  20882. /**
  20883. * Add the required samplers to the current list.
  20884. * @param samplers defines the current sampler list.
  20885. */
  20886. static AddSamplers(samplers: string[]): void;
  20887. /**
  20888. * Add the required uniforms to the current buffer.
  20889. * @param uniformBuffer defines the current uniform buffer.
  20890. */
  20891. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20892. /**
  20893. * Makes a duplicate of the current configuration into another one.
  20894. * @param clearCoatConfiguration define the config where to copy the info
  20895. */
  20896. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  20897. /**
  20898. * Serializes this clear coat configuration.
  20899. * @returns - An object with the serialized config.
  20900. */
  20901. serialize(): any;
  20902. /**
  20903. * Parses a anisotropy Configuration from a serialized object.
  20904. * @param source - Serialized object.
  20905. * @param scene Defines the scene we are parsing for
  20906. * @param rootUrl Defines the rootUrl to load from
  20907. */
  20908. parse(source: any, scene: Scene, rootUrl: string): void;
  20909. }
  20910. }
  20911. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  20912. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20913. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20914. import { Vector2 } from "babylonjs/Maths/math.vector";
  20915. import { Scene } from "babylonjs/scene";
  20916. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20917. import { Nullable } from "babylonjs/types";
  20918. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20919. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20920. /**
  20921. * @hidden
  20922. */
  20923. export interface IMaterialAnisotropicDefines {
  20924. ANISOTROPIC: boolean;
  20925. ANISOTROPIC_TEXTURE: boolean;
  20926. ANISOTROPIC_TEXTUREDIRECTUV: number;
  20927. MAINUV1: boolean;
  20928. _areTexturesDirty: boolean;
  20929. _needUVs: boolean;
  20930. }
  20931. /**
  20932. * Define the code related to the anisotropic parameters of the pbr material.
  20933. */
  20934. export class PBRAnisotropicConfiguration {
  20935. private _isEnabled;
  20936. /**
  20937. * Defines if the anisotropy is enabled in the material.
  20938. */
  20939. isEnabled: boolean;
  20940. /**
  20941. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  20942. */
  20943. intensity: number;
  20944. /**
  20945. * Defines if the effect is along the tangents, bitangents or in between.
  20946. * By default, the effect is "strectching" the highlights along the tangents.
  20947. */
  20948. direction: Vector2;
  20949. private _texture;
  20950. /**
  20951. * Stores the anisotropy values in a texture.
  20952. * rg is direction (like normal from -1 to 1)
  20953. * b is a intensity
  20954. */
  20955. texture: Nullable<BaseTexture>;
  20956. /** @hidden */
  20957. private _internalMarkAllSubMeshesAsTexturesDirty;
  20958. /** @hidden */
  20959. _markAllSubMeshesAsTexturesDirty(): void;
  20960. /**
  20961. * Instantiate a new istance of anisotropy configuration.
  20962. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20963. */
  20964. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20965. /**
  20966. * Specifies that the submesh is ready to be used.
  20967. * @param defines the list of "defines" to update.
  20968. * @param scene defines the scene the material belongs to.
  20969. * @returns - boolean indicating that the submesh is ready or not.
  20970. */
  20971. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  20972. /**
  20973. * Checks to see if a texture is used in the material.
  20974. * @param defines the list of "defines" to update.
  20975. * @param mesh the mesh we are preparing the defines for.
  20976. * @param scene defines the scene the material belongs to.
  20977. */
  20978. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  20979. /**
  20980. * Binds the material data.
  20981. * @param uniformBuffer defines the Uniform buffer to fill in.
  20982. * @param scene defines the scene the material belongs to.
  20983. * @param isFrozen defines wether the material is frozen or not.
  20984. */
  20985. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  20986. /**
  20987. * Checks to see if a texture is used in the material.
  20988. * @param texture - Base texture to use.
  20989. * @returns - Boolean specifying if a texture is used in the material.
  20990. */
  20991. hasTexture(texture: BaseTexture): boolean;
  20992. /**
  20993. * Returns an array of the actively used textures.
  20994. * @param activeTextures Array of BaseTextures
  20995. */
  20996. getActiveTextures(activeTextures: BaseTexture[]): void;
  20997. /**
  20998. * Returns the animatable textures.
  20999. * @param animatables Array of animatable textures.
  21000. */
  21001. getAnimatables(animatables: IAnimatable[]): void;
  21002. /**
  21003. * Disposes the resources of the material.
  21004. * @param forceDisposeTextures - Forces the disposal of all textures.
  21005. */
  21006. dispose(forceDisposeTextures?: boolean): void;
  21007. /**
  21008. * Get the current class name of the texture useful for serialization or dynamic coding.
  21009. * @returns "PBRAnisotropicConfiguration"
  21010. */
  21011. getClassName(): string;
  21012. /**
  21013. * Add fallbacks to the effect fallbacks list.
  21014. * @param defines defines the Base texture to use.
  21015. * @param fallbacks defines the current fallback list.
  21016. * @param currentRank defines the current fallback rank.
  21017. * @returns the new fallback rank.
  21018. */
  21019. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  21020. /**
  21021. * Add the required uniforms to the current list.
  21022. * @param uniforms defines the current uniform list.
  21023. */
  21024. static AddUniforms(uniforms: string[]): void;
  21025. /**
  21026. * Add the required uniforms to the current buffer.
  21027. * @param uniformBuffer defines the current uniform buffer.
  21028. */
  21029. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  21030. /**
  21031. * Add the required samplers to the current list.
  21032. * @param samplers defines the current sampler list.
  21033. */
  21034. static AddSamplers(samplers: string[]): void;
  21035. /**
  21036. * Makes a duplicate of the current configuration into another one.
  21037. * @param anisotropicConfiguration define the config where to copy the info
  21038. */
  21039. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  21040. /**
  21041. * Serializes this anisotropy configuration.
  21042. * @returns - An object with the serialized config.
  21043. */
  21044. serialize(): any;
  21045. /**
  21046. * Parses a anisotropy Configuration from a serialized object.
  21047. * @param source - Serialized object.
  21048. * @param scene Defines the scene we are parsing for
  21049. * @param rootUrl Defines the rootUrl to load from
  21050. */
  21051. parse(source: any, scene: Scene, rootUrl: string): void;
  21052. }
  21053. }
  21054. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  21055. import { Scene } from "babylonjs/scene";
  21056. /**
  21057. * @hidden
  21058. */
  21059. export interface IMaterialBRDFDefines {
  21060. BRDF_V_HEIGHT_CORRELATED: boolean;
  21061. MS_BRDF_ENERGY_CONSERVATION: boolean;
  21062. SPHERICAL_HARMONICS: boolean;
  21063. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  21064. /** @hidden */
  21065. _areMiscDirty: boolean;
  21066. }
  21067. /**
  21068. * Define the code related to the BRDF parameters of the pbr material.
  21069. */
  21070. export class PBRBRDFConfiguration {
  21071. /**
  21072. * Default value used for the energy conservation.
  21073. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  21074. */
  21075. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  21076. /**
  21077. * Default value used for the Smith Visibility Height Correlated mode.
  21078. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  21079. */
  21080. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  21081. /**
  21082. * Default value used for the IBL diffuse part.
  21083. * This can help switching back to the polynomials mode globally which is a tiny bit
  21084. * less GPU intensive at the drawback of a lower quality.
  21085. */
  21086. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  21087. /**
  21088. * Default value used for activating energy conservation for the specular workflow.
  21089. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  21090. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  21091. */
  21092. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  21093. private _useEnergyConservation;
  21094. /**
  21095. * Defines if the material uses energy conservation.
  21096. */
  21097. useEnergyConservation: boolean;
  21098. private _useSmithVisibilityHeightCorrelated;
  21099. /**
  21100. * LEGACY Mode set to false
  21101. * Defines if the material uses height smith correlated visibility term.
  21102. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  21103. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  21104. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  21105. * Not relying on height correlated will also disable energy conservation.
  21106. */
  21107. useSmithVisibilityHeightCorrelated: boolean;
  21108. private _useSphericalHarmonics;
  21109. /**
  21110. * LEGACY Mode set to false
  21111. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  21112. * diffuse part of the IBL.
  21113. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  21114. * to the ground truth.
  21115. */
  21116. useSphericalHarmonics: boolean;
  21117. private _useSpecularGlossinessInputEnergyConservation;
  21118. /**
  21119. * Defines if the material uses energy conservation, when the specular workflow is active.
  21120. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  21121. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  21122. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  21123. */
  21124. useSpecularGlossinessInputEnergyConservation: boolean;
  21125. /** @hidden */
  21126. private _internalMarkAllSubMeshesAsMiscDirty;
  21127. /** @hidden */
  21128. _markAllSubMeshesAsMiscDirty(): void;
  21129. /**
  21130. * Instantiate a new istance of clear coat configuration.
  21131. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  21132. */
  21133. constructor(markAllSubMeshesAsMiscDirty: () => void);
  21134. /**
  21135. * Checks to see if a texture is used in the material.
  21136. * @param defines the list of "defines" to update.
  21137. */
  21138. prepareDefines(defines: IMaterialBRDFDefines): void;
  21139. /**
  21140. * Get the current class name of the texture useful for serialization or dynamic coding.
  21141. * @returns "PBRClearCoatConfiguration"
  21142. */
  21143. getClassName(): string;
  21144. /**
  21145. * Makes a duplicate of the current configuration into another one.
  21146. * @param brdfConfiguration define the config where to copy the info
  21147. */
  21148. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  21149. /**
  21150. * Serializes this BRDF configuration.
  21151. * @returns - An object with the serialized config.
  21152. */
  21153. serialize(): any;
  21154. /**
  21155. * Parses a anisotropy Configuration from a serialized object.
  21156. * @param source - Serialized object.
  21157. * @param scene Defines the scene we are parsing for
  21158. * @param rootUrl Defines the rootUrl to load from
  21159. */
  21160. parse(source: any, scene: Scene, rootUrl: string): void;
  21161. }
  21162. }
  21163. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  21164. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21165. import { Color3 } from "babylonjs/Maths/math.color";
  21166. import { Scene } from "babylonjs/scene";
  21167. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21168. import { Nullable } from "babylonjs/types";
  21169. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21170. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  21171. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21172. /**
  21173. * @hidden
  21174. */
  21175. export interface IMaterialSheenDefines {
  21176. SHEEN: boolean;
  21177. SHEEN_TEXTURE: boolean;
  21178. SHEEN_TEXTURE_ROUGHNESS: boolean;
  21179. SHEEN_TEXTUREDIRECTUV: number;
  21180. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  21181. SHEEN_LINKWITHALBEDO: boolean;
  21182. SHEEN_ROUGHNESS: boolean;
  21183. SHEEN_ALBEDOSCALING: boolean;
  21184. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21185. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21186. /** @hidden */
  21187. _areTexturesDirty: boolean;
  21188. }
  21189. /**
  21190. * Define the code related to the Sheen parameters of the pbr material.
  21191. */
  21192. export class PBRSheenConfiguration {
  21193. private _isEnabled;
  21194. /**
  21195. * Defines if the material uses sheen.
  21196. */
  21197. isEnabled: boolean;
  21198. private _linkSheenWithAlbedo;
  21199. /**
  21200. * Defines if the sheen is linked to the sheen color.
  21201. */
  21202. linkSheenWithAlbedo: boolean;
  21203. /**
  21204. * Defines the sheen intensity.
  21205. */
  21206. intensity: number;
  21207. /**
  21208. * Defines the sheen color.
  21209. */
  21210. color: Color3;
  21211. private _texture;
  21212. /**
  21213. * Stores the sheen tint values in a texture.
  21214. * rgb is tint
  21215. * 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)
  21216. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  21217. */
  21218. texture: Nullable<BaseTexture>;
  21219. private _useRoughnessFromMainTexture;
  21220. /**
  21221. * Indicates that the alpha channel of the texture property will be used for roughness.
  21222. * Has no effect if the roughness (and texture!) property is not defined
  21223. */
  21224. useRoughnessFromMainTexture: boolean;
  21225. private _roughness;
  21226. /**
  21227. * Defines the sheen roughness.
  21228. * It is not taken into account if linkSheenWithAlbedo is true.
  21229. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  21230. */
  21231. roughness: Nullable<number>;
  21232. private _textureRoughness;
  21233. /**
  21234. * Stores the sheen roughness in a texture.
  21235. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  21236. */
  21237. textureRoughness: Nullable<BaseTexture>;
  21238. private _albedoScaling;
  21239. /**
  21240. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  21241. * It allows the strength of the sheen effect to not depend on the base color of the material,
  21242. * making it easier to setup and tweak the effect
  21243. */
  21244. albedoScaling: boolean;
  21245. /** @hidden */
  21246. private _internalMarkAllSubMeshesAsTexturesDirty;
  21247. /** @hidden */
  21248. _markAllSubMeshesAsTexturesDirty(): void;
  21249. /**
  21250. * Instantiate a new istance of clear coat configuration.
  21251. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  21252. */
  21253. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  21254. /**
  21255. * Specifies that the submesh is ready to be used.
  21256. * @param defines the list of "defines" to update.
  21257. * @param scene defines the scene the material belongs to.
  21258. * @returns - boolean indicating that the submesh is ready or not.
  21259. */
  21260. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  21261. /**
  21262. * Checks to see if a texture is used in the material.
  21263. * @param defines the list of "defines" to update.
  21264. * @param scene defines the scene the material belongs to.
  21265. */
  21266. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  21267. /**
  21268. * Binds the material data.
  21269. * @param uniformBuffer defines the Uniform buffer to fill in.
  21270. * @param scene defines the scene the material belongs to.
  21271. * @param isFrozen defines wether the material is frozen or not.
  21272. * @param subMesh the submesh to bind data for
  21273. */
  21274. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  21275. /**
  21276. * Checks to see if a texture is used in the material.
  21277. * @param texture - Base texture to use.
  21278. * @returns - Boolean specifying if a texture is used in the material.
  21279. */
  21280. hasTexture(texture: BaseTexture): boolean;
  21281. /**
  21282. * Returns an array of the actively used textures.
  21283. * @param activeTextures Array of BaseTextures
  21284. */
  21285. getActiveTextures(activeTextures: BaseTexture[]): void;
  21286. /**
  21287. * Returns the animatable textures.
  21288. * @param animatables Array of animatable textures.
  21289. */
  21290. getAnimatables(animatables: IAnimatable[]): void;
  21291. /**
  21292. * Disposes the resources of the material.
  21293. * @param forceDisposeTextures - Forces the disposal of all textures.
  21294. */
  21295. dispose(forceDisposeTextures?: boolean): void;
  21296. /**
  21297. * Get the current class name of the texture useful for serialization or dynamic coding.
  21298. * @returns "PBRSheenConfiguration"
  21299. */
  21300. getClassName(): string;
  21301. /**
  21302. * Add fallbacks to the effect fallbacks list.
  21303. * @param defines defines the Base texture to use.
  21304. * @param fallbacks defines the current fallback list.
  21305. * @param currentRank defines the current fallback rank.
  21306. * @returns the new fallback rank.
  21307. */
  21308. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  21309. /**
  21310. * Add the required uniforms to the current list.
  21311. * @param uniforms defines the current uniform list.
  21312. */
  21313. static AddUniforms(uniforms: string[]): void;
  21314. /**
  21315. * Add the required uniforms to the current buffer.
  21316. * @param uniformBuffer defines the current uniform buffer.
  21317. */
  21318. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  21319. /**
  21320. * Add the required samplers to the current list.
  21321. * @param samplers defines the current sampler list.
  21322. */
  21323. static AddSamplers(samplers: string[]): void;
  21324. /**
  21325. * Makes a duplicate of the current configuration into another one.
  21326. * @param sheenConfiguration define the config where to copy the info
  21327. */
  21328. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  21329. /**
  21330. * Serializes this BRDF configuration.
  21331. * @returns - An object with the serialized config.
  21332. */
  21333. serialize(): any;
  21334. /**
  21335. * Parses a anisotropy Configuration from a serialized object.
  21336. * @param source - Serialized object.
  21337. * @param scene Defines the scene we are parsing for
  21338. * @param rootUrl Defines the rootUrl to load from
  21339. */
  21340. parse(source: any, scene: Scene, rootUrl: string): void;
  21341. }
  21342. }
  21343. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  21344. import { Nullable } from "babylonjs/types";
  21345. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21346. import { Color3 } from "babylonjs/Maths/math.color";
  21347. import { SmartArray } from "babylonjs/Misc/smartArray";
  21348. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21349. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21350. import { Effect } from "babylonjs/Materials/effect";
  21351. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21352. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  21353. import { Engine } from "babylonjs/Engines/engine";
  21354. import { Scene } from "babylonjs/scene";
  21355. /**
  21356. * @hidden
  21357. */
  21358. export interface IMaterialSubSurfaceDefines {
  21359. SUBSURFACE: boolean;
  21360. SS_REFRACTION: boolean;
  21361. SS_TRANSLUCENCY: boolean;
  21362. SS_SCATTERING: boolean;
  21363. SS_THICKNESSANDMASK_TEXTURE: boolean;
  21364. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  21365. SS_REFRACTIONMAP_3D: boolean;
  21366. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  21367. SS_LODINREFRACTIONALPHA: boolean;
  21368. SS_GAMMAREFRACTION: boolean;
  21369. SS_RGBDREFRACTION: boolean;
  21370. SS_LINEARSPECULARREFRACTION: boolean;
  21371. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  21372. SS_ALBEDOFORREFRACTIONTINT: boolean;
  21373. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  21374. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  21375. /** @hidden */
  21376. _areTexturesDirty: boolean;
  21377. }
  21378. /**
  21379. * Define the code related to the sub surface parameters of the pbr material.
  21380. */
  21381. export class PBRSubSurfaceConfiguration {
  21382. private _isRefractionEnabled;
  21383. /**
  21384. * Defines if the refraction is enabled in the material.
  21385. */
  21386. isRefractionEnabled: boolean;
  21387. private _isTranslucencyEnabled;
  21388. /**
  21389. * Defines if the translucency is enabled in the material.
  21390. */
  21391. isTranslucencyEnabled: boolean;
  21392. private _isScatteringEnabled;
  21393. /**
  21394. * Defines if the sub surface scattering is enabled in the material.
  21395. */
  21396. isScatteringEnabled: boolean;
  21397. private _scatteringDiffusionProfileIndex;
  21398. /**
  21399. * Diffusion profile for subsurface scattering.
  21400. * Useful for better scattering in the skins or foliages.
  21401. */
  21402. get scatteringDiffusionProfile(): Nullable<Color3>;
  21403. set scatteringDiffusionProfile(c: Nullable<Color3>);
  21404. /**
  21405. * Defines the refraction intensity of the material.
  21406. * The refraction when enabled replaces the Diffuse part of the material.
  21407. * The intensity helps transitionning between diffuse and refraction.
  21408. */
  21409. refractionIntensity: number;
  21410. /**
  21411. * Defines the translucency intensity of the material.
  21412. * When translucency has been enabled, this defines how much of the "translucency"
  21413. * is addded to the diffuse part of the material.
  21414. */
  21415. translucencyIntensity: number;
  21416. /**
  21417. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  21418. */
  21419. useAlbedoToTintRefraction: boolean;
  21420. private _thicknessTexture;
  21421. /**
  21422. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  21423. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  21424. * 0 would mean minimumThickness
  21425. * 1 would mean maximumThickness
  21426. * The other channels might be use as a mask to vary the different effects intensity.
  21427. */
  21428. thicknessTexture: Nullable<BaseTexture>;
  21429. private _refractionTexture;
  21430. /**
  21431. * Defines the texture to use for refraction.
  21432. */
  21433. refractionTexture: Nullable<BaseTexture>;
  21434. private _indexOfRefraction;
  21435. /**
  21436. * Index of refraction of the material base layer.
  21437. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  21438. *
  21439. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  21440. *
  21441. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  21442. */
  21443. indexOfRefraction: number;
  21444. private _volumeIndexOfRefraction;
  21445. /**
  21446. * Index of refraction of the material's volume.
  21447. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  21448. *
  21449. * This ONLY impacts refraction. If not provided or given a non-valid value,
  21450. * the volume will use the same IOR as the surface.
  21451. */
  21452. get volumeIndexOfRefraction(): number;
  21453. set volumeIndexOfRefraction(value: number);
  21454. private _invertRefractionY;
  21455. /**
  21456. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21457. */
  21458. invertRefractionY: boolean;
  21459. private _linkRefractionWithTransparency;
  21460. /**
  21461. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21462. * Materials half opaque for instance using refraction could benefit from this control.
  21463. */
  21464. linkRefractionWithTransparency: boolean;
  21465. /**
  21466. * Defines the minimum thickness stored in the thickness map.
  21467. * If no thickness map is defined, this value will be used to simulate thickness.
  21468. */
  21469. minimumThickness: number;
  21470. /**
  21471. * Defines the maximum thickness stored in the thickness map.
  21472. */
  21473. maximumThickness: number;
  21474. /**
  21475. * Defines the volume tint of the material.
  21476. * This is used for both translucency and scattering.
  21477. */
  21478. tintColor: Color3;
  21479. /**
  21480. * Defines the distance at which the tint color should be found in the media.
  21481. * This is used for refraction only.
  21482. */
  21483. tintColorAtDistance: number;
  21484. /**
  21485. * Defines how far each channel transmit through the media.
  21486. * It is defined as a color to simplify it selection.
  21487. */
  21488. diffusionDistance: Color3;
  21489. private _useMaskFromThicknessTexture;
  21490. /**
  21491. * Stores the intensity of the different subsurface effects in the thickness texture.
  21492. * * the green channel is the translucency intensity.
  21493. * * the blue channel is the scattering intensity.
  21494. * * the alpha channel is the refraction intensity.
  21495. */
  21496. useMaskFromThicknessTexture: boolean;
  21497. private _scene;
  21498. private _useMaskFromThicknessTextureGltf;
  21499. /**
  21500. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  21501. * matches the channel-packing that is used by glTF.
  21502. * * the red channel is the transmission/translucency intensity.
  21503. * * the green channel is the thickness.
  21504. */
  21505. useMaskFromThicknessTextureGltf: boolean;
  21506. /** @hidden */
  21507. private _internalMarkAllSubMeshesAsTexturesDirty;
  21508. private _internalMarkScenePrePassDirty;
  21509. /** @hidden */
  21510. _markAllSubMeshesAsTexturesDirty(): void;
  21511. /** @hidden */
  21512. _markScenePrePassDirty(): void;
  21513. /**
  21514. * Instantiate a new istance of sub surface configuration.
  21515. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  21516. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  21517. * @param scene The scene
  21518. */
  21519. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  21520. /**
  21521. * Gets wehter the submesh is ready to be used or not.
  21522. * @param defines the list of "defines" to update.
  21523. * @param scene defines the scene the material belongs to.
  21524. * @returns - boolean indicating that the submesh is ready or not.
  21525. */
  21526. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  21527. /**
  21528. * Checks to see if a texture is used in the material.
  21529. * @param defines the list of "defines" to update.
  21530. * @param scene defines the scene to the material belongs to.
  21531. */
  21532. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  21533. /**
  21534. * Binds the material data.
  21535. * @param uniformBuffer defines the Uniform buffer to fill in.
  21536. * @param scene defines the scene the material belongs to.
  21537. * @param engine defines the engine the material belongs to.
  21538. * @param isFrozen defines whether the material is frozen or not.
  21539. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  21540. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  21541. */
  21542. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  21543. /**
  21544. * Unbinds the material from the mesh.
  21545. * @param activeEffect defines the effect that should be unbound from.
  21546. * @returns true if unbound, otherwise false
  21547. */
  21548. unbind(activeEffect: Effect): boolean;
  21549. /**
  21550. * Returns the texture used for refraction or null if none is used.
  21551. * @param scene defines the scene the material belongs to.
  21552. * @returns - Refraction texture if present. If no refraction texture and refraction
  21553. * is linked with transparency, returns environment texture. Otherwise, returns null.
  21554. */
  21555. private _getRefractionTexture;
  21556. /**
  21557. * Returns true if alpha blending should be disabled.
  21558. */
  21559. get disableAlphaBlending(): boolean;
  21560. /**
  21561. * Fills the list of render target textures.
  21562. * @param renderTargets the list of render targets to update
  21563. */
  21564. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  21565. /**
  21566. * Checks to see if a texture is used in the material.
  21567. * @param texture - Base texture to use.
  21568. * @returns - Boolean specifying if a texture is used in the material.
  21569. */
  21570. hasTexture(texture: BaseTexture): boolean;
  21571. /**
  21572. * Gets a boolean indicating that current material needs to register RTT
  21573. * @returns true if this uses a render target otherwise false.
  21574. */
  21575. hasRenderTargetTextures(): boolean;
  21576. /**
  21577. * Returns an array of the actively used textures.
  21578. * @param activeTextures Array of BaseTextures
  21579. */
  21580. getActiveTextures(activeTextures: BaseTexture[]): void;
  21581. /**
  21582. * Returns the animatable textures.
  21583. * @param animatables Array of animatable textures.
  21584. */
  21585. getAnimatables(animatables: IAnimatable[]): void;
  21586. /**
  21587. * Disposes the resources of the material.
  21588. * @param forceDisposeTextures - Forces the disposal of all textures.
  21589. */
  21590. dispose(forceDisposeTextures?: boolean): void;
  21591. /**
  21592. * Get the current class name of the texture useful for serialization or dynamic coding.
  21593. * @returns "PBRSubSurfaceConfiguration"
  21594. */
  21595. getClassName(): string;
  21596. /**
  21597. * Add fallbacks to the effect fallbacks list.
  21598. * @param defines defines the Base texture to use.
  21599. * @param fallbacks defines the current fallback list.
  21600. * @param currentRank defines the current fallback rank.
  21601. * @returns the new fallback rank.
  21602. */
  21603. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  21604. /**
  21605. * Add the required uniforms to the current list.
  21606. * @param uniforms defines the current uniform list.
  21607. */
  21608. static AddUniforms(uniforms: string[]): void;
  21609. /**
  21610. * Add the required samplers to the current list.
  21611. * @param samplers defines the current sampler list.
  21612. */
  21613. static AddSamplers(samplers: string[]): void;
  21614. /**
  21615. * Add the required uniforms to the current buffer.
  21616. * @param uniformBuffer defines the current uniform buffer.
  21617. */
  21618. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  21619. /**
  21620. * Makes a duplicate of the current configuration into another one.
  21621. * @param configuration define the config where to copy the info
  21622. */
  21623. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  21624. /**
  21625. * Serializes this Sub Surface configuration.
  21626. * @returns - An object with the serialized config.
  21627. */
  21628. serialize(): any;
  21629. /**
  21630. * Parses a anisotropy Configuration from a serialized object.
  21631. * @param source - Serialized object.
  21632. * @param scene Defines the scene we are parsing for
  21633. * @param rootUrl Defines the rootUrl to load from
  21634. */
  21635. parse(source: any, scene: Scene, rootUrl: string): void;
  21636. }
  21637. }
  21638. declare module "babylonjs/Maths/sphericalPolynomial" {
  21639. import { Vector3 } from "babylonjs/Maths/math.vector";
  21640. import { Color3 } from "babylonjs/Maths/math.color";
  21641. /**
  21642. * Class representing spherical harmonics coefficients to the 3rd degree
  21643. */
  21644. export class SphericalHarmonics {
  21645. /**
  21646. * Defines whether or not the harmonics have been prescaled for rendering.
  21647. */
  21648. preScaled: boolean;
  21649. /**
  21650. * The l0,0 coefficients of the spherical harmonics
  21651. */
  21652. l00: Vector3;
  21653. /**
  21654. * The l1,-1 coefficients of the spherical harmonics
  21655. */
  21656. l1_1: Vector3;
  21657. /**
  21658. * The l1,0 coefficients of the spherical harmonics
  21659. */
  21660. l10: Vector3;
  21661. /**
  21662. * The l1,1 coefficients of the spherical harmonics
  21663. */
  21664. l11: Vector3;
  21665. /**
  21666. * The l2,-2 coefficients of the spherical harmonics
  21667. */
  21668. l2_2: Vector3;
  21669. /**
  21670. * The l2,-1 coefficients of the spherical harmonics
  21671. */
  21672. l2_1: Vector3;
  21673. /**
  21674. * The l2,0 coefficients of the spherical harmonics
  21675. */
  21676. l20: Vector3;
  21677. /**
  21678. * The l2,1 coefficients of the spherical harmonics
  21679. */
  21680. l21: Vector3;
  21681. /**
  21682. * The l2,2 coefficients of the spherical harmonics
  21683. */
  21684. l22: Vector3;
  21685. /**
  21686. * Adds a light to the spherical harmonics
  21687. * @param direction the direction of the light
  21688. * @param color the color of the light
  21689. * @param deltaSolidAngle the delta solid angle of the light
  21690. */
  21691. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  21692. /**
  21693. * Scales the spherical harmonics by the given amount
  21694. * @param scale the amount to scale
  21695. */
  21696. scaleInPlace(scale: number): void;
  21697. /**
  21698. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  21699. *
  21700. * ```
  21701. * E_lm = A_l * L_lm
  21702. * ```
  21703. *
  21704. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  21705. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  21706. * the scaling factors are given in equation 9.
  21707. */
  21708. convertIncidentRadianceToIrradiance(): void;
  21709. /**
  21710. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  21711. *
  21712. * ```
  21713. * L = (1/pi) * E * rho
  21714. * ```
  21715. *
  21716. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  21717. */
  21718. convertIrradianceToLambertianRadiance(): void;
  21719. /**
  21720. * Integrates the reconstruction coefficients directly in to the SH preventing further
  21721. * required operations at run time.
  21722. *
  21723. * This is simply done by scaling back the SH with Ylm constants parameter.
  21724. * The trigonometric part being applied by the shader at run time.
  21725. */
  21726. preScaleForRendering(): void;
  21727. /**
  21728. * Constructs a spherical harmonics from an array.
  21729. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  21730. * @returns the spherical harmonics
  21731. */
  21732. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  21733. /**
  21734. * Gets the spherical harmonics from polynomial
  21735. * @param polynomial the spherical polynomial
  21736. * @returns the spherical harmonics
  21737. */
  21738. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  21739. }
  21740. /**
  21741. * Class representing spherical polynomial coefficients to the 3rd degree
  21742. */
  21743. export class SphericalPolynomial {
  21744. private _harmonics;
  21745. /**
  21746. * The spherical harmonics used to create the polynomials.
  21747. */
  21748. get preScaledHarmonics(): SphericalHarmonics;
  21749. /**
  21750. * The x coefficients of the spherical polynomial
  21751. */
  21752. x: Vector3;
  21753. /**
  21754. * The y coefficients of the spherical polynomial
  21755. */
  21756. y: Vector3;
  21757. /**
  21758. * The z coefficients of the spherical polynomial
  21759. */
  21760. z: Vector3;
  21761. /**
  21762. * The xx coefficients of the spherical polynomial
  21763. */
  21764. xx: Vector3;
  21765. /**
  21766. * The yy coefficients of the spherical polynomial
  21767. */
  21768. yy: Vector3;
  21769. /**
  21770. * The zz coefficients of the spherical polynomial
  21771. */
  21772. zz: Vector3;
  21773. /**
  21774. * The xy coefficients of the spherical polynomial
  21775. */
  21776. xy: Vector3;
  21777. /**
  21778. * The yz coefficients of the spherical polynomial
  21779. */
  21780. yz: Vector3;
  21781. /**
  21782. * The zx coefficients of the spherical polynomial
  21783. */
  21784. zx: Vector3;
  21785. /**
  21786. * Adds an ambient color to the spherical polynomial
  21787. * @param color the color to add
  21788. */
  21789. addAmbient(color: Color3): void;
  21790. /**
  21791. * Scales the spherical polynomial by the given amount
  21792. * @param scale the amount to scale
  21793. */
  21794. scaleInPlace(scale: number): void;
  21795. /**
  21796. * Gets the spherical polynomial from harmonics
  21797. * @param harmonics the spherical harmonics
  21798. * @returns the spherical polynomial
  21799. */
  21800. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  21801. /**
  21802. * Constructs a spherical polynomial from an array.
  21803. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  21804. * @returns the spherical polynomial
  21805. */
  21806. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  21807. }
  21808. }
  21809. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  21810. import { Nullable } from "babylonjs/types";
  21811. /**
  21812. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  21813. */
  21814. export interface CubeMapInfo {
  21815. /**
  21816. * The pixel array for the front face.
  21817. * This is stored in format, left to right, up to down format.
  21818. */
  21819. front: Nullable<ArrayBufferView>;
  21820. /**
  21821. * The pixel array for the back face.
  21822. * This is stored in format, left to right, up to down format.
  21823. */
  21824. back: Nullable<ArrayBufferView>;
  21825. /**
  21826. * The pixel array for the left face.
  21827. * This is stored in format, left to right, up to down format.
  21828. */
  21829. left: Nullable<ArrayBufferView>;
  21830. /**
  21831. * The pixel array for the right face.
  21832. * This is stored in format, left to right, up to down format.
  21833. */
  21834. right: Nullable<ArrayBufferView>;
  21835. /**
  21836. * The pixel array for the up face.
  21837. * This is stored in format, left to right, up to down format.
  21838. */
  21839. up: Nullable<ArrayBufferView>;
  21840. /**
  21841. * The pixel array for the down face.
  21842. * This is stored in format, left to right, up to down format.
  21843. */
  21844. down: Nullable<ArrayBufferView>;
  21845. /**
  21846. * The size of the cubemap stored.
  21847. *
  21848. * Each faces will be size * size pixels.
  21849. */
  21850. size: number;
  21851. /**
  21852. * The format of the texture.
  21853. *
  21854. * RGBA, RGB.
  21855. */
  21856. format: number;
  21857. /**
  21858. * The type of the texture data.
  21859. *
  21860. * UNSIGNED_INT, FLOAT.
  21861. */
  21862. type: number;
  21863. /**
  21864. * Specifies whether the texture is in gamma space.
  21865. */
  21866. gammaSpace: boolean;
  21867. }
  21868. /**
  21869. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  21870. */
  21871. export class PanoramaToCubeMapTools {
  21872. private static FACE_LEFT;
  21873. private static FACE_RIGHT;
  21874. private static FACE_FRONT;
  21875. private static FACE_BACK;
  21876. private static FACE_DOWN;
  21877. private static FACE_UP;
  21878. /**
  21879. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  21880. *
  21881. * @param float32Array The source data.
  21882. * @param inputWidth The width of the input panorama.
  21883. * @param inputHeight The height of the input panorama.
  21884. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  21885. * @return The cubemap data
  21886. */
  21887. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  21888. private static CreateCubemapTexture;
  21889. private static CalcProjectionSpherical;
  21890. }
  21891. }
  21892. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  21893. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  21894. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21895. import { Nullable } from "babylonjs/types";
  21896. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  21897. /**
  21898. * Helper class dealing with the extraction of spherical polynomial dataArray
  21899. * from a cube map.
  21900. */
  21901. export class CubeMapToSphericalPolynomialTools {
  21902. private static FileFaces;
  21903. /**
  21904. * Converts a texture to the according Spherical Polynomial data.
  21905. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21906. *
  21907. * @param texture The texture to extract the information from.
  21908. * @return The Spherical Polynomial data.
  21909. */
  21910. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<Promise<SphericalPolynomial>>;
  21911. /**
  21912. * Converts a cubemap to the according Spherical Polynomial data.
  21913. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21914. *
  21915. * @param cubeInfo The Cube map to extract the information from.
  21916. * @return The Spherical Polynomial data.
  21917. */
  21918. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  21919. }
  21920. }
  21921. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  21922. import { Nullable } from "babylonjs/types";
  21923. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  21924. module "babylonjs/Materials/Textures/baseTexture" {
  21925. interface BaseTexture {
  21926. /**
  21927. * Get the polynomial representation of the texture data.
  21928. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  21929. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  21930. */
  21931. sphericalPolynomial: Nullable<SphericalPolynomial>;
  21932. }
  21933. }
  21934. }
  21935. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  21936. /** @hidden */
  21937. export var pbrFragmentDeclaration: {
  21938. name: string;
  21939. shader: string;
  21940. };
  21941. }
  21942. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  21943. import "babylonjs/Shaders/ShadersInclude/sceneUboDeclaration";
  21944. import "babylonjs/Shaders/ShadersInclude/meshUboDeclaration";
  21945. /** @hidden */
  21946. export var pbrUboDeclaration: {
  21947. name: string;
  21948. shader: string;
  21949. };
  21950. }
  21951. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  21952. /** @hidden */
  21953. export var pbrFragmentExtraDeclaration: {
  21954. name: string;
  21955. shader: string;
  21956. };
  21957. }
  21958. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  21959. /** @hidden */
  21960. export var pbrFragmentSamplersDeclaration: {
  21961. name: string;
  21962. shader: string;
  21963. };
  21964. }
  21965. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  21966. /** @hidden */
  21967. export var subSurfaceScatteringFunctions: {
  21968. name: string;
  21969. shader: string;
  21970. };
  21971. }
  21972. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  21973. /** @hidden */
  21974. export var importanceSampling: {
  21975. name: string;
  21976. shader: string;
  21977. };
  21978. }
  21979. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  21980. /** @hidden */
  21981. export var pbrHelperFunctions: {
  21982. name: string;
  21983. shader: string;
  21984. };
  21985. }
  21986. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  21987. /** @hidden */
  21988. export var harmonicsFunctions: {
  21989. name: string;
  21990. shader: string;
  21991. };
  21992. }
  21993. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  21994. /** @hidden */
  21995. export var pbrDirectLightingSetupFunctions: {
  21996. name: string;
  21997. shader: string;
  21998. };
  21999. }
  22000. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  22001. /** @hidden */
  22002. export var pbrDirectLightingFalloffFunctions: {
  22003. name: string;
  22004. shader: string;
  22005. };
  22006. }
  22007. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  22008. /** @hidden */
  22009. export var pbrBRDFFunctions: {
  22010. name: string;
  22011. shader: string;
  22012. };
  22013. }
  22014. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  22015. /** @hidden */
  22016. export var hdrFilteringFunctions: {
  22017. name: string;
  22018. shader: string;
  22019. };
  22020. }
  22021. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  22022. /** @hidden */
  22023. export var pbrDirectLightingFunctions: {
  22024. name: string;
  22025. shader: string;
  22026. };
  22027. }
  22028. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  22029. /** @hidden */
  22030. export var pbrIBLFunctions: {
  22031. name: string;
  22032. shader: string;
  22033. };
  22034. }
  22035. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  22036. /** @hidden */
  22037. export var pbrBlockAlbedoOpacity: {
  22038. name: string;
  22039. shader: string;
  22040. };
  22041. }
  22042. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  22043. /** @hidden */
  22044. export var pbrBlockReflectivity: {
  22045. name: string;
  22046. shader: string;
  22047. };
  22048. }
  22049. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  22050. /** @hidden */
  22051. export var pbrBlockAmbientOcclusion: {
  22052. name: string;
  22053. shader: string;
  22054. };
  22055. }
  22056. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  22057. /** @hidden */
  22058. export var pbrBlockAlphaFresnel: {
  22059. name: string;
  22060. shader: string;
  22061. };
  22062. }
  22063. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  22064. /** @hidden */
  22065. export var pbrBlockAnisotropic: {
  22066. name: string;
  22067. shader: string;
  22068. };
  22069. }
  22070. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  22071. /** @hidden */
  22072. export var pbrBlockReflection: {
  22073. name: string;
  22074. shader: string;
  22075. };
  22076. }
  22077. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  22078. /** @hidden */
  22079. export var pbrBlockSheen: {
  22080. name: string;
  22081. shader: string;
  22082. };
  22083. }
  22084. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  22085. /** @hidden */
  22086. export var pbrBlockClearcoat: {
  22087. name: string;
  22088. shader: string;
  22089. };
  22090. }
  22091. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  22092. /** @hidden */
  22093. export var pbrBlockSubSurface: {
  22094. name: string;
  22095. shader: string;
  22096. };
  22097. }
  22098. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  22099. /** @hidden */
  22100. export var pbrBlockNormalGeometric: {
  22101. name: string;
  22102. shader: string;
  22103. };
  22104. }
  22105. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  22106. /** @hidden */
  22107. export var pbrBlockNormalFinal: {
  22108. name: string;
  22109. shader: string;
  22110. };
  22111. }
  22112. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  22113. /** @hidden */
  22114. export var pbrBlockLightmapInit: {
  22115. name: string;
  22116. shader: string;
  22117. };
  22118. }
  22119. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  22120. /** @hidden */
  22121. export var pbrBlockGeometryInfo: {
  22122. name: string;
  22123. shader: string;
  22124. };
  22125. }
  22126. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  22127. /** @hidden */
  22128. export var pbrBlockReflectance0: {
  22129. name: string;
  22130. shader: string;
  22131. };
  22132. }
  22133. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  22134. /** @hidden */
  22135. export var pbrBlockReflectance: {
  22136. name: string;
  22137. shader: string;
  22138. };
  22139. }
  22140. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  22141. /** @hidden */
  22142. export var pbrBlockDirectLighting: {
  22143. name: string;
  22144. shader: string;
  22145. };
  22146. }
  22147. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  22148. /** @hidden */
  22149. export var pbrBlockFinalLitComponents: {
  22150. name: string;
  22151. shader: string;
  22152. };
  22153. }
  22154. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  22155. /** @hidden */
  22156. export var pbrBlockFinalUnlitComponents: {
  22157. name: string;
  22158. shader: string;
  22159. };
  22160. }
  22161. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  22162. /** @hidden */
  22163. export var pbrBlockFinalColorComposition: {
  22164. name: string;
  22165. shader: string;
  22166. };
  22167. }
  22168. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  22169. /** @hidden */
  22170. export var pbrBlockImageProcessing: {
  22171. name: string;
  22172. shader: string;
  22173. };
  22174. }
  22175. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  22176. /** @hidden */
  22177. export var pbrDebug: {
  22178. name: string;
  22179. shader: string;
  22180. };
  22181. }
  22182. declare module "babylonjs/Shaders/pbr.fragment" {
  22183. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  22184. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  22185. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  22186. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  22187. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  22188. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  22189. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  22190. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  22191. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  22192. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  22193. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  22194. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  22195. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  22196. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  22197. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  22198. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  22199. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  22200. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  22201. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  22202. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  22203. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  22204. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  22205. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  22206. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  22207. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  22208. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  22209. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  22210. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  22211. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  22212. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  22213. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  22214. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  22215. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  22216. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  22217. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  22218. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  22219. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  22220. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  22221. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  22222. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  22223. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  22224. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  22225. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  22226. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  22227. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  22228. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  22229. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  22230. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  22231. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  22232. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  22233. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  22234. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  22235. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  22236. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  22237. /** @hidden */
  22238. export var pbrPixelShader: {
  22239. name: string;
  22240. shader: string;
  22241. };
  22242. }
  22243. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  22244. /** @hidden */
  22245. export var pbrVertexDeclaration: {
  22246. name: string;
  22247. shader: string;
  22248. };
  22249. }
  22250. declare module "babylonjs/Shaders/pbr.vertex" {
  22251. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  22252. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  22253. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  22254. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  22255. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  22256. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  22257. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  22258. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  22259. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  22260. import "babylonjs/Shaders/ShadersInclude/lightVxFragmentDeclaration";
  22261. import "babylonjs/Shaders/ShadersInclude/lightVxUboDeclaration";
  22262. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  22263. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  22264. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  22265. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  22266. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  22267. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  22268. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  22269. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  22270. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  22271. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  22272. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  22273. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  22274. /** @hidden */
  22275. export var pbrVertexShader: {
  22276. name: string;
  22277. shader: string;
  22278. };
  22279. }
  22280. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  22281. import { Nullable } from "babylonjs/types";
  22282. import { Scene } from "babylonjs/scene";
  22283. import { Matrix } from "babylonjs/Maths/math.vector";
  22284. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22285. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22286. import { Mesh } from "babylonjs/Meshes/mesh";
  22287. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  22288. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  22289. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  22290. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  22291. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  22292. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  22293. import { Color3 } from "babylonjs/Maths/math.color";
  22294. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  22295. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  22296. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22297. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  22298. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22299. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22300. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  22301. import "babylonjs/Shaders/pbr.fragment";
  22302. import "babylonjs/Shaders/pbr.vertex";
  22303. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  22304. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  22305. /**
  22306. * Manages the defines for the PBR Material.
  22307. * @hidden
  22308. */
  22309. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  22310. PBR: boolean;
  22311. NUM_SAMPLES: string;
  22312. REALTIME_FILTERING: boolean;
  22313. MAINUV1: boolean;
  22314. MAINUV2: boolean;
  22315. UV1: boolean;
  22316. UV2: boolean;
  22317. ALBEDO: boolean;
  22318. GAMMAALBEDO: boolean;
  22319. ALBEDODIRECTUV: number;
  22320. VERTEXCOLOR: boolean;
  22321. DETAIL: boolean;
  22322. DETAILDIRECTUV: number;
  22323. DETAIL_NORMALBLENDMETHOD: number;
  22324. AMBIENT: boolean;
  22325. AMBIENTDIRECTUV: number;
  22326. AMBIENTINGRAYSCALE: boolean;
  22327. OPACITY: boolean;
  22328. VERTEXALPHA: boolean;
  22329. OPACITYDIRECTUV: number;
  22330. OPACITYRGB: boolean;
  22331. ALPHATEST: boolean;
  22332. DEPTHPREPASS: boolean;
  22333. ALPHABLEND: boolean;
  22334. ALPHAFROMALBEDO: boolean;
  22335. ALPHATESTVALUE: string;
  22336. SPECULAROVERALPHA: boolean;
  22337. RADIANCEOVERALPHA: boolean;
  22338. ALPHAFRESNEL: boolean;
  22339. LINEARALPHAFRESNEL: boolean;
  22340. PREMULTIPLYALPHA: boolean;
  22341. EMISSIVE: boolean;
  22342. EMISSIVEDIRECTUV: number;
  22343. REFLECTIVITY: boolean;
  22344. REFLECTIVITYDIRECTUV: number;
  22345. SPECULARTERM: boolean;
  22346. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  22347. MICROSURFACEAUTOMATIC: boolean;
  22348. LODBASEDMICROSFURACE: boolean;
  22349. MICROSURFACEMAP: boolean;
  22350. MICROSURFACEMAPDIRECTUV: number;
  22351. METALLICWORKFLOW: boolean;
  22352. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  22353. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  22354. METALLNESSSTOREINMETALMAPBLUE: boolean;
  22355. AOSTOREINMETALMAPRED: boolean;
  22356. METALLIC_REFLECTANCE: boolean;
  22357. METALLIC_REFLECTANCEDIRECTUV: number;
  22358. ENVIRONMENTBRDF: boolean;
  22359. ENVIRONMENTBRDF_RGBD: boolean;
  22360. NORMAL: boolean;
  22361. TANGENT: boolean;
  22362. BUMP: boolean;
  22363. BUMPDIRECTUV: number;
  22364. OBJECTSPACE_NORMALMAP: boolean;
  22365. PARALLAX: boolean;
  22366. PARALLAXOCCLUSION: boolean;
  22367. NORMALXYSCALE: boolean;
  22368. LIGHTMAP: boolean;
  22369. LIGHTMAPDIRECTUV: number;
  22370. USELIGHTMAPASSHADOWMAP: boolean;
  22371. GAMMALIGHTMAP: boolean;
  22372. RGBDLIGHTMAP: boolean;
  22373. REFLECTION: boolean;
  22374. REFLECTIONMAP_3D: boolean;
  22375. REFLECTIONMAP_SPHERICAL: boolean;
  22376. REFLECTIONMAP_PLANAR: boolean;
  22377. REFLECTIONMAP_CUBIC: boolean;
  22378. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  22379. REFLECTIONMAP_PROJECTION: boolean;
  22380. REFLECTIONMAP_SKYBOX: boolean;
  22381. REFLECTIONMAP_EXPLICIT: boolean;
  22382. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  22383. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  22384. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  22385. INVERTCUBICMAP: boolean;
  22386. USESPHERICALFROMREFLECTIONMAP: boolean;
  22387. USEIRRADIANCEMAP: boolean;
  22388. SPHERICAL_HARMONICS: boolean;
  22389. USESPHERICALINVERTEX: boolean;
  22390. REFLECTIONMAP_OPPOSITEZ: boolean;
  22391. LODINREFLECTIONALPHA: boolean;
  22392. GAMMAREFLECTION: boolean;
  22393. RGBDREFLECTION: boolean;
  22394. LINEARSPECULARREFLECTION: boolean;
  22395. RADIANCEOCCLUSION: boolean;
  22396. HORIZONOCCLUSION: boolean;
  22397. INSTANCES: boolean;
  22398. THIN_INSTANCES: boolean;
  22399. PREPASS: boolean;
  22400. PREPASS_IRRADIANCE: boolean;
  22401. PREPASS_IRRADIANCE_INDEX: number;
  22402. PREPASS_ALBEDO: boolean;
  22403. PREPASS_ALBEDO_INDEX: number;
  22404. PREPASS_DEPTHNORMAL: boolean;
  22405. PREPASS_DEPTHNORMAL_INDEX: number;
  22406. PREPASS_POSITION: boolean;
  22407. PREPASS_POSITION_INDEX: number;
  22408. PREPASS_VELOCITY: boolean;
  22409. PREPASS_VELOCITY_INDEX: number;
  22410. PREPASS_REFLECTIVITY: boolean;
  22411. PREPASS_REFLECTIVITY_INDEX: number;
  22412. SCENE_MRT_COUNT: number;
  22413. NUM_BONE_INFLUENCERS: number;
  22414. BonesPerMesh: number;
  22415. BONETEXTURE: boolean;
  22416. BONES_VELOCITY_ENABLED: boolean;
  22417. NONUNIFORMSCALING: boolean;
  22418. MORPHTARGETS: boolean;
  22419. MORPHTARGETS_NORMAL: boolean;
  22420. MORPHTARGETS_TANGENT: boolean;
  22421. MORPHTARGETS_UV: boolean;
  22422. NUM_MORPH_INFLUENCERS: number;
  22423. IMAGEPROCESSING: boolean;
  22424. VIGNETTE: boolean;
  22425. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22426. VIGNETTEBLENDMODEOPAQUE: boolean;
  22427. TONEMAPPING: boolean;
  22428. TONEMAPPING_ACES: boolean;
  22429. CONTRAST: boolean;
  22430. COLORCURVES: boolean;
  22431. COLORGRADING: boolean;
  22432. COLORGRADING3D: boolean;
  22433. SAMPLER3DGREENDEPTH: boolean;
  22434. SAMPLER3DBGRMAP: boolean;
  22435. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22436. EXPOSURE: boolean;
  22437. MULTIVIEW: boolean;
  22438. USEPHYSICALLIGHTFALLOFF: boolean;
  22439. USEGLTFLIGHTFALLOFF: boolean;
  22440. TWOSIDEDLIGHTING: boolean;
  22441. SHADOWFLOAT: boolean;
  22442. CLIPPLANE: boolean;
  22443. CLIPPLANE2: boolean;
  22444. CLIPPLANE3: boolean;
  22445. CLIPPLANE4: boolean;
  22446. CLIPPLANE5: boolean;
  22447. CLIPPLANE6: boolean;
  22448. POINTSIZE: boolean;
  22449. FOG: boolean;
  22450. LOGARITHMICDEPTH: boolean;
  22451. FORCENORMALFORWARD: boolean;
  22452. SPECULARAA: boolean;
  22453. CLEARCOAT: boolean;
  22454. CLEARCOAT_DEFAULTIOR: boolean;
  22455. CLEARCOAT_TEXTURE: boolean;
  22456. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  22457. CLEARCOAT_TEXTUREDIRECTUV: number;
  22458. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  22459. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  22460. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  22461. CLEARCOAT_BUMP: boolean;
  22462. CLEARCOAT_BUMPDIRECTUV: number;
  22463. CLEARCOAT_REMAP_F0: boolean;
  22464. CLEARCOAT_TINT: boolean;
  22465. CLEARCOAT_TINT_TEXTURE: boolean;
  22466. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  22467. ANISOTROPIC: boolean;
  22468. ANISOTROPIC_TEXTURE: boolean;
  22469. ANISOTROPIC_TEXTUREDIRECTUV: number;
  22470. BRDF_V_HEIGHT_CORRELATED: boolean;
  22471. MS_BRDF_ENERGY_CONSERVATION: boolean;
  22472. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  22473. SHEEN: boolean;
  22474. SHEEN_TEXTURE: boolean;
  22475. SHEEN_TEXTURE_ROUGHNESS: boolean;
  22476. SHEEN_TEXTUREDIRECTUV: number;
  22477. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  22478. SHEEN_LINKWITHALBEDO: boolean;
  22479. SHEEN_ROUGHNESS: boolean;
  22480. SHEEN_ALBEDOSCALING: boolean;
  22481. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  22482. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  22483. SUBSURFACE: boolean;
  22484. SS_REFRACTION: boolean;
  22485. SS_TRANSLUCENCY: boolean;
  22486. SS_SCATTERING: boolean;
  22487. SS_THICKNESSANDMASK_TEXTURE: boolean;
  22488. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  22489. SS_REFRACTIONMAP_3D: boolean;
  22490. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  22491. SS_LODINREFRACTIONALPHA: boolean;
  22492. SS_GAMMAREFRACTION: boolean;
  22493. SS_RGBDREFRACTION: boolean;
  22494. SS_LINEARSPECULARREFRACTION: boolean;
  22495. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  22496. SS_ALBEDOFORREFRACTIONTINT: boolean;
  22497. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  22498. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  22499. UNLIT: boolean;
  22500. DEBUGMODE: number;
  22501. /**
  22502. * Initializes the PBR Material defines.
  22503. */
  22504. constructor();
  22505. /**
  22506. * Resets the PBR Material defines.
  22507. */
  22508. reset(): void;
  22509. }
  22510. /**
  22511. * The Physically based material base class of BJS.
  22512. *
  22513. * This offers the main features of a standard PBR material.
  22514. * For more information, please refer to the documentation :
  22515. * https://doc.babylonjs.com/how_to/physically_based_rendering
  22516. */
  22517. export abstract class PBRBaseMaterial extends PushMaterial {
  22518. /**
  22519. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  22520. */
  22521. static readonly PBRMATERIAL_OPAQUE: number;
  22522. /**
  22523. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  22524. */
  22525. static readonly PBRMATERIAL_ALPHATEST: number;
  22526. /**
  22527. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22528. */
  22529. static readonly PBRMATERIAL_ALPHABLEND: number;
  22530. /**
  22531. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22532. * They are also discarded below the alpha cutoff threshold to improve performances.
  22533. */
  22534. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  22535. /**
  22536. * Defines the default value of how much AO map is occluding the analytical lights
  22537. * (point spot...).
  22538. */
  22539. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  22540. /**
  22541. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  22542. */
  22543. static readonly LIGHTFALLOFF_PHYSICAL: number;
  22544. /**
  22545. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  22546. * to enhance interoperability with other engines.
  22547. */
  22548. static readonly LIGHTFALLOFF_GLTF: number;
  22549. /**
  22550. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  22551. * to enhance interoperability with other materials.
  22552. */
  22553. static readonly LIGHTFALLOFF_STANDARD: number;
  22554. /**
  22555. * Intensity of the direct lights e.g. the four lights available in your scene.
  22556. * This impacts both the direct diffuse and specular highlights.
  22557. */
  22558. protected _directIntensity: number;
  22559. /**
  22560. * Intensity of the emissive part of the material.
  22561. * This helps controlling the emissive effect without modifying the emissive color.
  22562. */
  22563. protected _emissiveIntensity: number;
  22564. /**
  22565. * Intensity of the environment e.g. how much the environment will light the object
  22566. * either through harmonics for rough material or through the refelction for shiny ones.
  22567. */
  22568. protected _environmentIntensity: number;
  22569. /**
  22570. * This is a special control allowing the reduction of the specular highlights coming from the
  22571. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  22572. */
  22573. protected _specularIntensity: number;
  22574. /**
  22575. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  22576. */
  22577. private _lightingInfos;
  22578. /**
  22579. * Debug Control allowing disabling the bump map on this material.
  22580. */
  22581. protected _disableBumpMap: boolean;
  22582. /**
  22583. * AKA Diffuse Texture in standard nomenclature.
  22584. */
  22585. protected _albedoTexture: Nullable<BaseTexture>;
  22586. /**
  22587. * AKA Occlusion Texture in other nomenclature.
  22588. */
  22589. protected _ambientTexture: Nullable<BaseTexture>;
  22590. /**
  22591. * AKA Occlusion Texture Intensity in other nomenclature.
  22592. */
  22593. protected _ambientTextureStrength: number;
  22594. /**
  22595. * Defines how much the AO map is occluding the analytical lights (point spot...).
  22596. * 1 means it completely occludes it
  22597. * 0 mean it has no impact
  22598. */
  22599. protected _ambientTextureImpactOnAnalyticalLights: number;
  22600. /**
  22601. * Stores the alpha values in a texture.
  22602. */
  22603. protected _opacityTexture: Nullable<BaseTexture>;
  22604. /**
  22605. * Stores the reflection values in a texture.
  22606. */
  22607. protected _reflectionTexture: Nullable<BaseTexture>;
  22608. /**
  22609. * Stores the emissive values in a texture.
  22610. */
  22611. protected _emissiveTexture: Nullable<BaseTexture>;
  22612. /**
  22613. * AKA Specular texture in other nomenclature.
  22614. */
  22615. protected _reflectivityTexture: Nullable<BaseTexture>;
  22616. /**
  22617. * Used to switch from specular/glossiness to metallic/roughness workflow.
  22618. */
  22619. protected _metallicTexture: Nullable<BaseTexture>;
  22620. /**
  22621. * Specifies the metallic scalar of the metallic/roughness workflow.
  22622. * Can also be used to scale the metalness values of the metallic texture.
  22623. */
  22624. protected _metallic: Nullable<number>;
  22625. /**
  22626. * Specifies the roughness scalar of the metallic/roughness workflow.
  22627. * Can also be used to scale the roughness values of the metallic texture.
  22628. */
  22629. protected _roughness: Nullable<number>;
  22630. /**
  22631. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  22632. * By default the indexOfrefraction is used to compute F0;
  22633. *
  22634. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  22635. *
  22636. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  22637. * F90 = metallicReflectanceColor;
  22638. */
  22639. protected _metallicF0Factor: number;
  22640. /**
  22641. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  22642. * By default the F90 is always 1;
  22643. *
  22644. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  22645. *
  22646. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  22647. * F90 = metallicReflectanceColor;
  22648. */
  22649. protected _metallicReflectanceColor: Color3;
  22650. /**
  22651. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  22652. * This is multiply against the scalar values defined in the material.
  22653. */
  22654. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  22655. /**
  22656. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  22657. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  22658. */
  22659. protected _microSurfaceTexture: Nullable<BaseTexture>;
  22660. /**
  22661. * Stores surface normal data used to displace a mesh in a texture.
  22662. */
  22663. protected _bumpTexture: Nullable<BaseTexture>;
  22664. /**
  22665. * Stores the pre-calculated light information of a mesh in a texture.
  22666. */
  22667. protected _lightmapTexture: Nullable<BaseTexture>;
  22668. /**
  22669. * The color of a material in ambient lighting.
  22670. */
  22671. protected _ambientColor: Color3;
  22672. /**
  22673. * AKA Diffuse Color in other nomenclature.
  22674. */
  22675. protected _albedoColor: Color3;
  22676. /**
  22677. * AKA Specular Color in other nomenclature.
  22678. */
  22679. protected _reflectivityColor: Color3;
  22680. /**
  22681. * The color applied when light is reflected from a material.
  22682. */
  22683. protected _reflectionColor: Color3;
  22684. /**
  22685. * The color applied when light is emitted from a material.
  22686. */
  22687. protected _emissiveColor: Color3;
  22688. /**
  22689. * AKA Glossiness in other nomenclature.
  22690. */
  22691. protected _microSurface: number;
  22692. /**
  22693. * Specifies that the material will use the light map as a show map.
  22694. */
  22695. protected _useLightmapAsShadowmap: boolean;
  22696. /**
  22697. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  22698. * makes the reflect vector face the model (under horizon).
  22699. */
  22700. protected _useHorizonOcclusion: boolean;
  22701. /**
  22702. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  22703. * too much the area relying on ambient texture to define their ambient occlusion.
  22704. */
  22705. protected _useRadianceOcclusion: boolean;
  22706. /**
  22707. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  22708. */
  22709. protected _useAlphaFromAlbedoTexture: boolean;
  22710. /**
  22711. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  22712. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  22713. */
  22714. protected _useSpecularOverAlpha: boolean;
  22715. /**
  22716. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  22717. */
  22718. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  22719. /**
  22720. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  22721. */
  22722. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  22723. /**
  22724. * Specifies if the metallic texture contains the roughness information in its green channel.
  22725. */
  22726. protected _useRoughnessFromMetallicTextureGreen: boolean;
  22727. /**
  22728. * Specifies if the metallic texture contains the metallness information in its blue channel.
  22729. */
  22730. protected _useMetallnessFromMetallicTextureBlue: boolean;
  22731. /**
  22732. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  22733. */
  22734. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  22735. /**
  22736. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  22737. */
  22738. protected _useAmbientInGrayScale: boolean;
  22739. /**
  22740. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  22741. * The material will try to infer what glossiness each pixel should be.
  22742. */
  22743. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  22744. /**
  22745. * Defines the falloff type used in this material.
  22746. * It by default is Physical.
  22747. */
  22748. protected _lightFalloff: number;
  22749. /**
  22750. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  22751. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  22752. */
  22753. protected _useRadianceOverAlpha: boolean;
  22754. /**
  22755. * Allows using an object space normal map (instead of tangent space).
  22756. */
  22757. protected _useObjectSpaceNormalMap: boolean;
  22758. /**
  22759. * Allows using the bump map in parallax mode.
  22760. */
  22761. protected _useParallax: boolean;
  22762. /**
  22763. * Allows using the bump map in parallax occlusion mode.
  22764. */
  22765. protected _useParallaxOcclusion: boolean;
  22766. /**
  22767. * Controls the scale bias of the parallax mode.
  22768. */
  22769. protected _parallaxScaleBias: number;
  22770. /**
  22771. * If sets to true, disables all the lights affecting the material.
  22772. */
  22773. protected _disableLighting: boolean;
  22774. /**
  22775. * Number of Simultaneous lights allowed on the material.
  22776. */
  22777. protected _maxSimultaneousLights: number;
  22778. /**
  22779. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  22780. */
  22781. protected _invertNormalMapX: boolean;
  22782. /**
  22783. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  22784. */
  22785. protected _invertNormalMapY: boolean;
  22786. /**
  22787. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  22788. */
  22789. protected _twoSidedLighting: boolean;
  22790. /**
  22791. * Defines the alpha limits in alpha test mode.
  22792. */
  22793. protected _alphaCutOff: number;
  22794. /**
  22795. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22796. */
  22797. protected _forceAlphaTest: boolean;
  22798. /**
  22799. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22800. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  22801. */
  22802. protected _useAlphaFresnel: boolean;
  22803. /**
  22804. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22805. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22806. */
  22807. protected _useLinearAlphaFresnel: boolean;
  22808. /**
  22809. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  22810. * from cos thetav and roughness:
  22811. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  22812. */
  22813. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  22814. /**
  22815. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22816. */
  22817. protected _forceIrradianceInFragment: boolean;
  22818. private _realTimeFiltering;
  22819. /**
  22820. * Enables realtime filtering on the texture.
  22821. */
  22822. get realTimeFiltering(): boolean;
  22823. set realTimeFiltering(b: boolean);
  22824. private _realTimeFilteringQuality;
  22825. /**
  22826. * Quality switch for realtime filtering
  22827. */
  22828. get realTimeFilteringQuality(): number;
  22829. set realTimeFilteringQuality(n: number);
  22830. /**
  22831. * Can this material render to several textures at once
  22832. */
  22833. get canRenderToMRT(): boolean;
  22834. /**
  22835. * Force normal to face away from face.
  22836. */
  22837. protected _forceNormalForward: boolean;
  22838. /**
  22839. * Enables specular anti aliasing in the PBR shader.
  22840. * It will both interacts on the Geometry for analytical and IBL lighting.
  22841. * It also prefilter the roughness map based on the bump values.
  22842. */
  22843. protected _enableSpecularAntiAliasing: boolean;
  22844. /**
  22845. * Default configuration related to image processing available in the PBR Material.
  22846. */
  22847. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22848. /**
  22849. * Keep track of the image processing observer to allow dispose and replace.
  22850. */
  22851. private _imageProcessingObserver;
  22852. /**
  22853. * Attaches a new image processing configuration to the PBR Material.
  22854. * @param configuration
  22855. */
  22856. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22857. /**
  22858. * Stores the available render targets.
  22859. */
  22860. private _renderTargets;
  22861. /**
  22862. * Sets the global ambient color for the material used in lighting calculations.
  22863. */
  22864. private _globalAmbientColor;
  22865. /**
  22866. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  22867. */
  22868. private _useLogarithmicDepth;
  22869. /**
  22870. * If set to true, no lighting calculations will be applied.
  22871. */
  22872. private _unlit;
  22873. private _debugMode;
  22874. /**
  22875. * @hidden
  22876. * This is reserved for the inspector.
  22877. * Defines the material debug mode.
  22878. * It helps seeing only some components of the material while troubleshooting.
  22879. */
  22880. debugMode: number;
  22881. /**
  22882. * @hidden
  22883. * This is reserved for the inspector.
  22884. * Specify from where on screen the debug mode should start.
  22885. * The value goes from -1 (full screen) to 1 (not visible)
  22886. * It helps with side by side comparison against the final render
  22887. * This defaults to -1
  22888. */
  22889. private debugLimit;
  22890. /**
  22891. * @hidden
  22892. * This is reserved for the inspector.
  22893. * As the default viewing range might not be enough (if the ambient is really small for instance)
  22894. * You can use the factor to better multiply the final value.
  22895. */
  22896. private debugFactor;
  22897. /**
  22898. * Defines the clear coat layer parameters for the material.
  22899. */
  22900. readonly clearCoat: PBRClearCoatConfiguration;
  22901. /**
  22902. * Defines the anisotropic parameters for the material.
  22903. */
  22904. readonly anisotropy: PBRAnisotropicConfiguration;
  22905. /**
  22906. * Defines the BRDF parameters for the material.
  22907. */
  22908. readonly brdf: PBRBRDFConfiguration;
  22909. /**
  22910. * Defines the Sheen parameters for the material.
  22911. */
  22912. readonly sheen: PBRSheenConfiguration;
  22913. /**
  22914. * Defines the SubSurface parameters for the material.
  22915. */
  22916. readonly subSurface: PBRSubSurfaceConfiguration;
  22917. /**
  22918. * Defines additionnal PrePass parameters for the material.
  22919. */
  22920. readonly prePassConfiguration: PrePassConfiguration;
  22921. /**
  22922. * Defines the detail map parameters for the material.
  22923. */
  22924. readonly detailMap: DetailMapConfiguration;
  22925. protected _rebuildInParallel: boolean;
  22926. /**
  22927. * Instantiates a new PBRMaterial instance.
  22928. *
  22929. * @param name The material name
  22930. * @param scene The scene the material will be use in.
  22931. */
  22932. constructor(name: string, scene: Scene);
  22933. /**
  22934. * Gets a boolean indicating that current material needs to register RTT
  22935. */
  22936. get hasRenderTargetTextures(): boolean;
  22937. /**
  22938. * Gets the name of the material class.
  22939. */
  22940. getClassName(): string;
  22941. /**
  22942. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22943. */
  22944. get useLogarithmicDepth(): boolean;
  22945. /**
  22946. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22947. */
  22948. set useLogarithmicDepth(value: boolean);
  22949. /**
  22950. * Returns true if alpha blending should be disabled.
  22951. */
  22952. protected get _disableAlphaBlending(): boolean;
  22953. /**
  22954. * Specifies whether or not this material should be rendered in alpha blend mode.
  22955. */
  22956. needAlphaBlending(): boolean;
  22957. /**
  22958. * Specifies whether or not this material should be rendered in alpha test mode.
  22959. */
  22960. needAlphaTesting(): boolean;
  22961. /**
  22962. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  22963. */
  22964. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  22965. /**
  22966. * Specifies whether or not there is a usable alpha channel for transparency.
  22967. */
  22968. protected _hasAlphaChannel(): boolean;
  22969. /**
  22970. * Gets the texture used for the alpha test.
  22971. */
  22972. getAlphaTestTexture(): Nullable<BaseTexture>;
  22973. /**
  22974. * Specifies that the submesh is ready to be used.
  22975. * @param mesh - BJS mesh.
  22976. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  22977. * @param useInstances - Specifies that instances should be used.
  22978. * @returns - boolean indicating that the submesh is ready or not.
  22979. */
  22980. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22981. /**
  22982. * Specifies if the material uses metallic roughness workflow.
  22983. * @returns boolean specifiying if the material uses metallic roughness workflow.
  22984. */
  22985. isMetallicWorkflow(): boolean;
  22986. private _prepareEffect;
  22987. private _prepareDefines;
  22988. /**
  22989. * Force shader compilation
  22990. */
  22991. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  22992. /**
  22993. * Initializes the uniform buffer layout for the shader.
  22994. */
  22995. buildUniformLayout(): void;
  22996. /**
  22997. * Unbinds the material from the mesh
  22998. */
  22999. unbind(): void;
  23000. /**
  23001. * Binds the submesh data.
  23002. * @param world - The world matrix.
  23003. * @param mesh - The BJS mesh.
  23004. * @param subMesh - A submesh of the BJS mesh.
  23005. */
  23006. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23007. /**
  23008. * Returns the animatable textures.
  23009. * @returns - Array of animatable textures.
  23010. */
  23011. getAnimatables(): IAnimatable[];
  23012. /**
  23013. * Returns the texture used for reflections.
  23014. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  23015. */
  23016. private _getReflectionTexture;
  23017. /**
  23018. * Returns an array of the actively used textures.
  23019. * @returns - Array of BaseTextures
  23020. */
  23021. getActiveTextures(): BaseTexture[];
  23022. /**
  23023. * Checks to see if a texture is used in the material.
  23024. * @param texture - Base texture to use.
  23025. * @returns - Boolean specifying if a texture is used in the material.
  23026. */
  23027. hasTexture(texture: BaseTexture): boolean;
  23028. /**
  23029. * Sets the required values to the prepass renderer.
  23030. * @param prePassRenderer defines the prepass renderer to setup
  23031. */
  23032. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  23033. /**
  23034. * Disposes the resources of the material.
  23035. * @param forceDisposeEffect - Forces the disposal of effects.
  23036. * @param forceDisposeTextures - Forces the disposal of all textures.
  23037. */
  23038. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  23039. }
  23040. }
  23041. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  23042. import { Nullable } from "babylonjs/types";
  23043. import { Scene } from "babylonjs/scene";
  23044. import { Color3 } from "babylonjs/Maths/math.color";
  23045. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  23046. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  23047. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23048. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  23049. /**
  23050. * The Physically based material of BJS.
  23051. *
  23052. * This offers the main features of a standard PBR material.
  23053. * For more information, please refer to the documentation :
  23054. * https://doc.babylonjs.com/how_to/physically_based_rendering
  23055. */
  23056. export class PBRMaterial extends PBRBaseMaterial {
  23057. /**
  23058. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  23059. */
  23060. static readonly PBRMATERIAL_OPAQUE: number;
  23061. /**
  23062. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  23063. */
  23064. static readonly PBRMATERIAL_ALPHATEST: number;
  23065. /**
  23066. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23067. */
  23068. static readonly PBRMATERIAL_ALPHABLEND: number;
  23069. /**
  23070. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23071. * They are also discarded below the alpha cutoff threshold to improve performances.
  23072. */
  23073. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  23074. /**
  23075. * Defines the default value of how much AO map is occluding the analytical lights
  23076. * (point spot...).
  23077. */
  23078. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  23079. /**
  23080. * Intensity of the direct lights e.g. the four lights available in your scene.
  23081. * This impacts both the direct diffuse and specular highlights.
  23082. */
  23083. directIntensity: number;
  23084. /**
  23085. * Intensity of the emissive part of the material.
  23086. * This helps controlling the emissive effect without modifying the emissive color.
  23087. */
  23088. emissiveIntensity: number;
  23089. /**
  23090. * Intensity of the environment e.g. how much the environment will light the object
  23091. * either through harmonics for rough material or through the refelction for shiny ones.
  23092. */
  23093. environmentIntensity: number;
  23094. /**
  23095. * This is a special control allowing the reduction of the specular highlights coming from the
  23096. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  23097. */
  23098. specularIntensity: number;
  23099. /**
  23100. * Debug Control allowing disabling the bump map on this material.
  23101. */
  23102. disableBumpMap: boolean;
  23103. /**
  23104. * AKA Diffuse Texture in standard nomenclature.
  23105. */
  23106. albedoTexture: BaseTexture;
  23107. /**
  23108. * AKA Occlusion Texture in other nomenclature.
  23109. */
  23110. ambientTexture: BaseTexture;
  23111. /**
  23112. * AKA Occlusion Texture Intensity in other nomenclature.
  23113. */
  23114. ambientTextureStrength: number;
  23115. /**
  23116. * Defines how much the AO map is occluding the analytical lights (point spot...).
  23117. * 1 means it completely occludes it
  23118. * 0 mean it has no impact
  23119. */
  23120. ambientTextureImpactOnAnalyticalLights: number;
  23121. /**
  23122. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  23123. */
  23124. opacityTexture: BaseTexture;
  23125. /**
  23126. * Stores the reflection values in a texture.
  23127. */
  23128. reflectionTexture: Nullable<BaseTexture>;
  23129. /**
  23130. * Stores the emissive values in a texture.
  23131. */
  23132. emissiveTexture: BaseTexture;
  23133. /**
  23134. * AKA Specular texture in other nomenclature.
  23135. */
  23136. reflectivityTexture: BaseTexture;
  23137. /**
  23138. * Used to switch from specular/glossiness to metallic/roughness workflow.
  23139. */
  23140. metallicTexture: BaseTexture;
  23141. /**
  23142. * Specifies the metallic scalar of the metallic/roughness workflow.
  23143. * Can also be used to scale the metalness values of the metallic texture.
  23144. */
  23145. metallic: Nullable<number>;
  23146. /**
  23147. * Specifies the roughness scalar of the metallic/roughness workflow.
  23148. * Can also be used to scale the roughness values of the metallic texture.
  23149. */
  23150. roughness: Nullable<number>;
  23151. /**
  23152. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  23153. * By default the indexOfrefraction is used to compute F0;
  23154. *
  23155. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  23156. *
  23157. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  23158. * F90 = metallicReflectanceColor;
  23159. */
  23160. metallicF0Factor: number;
  23161. /**
  23162. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  23163. * By default the F90 is always 1;
  23164. *
  23165. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  23166. *
  23167. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  23168. * F90 = metallicReflectanceColor;
  23169. */
  23170. metallicReflectanceColor: Color3;
  23171. /**
  23172. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  23173. * This is multiply against the scalar values defined in the material.
  23174. */
  23175. metallicReflectanceTexture: Nullable<BaseTexture>;
  23176. /**
  23177. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  23178. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  23179. */
  23180. microSurfaceTexture: BaseTexture;
  23181. /**
  23182. * Stores surface normal data used to displace a mesh in a texture.
  23183. */
  23184. bumpTexture: BaseTexture;
  23185. /**
  23186. * Stores the pre-calculated light information of a mesh in a texture.
  23187. */
  23188. lightmapTexture: BaseTexture;
  23189. /**
  23190. * Stores the refracted light information in a texture.
  23191. */
  23192. get refractionTexture(): Nullable<BaseTexture>;
  23193. set refractionTexture(value: Nullable<BaseTexture>);
  23194. /**
  23195. * The color of a material in ambient lighting.
  23196. */
  23197. ambientColor: Color3;
  23198. /**
  23199. * AKA Diffuse Color in other nomenclature.
  23200. */
  23201. albedoColor: Color3;
  23202. /**
  23203. * AKA Specular Color in other nomenclature.
  23204. */
  23205. reflectivityColor: Color3;
  23206. /**
  23207. * The color reflected from the material.
  23208. */
  23209. reflectionColor: Color3;
  23210. /**
  23211. * The color emitted from the material.
  23212. */
  23213. emissiveColor: Color3;
  23214. /**
  23215. * AKA Glossiness in other nomenclature.
  23216. */
  23217. microSurface: number;
  23218. /**
  23219. * Index of refraction of the material base layer.
  23220. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  23221. *
  23222. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  23223. *
  23224. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  23225. */
  23226. get indexOfRefraction(): number;
  23227. set indexOfRefraction(value: number);
  23228. /**
  23229. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  23230. */
  23231. get invertRefractionY(): boolean;
  23232. set invertRefractionY(value: boolean);
  23233. /**
  23234. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  23235. * Materials half opaque for instance using refraction could benefit from this control.
  23236. */
  23237. get linkRefractionWithTransparency(): boolean;
  23238. set linkRefractionWithTransparency(value: boolean);
  23239. /**
  23240. * If true, the light map contains occlusion information instead of lighting info.
  23241. */
  23242. useLightmapAsShadowmap: boolean;
  23243. /**
  23244. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  23245. */
  23246. useAlphaFromAlbedoTexture: boolean;
  23247. /**
  23248. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  23249. */
  23250. forceAlphaTest: boolean;
  23251. /**
  23252. * Defines the alpha limits in alpha test mode.
  23253. */
  23254. alphaCutOff: number;
  23255. /**
  23256. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  23257. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  23258. */
  23259. useSpecularOverAlpha: boolean;
  23260. /**
  23261. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  23262. */
  23263. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  23264. /**
  23265. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  23266. */
  23267. useRoughnessFromMetallicTextureAlpha: boolean;
  23268. /**
  23269. * Specifies if the metallic texture contains the roughness information in its green channel.
  23270. */
  23271. useRoughnessFromMetallicTextureGreen: boolean;
  23272. /**
  23273. * Specifies if the metallic texture contains the metallness information in its blue channel.
  23274. */
  23275. useMetallnessFromMetallicTextureBlue: boolean;
  23276. /**
  23277. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  23278. */
  23279. useAmbientOcclusionFromMetallicTextureRed: boolean;
  23280. /**
  23281. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  23282. */
  23283. useAmbientInGrayScale: boolean;
  23284. /**
  23285. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  23286. * The material will try to infer what glossiness each pixel should be.
  23287. */
  23288. useAutoMicroSurfaceFromReflectivityMap: boolean;
  23289. /**
  23290. * BJS is using an harcoded light falloff based on a manually sets up range.
  23291. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  23292. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  23293. */
  23294. get usePhysicalLightFalloff(): boolean;
  23295. /**
  23296. * BJS is using an harcoded light falloff based on a manually sets up range.
  23297. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  23298. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  23299. */
  23300. set usePhysicalLightFalloff(value: boolean);
  23301. /**
  23302. * In order to support the falloff compatibility with gltf, a special mode has been added
  23303. * to reproduce the gltf light falloff.
  23304. */
  23305. get useGLTFLightFalloff(): boolean;
  23306. /**
  23307. * In order to support the falloff compatibility with gltf, a special mode has been added
  23308. * to reproduce the gltf light falloff.
  23309. */
  23310. set useGLTFLightFalloff(value: boolean);
  23311. /**
  23312. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  23313. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  23314. */
  23315. useRadianceOverAlpha: boolean;
  23316. /**
  23317. * Allows using an object space normal map (instead of tangent space).
  23318. */
  23319. useObjectSpaceNormalMap: boolean;
  23320. /**
  23321. * Allows using the bump map in parallax mode.
  23322. */
  23323. useParallax: boolean;
  23324. /**
  23325. * Allows using the bump map in parallax occlusion mode.
  23326. */
  23327. useParallaxOcclusion: boolean;
  23328. /**
  23329. * Controls the scale bias of the parallax mode.
  23330. */
  23331. parallaxScaleBias: number;
  23332. /**
  23333. * If sets to true, disables all the lights affecting the material.
  23334. */
  23335. disableLighting: boolean;
  23336. /**
  23337. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  23338. */
  23339. forceIrradianceInFragment: boolean;
  23340. /**
  23341. * Number of Simultaneous lights allowed on the material.
  23342. */
  23343. maxSimultaneousLights: number;
  23344. /**
  23345. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  23346. */
  23347. invertNormalMapX: boolean;
  23348. /**
  23349. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  23350. */
  23351. invertNormalMapY: boolean;
  23352. /**
  23353. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  23354. */
  23355. twoSidedLighting: boolean;
  23356. /**
  23357. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  23358. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  23359. */
  23360. useAlphaFresnel: boolean;
  23361. /**
  23362. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  23363. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  23364. */
  23365. useLinearAlphaFresnel: boolean;
  23366. /**
  23367. * Let user defines the brdf lookup texture used for IBL.
  23368. * A default 8bit version is embedded but you could point at :
  23369. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  23370. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  23371. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  23372. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  23373. */
  23374. environmentBRDFTexture: Nullable<BaseTexture>;
  23375. /**
  23376. * Force normal to face away from face.
  23377. */
  23378. forceNormalForward: boolean;
  23379. /**
  23380. * Enables specular anti aliasing in the PBR shader.
  23381. * It will both interacts on the Geometry for analytical and IBL lighting.
  23382. * It also prefilter the roughness map based on the bump values.
  23383. */
  23384. enableSpecularAntiAliasing: boolean;
  23385. /**
  23386. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  23387. * makes the reflect vector face the model (under horizon).
  23388. */
  23389. useHorizonOcclusion: boolean;
  23390. /**
  23391. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  23392. * too much the area relying on ambient texture to define their ambient occlusion.
  23393. */
  23394. useRadianceOcclusion: boolean;
  23395. /**
  23396. * If set to true, no lighting calculations will be applied.
  23397. */
  23398. unlit: boolean;
  23399. /**
  23400. * Gets the image processing configuration used either in this material.
  23401. */
  23402. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23403. /**
  23404. * Sets the Default image processing configuration used either in the this material.
  23405. *
  23406. * If sets to null, the scene one is in use.
  23407. */
  23408. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23409. /**
  23410. * Gets wether the color curves effect is enabled.
  23411. */
  23412. get cameraColorCurvesEnabled(): boolean;
  23413. /**
  23414. * Sets wether the color curves effect is enabled.
  23415. */
  23416. set cameraColorCurvesEnabled(value: boolean);
  23417. /**
  23418. * Gets wether the color grading effect is enabled.
  23419. */
  23420. get cameraColorGradingEnabled(): boolean;
  23421. /**
  23422. * Gets wether the color grading effect is enabled.
  23423. */
  23424. set cameraColorGradingEnabled(value: boolean);
  23425. /**
  23426. * Gets wether tonemapping is enabled or not.
  23427. */
  23428. get cameraToneMappingEnabled(): boolean;
  23429. /**
  23430. * Sets wether tonemapping is enabled or not
  23431. */
  23432. set cameraToneMappingEnabled(value: boolean);
  23433. /**
  23434. * The camera exposure used on this material.
  23435. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  23436. * This corresponds to a photographic exposure.
  23437. */
  23438. get cameraExposure(): number;
  23439. /**
  23440. * The camera exposure used on this material.
  23441. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  23442. * This corresponds to a photographic exposure.
  23443. */
  23444. set cameraExposure(value: number);
  23445. /**
  23446. * Gets The camera contrast used on this material.
  23447. */
  23448. get cameraContrast(): number;
  23449. /**
  23450. * Sets The camera contrast used on this material.
  23451. */
  23452. set cameraContrast(value: number);
  23453. /**
  23454. * Gets the Color Grading 2D Lookup Texture.
  23455. */
  23456. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  23457. /**
  23458. * Sets the Color Grading 2D Lookup Texture.
  23459. */
  23460. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  23461. /**
  23462. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  23463. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  23464. * 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;
  23465. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  23466. */
  23467. get cameraColorCurves(): Nullable<ColorCurves>;
  23468. /**
  23469. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  23470. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  23471. * 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;
  23472. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  23473. */
  23474. set cameraColorCurves(value: Nullable<ColorCurves>);
  23475. /**
  23476. * Instantiates a new PBRMaterial instance.
  23477. *
  23478. * @param name The material name
  23479. * @param scene The scene the material will be use in.
  23480. */
  23481. constructor(name: string, scene: Scene);
  23482. /**
  23483. * Returns the name of this material class.
  23484. */
  23485. getClassName(): string;
  23486. /**
  23487. * Makes a duplicate of the current material.
  23488. * @param name - name to use for the new material.
  23489. */
  23490. clone(name: string): PBRMaterial;
  23491. /**
  23492. * Serializes this PBR Material.
  23493. * @returns - An object with the serialized material.
  23494. */
  23495. serialize(): any;
  23496. /**
  23497. * Parses a PBR Material from a serialized object.
  23498. * @param source - Serialized object.
  23499. * @param scene - BJS scene instance.
  23500. * @param rootUrl - url for the scene object
  23501. * @returns - PBRMaterial
  23502. */
  23503. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  23504. }
  23505. }
  23506. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  23507. /** @hidden */
  23508. export var mrtFragmentDeclaration: {
  23509. name: string;
  23510. shader: string;
  23511. };
  23512. }
  23513. declare module "babylonjs/Shaders/geometry.fragment" {
  23514. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  23515. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  23516. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  23517. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  23518. /** @hidden */
  23519. export var geometryPixelShader: {
  23520. name: string;
  23521. shader: string;
  23522. };
  23523. }
  23524. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  23525. /** @hidden */
  23526. export var instancesDeclaration: {
  23527. name: string;
  23528. shader: string;
  23529. };
  23530. }
  23531. declare module "babylonjs/Shaders/geometry.vertex" {
  23532. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  23533. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  23534. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  23535. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  23536. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  23537. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  23538. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  23539. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  23540. /** @hidden */
  23541. export var geometryVertexShader: {
  23542. name: string;
  23543. shader: string;
  23544. };
  23545. }
  23546. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  23547. import { Matrix } from "babylonjs/Maths/math.vector";
  23548. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23549. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23550. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  23551. import { Effect } from "babylonjs/Materials/effect";
  23552. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  23553. import { Scene } from "babylonjs/scene";
  23554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23555. import { Nullable } from "babylonjs/types";
  23556. import "babylonjs/Shaders/geometry.fragment";
  23557. import "babylonjs/Shaders/geometry.vertex";
  23558. /** @hidden */
  23559. interface ISavedTransformationMatrix {
  23560. world: Matrix;
  23561. viewProjection: Matrix;
  23562. }
  23563. /**
  23564. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  23565. */
  23566. export class GeometryBufferRenderer {
  23567. /**
  23568. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  23569. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  23570. */
  23571. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  23572. /**
  23573. * Constant used to retrieve the position texture index in the G-Buffer textures array
  23574. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  23575. */
  23576. static readonly POSITION_TEXTURE_TYPE: number;
  23577. /**
  23578. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  23579. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  23580. */
  23581. static readonly VELOCITY_TEXTURE_TYPE: number;
  23582. /**
  23583. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  23584. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  23585. */
  23586. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  23587. /**
  23588. * Dictionary used to store the previous transformation matrices of each rendered mesh
  23589. * in order to compute objects velocities when enableVelocity is set to "true"
  23590. * @hidden
  23591. */
  23592. _previousTransformationMatrices: {
  23593. [index: number]: ISavedTransformationMatrix;
  23594. };
  23595. /**
  23596. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  23597. * in order to compute objects velocities when enableVelocity is set to "true"
  23598. * @hidden
  23599. */
  23600. _previousBonesTransformationMatrices: {
  23601. [index: number]: Float32Array;
  23602. };
  23603. /**
  23604. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  23605. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  23606. */
  23607. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  23608. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  23609. renderTransparentMeshes: boolean;
  23610. private _scene;
  23611. private _resizeObserver;
  23612. private _multiRenderTarget;
  23613. private _ratio;
  23614. private _enablePosition;
  23615. private _enableVelocity;
  23616. private _enableReflectivity;
  23617. private _positionIndex;
  23618. private _velocityIndex;
  23619. private _reflectivityIndex;
  23620. private _depthNormalIndex;
  23621. private _linkedWithPrePass;
  23622. private _prePassRenderer;
  23623. private _attachments;
  23624. protected _effect: Effect;
  23625. protected _cachedDefines: string;
  23626. /**
  23627. * @hidden
  23628. * Sets up internal structures to share outputs with PrePassRenderer
  23629. * This method should only be called by the PrePassRenderer itself
  23630. */
  23631. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  23632. /**
  23633. * @hidden
  23634. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  23635. * This method should only be called by the PrePassRenderer itself
  23636. */
  23637. _unlinkPrePassRenderer(): void;
  23638. /**
  23639. * @hidden
  23640. * Resets the geometry buffer layout
  23641. */
  23642. _resetLayout(): void;
  23643. /**
  23644. * @hidden
  23645. * Replaces a texture in the geometry buffer renderer
  23646. * Useful when linking textures of the prepass renderer
  23647. */
  23648. _forceTextureType(geometryBufferType: number, index: number): void;
  23649. /**
  23650. * @hidden
  23651. * Sets texture attachments
  23652. * Useful when linking textures of the prepass renderer
  23653. */
  23654. _setAttachments(attachments: number[]): void;
  23655. /**
  23656. * @hidden
  23657. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  23658. * Useful when linking textures of the prepass renderer
  23659. */
  23660. _linkInternalTexture(internalTexture: InternalTexture): void;
  23661. /**
  23662. * Gets the render list (meshes to be rendered) used in the G buffer.
  23663. */
  23664. get renderList(): Nullable<AbstractMesh[]>;
  23665. /**
  23666. * Set the render list (meshes to be rendered) used in the G buffer.
  23667. */
  23668. set renderList(meshes: Nullable<AbstractMesh[]>);
  23669. /**
  23670. * Gets wether or not G buffer are supported by the running hardware.
  23671. * This requires draw buffer supports
  23672. */
  23673. get isSupported(): boolean;
  23674. /**
  23675. * Returns the index of the given texture type in the G-Buffer textures array
  23676. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  23677. * @returns the index of the given texture type in the G-Buffer textures array
  23678. */
  23679. getTextureIndex(textureType: number): number;
  23680. /**
  23681. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  23682. */
  23683. get enablePosition(): boolean;
  23684. /**
  23685. * Sets whether or not objects positions are enabled for the G buffer.
  23686. */
  23687. set enablePosition(enable: boolean);
  23688. /**
  23689. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  23690. */
  23691. get enableVelocity(): boolean;
  23692. /**
  23693. * Sets wether or not objects velocities are enabled for the G buffer.
  23694. */
  23695. set enableVelocity(enable: boolean);
  23696. /**
  23697. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  23698. */
  23699. get enableReflectivity(): boolean;
  23700. /**
  23701. * Sets wether or not objects roughness are enabled for the G buffer.
  23702. */
  23703. set enableReflectivity(enable: boolean);
  23704. /**
  23705. * Gets the scene associated with the buffer.
  23706. */
  23707. get scene(): Scene;
  23708. /**
  23709. * Gets the ratio used by the buffer during its creation.
  23710. * How big is the buffer related to the main canvas.
  23711. */
  23712. get ratio(): number;
  23713. /** @hidden */
  23714. static _SceneComponentInitialization: (scene: Scene) => void;
  23715. /**
  23716. * Creates a new G Buffer for the scene
  23717. * @param scene The scene the buffer belongs to
  23718. * @param ratio How big is the buffer related to the main canvas.
  23719. */
  23720. constructor(scene: Scene, ratio?: number);
  23721. /**
  23722. * Checks wether everything is ready to render a submesh to the G buffer.
  23723. * @param subMesh the submesh to check readiness for
  23724. * @param useInstances is the mesh drawn using instance or not
  23725. * @returns true if ready otherwise false
  23726. */
  23727. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  23728. /**
  23729. * Gets the current underlying G Buffer.
  23730. * @returns the buffer
  23731. */
  23732. getGBuffer(): MultiRenderTarget;
  23733. /**
  23734. * Gets the number of samples used to render the buffer (anti aliasing).
  23735. */
  23736. get samples(): number;
  23737. /**
  23738. * Sets the number of samples used to render the buffer (anti aliasing).
  23739. */
  23740. set samples(value: number);
  23741. /**
  23742. * Disposes the renderer and frees up associated resources.
  23743. */
  23744. dispose(): void;
  23745. private _assignRenderTargetIndices;
  23746. protected _createRenderTargets(): void;
  23747. private _copyBonesTransformationMatrices;
  23748. }
  23749. }
  23750. declare module "babylonjs/Rendering/prePassRenderer" {
  23751. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  23752. import { Scene } from "babylonjs/scene";
  23753. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  23754. import { Effect } from "babylonjs/Materials/effect";
  23755. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  23756. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23757. import { Material } from "babylonjs/Materials/material";
  23758. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23759. /**
  23760. * Renders a pre pass of the scene
  23761. * This means every mesh in the scene will be rendered to a render target texture
  23762. * And then this texture will be composited to the rendering canvas with post processes
  23763. * It is necessary for effects like subsurface scattering or deferred shading
  23764. */
  23765. export class PrePassRenderer {
  23766. /** @hidden */
  23767. static _SceneComponentInitialization: (scene: Scene) => void;
  23768. private _textureFormats;
  23769. /**
  23770. * To save performance, we can excluded skinned meshes from the prepass
  23771. */
  23772. excludedSkinnedMesh: AbstractMesh[];
  23773. /**
  23774. * Force material to be excluded from the prepass
  23775. * Can be useful when `useGeometryBufferFallback` is set to `true`
  23776. * and you don't want a material to show in the effect.
  23777. */
  23778. excludedMaterials: Material[];
  23779. private _textureIndices;
  23780. private _scene;
  23781. private _engine;
  23782. private _isDirty;
  23783. /**
  23784. * Number of textures in the multi render target texture where the scene is directly rendered
  23785. */
  23786. mrtCount: number;
  23787. /**
  23788. * The render target where the scene is directly rendered
  23789. */
  23790. prePassRT: MultiRenderTarget;
  23791. private _multiRenderAttachments;
  23792. private _defaultAttachments;
  23793. private _postProcesses;
  23794. private readonly _clearColor;
  23795. /**
  23796. * Image processing post process for composition
  23797. */
  23798. imageProcessingPostProcess: ImageProcessingPostProcess;
  23799. /**
  23800. * Configuration for prepass effects
  23801. */
  23802. private _effectConfigurations;
  23803. private _mrtFormats;
  23804. private _mrtLayout;
  23805. private _enabled;
  23806. /**
  23807. * Indicates if the prepass is enabled
  23808. */
  23809. get enabled(): boolean;
  23810. /**
  23811. * How many samples are used for MSAA of the scene render target
  23812. */
  23813. get samples(): number;
  23814. set samples(n: number);
  23815. private _geometryBuffer;
  23816. private _useGeometryBufferFallback;
  23817. /**
  23818. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  23819. */
  23820. get useGeometryBufferFallback(): boolean;
  23821. set useGeometryBufferFallback(value: boolean);
  23822. /**
  23823. * Set to true to disable gamma transform in PrePass.
  23824. * Can be useful in case you already proceed to gamma transform on a material level
  23825. * and your post processes don't need to be in linear color space.
  23826. */
  23827. disableGammaTransform: boolean;
  23828. /**
  23829. * Instanciates a prepass renderer
  23830. * @param scene The scene
  23831. */
  23832. constructor(scene: Scene);
  23833. private _initializeAttachments;
  23834. private _createCompositionEffect;
  23835. /**
  23836. * Indicates if rendering a prepass is supported
  23837. */
  23838. get isSupported(): boolean;
  23839. /**
  23840. * Sets the proper output textures to draw in the engine.
  23841. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  23842. * @param subMesh Submesh on which the effect is applied
  23843. */
  23844. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  23845. /**
  23846. * Restores attachments for single texture draw.
  23847. */
  23848. restoreAttachments(): void;
  23849. /**
  23850. * @hidden
  23851. */
  23852. _beforeCameraDraw(): void;
  23853. /**
  23854. * @hidden
  23855. */
  23856. _afterCameraDraw(): void;
  23857. private _checkRTSize;
  23858. private _bindFrameBuffer;
  23859. /**
  23860. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  23861. */
  23862. clear(): void;
  23863. private _setState;
  23864. private _updateGeometryBufferLayout;
  23865. /**
  23866. * Adds an effect configuration to the prepass.
  23867. * If an effect has already been added, it won't add it twice and will return the configuration
  23868. * already present.
  23869. * @param cfg the effect configuration
  23870. * @return the effect configuration now used by the prepass
  23871. */
  23872. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  23873. /**
  23874. * Returns the index of a texture in the multi render target texture array.
  23875. * @param type Texture type
  23876. * @return The index
  23877. */
  23878. getIndex(type: number): number;
  23879. private _enable;
  23880. private _disable;
  23881. private _resetLayout;
  23882. private _resetPostProcessChain;
  23883. private _bindPostProcessChain;
  23884. /**
  23885. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  23886. */
  23887. markAsDirty(): void;
  23888. /**
  23889. * Enables a texture on the MultiRenderTarget for prepass
  23890. */
  23891. private _enableTextures;
  23892. private _update;
  23893. private _markAllMaterialsAsPrePassDirty;
  23894. /**
  23895. * Disposes the prepass renderer.
  23896. */
  23897. dispose(): void;
  23898. }
  23899. }
  23900. declare module "babylonjs/PostProcesses/postProcess" {
  23901. import { Nullable } from "babylonjs/types";
  23902. import { SmartArray } from "babylonjs/Misc/smartArray";
  23903. import { Observable } from "babylonjs/Misc/observable";
  23904. import { Vector2 } from "babylonjs/Maths/math.vector";
  23905. import { Camera } from "babylonjs/Cameras/camera";
  23906. import { Effect } from "babylonjs/Materials/effect";
  23907. import "babylonjs/Shaders/postprocess.vertex";
  23908. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23909. import { Engine } from "babylonjs/Engines/engine";
  23910. import { Color4 } from "babylonjs/Maths/math.color";
  23911. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23912. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23913. import { Scene } from "babylonjs/scene";
  23914. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23915. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  23916. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  23917. /**
  23918. * Size options for a post process
  23919. */
  23920. export type PostProcessOptions = {
  23921. width: number;
  23922. height: number;
  23923. };
  23924. /**
  23925. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23926. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23927. */
  23928. export class PostProcess {
  23929. /**
  23930. * Gets or sets the unique id of the post process
  23931. */
  23932. uniqueId: number;
  23933. /** Name of the PostProcess. */
  23934. name: string;
  23935. /**
  23936. * Width of the texture to apply the post process on
  23937. */
  23938. width: number;
  23939. /**
  23940. * Height of the texture to apply the post process on
  23941. */
  23942. height: number;
  23943. /**
  23944. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23945. */
  23946. nodeMaterialSource: Nullable<NodeMaterial>;
  23947. /**
  23948. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23949. * @hidden
  23950. */
  23951. _outputTexture: Nullable<InternalTexture>;
  23952. /**
  23953. * Sampling mode used by the shader
  23954. * See https://doc.babylonjs.com/classes/3.1/texture
  23955. */
  23956. renderTargetSamplingMode: number;
  23957. /**
  23958. * Clear color to use when screen clearing
  23959. */
  23960. clearColor: Color4;
  23961. /**
  23962. * If the buffer needs to be cleared before applying the post process. (default: true)
  23963. * Should be set to false if shader will overwrite all previous pixels.
  23964. */
  23965. autoClear: boolean;
  23966. /**
  23967. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23968. */
  23969. alphaMode: number;
  23970. /**
  23971. * Sets the setAlphaBlendConstants of the babylon engine
  23972. */
  23973. alphaConstants: Color4;
  23974. /**
  23975. * Animations to be used for the post processing
  23976. */
  23977. animations: import("babylonjs/Animations/animation").Animation[];
  23978. /**
  23979. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23980. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23981. */
  23982. enablePixelPerfectMode: boolean;
  23983. /**
  23984. * Force the postprocess to be applied without taking in account viewport
  23985. */
  23986. forceFullscreenViewport: boolean;
  23987. /**
  23988. * List of inspectable custom properties (used by the Inspector)
  23989. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23990. */
  23991. inspectableCustomProperties: IInspectable[];
  23992. /**
  23993. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23994. *
  23995. * | Value | Type | Description |
  23996. * | ----- | ----------------------------------- | ----------- |
  23997. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23998. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23999. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  24000. *
  24001. */
  24002. scaleMode: number;
  24003. /**
  24004. * Force textures to be a power of two (default: false)
  24005. */
  24006. alwaysForcePOT: boolean;
  24007. private _samples;
  24008. /**
  24009. * Number of sample textures (default: 1)
  24010. */
  24011. get samples(): number;
  24012. set samples(n: number);
  24013. /**
  24014. * Modify the scale of the post process to be the same as the viewport (default: false)
  24015. */
  24016. adaptScaleToCurrentViewport: boolean;
  24017. private _camera;
  24018. protected _scene: Scene;
  24019. private _engine;
  24020. private _options;
  24021. private _reusable;
  24022. private _textureType;
  24023. private _textureFormat;
  24024. /**
  24025. * Smart array of input and output textures for the post process.
  24026. * @hidden
  24027. */
  24028. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  24029. /**
  24030. * The index in _textures that corresponds to the output texture.
  24031. * @hidden
  24032. */
  24033. _currentRenderTextureInd: number;
  24034. private _effect;
  24035. private _samplers;
  24036. private _fragmentUrl;
  24037. private _vertexUrl;
  24038. private _parameters;
  24039. private _scaleRatio;
  24040. protected _indexParameters: any;
  24041. private _shareOutputWithPostProcess;
  24042. private _texelSize;
  24043. private _forcedOutputTexture;
  24044. /**
  24045. * Prepass configuration in case this post process needs a texture from prepass
  24046. * @hidden
  24047. */
  24048. _prePassEffectConfiguration: PrePassEffectConfiguration;
  24049. /**
  24050. * Returns the fragment url or shader name used in the post process.
  24051. * @returns the fragment url or name in the shader store.
  24052. */
  24053. getEffectName(): string;
  24054. /**
  24055. * An event triggered when the postprocess is activated.
  24056. */
  24057. onActivateObservable: Observable<Camera>;
  24058. private _onActivateObserver;
  24059. /**
  24060. * A function that is added to the onActivateObservable
  24061. */
  24062. set onActivate(callback: Nullable<(camera: Camera) => void>);
  24063. /**
  24064. * An event triggered when the postprocess changes its size.
  24065. */
  24066. onSizeChangedObservable: Observable<PostProcess>;
  24067. private _onSizeChangedObserver;
  24068. /**
  24069. * A function that is added to the onSizeChangedObservable
  24070. */
  24071. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  24072. /**
  24073. * An event triggered when the postprocess applies its effect.
  24074. */
  24075. onApplyObservable: Observable<Effect>;
  24076. private _onApplyObserver;
  24077. /**
  24078. * A function that is added to the onApplyObservable
  24079. */
  24080. set onApply(callback: (effect: Effect) => void);
  24081. /**
  24082. * An event triggered before rendering the postprocess
  24083. */
  24084. onBeforeRenderObservable: Observable<Effect>;
  24085. private _onBeforeRenderObserver;
  24086. /**
  24087. * A function that is added to the onBeforeRenderObservable
  24088. */
  24089. set onBeforeRender(callback: (effect: Effect) => void);
  24090. /**
  24091. * An event triggered after rendering the postprocess
  24092. */
  24093. onAfterRenderObservable: Observable<Effect>;
  24094. private _onAfterRenderObserver;
  24095. /**
  24096. * A function that is added to the onAfterRenderObservable
  24097. */
  24098. set onAfterRender(callback: (efect: Effect) => void);
  24099. /**
  24100. * 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
  24101. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  24102. */
  24103. get inputTexture(): InternalTexture;
  24104. set inputTexture(value: InternalTexture);
  24105. /**
  24106. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  24107. * the only way to unset it is to use this function to restore its internal state
  24108. */
  24109. restoreDefaultInputTexture(): void;
  24110. /**
  24111. * Gets the camera which post process is applied to.
  24112. * @returns The camera the post process is applied to.
  24113. */
  24114. getCamera(): Camera;
  24115. /**
  24116. * Gets the texel size of the postprocess.
  24117. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  24118. */
  24119. get texelSize(): Vector2;
  24120. /**
  24121. * Creates a new instance PostProcess
  24122. * @param name The name of the PostProcess.
  24123. * @param fragmentUrl The url of the fragment shader to be used.
  24124. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  24125. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  24126. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  24127. * @param camera The camera to apply the render pass to.
  24128. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  24129. * @param engine The engine which the post process will be applied. (default: current engine)
  24130. * @param reusable If the post process can be reused on the same frame. (default: false)
  24131. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  24132. * @param textureType Type of textures used when performing the post process. (default: 0)
  24133. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  24134. * @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
  24135. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  24136. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  24137. */
  24138. 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);
  24139. /**
  24140. * Gets a string identifying the name of the class
  24141. * @returns "PostProcess" string
  24142. */
  24143. getClassName(): string;
  24144. /**
  24145. * Gets the engine which this post process belongs to.
  24146. * @returns The engine the post process was enabled with.
  24147. */
  24148. getEngine(): Engine;
  24149. /**
  24150. * The effect that is created when initializing the post process.
  24151. * @returns The created effect corresponding the the postprocess.
  24152. */
  24153. getEffect(): Effect;
  24154. /**
  24155. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  24156. * @param postProcess The post process to share the output with.
  24157. * @returns This post process.
  24158. */
  24159. shareOutputWith(postProcess: PostProcess): PostProcess;
  24160. /**
  24161. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  24162. * This should be called if the post process that shares output with this post process is disabled/disposed.
  24163. */
  24164. useOwnOutput(): void;
  24165. /**
  24166. * Updates the effect with the current post process compile time values and recompiles the shader.
  24167. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  24168. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  24169. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  24170. * @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
  24171. * @param onCompiled Called when the shader has been compiled.
  24172. * @param onError Called if there is an error when compiling a shader.
  24173. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  24174. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  24175. */
  24176. 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;
  24177. /**
  24178. * The post process is reusable if it can be used multiple times within one frame.
  24179. * @returns If the post process is reusable
  24180. */
  24181. isReusable(): boolean;
  24182. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  24183. markTextureDirty(): void;
  24184. /**
  24185. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  24186. * 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.
  24187. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  24188. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  24189. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  24190. * @returns The target texture that was bound to be written to.
  24191. */
  24192. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  24193. /**
  24194. * If the post process is supported.
  24195. */
  24196. get isSupported(): boolean;
  24197. /**
  24198. * The aspect ratio of the output texture.
  24199. */
  24200. get aspectRatio(): number;
  24201. /**
  24202. * Get a value indicating if the post-process is ready to be used
  24203. * @returns true if the post-process is ready (shader is compiled)
  24204. */
  24205. isReady(): boolean;
  24206. /**
  24207. * Binds all textures and uniforms to the shader, this will be run on every pass.
  24208. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  24209. */
  24210. apply(): Nullable<Effect>;
  24211. private _disposeTextures;
  24212. /**
  24213. * Sets the required values to the prepass renderer.
  24214. * @param prePassRenderer defines the prepass renderer to setup.
  24215. * @returns true if the pre pass is needed.
  24216. */
  24217. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  24218. /**
  24219. * Disposes the post process.
  24220. * @param camera The camera to dispose the post process on.
  24221. */
  24222. dispose(camera?: Camera): void;
  24223. /**
  24224. * Serializes the particle system to a JSON object
  24225. * @returns the JSON object
  24226. */
  24227. serialize(): any;
  24228. /**
  24229. * Creates a material from parsed material data
  24230. * @param parsedPostProcess defines parsed post process data
  24231. * @param scene defines the hosting scene
  24232. * @param rootUrl defines the root URL to use to load textures
  24233. * @returns a new post process
  24234. */
  24235. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  24236. }
  24237. }
  24238. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  24239. /** @hidden */
  24240. export var kernelBlurVaryingDeclaration: {
  24241. name: string;
  24242. shader: string;
  24243. };
  24244. }
  24245. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  24246. /** @hidden */
  24247. export var packingFunctions: {
  24248. name: string;
  24249. shader: string;
  24250. };
  24251. }
  24252. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  24253. /** @hidden */
  24254. export var kernelBlurFragment: {
  24255. name: string;
  24256. shader: string;
  24257. };
  24258. }
  24259. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  24260. /** @hidden */
  24261. export var kernelBlurFragment2: {
  24262. name: string;
  24263. shader: string;
  24264. };
  24265. }
  24266. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  24267. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  24268. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  24269. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  24270. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  24271. /** @hidden */
  24272. export var kernelBlurPixelShader: {
  24273. name: string;
  24274. shader: string;
  24275. };
  24276. }
  24277. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  24278. /** @hidden */
  24279. export var kernelBlurVertex: {
  24280. name: string;
  24281. shader: string;
  24282. };
  24283. }
  24284. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  24285. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  24286. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  24287. /** @hidden */
  24288. export var kernelBlurVertexShader: {
  24289. name: string;
  24290. shader: string;
  24291. };
  24292. }
  24293. declare module "babylonjs/PostProcesses/blurPostProcess" {
  24294. import { Vector2 } from "babylonjs/Maths/math.vector";
  24295. import { Nullable } from "babylonjs/types";
  24296. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  24297. import { Camera } from "babylonjs/Cameras/camera";
  24298. import { Effect } from "babylonjs/Materials/effect";
  24299. import { Engine } from "babylonjs/Engines/engine";
  24300. import "babylonjs/Shaders/kernelBlur.fragment";
  24301. import "babylonjs/Shaders/kernelBlur.vertex";
  24302. import { Scene } from "babylonjs/scene";
  24303. /**
  24304. * The Blur Post Process which blurs an image based on a kernel and direction.
  24305. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  24306. */
  24307. export class BlurPostProcess extends PostProcess {
  24308. private blockCompilation;
  24309. protected _kernel: number;
  24310. protected _idealKernel: number;
  24311. protected _packedFloat: boolean;
  24312. private _staticDefines;
  24313. /** The direction in which to blur the image. */
  24314. direction: Vector2;
  24315. /**
  24316. * Sets the length in pixels of the blur sample region
  24317. */
  24318. set kernel(v: number);
  24319. /**
  24320. * Gets the length in pixels of the blur sample region
  24321. */
  24322. get kernel(): number;
  24323. /**
  24324. * Sets wether or not the blur needs to unpack/repack floats
  24325. */
  24326. set packedFloat(v: boolean);
  24327. /**
  24328. * Gets wether or not the blur is unpacking/repacking floats
  24329. */
  24330. get packedFloat(): boolean;
  24331. /**
  24332. * Gets a string identifying the name of the class
  24333. * @returns "BlurPostProcess" string
  24334. */
  24335. getClassName(): string;
  24336. /**
  24337. * Creates a new instance BlurPostProcess
  24338. * @param name The name of the effect.
  24339. * @param direction The direction in which to blur the image.
  24340. * @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.
  24341. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  24342. * @param camera The camera to apply the render pass to.
  24343. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  24344. * @param engine The engine which the post process will be applied. (default: current engine)
  24345. * @param reusable If the post process can be reused on the same frame. (default: false)
  24346. * @param textureType Type of textures used when performing the post process. (default: 0)
  24347. * @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)
  24348. */
  24349. 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);
  24350. /**
  24351. * Updates the effect with the current post process compile time values and recompiles the shader.
  24352. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  24353. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  24354. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  24355. * @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
  24356. * @param onCompiled Called when the shader has been compiled.
  24357. * @param onError Called if there is an error when compiling a shader.
  24358. */
  24359. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  24360. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  24361. /**
  24362. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  24363. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  24364. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  24365. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  24366. * The gaps between physical kernels are compensated for in the weighting of the samples
  24367. * @param idealKernel Ideal blur kernel.
  24368. * @return Nearest best kernel.
  24369. */
  24370. protected _nearestBestKernel(idealKernel: number): number;
  24371. /**
  24372. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  24373. * @param x The point on the Gaussian distribution to sample.
  24374. * @return the value of the Gaussian function at x.
  24375. */
  24376. protected _gaussianWeight(x: number): number;
  24377. /**
  24378. * Generates a string that can be used as a floating point number in GLSL.
  24379. * @param x Value to print.
  24380. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  24381. * @return GLSL float string.
  24382. */
  24383. protected _glslFloat(x: number, decimalFigures?: number): string;
  24384. /** @hidden */
  24385. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  24386. }
  24387. }
  24388. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  24389. import { Scene } from "babylonjs/scene";
  24390. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24391. import { Plane } from "babylonjs/Maths/math.plane";
  24392. /**
  24393. * Mirror texture can be used to simulate the view from a mirror in a scene.
  24394. * It will dynamically be rendered every frame to adapt to the camera point of view.
  24395. * You can then easily use it as a reflectionTexture on a flat surface.
  24396. * In case the surface is not a plane, please consider relying on reflection probes.
  24397. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24398. */
  24399. export class MirrorTexture extends RenderTargetTexture {
  24400. private scene;
  24401. /**
  24402. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  24403. * 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.
  24404. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24405. */
  24406. mirrorPlane: Plane;
  24407. /**
  24408. * Define the blur ratio used to blur the reflection if needed.
  24409. */
  24410. set blurRatio(value: number);
  24411. get blurRatio(): number;
  24412. /**
  24413. * Define the adaptive blur kernel used to blur the reflection if needed.
  24414. * This will autocompute the closest best match for the `blurKernel`
  24415. */
  24416. set adaptiveBlurKernel(value: number);
  24417. /**
  24418. * Define the blur kernel used to blur the reflection if needed.
  24419. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24420. */
  24421. set blurKernel(value: number);
  24422. /**
  24423. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  24424. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24425. */
  24426. set blurKernelX(value: number);
  24427. get blurKernelX(): number;
  24428. /**
  24429. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  24430. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24431. */
  24432. set blurKernelY(value: number);
  24433. get blurKernelY(): number;
  24434. private _autoComputeBlurKernel;
  24435. protected _onRatioRescale(): void;
  24436. private _updateGammaSpace;
  24437. private _imageProcessingConfigChangeObserver;
  24438. private _transformMatrix;
  24439. private _mirrorMatrix;
  24440. private _savedViewMatrix;
  24441. private _blurX;
  24442. private _blurY;
  24443. private _adaptiveBlurKernel;
  24444. private _blurKernelX;
  24445. private _blurKernelY;
  24446. private _blurRatio;
  24447. /**
  24448. * Instantiates a Mirror Texture.
  24449. * Mirror texture can be used to simulate the view from a mirror in a scene.
  24450. * It will dynamically be rendered every frame to adapt to the camera point of view.
  24451. * You can then easily use it as a reflectionTexture on a flat surface.
  24452. * In case the surface is not a plane, please consider relying on reflection probes.
  24453. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24454. * @param name
  24455. * @param size
  24456. * @param scene
  24457. * @param generateMipMaps
  24458. * @param type
  24459. * @param samplingMode
  24460. * @param generateDepthBuffer
  24461. */
  24462. constructor(name: string, size: number | {
  24463. width: number;
  24464. height: number;
  24465. } | {
  24466. ratio: number;
  24467. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  24468. private _preparePostProcesses;
  24469. /**
  24470. * Clone the mirror texture.
  24471. * @returns the cloned texture
  24472. */
  24473. clone(): MirrorTexture;
  24474. /**
  24475. * Serialize the texture to a JSON representation you could use in Parse later on
  24476. * @returns the serialized JSON representation
  24477. */
  24478. serialize(): any;
  24479. /**
  24480. * Dispose the texture and release its associated resources.
  24481. */
  24482. dispose(): void;
  24483. }
  24484. }
  24485. declare module "babylonjs/Materials/Textures/texture" {
  24486. import { Observable } from "babylonjs/Misc/observable";
  24487. import { Nullable } from "babylonjs/types";
  24488. import { Matrix } from "babylonjs/Maths/math.vector";
  24489. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24490. import { IInspectable } from "babylonjs/Misc/iInspectable";
  24491. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  24492. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  24493. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  24494. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24495. import { Scene } from "babylonjs/scene";
  24496. /**
  24497. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24498. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24499. */
  24500. export class Texture extends BaseTexture {
  24501. /**
  24502. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  24503. */
  24504. static SerializeBuffers: boolean;
  24505. /**
  24506. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  24507. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  24508. */
  24509. static ForceSerializeBuffers: boolean;
  24510. /** @hidden */
  24511. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  24512. /** @hidden */
  24513. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  24514. /** @hidden */
  24515. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  24516. /** nearest is mag = nearest and min = nearest and mip = linear */
  24517. static readonly NEAREST_SAMPLINGMODE: number;
  24518. /** nearest is mag = nearest and min = nearest and mip = linear */
  24519. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  24520. /** Bilinear is mag = linear and min = linear and mip = nearest */
  24521. static readonly BILINEAR_SAMPLINGMODE: number;
  24522. /** Bilinear is mag = linear and min = linear and mip = nearest */
  24523. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  24524. /** Trilinear is mag = linear and min = linear and mip = linear */
  24525. static readonly TRILINEAR_SAMPLINGMODE: number;
  24526. /** Trilinear is mag = linear and min = linear and mip = linear */
  24527. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  24528. /** mag = nearest and min = nearest and mip = nearest */
  24529. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  24530. /** mag = nearest and min = linear and mip = nearest */
  24531. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  24532. /** mag = nearest and min = linear and mip = linear */
  24533. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  24534. /** mag = nearest and min = linear and mip = none */
  24535. static readonly NEAREST_LINEAR: number;
  24536. /** mag = nearest and min = nearest and mip = none */
  24537. static readonly NEAREST_NEAREST: number;
  24538. /** mag = linear and min = nearest and mip = nearest */
  24539. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  24540. /** mag = linear and min = nearest and mip = linear */
  24541. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  24542. /** mag = linear and min = linear and mip = none */
  24543. static readonly LINEAR_LINEAR: number;
  24544. /** mag = linear and min = nearest and mip = none */
  24545. static readonly LINEAR_NEAREST: number;
  24546. /** Explicit coordinates mode */
  24547. static readonly EXPLICIT_MODE: number;
  24548. /** Spherical coordinates mode */
  24549. static readonly SPHERICAL_MODE: number;
  24550. /** Planar coordinates mode */
  24551. static readonly PLANAR_MODE: number;
  24552. /** Cubic coordinates mode */
  24553. static readonly CUBIC_MODE: number;
  24554. /** Projection coordinates mode */
  24555. static readonly PROJECTION_MODE: number;
  24556. /** Inverse Cubic coordinates mode */
  24557. static readonly SKYBOX_MODE: number;
  24558. /** Inverse Cubic coordinates mode */
  24559. static readonly INVCUBIC_MODE: number;
  24560. /** Equirectangular coordinates mode */
  24561. static readonly EQUIRECTANGULAR_MODE: number;
  24562. /** Equirectangular Fixed coordinates mode */
  24563. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  24564. /** Equirectangular Fixed Mirrored coordinates mode */
  24565. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  24566. /** Texture is not repeating outside of 0..1 UVs */
  24567. static readonly CLAMP_ADDRESSMODE: number;
  24568. /** Texture is repeating outside of 0..1 UVs */
  24569. static readonly WRAP_ADDRESSMODE: number;
  24570. /** Texture is repeating and mirrored */
  24571. static readonly MIRROR_ADDRESSMODE: number;
  24572. /**
  24573. * 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
  24574. */
  24575. static UseSerializedUrlIfAny: boolean;
  24576. /**
  24577. * Define the url of the texture.
  24578. */
  24579. url: Nullable<string>;
  24580. /**
  24581. * Define an offset on the texture to offset the u coordinates of the UVs
  24582. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24583. */
  24584. uOffset: number;
  24585. /**
  24586. * Define an offset on the texture to offset the v coordinates of the UVs
  24587. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24588. */
  24589. vOffset: number;
  24590. /**
  24591. * Define an offset on the texture to scale the u coordinates of the UVs
  24592. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24593. */
  24594. uScale: number;
  24595. /**
  24596. * Define an offset on the texture to scale the v coordinates of the UVs
  24597. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24598. */
  24599. vScale: number;
  24600. /**
  24601. * Define an offset on the texture to rotate around the u coordinates of the UVs
  24602. * @see https://doc.babylonjs.com/how_to/more_materials
  24603. */
  24604. uAng: number;
  24605. /**
  24606. * Define an offset on the texture to rotate around the v coordinates of the UVs
  24607. * @see https://doc.babylonjs.com/how_to/more_materials
  24608. */
  24609. vAng: number;
  24610. /**
  24611. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  24612. * @see https://doc.babylonjs.com/how_to/more_materials
  24613. */
  24614. wAng: number;
  24615. /**
  24616. * Defines the center of rotation (U)
  24617. */
  24618. uRotationCenter: number;
  24619. /**
  24620. * Defines the center of rotation (V)
  24621. */
  24622. vRotationCenter: number;
  24623. /**
  24624. * Defines the center of rotation (W)
  24625. */
  24626. wRotationCenter: number;
  24627. /**
  24628. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  24629. */
  24630. homogeneousRotationInUVTransform: boolean;
  24631. /**
  24632. * Are mip maps generated for this texture or not.
  24633. */
  24634. get noMipmap(): boolean;
  24635. /**
  24636. * List of inspectable custom properties (used by the Inspector)
  24637. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24638. */
  24639. inspectableCustomProperties: Nullable<IInspectable[]>;
  24640. private _noMipmap;
  24641. /** @hidden */
  24642. _invertY: boolean;
  24643. private _rowGenerationMatrix;
  24644. private _cachedTextureMatrix;
  24645. private _projectionModeMatrix;
  24646. private _t0;
  24647. private _t1;
  24648. private _t2;
  24649. private _cachedUOffset;
  24650. private _cachedVOffset;
  24651. private _cachedUScale;
  24652. private _cachedVScale;
  24653. private _cachedUAng;
  24654. private _cachedVAng;
  24655. private _cachedWAng;
  24656. private _cachedProjectionMatrixId;
  24657. private _cachedURotationCenter;
  24658. private _cachedVRotationCenter;
  24659. private _cachedWRotationCenter;
  24660. private _cachedHomogeneousRotationInUVTransform;
  24661. private _cachedCoordinatesMode;
  24662. /** @hidden */
  24663. protected _initialSamplingMode: number;
  24664. /** @hidden */
  24665. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  24666. private _deleteBuffer;
  24667. protected _format: Nullable<number>;
  24668. private _delayedOnLoad;
  24669. private _delayedOnError;
  24670. private _mimeType?;
  24671. private _loaderOptions?;
  24672. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  24673. get mimeType(): string | undefined;
  24674. /**
  24675. * Observable triggered once the texture has been loaded.
  24676. */
  24677. onLoadObservable: Observable<Texture>;
  24678. protected _isBlocking: boolean;
  24679. /**
  24680. * Is the texture preventing material to render while loading.
  24681. * If false, a default texture will be used instead of the loading one during the preparation step.
  24682. */
  24683. set isBlocking(value: boolean);
  24684. get isBlocking(): boolean;
  24685. /**
  24686. * Get the current sampling mode associated with the texture.
  24687. */
  24688. get samplingMode(): number;
  24689. /**
  24690. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  24691. */
  24692. get invertY(): boolean;
  24693. /**
  24694. * Instantiates a new texture.
  24695. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24696. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24697. * @param url defines the url of the picture to load as a texture
  24698. * @param sceneOrEngine defines the scene or engine the texture will belong to
  24699. * @param noMipmap defines if the texture will require mip maps or not
  24700. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  24701. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24702. * @param onLoad defines a callback triggered when the texture has been loaded
  24703. * @param onError defines a callback triggered when an error occurred during the loading session
  24704. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  24705. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  24706. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24707. * @param mimeType defines an optional mime type information
  24708. * @param loaderOptions options to be passed to the loader
  24709. */
  24710. 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);
  24711. /**
  24712. * Update the url (and optional buffer) of this texture if url was null during construction.
  24713. * @param url the url of the texture
  24714. * @param buffer the buffer of the texture (defaults to null)
  24715. * @param onLoad callback called when the texture is loaded (defaults to null)
  24716. */
  24717. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  24718. /**
  24719. * Finish the loading sequence of a texture flagged as delayed load.
  24720. * @hidden
  24721. */
  24722. delayLoad(): void;
  24723. private _prepareRowForTextureGeneration;
  24724. /**
  24725. * Checks if the texture has the same transform matrix than another texture
  24726. * @param texture texture to check against
  24727. * @returns true if the transforms are the same, else false
  24728. */
  24729. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  24730. /**
  24731. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  24732. * @returns the transform matrix of the texture.
  24733. */
  24734. getTextureMatrix(uBase?: number): Matrix;
  24735. /**
  24736. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  24737. * @returns The reflection texture transform
  24738. */
  24739. getReflectionTextureMatrix(): Matrix;
  24740. /**
  24741. * Clones the texture.
  24742. * @returns the cloned texture
  24743. */
  24744. clone(): Texture;
  24745. /**
  24746. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24747. * @returns The JSON representation of the texture
  24748. */
  24749. serialize(): any;
  24750. /**
  24751. * Get the current class name of the texture useful for serialization or dynamic coding.
  24752. * @returns "Texture"
  24753. */
  24754. getClassName(): string;
  24755. /**
  24756. * Dispose the texture and release its associated resources.
  24757. */
  24758. dispose(): void;
  24759. /**
  24760. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  24761. * @param parsedTexture Define the JSON representation of the texture
  24762. * @param scene Define the scene the parsed texture should be instantiated in
  24763. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  24764. * @returns The parsed texture if successful
  24765. */
  24766. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  24767. /**
  24768. * Creates a texture from its base 64 representation.
  24769. * @param data Define the base64 payload without the data: prefix
  24770. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24771. * @param scene Define the scene the texture should belong to
  24772. * @param noMipmap Forces the texture to not create mip map information if true
  24773. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24774. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24775. * @param onLoad define a callback triggered when the texture has been loaded
  24776. * @param onError define a callback triggered when an error occurred during the loading session
  24777. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24778. * @returns the created texture
  24779. */
  24780. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  24781. /**
  24782. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  24783. * @param data Define the base64 payload without the data: prefix
  24784. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24785. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  24786. * @param scene Define the scene the texture should belong to
  24787. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  24788. * @param noMipmap Forces the texture to not create mip map information if true
  24789. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24790. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24791. * @param onLoad define a callback triggered when the texture has been loaded
  24792. * @param onError define a callback triggered when an error occurred during the loading session
  24793. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24794. * @returns the created texture
  24795. */
  24796. 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;
  24797. }
  24798. }
  24799. declare module "babylonjs/Sprites/thinSprite" {
  24800. import { IVector3Like, IColor4Like } from "babylonjs/Maths/math.like";
  24801. import { Nullable } from "babylonjs/types";
  24802. /**
  24803. * ThinSprite Class used to represent a thin sprite
  24804. * This is the base class for sprites but can also directly be used with ThinEngine
  24805. * @see https://doc.babylonjs.com/babylon101/sprites
  24806. */
  24807. export class ThinSprite {
  24808. /** Gets or sets the cell index in the sprite sheet */
  24809. cellIndex: number;
  24810. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  24811. cellRef: string;
  24812. /** Gets or sets the current world position */
  24813. position: IVector3Like;
  24814. /** Gets or sets the main color */
  24815. color: IColor4Like;
  24816. /** Gets or sets the width */
  24817. width: number;
  24818. /** Gets or sets the height */
  24819. height: number;
  24820. /** Gets or sets rotation angle */
  24821. angle: number;
  24822. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  24823. invertU: boolean;
  24824. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  24825. invertV: boolean;
  24826. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  24827. isVisible: boolean;
  24828. /**
  24829. * Returns a boolean indicating if the animation is started
  24830. */
  24831. get animationStarted(): boolean;
  24832. /** Gets the initial key for the animation (setting it will restart the animation) */
  24833. get fromIndex(): number;
  24834. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  24835. get toIndex(): number;
  24836. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  24837. get loopAnimation(): boolean;
  24838. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  24839. get delay(): number;
  24840. /** @hidden */
  24841. _xOffset: number;
  24842. /** @hidden */
  24843. _yOffset: number;
  24844. /** @hidden */
  24845. _xSize: number;
  24846. /** @hidden */
  24847. _ySize: number;
  24848. private _animationStarted;
  24849. protected _loopAnimation: boolean;
  24850. protected _fromIndex: number;
  24851. protected _toIndex: number;
  24852. protected _delay: number;
  24853. private _direction;
  24854. private _time;
  24855. private _onBaseAnimationEnd;
  24856. /**
  24857. * Creates a new Thin Sprite
  24858. */
  24859. constructor();
  24860. /**
  24861. * Starts an animation
  24862. * @param from defines the initial key
  24863. * @param to defines the end key
  24864. * @param loop defines if the animation must loop
  24865. * @param delay defines the start delay (in ms)
  24866. * @param onAnimationEnd defines a callback for when the animation ends
  24867. */
  24868. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  24869. /** Stops current animation (if any) */
  24870. stopAnimation(): void;
  24871. /** @hidden */
  24872. _animate(deltaTime: number): void;
  24873. }
  24874. }
  24875. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility" {
  24876. /** @hidden */
  24877. export var imageProcessingCompatibility: {
  24878. name: string;
  24879. shader: string;
  24880. };
  24881. }
  24882. declare module "babylonjs/Shaders/sprites.fragment" {
  24883. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  24884. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  24885. import "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility";
  24886. /** @hidden */
  24887. export var spritesPixelShader: {
  24888. name: string;
  24889. shader: string;
  24890. };
  24891. }
  24892. declare module "babylonjs/Shaders/sprites.vertex" {
  24893. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  24894. /** @hidden */
  24895. export var spritesVertexShader: {
  24896. name: string;
  24897. shader: string;
  24898. };
  24899. }
  24900. declare module "babylonjs/Sprites/spriteRenderer" {
  24901. import { Nullable } from "babylonjs/types";
  24902. import { IMatrixLike } from "babylonjs/Maths/math.like";
  24903. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  24904. import { ThinSprite } from "babylonjs/Sprites/thinSprite";
  24905. import { ISize } from "babylonjs/Maths/math.size";
  24906. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  24907. import { Scene } from "babylonjs/scene";
  24908. import "babylonjs/Engines/Extensions/engine.alpha";
  24909. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  24910. import "babylonjs/Shaders/sprites.fragment";
  24911. import "babylonjs/Shaders/sprites.vertex";
  24912. /**
  24913. * Class used to render sprites.
  24914. *
  24915. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  24916. */
  24917. export class SpriteRenderer {
  24918. /**
  24919. * Defines the texture of the spritesheet
  24920. */
  24921. texture: Nullable<ThinTexture>;
  24922. /**
  24923. * Defines the default width of a cell in the spritesheet
  24924. */
  24925. cellWidth: number;
  24926. /**
  24927. * Defines the default height of a cell in the spritesheet
  24928. */
  24929. cellHeight: number;
  24930. /**
  24931. * Blend mode use to render the particle, it can be any of
  24932. * the static Constants.ALPHA_x properties provided in this class.
  24933. * Default value is Constants.ALPHA_COMBINE
  24934. */
  24935. blendMode: number;
  24936. /**
  24937. * Gets or sets a boolean indicating if alpha mode is automatically
  24938. * reset.
  24939. */
  24940. autoResetAlpha: boolean;
  24941. /**
  24942. * Disables writing to the depth buffer when rendering the sprites.
  24943. * It can be handy to disable depth writing when using textures without alpha channel
  24944. * and setting some specific blend modes.
  24945. */
  24946. disableDepthWrite: boolean;
  24947. /**
  24948. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  24949. */
  24950. fogEnabled: boolean;
  24951. /**
  24952. * Gets the capacity of the manager
  24953. */
  24954. get capacity(): number;
  24955. private readonly _engine;
  24956. private readonly _useVAO;
  24957. private readonly _useInstancing;
  24958. private readonly _scene;
  24959. private readonly _capacity;
  24960. private readonly _epsilon;
  24961. private _vertexBufferSize;
  24962. private _vertexData;
  24963. private _buffer;
  24964. private _vertexBuffers;
  24965. private _spriteBuffer;
  24966. private _indexBuffer;
  24967. private _effectBase;
  24968. private _effectFog;
  24969. private _vertexArrayObject;
  24970. /**
  24971. * Creates a new sprite Renderer
  24972. * @param engine defines the engine the renderer works with
  24973. * @param capacity defines the maximum allowed number of sprites
  24974. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24975. * @param scene defines the hosting scene
  24976. */
  24977. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  24978. /**
  24979. * Render all child sprites
  24980. * @param sprites defines the list of sprites to render
  24981. * @param deltaTime defines the time since last frame
  24982. * @param viewMatrix defines the viewMatrix to use to render the sprites
  24983. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  24984. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  24985. */
  24986. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  24987. private _appendSpriteVertex;
  24988. /**
  24989. * Release associated resources
  24990. */
  24991. dispose(): void;
  24992. }
  24993. }
  24994. declare module "babylonjs/Sprites/spriteManager" {
  24995. import { IDisposable, Scene } from "babylonjs/scene";
  24996. import { Nullable } from "babylonjs/types";
  24997. import { Observable } from "babylonjs/Misc/observable";
  24998. import { Sprite } from "babylonjs/Sprites/sprite";
  24999. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  25000. import { Camera } from "babylonjs/Cameras/camera";
  25001. import { Texture } from "babylonjs/Materials/Textures/texture";
  25002. import { Ray } from "babylonjs/Culling/ray";
  25003. /**
  25004. * Defines the minimum interface to fullfil in order to be a sprite manager.
  25005. */
  25006. export interface ISpriteManager extends IDisposable {
  25007. /**
  25008. * Gets manager's name
  25009. */
  25010. name: string;
  25011. /**
  25012. * Restricts the camera to viewing objects with the same layerMask.
  25013. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  25014. */
  25015. layerMask: number;
  25016. /**
  25017. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25018. */
  25019. isPickable: boolean;
  25020. /**
  25021. * Gets the hosting scene
  25022. */
  25023. scene: Scene;
  25024. /**
  25025. * Specifies the rendering group id for this mesh (0 by default)
  25026. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25027. */
  25028. renderingGroupId: number;
  25029. /**
  25030. * Defines the list of sprites managed by the manager.
  25031. */
  25032. sprites: Array<Sprite>;
  25033. /**
  25034. * Gets or sets the spritesheet texture
  25035. */
  25036. texture: Texture;
  25037. /** Defines the default width of a cell in the spritesheet */
  25038. cellWidth: number;
  25039. /** Defines the default height of a cell in the spritesheet */
  25040. cellHeight: number;
  25041. /**
  25042. * Tests the intersection of a sprite with a specific ray.
  25043. * @param ray The ray we are sending to test the collision
  25044. * @param camera The camera space we are sending rays in
  25045. * @param predicate A predicate allowing excluding sprites from the list of object to test
  25046. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25047. * @returns picking info or null.
  25048. */
  25049. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  25050. /**
  25051. * Intersects the sprites with a ray
  25052. * @param ray defines the ray to intersect with
  25053. * @param camera defines the current active camera
  25054. * @param predicate defines a predicate used to select candidate sprites
  25055. * @returns null if no hit or a PickingInfo array
  25056. */
  25057. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  25058. /**
  25059. * Renders the list of sprites on screen.
  25060. */
  25061. render(): void;
  25062. }
  25063. /**
  25064. * Class used to manage multiple sprites on the same spritesheet
  25065. * @see https://doc.babylonjs.com/babylon101/sprites
  25066. */
  25067. export class SpriteManager implements ISpriteManager {
  25068. /** defines the manager's name */
  25069. name: string;
  25070. /** Define the Url to load snippets */
  25071. static SnippetUrl: string;
  25072. /** Snippet ID if the manager was created from the snippet server */
  25073. snippetId: string;
  25074. /** Gets the list of sprites */
  25075. sprites: Sprite[];
  25076. /** Gets or sets the rendering group id (0 by default) */
  25077. renderingGroupId: number;
  25078. /** Gets or sets camera layer mask */
  25079. layerMask: number;
  25080. /** Gets or sets a boolean indicating if the sprites are pickable */
  25081. isPickable: boolean;
  25082. /**
  25083. * An event triggered when the manager is disposed.
  25084. */
  25085. onDisposeObservable: Observable<SpriteManager>;
  25086. /**
  25087. * Callback called when the manager is disposed
  25088. */
  25089. set onDispose(callback: () => void);
  25090. /**
  25091. * Gets or sets the unique id of the sprite
  25092. */
  25093. uniqueId: number;
  25094. /**
  25095. * Gets the array of sprites
  25096. */
  25097. get children(): Sprite[];
  25098. /**
  25099. * Gets the hosting scene
  25100. */
  25101. get scene(): Scene;
  25102. /**
  25103. * Gets the capacity of the manager
  25104. */
  25105. get capacity(): number;
  25106. /**
  25107. * Gets or sets the spritesheet texture
  25108. */
  25109. get texture(): Texture;
  25110. set texture(value: Texture);
  25111. /** Defines the default width of a cell in the spritesheet */
  25112. get cellWidth(): number;
  25113. set cellWidth(value: number);
  25114. /** Defines the default height of a cell in the spritesheet */
  25115. get cellHeight(): number;
  25116. set cellHeight(value: number);
  25117. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  25118. get fogEnabled(): boolean;
  25119. set fogEnabled(value: boolean);
  25120. /**
  25121. * Blend mode use to render the particle, it can be any of
  25122. * the static Constants.ALPHA_x properties provided in this class.
  25123. * Default value is Constants.ALPHA_COMBINE
  25124. */
  25125. get blendMode(): number;
  25126. set blendMode(blendMode: number);
  25127. /** Disables writing to the depth buffer when rendering the sprites.
  25128. * It can be handy to disable depth writing when using textures without alpha channel
  25129. * and setting some specific blend modes.
  25130. */
  25131. disableDepthWrite: boolean;
  25132. private _spriteRenderer;
  25133. /** Associative array from JSON sprite data file */
  25134. private _cellData;
  25135. /** Array of sprite names from JSON sprite data file */
  25136. private _spriteMap;
  25137. /** True when packed cell data from JSON file is ready*/
  25138. private _packedAndReady;
  25139. private _textureContent;
  25140. private _onDisposeObserver;
  25141. private _fromPacked;
  25142. private _scene;
  25143. /**
  25144. * Creates a new sprite manager
  25145. * @param name defines the manager's name
  25146. * @param imgUrl defines the sprite sheet url
  25147. * @param capacity defines the maximum allowed number of sprites
  25148. * @param cellSize defines the size of a sprite cell
  25149. * @param scene defines the hosting scene
  25150. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  25151. * @param samplingMode defines the smapling mode to use with spritesheet
  25152. * @param fromPacked set to false; do not alter
  25153. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  25154. */
  25155. constructor(
  25156. /** defines the manager's name */
  25157. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  25158. /**
  25159. * Returns the string "SpriteManager"
  25160. * @returns "SpriteManager"
  25161. */
  25162. getClassName(): string;
  25163. private _makePacked;
  25164. private _checkTextureAlpha;
  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. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  25171. * @returns null if no hit or a PickingInfo
  25172. */
  25173. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  25174. /**
  25175. * Intersects the sprites with a ray
  25176. * @param ray defines the ray to intersect with
  25177. * @param camera defines the current active camera
  25178. * @param predicate defines a predicate used to select candidate sprites
  25179. * @returns null if no hit or a PickingInfo array
  25180. */
  25181. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  25182. /**
  25183. * Render all child sprites
  25184. */
  25185. render(): void;
  25186. private _customUpdate;
  25187. /**
  25188. * Release associated resources
  25189. */
  25190. dispose(): void;
  25191. /**
  25192. * Serializes the sprite manager to a JSON object
  25193. * @param serializeTexture defines if the texture must be serialized as well
  25194. * @returns the JSON object
  25195. */
  25196. serialize(serializeTexture?: boolean): any;
  25197. /**
  25198. * Parses a JSON object to create a new sprite manager.
  25199. * @param parsedManager The JSON object to parse
  25200. * @param scene The scene to create the sprite managerin
  25201. * @param rootUrl The root url to use to load external dependencies like texture
  25202. * @returns the new sprite manager
  25203. */
  25204. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  25205. /**
  25206. * Creates a sprite manager from a snippet saved in a remote file
  25207. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  25208. * @param url defines the url to load from
  25209. * @param scene defines the hosting scene
  25210. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  25211. * @returns a promise that will resolve to the new sprite manager
  25212. */
  25213. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  25214. /**
  25215. * Creates a sprite manager from a snippet saved by the sprite editor
  25216. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  25217. * @param scene defines the hosting scene
  25218. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  25219. * @returns a promise that will resolve to the new sprite manager
  25220. */
  25221. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  25222. }
  25223. }
  25224. declare module "babylonjs/Sprites/sprite" {
  25225. import { Vector3 } from "babylonjs/Maths/math.vector";
  25226. import { Nullable } from "babylonjs/types";
  25227. import { ActionManager } from "babylonjs/Actions/actionManager";
  25228. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  25229. import { Color4 } from "babylonjs/Maths/math.color";
  25230. import { Observable } from "babylonjs/Misc/observable";
  25231. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25232. import { ThinSprite } from "babylonjs/Sprites/thinSprite";
  25233. import { Animation } from "babylonjs/Animations/animation";
  25234. /**
  25235. * Class used to represent a sprite
  25236. * @see https://doc.babylonjs.com/babylon101/sprites
  25237. */
  25238. export class Sprite extends ThinSprite implements IAnimatable {
  25239. /** defines the name */
  25240. name: string;
  25241. /** Gets or sets the current world position */
  25242. position: Vector3;
  25243. /** Gets or sets the main color */
  25244. color: Color4;
  25245. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  25246. disposeWhenFinishedAnimating: boolean;
  25247. /** Gets the list of attached animations */
  25248. animations: Nullable<Array<Animation>>;
  25249. /** Gets or sets a boolean indicating if the sprite can be picked */
  25250. isPickable: boolean;
  25251. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  25252. useAlphaForPicking: boolean;
  25253. /**
  25254. * Gets or sets the associated action manager
  25255. */
  25256. actionManager: Nullable<ActionManager>;
  25257. /**
  25258. * An event triggered when the control has been disposed
  25259. */
  25260. onDisposeObservable: Observable<Sprite>;
  25261. private _manager;
  25262. private _onAnimationEnd;
  25263. /**
  25264. * Gets or sets the sprite size
  25265. */
  25266. get size(): number;
  25267. set size(value: number);
  25268. /**
  25269. * Gets or sets the unique id of the sprite
  25270. */
  25271. uniqueId: number;
  25272. /**
  25273. * Gets the manager of this sprite
  25274. */
  25275. get manager(): ISpriteManager;
  25276. /**
  25277. * Creates a new Sprite
  25278. * @param name defines the name
  25279. * @param manager defines the manager
  25280. */
  25281. constructor(
  25282. /** defines the name */
  25283. name: string, manager: ISpriteManager);
  25284. /**
  25285. * Returns the string "Sprite"
  25286. * @returns "Sprite"
  25287. */
  25288. getClassName(): string;
  25289. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  25290. get fromIndex(): number;
  25291. set fromIndex(value: number);
  25292. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  25293. get toIndex(): number;
  25294. set toIndex(value: number);
  25295. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  25296. get loopAnimation(): boolean;
  25297. set loopAnimation(value: boolean);
  25298. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  25299. get delay(): number;
  25300. set delay(value: number);
  25301. /**
  25302. * Starts an animation
  25303. * @param from defines the initial key
  25304. * @param to defines the end key
  25305. * @param loop defines if the animation must loop
  25306. * @param delay defines the start delay (in ms)
  25307. * @param onAnimationEnd defines a callback to call when animation ends
  25308. */
  25309. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  25310. private _endAnimation;
  25311. /** Release associated resources */
  25312. dispose(): void;
  25313. /**
  25314. * Serializes the sprite to a JSON object
  25315. * @returns the JSON object
  25316. */
  25317. serialize(): any;
  25318. /**
  25319. * Parses a JSON object to create a new sprite
  25320. * @param parsedSprite The JSON object to parse
  25321. * @param manager defines the hosting manager
  25322. * @returns the new sprite
  25323. */
  25324. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  25325. }
  25326. }
  25327. declare module "babylonjs/Collisions/pickingInfo" {
  25328. import { Nullable } from "babylonjs/types";
  25329. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  25330. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25331. import { Sprite } from "babylonjs/Sprites/sprite";
  25332. import { Ray } from "babylonjs/Culling/ray";
  25333. /**
  25334. * Information about the result of picking within a scene
  25335. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  25336. */
  25337. export class PickingInfo {
  25338. /** @hidden */
  25339. _pickingUnavailable: boolean;
  25340. /**
  25341. * If the pick collided with an object
  25342. */
  25343. hit: boolean;
  25344. /**
  25345. * Distance away where the pick collided
  25346. */
  25347. distance: number;
  25348. /**
  25349. * The location of pick collision
  25350. */
  25351. pickedPoint: Nullable<Vector3>;
  25352. /**
  25353. * The mesh corresponding the the pick collision
  25354. */
  25355. pickedMesh: Nullable<AbstractMesh>;
  25356. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  25357. bu: number;
  25358. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  25359. bv: number;
  25360. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  25361. faceId: number;
  25362. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  25363. subMeshFaceId: number;
  25364. /** Id of the the submesh that was picked */
  25365. subMeshId: number;
  25366. /** If a sprite was picked, this will be the sprite the pick collided with */
  25367. pickedSprite: Nullable<Sprite>;
  25368. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  25369. thinInstanceIndex: number;
  25370. /**
  25371. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  25372. */
  25373. originMesh: Nullable<AbstractMesh>;
  25374. /**
  25375. * The ray that was used to perform the picking.
  25376. */
  25377. ray: Nullable<Ray>;
  25378. /**
  25379. * Gets the normal correspodning to the face the pick collided with
  25380. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  25381. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  25382. * @returns The normal correspodning to the face the pick collided with
  25383. */
  25384. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  25385. /**
  25386. * Gets the texture coordinates of where the pick occured
  25387. * @returns the vector containing the coordnates of the texture
  25388. */
  25389. getTextureCoordinates(): Nullable<Vector2>;
  25390. }
  25391. }
  25392. declare module "babylonjs/Events/pointerEvents" {
  25393. import { Nullable } from "babylonjs/types";
  25394. import { Vector2 } from "babylonjs/Maths/math.vector";
  25395. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  25396. import { Ray } from "babylonjs/Culling/ray";
  25397. /**
  25398. * Gather the list of pointer event types as constants.
  25399. */
  25400. export class PointerEventTypes {
  25401. /**
  25402. * 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.
  25403. */
  25404. static readonly POINTERDOWN: number;
  25405. /**
  25406. * The pointerup event is fired when a pointer is no longer active.
  25407. */
  25408. static readonly POINTERUP: number;
  25409. /**
  25410. * The pointermove event is fired when a pointer changes coordinates.
  25411. */
  25412. static readonly POINTERMOVE: number;
  25413. /**
  25414. * The pointerwheel event is fired when a mouse wheel has been rotated.
  25415. */
  25416. static readonly POINTERWHEEL: number;
  25417. /**
  25418. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  25419. */
  25420. static readonly POINTERPICK: number;
  25421. /**
  25422. * The pointertap event is fired when a the object has been touched and released without drag.
  25423. */
  25424. static readonly POINTERTAP: number;
  25425. /**
  25426. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  25427. */
  25428. static readonly POINTERDOUBLETAP: number;
  25429. }
  25430. /**
  25431. * Base class of pointer info types.
  25432. */
  25433. export class PointerInfoBase {
  25434. /**
  25435. * Defines the type of event (PointerEventTypes)
  25436. */
  25437. type: number;
  25438. /**
  25439. * Defines the related dom event
  25440. */
  25441. event: PointerEvent | MouseWheelEvent;
  25442. /**
  25443. * Instantiates the base class of pointers info.
  25444. * @param type Defines the type of event (PointerEventTypes)
  25445. * @param event Defines the related dom event
  25446. */
  25447. constructor(
  25448. /**
  25449. * Defines the type of event (PointerEventTypes)
  25450. */
  25451. type: number,
  25452. /**
  25453. * Defines the related dom event
  25454. */
  25455. event: PointerEvent | MouseWheelEvent);
  25456. }
  25457. /**
  25458. * This class is used to store pointer related info for the onPrePointerObservable event.
  25459. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  25460. */
  25461. export class PointerInfoPre extends PointerInfoBase {
  25462. /**
  25463. * Ray from a pointer if availible (eg. 6dof controller)
  25464. */
  25465. ray: Nullable<Ray>;
  25466. /**
  25467. * Defines the local position of the pointer on the canvas.
  25468. */
  25469. localPosition: Vector2;
  25470. /**
  25471. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  25472. */
  25473. skipOnPointerObservable: boolean;
  25474. /**
  25475. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  25476. * @param type Defines the type of event (PointerEventTypes)
  25477. * @param event Defines the related dom event
  25478. * @param localX Defines the local x coordinates of the pointer when the event occured
  25479. * @param localY Defines the local y coordinates of the pointer when the event occured
  25480. */
  25481. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  25482. }
  25483. /**
  25484. * This type contains all the data related to a pointer event in Babylon.js.
  25485. * 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.
  25486. */
  25487. export class PointerInfo extends PointerInfoBase {
  25488. /**
  25489. * Defines the picking info associated to the info (if any)\
  25490. */
  25491. pickInfo: Nullable<PickingInfo>;
  25492. /**
  25493. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  25494. * @param type Defines the type of event (PointerEventTypes)
  25495. * @param event Defines the related dom event
  25496. * @param pickInfo Defines the picking info associated to the info (if any)\
  25497. */
  25498. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  25499. /**
  25500. * Defines the picking info associated to the info (if any)\
  25501. */
  25502. pickInfo: Nullable<PickingInfo>);
  25503. }
  25504. /**
  25505. * Data relating to a touch event on the screen.
  25506. */
  25507. export interface PointerTouch {
  25508. /**
  25509. * X coordinate of touch.
  25510. */
  25511. x: number;
  25512. /**
  25513. * Y coordinate of touch.
  25514. */
  25515. y: number;
  25516. /**
  25517. * Id of touch. Unique for each finger.
  25518. */
  25519. pointerId: number;
  25520. /**
  25521. * Event type passed from DOM.
  25522. */
  25523. type: any;
  25524. }
  25525. }
  25526. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  25527. import { Observable } from "babylonjs/Misc/observable";
  25528. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  25529. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25530. /**
  25531. * Manage the mouse inputs to control the movement of a free camera.
  25532. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25533. */
  25534. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  25535. /**
  25536. * Define if touch is enabled in the mouse input
  25537. */
  25538. touchEnabled: boolean;
  25539. /**
  25540. * Defines the camera the input is attached to.
  25541. */
  25542. camera: FreeCamera;
  25543. /**
  25544. * Defines the buttons associated with the input to handle camera move.
  25545. */
  25546. buttons: number[];
  25547. /**
  25548. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  25549. */
  25550. angularSensibility: number;
  25551. private _pointerInput;
  25552. private _onMouseMove;
  25553. private _observer;
  25554. private previousPosition;
  25555. /**
  25556. * Observable for when a pointer move event occurs containing the move offset
  25557. */
  25558. onPointerMovedObservable: Observable<{
  25559. offsetX: number;
  25560. offsetY: number;
  25561. }>;
  25562. /**
  25563. * @hidden
  25564. * If the camera should be rotated automatically based on pointer movement
  25565. */
  25566. _allowCameraRotation: boolean;
  25567. /**
  25568. * Manage the mouse inputs to control the movement of a free camera.
  25569. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25570. * @param touchEnabled Defines if touch is enabled or not
  25571. */
  25572. constructor(
  25573. /**
  25574. * Define if touch is enabled in the mouse input
  25575. */
  25576. touchEnabled?: boolean);
  25577. /**
  25578. * Attach the input controls to a specific dom element to get the input from.
  25579. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25580. */
  25581. attachControl(noPreventDefault?: boolean): void;
  25582. /**
  25583. * Called on JS contextmenu event.
  25584. * Override this method to provide functionality.
  25585. */
  25586. protected onContextMenu(evt: PointerEvent): void;
  25587. /**
  25588. * Detach the current controls from the specified dom element.
  25589. */
  25590. detachControl(): void;
  25591. /**
  25592. * Gets the class name of the current intput.
  25593. * @returns the class name
  25594. */
  25595. getClassName(): string;
  25596. /**
  25597. * Get the friendly name associated with the input class.
  25598. * @returns the input friendly name
  25599. */
  25600. getSimpleName(): string;
  25601. }
  25602. }
  25603. declare module "babylonjs/Cameras/Inputs/BaseCameraMouseWheelInput" {
  25604. import { Observable } from "babylonjs/Misc/observable";
  25605. import { Camera } from "babylonjs/Cameras/camera";
  25606. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  25607. /**
  25608. * Base class for mouse wheel input..
  25609. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  25610. * for example usage.
  25611. */
  25612. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  25613. /**
  25614. * Defines the camera the input is attached to.
  25615. */
  25616. abstract camera: Camera;
  25617. /**
  25618. * How fast is the camera moves in relation to X axis mouseWheel events.
  25619. * Use negative value to reverse direction.
  25620. */
  25621. wheelPrecisionX: number;
  25622. /**
  25623. * How fast is the camera moves in relation to Y axis mouseWheel events.
  25624. * Use negative value to reverse direction.
  25625. */
  25626. wheelPrecisionY: number;
  25627. /**
  25628. * How fast is the camera moves in relation to Z axis mouseWheel events.
  25629. * Use negative value to reverse direction.
  25630. */
  25631. wheelPrecisionZ: number;
  25632. /**
  25633. * Observable for when a mouse wheel move event occurs.
  25634. */
  25635. onChangedObservable: Observable<{
  25636. wheelDeltaX: number;
  25637. wheelDeltaY: number;
  25638. wheelDeltaZ: number;
  25639. }>;
  25640. private _wheel;
  25641. private _observer;
  25642. /**
  25643. * Attach the input controls to a specific dom element to get the input from.
  25644. * @param noPreventDefault Defines whether event caught by the controls
  25645. * should call preventdefault().
  25646. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25647. */
  25648. attachControl(noPreventDefault?: boolean): void;
  25649. /**
  25650. * Detach the current controls from the specified dom element.
  25651. */
  25652. detachControl(): void;
  25653. /**
  25654. * Called for each rendered frame.
  25655. */
  25656. checkInputs(): void;
  25657. /**
  25658. * Gets the class name of the current intput.
  25659. * @returns the class name
  25660. */
  25661. getClassName(): string;
  25662. /**
  25663. * Get the friendly name associated with the input class.
  25664. * @returns the input friendly name
  25665. */
  25666. getSimpleName(): string;
  25667. /**
  25668. * Incremental value of multiple mouse wheel movements of the X axis.
  25669. * Should be zero-ed when read.
  25670. */
  25671. protected _wheelDeltaX: number;
  25672. /**
  25673. * Incremental value of multiple mouse wheel movements of the Y axis.
  25674. * Should be zero-ed when read.
  25675. */
  25676. protected _wheelDeltaY: number;
  25677. /**
  25678. * Incremental value of multiple mouse wheel movements of the Z axis.
  25679. * Should be zero-ed when read.
  25680. */
  25681. protected _wheelDeltaZ: number;
  25682. /**
  25683. * Firefox uses a different scheme to report scroll distances to other
  25684. * browsers. Rather than use complicated methods to calculate the exact
  25685. * multiple we need to apply, let's just cheat and use a constant.
  25686. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  25687. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  25688. */
  25689. private readonly _ffMultiplier;
  25690. /**
  25691. * Different event attributes for wheel data fall into a few set ranges.
  25692. * Some relevant but dated date here:
  25693. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  25694. */
  25695. private readonly _normalize;
  25696. }
  25697. }
  25698. declare module "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput" {
  25699. import { Nullable } from "babylonjs/types";
  25700. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25701. import { BaseCameraMouseWheelInput } from "babylonjs/Cameras/Inputs/BaseCameraMouseWheelInput";
  25702. import { Coordinate } from "babylonjs/Maths/math.axis";
  25703. /**
  25704. * Manage the mouse wheel inputs to control a free camera.
  25705. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25706. */
  25707. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  25708. /**
  25709. * Defines the camera the input is attached to.
  25710. */
  25711. camera: FreeCamera;
  25712. /**
  25713. * Gets the class name of the current input.
  25714. * @returns the class name
  25715. */
  25716. getClassName(): string;
  25717. /**
  25718. * Set which movement axis (relative to camera's orientation) the mouse
  25719. * wheel's X axis controls.
  25720. * @param axis The axis to be moved. Set null to clear.
  25721. */
  25722. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  25723. /**
  25724. * Get the configured movement axis (relative to camera's orientation) the
  25725. * mouse wheel's X axis controls.
  25726. * @returns The configured axis or null if none.
  25727. */
  25728. get wheelXMoveRelative(): Nullable<Coordinate>;
  25729. /**
  25730. * Set which movement axis (relative to camera's orientation) the mouse
  25731. * wheel's Y axis controls.
  25732. * @param axis The axis to be moved. Set null to clear.
  25733. */
  25734. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  25735. /**
  25736. * Get the configured movement axis (relative to camera's orientation) the
  25737. * mouse wheel's Y axis controls.
  25738. * @returns The configured axis or null if none.
  25739. */
  25740. get wheelYMoveRelative(): Nullable<Coordinate>;
  25741. /**
  25742. * Set which movement axis (relative to camera's orientation) the mouse
  25743. * wheel's Z axis controls.
  25744. * @param axis The axis to be moved. Set null to clear.
  25745. */
  25746. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  25747. /**
  25748. * Get the configured movement axis (relative to camera's orientation) the
  25749. * mouse wheel's Z axis controls.
  25750. * @returns The configured axis or null if none.
  25751. */
  25752. get wheelZMoveRelative(): Nullable<Coordinate>;
  25753. /**
  25754. * Set which rotation axis (relative to camera's orientation) the mouse
  25755. * wheel's X axis controls.
  25756. * @param axis The axis to be moved. Set null to clear.
  25757. */
  25758. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  25759. /**
  25760. * Get the configured rotation axis (relative to camera's orientation) the
  25761. * mouse wheel's X axis controls.
  25762. * @returns The configured axis or null if none.
  25763. */
  25764. get wheelXRotateRelative(): Nullable<Coordinate>;
  25765. /**
  25766. * Set which rotation axis (relative to camera's orientation) the mouse
  25767. * wheel's Y axis controls.
  25768. * @param axis The axis to be moved. Set null to clear.
  25769. */
  25770. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  25771. /**
  25772. * Get the configured rotation axis (relative to camera's orientation) the
  25773. * mouse wheel's Y axis controls.
  25774. * @returns The configured axis or null if none.
  25775. */
  25776. get wheelYRotateRelative(): Nullable<Coordinate>;
  25777. /**
  25778. * Set which rotation axis (relative to camera's orientation) the mouse
  25779. * wheel's Z axis controls.
  25780. * @param axis The axis to be moved. Set null to clear.
  25781. */
  25782. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  25783. /**
  25784. * Get the configured rotation axis (relative to camera's orientation) the
  25785. * mouse wheel's Z axis controls.
  25786. * @returns The configured axis or null if none.
  25787. */
  25788. get wheelZRotateRelative(): Nullable<Coordinate>;
  25789. /**
  25790. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  25791. * controls.
  25792. * @param axis The axis to be moved. Set null to clear.
  25793. */
  25794. set wheelXMoveScene(axis: Nullable<Coordinate>);
  25795. /**
  25796. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25797. * X axis controls.
  25798. * @returns The configured axis or null if none.
  25799. */
  25800. get wheelXMoveScene(): Nullable<Coordinate>;
  25801. /**
  25802. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  25803. * controls.
  25804. * @param axis The axis to be moved. Set null to clear.
  25805. */
  25806. set wheelYMoveScene(axis: Nullable<Coordinate>);
  25807. /**
  25808. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25809. * Y axis controls.
  25810. * @returns The configured axis or null if none.
  25811. */
  25812. get wheelYMoveScene(): Nullable<Coordinate>;
  25813. /**
  25814. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  25815. * controls.
  25816. * @param axis The axis to be moved. Set null to clear.
  25817. */
  25818. set wheelZMoveScene(axis: Nullable<Coordinate>);
  25819. /**
  25820. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25821. * Z axis controls.
  25822. * @returns The configured axis or null if none.
  25823. */
  25824. get wheelZMoveScene(): Nullable<Coordinate>;
  25825. /**
  25826. * Called for each rendered frame.
  25827. */
  25828. checkInputs(): void;
  25829. private _moveRelative;
  25830. private _rotateRelative;
  25831. private _moveScene;
  25832. /**
  25833. * These are set to the desired default behaviour.
  25834. */
  25835. private _wheelXAction;
  25836. private _wheelXActionCoordinate;
  25837. private _wheelYAction;
  25838. private _wheelYActionCoordinate;
  25839. private _wheelZAction;
  25840. private _wheelZActionCoordinate;
  25841. /**
  25842. * Update the camera according to any configured properties for the 3
  25843. * mouse-wheel axis.
  25844. */
  25845. private _updateCamera;
  25846. }
  25847. }
  25848. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  25849. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  25850. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25851. /**
  25852. * Manage the touch inputs to control the movement of a free camera.
  25853. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25854. */
  25855. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  25856. /**
  25857. * Define if mouse events can be treated as touch events
  25858. */
  25859. allowMouse: boolean;
  25860. /**
  25861. * Defines the camera the input is attached to.
  25862. */
  25863. camera: FreeCamera;
  25864. /**
  25865. * Defines the touch sensibility for rotation.
  25866. * The higher the faster.
  25867. */
  25868. touchAngularSensibility: number;
  25869. /**
  25870. * Defines the touch sensibility for move.
  25871. * The higher the faster.
  25872. */
  25873. touchMoveSensibility: number;
  25874. private _offsetX;
  25875. private _offsetY;
  25876. private _pointerPressed;
  25877. private _pointerInput?;
  25878. private _observer;
  25879. private _onLostFocus;
  25880. /**
  25881. * Manage the touch inputs to control the movement of a free camera.
  25882. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25883. * @param allowMouse Defines if mouse events can be treated as touch events
  25884. */
  25885. constructor(
  25886. /**
  25887. * Define if mouse events can be treated as touch events
  25888. */
  25889. allowMouse?: boolean);
  25890. /**
  25891. * Attach the input controls to a specific dom element to get the input from.
  25892. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25893. */
  25894. attachControl(noPreventDefault?: boolean): void;
  25895. /**
  25896. * Detach the current controls from the specified dom element.
  25897. */
  25898. detachControl(): void;
  25899. /**
  25900. * Update the current camera state depending on the inputs that have been used this frame.
  25901. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  25902. */
  25903. checkInputs(): void;
  25904. /**
  25905. * Gets the class name of the current intput.
  25906. * @returns the class name
  25907. */
  25908. getClassName(): string;
  25909. /**
  25910. * Get the friendly name associated with the input class.
  25911. * @returns the input friendly name
  25912. */
  25913. getSimpleName(): string;
  25914. }
  25915. }
  25916. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  25917. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25918. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25919. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  25920. import { FreeCameraMouseWheelInput } from "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput";
  25921. import { Nullable } from "babylonjs/types";
  25922. /**
  25923. * Default Inputs manager for the FreeCamera.
  25924. * It groups all the default supported inputs for ease of use.
  25925. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25926. */
  25927. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  25928. /**
  25929. * @hidden
  25930. */
  25931. _mouseInput: Nullable<FreeCameraMouseInput>;
  25932. /**
  25933. * @hidden
  25934. */
  25935. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  25936. /**
  25937. * Instantiates a new FreeCameraInputsManager.
  25938. * @param camera Defines the camera the inputs belong to
  25939. */
  25940. constructor(camera: FreeCamera);
  25941. /**
  25942. * Add keyboard input support to the input manager.
  25943. * @returns the current input manager
  25944. */
  25945. addKeyboard(): FreeCameraInputsManager;
  25946. /**
  25947. * Add mouse input support to the input manager.
  25948. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  25949. * @returns the current input manager
  25950. */
  25951. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  25952. /**
  25953. * Removes the mouse input support from the manager
  25954. * @returns the current input manager
  25955. */
  25956. removeMouse(): FreeCameraInputsManager;
  25957. /**
  25958. * Add mouse wheel input support to the input manager.
  25959. * @returns the current input manager
  25960. */
  25961. addMouseWheel(): FreeCameraInputsManager;
  25962. /**
  25963. * Removes the mouse wheel input support from the manager
  25964. * @returns the current input manager
  25965. */
  25966. removeMouseWheel(): FreeCameraInputsManager;
  25967. /**
  25968. * Add touch input support to the input manager.
  25969. * @returns the current input manager
  25970. */
  25971. addTouch(): FreeCameraInputsManager;
  25972. /**
  25973. * Remove all attached input methods from a camera
  25974. */
  25975. clear(): void;
  25976. }
  25977. }
  25978. declare module "babylonjs/Cameras/freeCamera" {
  25979. import { Vector3 } from "babylonjs/Maths/math.vector";
  25980. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25981. import { Scene } from "babylonjs/scene";
  25982. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  25983. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  25984. /**
  25985. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25986. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  25987. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25988. */
  25989. export class FreeCamera extends TargetCamera {
  25990. /**
  25991. * Define the collision ellipsoid of the camera.
  25992. * This is helpful to simulate a camera body like the player body around the camera
  25993. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  25994. */
  25995. ellipsoid: Vector3;
  25996. /**
  25997. * Define an offset for the position of the ellipsoid around the camera.
  25998. * This can be helpful to determine the center of the body near the gravity center of the body
  25999. * instead of its head.
  26000. */
  26001. ellipsoidOffset: Vector3;
  26002. /**
  26003. * Enable or disable collisions of the camera with the rest of the scene objects.
  26004. */
  26005. checkCollisions: boolean;
  26006. /**
  26007. * Enable or disable gravity on the camera.
  26008. */
  26009. applyGravity: boolean;
  26010. /**
  26011. * Define the input manager associated to the camera.
  26012. */
  26013. inputs: FreeCameraInputsManager;
  26014. /**
  26015. * Gets the input sensibility for a mouse input. (default is 2000.0)
  26016. * Higher values reduce sensitivity.
  26017. */
  26018. get angularSensibility(): number;
  26019. /**
  26020. * Sets the input sensibility for a mouse input. (default is 2000.0)
  26021. * Higher values reduce sensitivity.
  26022. */
  26023. set angularSensibility(value: number);
  26024. /**
  26025. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  26026. */
  26027. get keysUp(): number[];
  26028. set keysUp(value: number[]);
  26029. /**
  26030. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  26031. */
  26032. get keysUpward(): number[];
  26033. set keysUpward(value: number[]);
  26034. /**
  26035. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  26036. */
  26037. get keysDown(): number[];
  26038. set keysDown(value: number[]);
  26039. /**
  26040. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  26041. */
  26042. get keysDownward(): number[];
  26043. set keysDownward(value: number[]);
  26044. /**
  26045. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  26046. */
  26047. get keysLeft(): number[];
  26048. set keysLeft(value: number[]);
  26049. /**
  26050. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  26051. */
  26052. get keysRight(): number[];
  26053. set keysRight(value: number[]);
  26054. /**
  26055. * Event raised when the camera collide with a mesh in the scene.
  26056. */
  26057. onCollide: (collidedMesh: AbstractMesh) => void;
  26058. private _collider;
  26059. private _needMoveForGravity;
  26060. private _oldPosition;
  26061. private _diffPosition;
  26062. private _newPosition;
  26063. /** @hidden */
  26064. _localDirection: Vector3;
  26065. /** @hidden */
  26066. _transformedDirection: Vector3;
  26067. /**
  26068. * Instantiates a Free Camera.
  26069. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  26070. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  26071. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  26072. * @param name Define the name of the camera in the scene
  26073. * @param position Define the start position of the camera in the scene
  26074. * @param scene Define the scene the camera belongs to
  26075. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  26076. */
  26077. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26078. /**
  26079. * Attach the input controls to a specific dom element to get the input from.
  26080. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26081. */
  26082. attachControl(noPreventDefault?: boolean): void;
  26083. /**
  26084. * Attach the input controls to a specific dom element to get the input from.
  26085. * @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
  26086. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26087. * BACK COMPAT SIGNATURE ONLY.
  26088. */
  26089. attachControl(ignored: any, noPreventDefault?: boolean): void;
  26090. /**
  26091. * Detach the current controls from the specified dom element.
  26092. */
  26093. detachControl(): void;
  26094. /**
  26095. * Detach the current controls from the specified dom element.
  26096. * @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
  26097. */
  26098. detachControl(ignored: any): void;
  26099. private _collisionMask;
  26100. /**
  26101. * Define a collision mask to limit the list of object the camera can collide with
  26102. */
  26103. get collisionMask(): number;
  26104. set collisionMask(mask: number);
  26105. /** @hidden */
  26106. _collideWithWorld(displacement: Vector3): void;
  26107. private _onCollisionPositionChange;
  26108. /** @hidden */
  26109. _checkInputs(): void;
  26110. /** @hidden */
  26111. _decideIfNeedsToMove(): boolean;
  26112. /** @hidden */
  26113. _updatePosition(): void;
  26114. /**
  26115. * Destroy the camera and release the current resources hold by it.
  26116. */
  26117. dispose(): void;
  26118. /**
  26119. * Gets the current object class name.
  26120. * @return the class name
  26121. */
  26122. getClassName(): string;
  26123. }
  26124. }
  26125. declare module "babylonjs/Gamepads/gamepad" {
  26126. import { Observable } from "babylonjs/Misc/observable";
  26127. /**
  26128. * Represents a gamepad control stick position
  26129. */
  26130. export class StickValues {
  26131. /**
  26132. * The x component of the control stick
  26133. */
  26134. x: number;
  26135. /**
  26136. * The y component of the control stick
  26137. */
  26138. y: number;
  26139. /**
  26140. * Initializes the gamepad x and y control stick values
  26141. * @param x The x component of the gamepad control stick value
  26142. * @param y The y component of the gamepad control stick value
  26143. */
  26144. constructor(
  26145. /**
  26146. * The x component of the control stick
  26147. */
  26148. x: number,
  26149. /**
  26150. * The y component of the control stick
  26151. */
  26152. y: number);
  26153. }
  26154. /**
  26155. * An interface which manages callbacks for gamepad button changes
  26156. */
  26157. export interface GamepadButtonChanges {
  26158. /**
  26159. * Called when a gamepad has been changed
  26160. */
  26161. changed: boolean;
  26162. /**
  26163. * Called when a gamepad press event has been triggered
  26164. */
  26165. pressChanged: boolean;
  26166. /**
  26167. * Called when a touch event has been triggered
  26168. */
  26169. touchChanged: boolean;
  26170. /**
  26171. * Called when a value has changed
  26172. */
  26173. valueChanged: boolean;
  26174. }
  26175. /**
  26176. * Represents a gamepad
  26177. */
  26178. export class Gamepad {
  26179. /**
  26180. * The id of the gamepad
  26181. */
  26182. id: string;
  26183. /**
  26184. * The index of the gamepad
  26185. */
  26186. index: number;
  26187. /**
  26188. * The browser gamepad
  26189. */
  26190. browserGamepad: any;
  26191. /**
  26192. * Specifies what type of gamepad this represents
  26193. */
  26194. type: number;
  26195. private _leftStick;
  26196. private _rightStick;
  26197. /** @hidden */
  26198. _isConnected: boolean;
  26199. private _leftStickAxisX;
  26200. private _leftStickAxisY;
  26201. private _rightStickAxisX;
  26202. private _rightStickAxisY;
  26203. /**
  26204. * Triggered when the left control stick has been changed
  26205. */
  26206. private _onleftstickchanged;
  26207. /**
  26208. * Triggered when the right control stick has been changed
  26209. */
  26210. private _onrightstickchanged;
  26211. /**
  26212. * Represents a gamepad controller
  26213. */
  26214. static GAMEPAD: number;
  26215. /**
  26216. * Represents a generic controller
  26217. */
  26218. static GENERIC: number;
  26219. /**
  26220. * Represents an XBox controller
  26221. */
  26222. static XBOX: number;
  26223. /**
  26224. * Represents a pose-enabled controller
  26225. */
  26226. static POSE_ENABLED: number;
  26227. /**
  26228. * Represents an Dual Shock controller
  26229. */
  26230. static DUALSHOCK: number;
  26231. /**
  26232. * Specifies whether the left control stick should be Y-inverted
  26233. */
  26234. protected _invertLeftStickY: boolean;
  26235. /**
  26236. * Specifies if the gamepad has been connected
  26237. */
  26238. get isConnected(): boolean;
  26239. /**
  26240. * Initializes the gamepad
  26241. * @param id The id of the gamepad
  26242. * @param index The index of the gamepad
  26243. * @param browserGamepad The browser gamepad
  26244. * @param leftStickX The x component of the left joystick
  26245. * @param leftStickY The y component of the left joystick
  26246. * @param rightStickX The x component of the right joystick
  26247. * @param rightStickY The y component of the right joystick
  26248. */
  26249. constructor(
  26250. /**
  26251. * The id of the gamepad
  26252. */
  26253. id: string,
  26254. /**
  26255. * The index of the gamepad
  26256. */
  26257. index: number,
  26258. /**
  26259. * The browser gamepad
  26260. */
  26261. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  26262. /**
  26263. * Callback triggered when the left joystick has changed
  26264. * @param callback
  26265. */
  26266. onleftstickchanged(callback: (values: StickValues) => void): void;
  26267. /**
  26268. * Callback triggered when the right joystick has changed
  26269. * @param callback
  26270. */
  26271. onrightstickchanged(callback: (values: StickValues) => void): void;
  26272. /**
  26273. * Gets the left joystick
  26274. */
  26275. get leftStick(): StickValues;
  26276. /**
  26277. * Sets the left joystick values
  26278. */
  26279. set leftStick(newValues: StickValues);
  26280. /**
  26281. * Gets the right joystick
  26282. */
  26283. get rightStick(): StickValues;
  26284. /**
  26285. * Sets the right joystick value
  26286. */
  26287. set rightStick(newValues: StickValues);
  26288. /**
  26289. * Updates the gamepad joystick positions
  26290. */
  26291. update(): void;
  26292. /**
  26293. * Disposes the gamepad
  26294. */
  26295. dispose(): void;
  26296. }
  26297. /**
  26298. * Represents a generic gamepad
  26299. */
  26300. export class GenericPad extends Gamepad {
  26301. private _buttons;
  26302. private _onbuttondown;
  26303. private _onbuttonup;
  26304. /**
  26305. * Observable triggered when a button has been pressed
  26306. */
  26307. onButtonDownObservable: Observable<number>;
  26308. /**
  26309. * Observable triggered when a button has been released
  26310. */
  26311. onButtonUpObservable: Observable<number>;
  26312. /**
  26313. * Callback triggered when a button has been pressed
  26314. * @param callback Called when a button has been pressed
  26315. */
  26316. onbuttondown(callback: (buttonPressed: number) => void): void;
  26317. /**
  26318. * Callback triggered when a button has been released
  26319. * @param callback Called when a button has been released
  26320. */
  26321. onbuttonup(callback: (buttonReleased: number) => void): void;
  26322. /**
  26323. * Initializes the generic gamepad
  26324. * @param id The id of the generic gamepad
  26325. * @param index The index of the generic gamepad
  26326. * @param browserGamepad The browser gamepad
  26327. */
  26328. constructor(id: string, index: number, browserGamepad: any);
  26329. private _setButtonValue;
  26330. /**
  26331. * Updates the generic gamepad
  26332. */
  26333. update(): void;
  26334. /**
  26335. * Disposes the generic gamepad
  26336. */
  26337. dispose(): void;
  26338. }
  26339. }
  26340. declare module "babylonjs/Animations/runtimeAnimation" {
  26341. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  26342. import { Animatable } from "babylonjs/Animations/animatable";
  26343. import { Scene } from "babylonjs/scene";
  26344. /**
  26345. * Defines a runtime animation
  26346. */
  26347. export class RuntimeAnimation {
  26348. private _events;
  26349. /**
  26350. * The current frame of the runtime animation
  26351. */
  26352. private _currentFrame;
  26353. /**
  26354. * The animation used by the runtime animation
  26355. */
  26356. private _animation;
  26357. /**
  26358. * The target of the runtime animation
  26359. */
  26360. private _target;
  26361. /**
  26362. * The initiating animatable
  26363. */
  26364. private _host;
  26365. /**
  26366. * The original value of the runtime animation
  26367. */
  26368. private _originalValue;
  26369. /**
  26370. * The original blend value of the runtime animation
  26371. */
  26372. private _originalBlendValue;
  26373. /**
  26374. * The offsets cache of the runtime animation
  26375. */
  26376. private _offsetsCache;
  26377. /**
  26378. * The high limits cache of the runtime animation
  26379. */
  26380. private _highLimitsCache;
  26381. /**
  26382. * Specifies if the runtime animation has been stopped
  26383. */
  26384. private _stopped;
  26385. /**
  26386. * The blending factor of the runtime animation
  26387. */
  26388. private _blendingFactor;
  26389. /**
  26390. * The BabylonJS scene
  26391. */
  26392. private _scene;
  26393. /**
  26394. * The current value of the runtime animation
  26395. */
  26396. private _currentValue;
  26397. /** @hidden */
  26398. _animationState: _IAnimationState;
  26399. /**
  26400. * The active target of the runtime animation
  26401. */
  26402. private _activeTargets;
  26403. private _currentActiveTarget;
  26404. private _directTarget;
  26405. /**
  26406. * The target path of the runtime animation
  26407. */
  26408. private _targetPath;
  26409. /**
  26410. * The weight of the runtime animation
  26411. */
  26412. private _weight;
  26413. /**
  26414. * The ratio offset of the runtime animation
  26415. */
  26416. private _ratioOffset;
  26417. /**
  26418. * The previous delay of the runtime animation
  26419. */
  26420. private _previousDelay;
  26421. /**
  26422. * The previous ratio of the runtime animation
  26423. */
  26424. private _previousRatio;
  26425. private _enableBlending;
  26426. private _keys;
  26427. private _minFrame;
  26428. private _maxFrame;
  26429. private _minValue;
  26430. private _maxValue;
  26431. private _targetIsArray;
  26432. /**
  26433. * Gets the current frame of the runtime animation
  26434. */
  26435. get currentFrame(): number;
  26436. /**
  26437. * Gets the weight of the runtime animation
  26438. */
  26439. get weight(): number;
  26440. /**
  26441. * Gets the current value of the runtime animation
  26442. */
  26443. get currentValue(): any;
  26444. /**
  26445. * Gets the target path of the runtime animation
  26446. */
  26447. get targetPath(): string;
  26448. /**
  26449. * Gets the actual target of the runtime animation
  26450. */
  26451. get target(): any;
  26452. /**
  26453. * Gets the additive state of the runtime animation
  26454. */
  26455. get isAdditive(): boolean;
  26456. /** @hidden */
  26457. _onLoop: () => void;
  26458. /**
  26459. * Create a new RuntimeAnimation object
  26460. * @param target defines the target of the animation
  26461. * @param animation defines the source animation object
  26462. * @param scene defines the hosting scene
  26463. * @param host defines the initiating Animatable
  26464. */
  26465. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  26466. private _preparePath;
  26467. /**
  26468. * Gets the animation from the runtime animation
  26469. */
  26470. get animation(): Animation;
  26471. /**
  26472. * Resets the runtime animation to the beginning
  26473. * @param restoreOriginal defines whether to restore the target property to the original value
  26474. */
  26475. reset(restoreOriginal?: boolean): void;
  26476. /**
  26477. * Specifies if the runtime animation is stopped
  26478. * @returns Boolean specifying if the runtime animation is stopped
  26479. */
  26480. isStopped(): boolean;
  26481. /**
  26482. * Disposes of the runtime animation
  26483. */
  26484. dispose(): void;
  26485. /**
  26486. * Apply the interpolated value to the target
  26487. * @param currentValue defines the value computed by the animation
  26488. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  26489. */
  26490. setValue(currentValue: any, weight: number): void;
  26491. private _getOriginalValues;
  26492. private _setValue;
  26493. /**
  26494. * Gets the loop pmode of the runtime animation
  26495. * @returns Loop Mode
  26496. */
  26497. private _getCorrectLoopMode;
  26498. /**
  26499. * Move the current animation to a given frame
  26500. * @param frame defines the frame to move to
  26501. */
  26502. goToFrame(frame: number): void;
  26503. /**
  26504. * @hidden Internal use only
  26505. */
  26506. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  26507. /**
  26508. * Execute the current animation
  26509. * @param delay defines the delay to add to the current frame
  26510. * @param from defines the lower bound of the animation range
  26511. * @param to defines the upper bound of the animation range
  26512. * @param loop defines if the current animation must loop
  26513. * @param speedRatio defines the current speed ratio
  26514. * @param weight defines the weight of the animation (default is -1 so no weight)
  26515. * @param onLoop optional callback called when animation loops
  26516. * @returns a boolean indicating if the animation is running
  26517. */
  26518. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  26519. }
  26520. }
  26521. declare module "babylonjs/Animations/animatable" {
  26522. import { Animation } from "babylonjs/Animations/animation";
  26523. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  26524. import { Nullable } from "babylonjs/types";
  26525. import { Observable } from "babylonjs/Misc/observable";
  26526. import { Scene } from "babylonjs/scene";
  26527. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  26528. import { Node } from "babylonjs/node";
  26529. /**
  26530. * Class used to store an actual running animation
  26531. */
  26532. export class Animatable {
  26533. /** defines the target object */
  26534. target: any;
  26535. /** defines the starting frame number (default is 0) */
  26536. fromFrame: number;
  26537. /** defines the ending frame number (default is 100) */
  26538. toFrame: number;
  26539. /** defines if the animation must loop (default is false) */
  26540. loopAnimation: boolean;
  26541. /** defines a callback to call when animation ends if it is not looping */
  26542. onAnimationEnd?: (() => void) | null | undefined;
  26543. /** defines a callback to call when animation loops */
  26544. onAnimationLoop?: (() => void) | null | undefined;
  26545. /** defines whether the animation should be evaluated additively */
  26546. isAdditive: boolean;
  26547. private _localDelayOffset;
  26548. private _pausedDelay;
  26549. private _runtimeAnimations;
  26550. private _paused;
  26551. private _scene;
  26552. private _speedRatio;
  26553. private _weight;
  26554. private _syncRoot;
  26555. /**
  26556. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  26557. * This will only apply for non looping animation (default is true)
  26558. */
  26559. disposeOnEnd: boolean;
  26560. /**
  26561. * Gets a boolean indicating if the animation has started
  26562. */
  26563. animationStarted: boolean;
  26564. /**
  26565. * Observer raised when the animation ends
  26566. */
  26567. onAnimationEndObservable: Observable<Animatable>;
  26568. /**
  26569. * Observer raised when the animation loops
  26570. */
  26571. onAnimationLoopObservable: Observable<Animatable>;
  26572. /**
  26573. * Gets the root Animatable used to synchronize and normalize animations
  26574. */
  26575. get syncRoot(): Nullable<Animatable>;
  26576. /**
  26577. * Gets the current frame of the first RuntimeAnimation
  26578. * Used to synchronize Animatables
  26579. */
  26580. get masterFrame(): number;
  26581. /**
  26582. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  26583. */
  26584. get weight(): number;
  26585. set weight(value: number);
  26586. /**
  26587. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  26588. */
  26589. get speedRatio(): number;
  26590. set speedRatio(value: number);
  26591. /**
  26592. * Creates a new Animatable
  26593. * @param scene defines the hosting scene
  26594. * @param target defines the target object
  26595. * @param fromFrame defines the starting frame number (default is 0)
  26596. * @param toFrame defines the ending frame number (default is 100)
  26597. * @param loopAnimation defines if the animation must loop (default is false)
  26598. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  26599. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  26600. * @param animations defines a group of animation to add to the new Animatable
  26601. * @param onAnimationLoop defines a callback to call when animation loops
  26602. * @param isAdditive defines whether the animation should be evaluated additively
  26603. */
  26604. constructor(scene: Scene,
  26605. /** defines the target object */
  26606. target: any,
  26607. /** defines the starting frame number (default is 0) */
  26608. fromFrame?: number,
  26609. /** defines the ending frame number (default is 100) */
  26610. toFrame?: number,
  26611. /** defines if the animation must loop (default is false) */
  26612. loopAnimation?: boolean, speedRatio?: number,
  26613. /** defines a callback to call when animation ends if it is not looping */
  26614. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  26615. /** defines a callback to call when animation loops */
  26616. onAnimationLoop?: (() => void) | null | undefined,
  26617. /** defines whether the animation should be evaluated additively */
  26618. isAdditive?: boolean);
  26619. /**
  26620. * Synchronize and normalize current Animatable with a source Animatable
  26621. * This is useful when using animation weights and when animations are not of the same length
  26622. * @param root defines the root Animatable to synchronize with
  26623. * @returns the current Animatable
  26624. */
  26625. syncWith(root: Animatable): Animatable;
  26626. /**
  26627. * Gets the list of runtime animations
  26628. * @returns an array of RuntimeAnimation
  26629. */
  26630. getAnimations(): RuntimeAnimation[];
  26631. /**
  26632. * Adds more animations to the current animatable
  26633. * @param target defines the target of the animations
  26634. * @param animations defines the new animations to add
  26635. */
  26636. appendAnimations(target: any, animations: Animation[]): void;
  26637. /**
  26638. * Gets the source animation for a specific property
  26639. * @param property defines the propertyu to look for
  26640. * @returns null or the source animation for the given property
  26641. */
  26642. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  26643. /**
  26644. * Gets the runtime animation for a specific property
  26645. * @param property defines the propertyu to look for
  26646. * @returns null or the runtime animation for the given property
  26647. */
  26648. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  26649. /**
  26650. * Resets the animatable to its original state
  26651. */
  26652. reset(): void;
  26653. /**
  26654. * Allows the animatable to blend with current running animations
  26655. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  26656. * @param blendingSpeed defines the blending speed to use
  26657. */
  26658. enableBlending(blendingSpeed: number): void;
  26659. /**
  26660. * Disable animation blending
  26661. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  26662. */
  26663. disableBlending(): void;
  26664. /**
  26665. * Jump directly to a given frame
  26666. * @param frame defines the frame to jump to
  26667. */
  26668. goToFrame(frame: number): void;
  26669. /**
  26670. * Pause the animation
  26671. */
  26672. pause(): void;
  26673. /**
  26674. * Restart the animation
  26675. */
  26676. restart(): void;
  26677. private _raiseOnAnimationEnd;
  26678. /**
  26679. * Stop and delete the current animation
  26680. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  26681. * @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)
  26682. */
  26683. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  26684. /**
  26685. * Wait asynchronously for the animation to end
  26686. * @returns a promise which will be fullfilled when the animation ends
  26687. */
  26688. waitAsync(): Promise<Animatable>;
  26689. /** @hidden */
  26690. _animate(delay: number): boolean;
  26691. }
  26692. module "babylonjs/scene" {
  26693. interface Scene {
  26694. /** @hidden */
  26695. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  26696. /** @hidden */
  26697. _processLateAnimationBindingsForMatrices(holder: {
  26698. totalWeight: number;
  26699. totalAdditiveWeight: number;
  26700. animations: RuntimeAnimation[];
  26701. additiveAnimations: RuntimeAnimation[];
  26702. originalValue: Matrix;
  26703. }): any;
  26704. /** @hidden */
  26705. _processLateAnimationBindingsForQuaternions(holder: {
  26706. totalWeight: number;
  26707. totalAdditiveWeight: number;
  26708. animations: RuntimeAnimation[];
  26709. additiveAnimations: RuntimeAnimation[];
  26710. originalValue: Quaternion;
  26711. }, refQuaternion: Quaternion): Quaternion;
  26712. /** @hidden */
  26713. _processLateAnimationBindings(): void;
  26714. /**
  26715. * Will start the animation sequence of a given target
  26716. * @param target defines the target
  26717. * @param from defines from which frame should animation start
  26718. * @param to defines until which frame should animation run.
  26719. * @param weight defines the weight to apply to the animation (1.0 by default)
  26720. * @param loop defines if the animation loops
  26721. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  26722. * @param onAnimationEnd defines the function to be executed when the animation ends
  26723. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  26724. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  26725. * @param onAnimationLoop defines the callback to call when an animation loops
  26726. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26727. * @returns the animatable object created for this animation
  26728. */
  26729. 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;
  26730. /**
  26731. * Will start the animation sequence of a given target
  26732. * @param target defines the target
  26733. * @param from defines from which frame should animation start
  26734. * @param to defines until which frame should animation run.
  26735. * @param loop defines if the animation loops
  26736. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  26737. * @param onAnimationEnd defines the function to be executed when the animation ends
  26738. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  26739. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  26740. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  26741. * @param onAnimationLoop defines the callback to call when an animation loops
  26742. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26743. * @returns the animatable object created for this animation
  26744. */
  26745. 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;
  26746. /**
  26747. * Will start the animation sequence of a given target and its hierarchy
  26748. * @param target defines the target
  26749. * @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.
  26750. * @param from defines from which frame should animation start
  26751. * @param to defines until which frame should animation run.
  26752. * @param loop defines if the animation loops
  26753. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  26754. * @param onAnimationEnd defines the function to be executed when the animation ends
  26755. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  26756. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  26757. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  26758. * @param onAnimationLoop defines the callback to call when an animation loops
  26759. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26760. * @returns the list of created animatables
  26761. */
  26762. 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[];
  26763. /**
  26764. * Begin a new animation on a given node
  26765. * @param target defines the target where the animation will take place
  26766. * @param animations defines the list of animations to start
  26767. * @param from defines the initial value
  26768. * @param to defines the final value
  26769. * @param loop defines if you want animation to loop (off by default)
  26770. * @param speedRatio defines the speed ratio to apply to all animations
  26771. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26772. * @param onAnimationLoop defines the callback to call when an animation loops
  26773. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26774. * @returns the list of created animatables
  26775. */
  26776. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  26777. /**
  26778. * Begin a new animation on a given node and its hierarchy
  26779. * @param target defines the root node where the animation will take place
  26780. * @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.
  26781. * @param animations defines the list of animations to start
  26782. * @param from defines the initial value
  26783. * @param to defines the final value
  26784. * @param loop defines if you want animation to loop (off by default)
  26785. * @param speedRatio defines the speed ratio to apply to all animations
  26786. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26787. * @param onAnimationLoop defines the callback to call when an animation loops
  26788. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26789. * @returns the list of animatables created for all nodes
  26790. */
  26791. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  26792. /**
  26793. * Gets the animatable associated with a specific target
  26794. * @param target defines the target of the animatable
  26795. * @returns the required animatable if found
  26796. */
  26797. getAnimatableByTarget(target: any): Nullable<Animatable>;
  26798. /**
  26799. * Gets all animatables associated with a given target
  26800. * @param target defines the target to look animatables for
  26801. * @returns an array of Animatables
  26802. */
  26803. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  26804. /**
  26805. * Stops and removes all animations that have been applied to the scene
  26806. */
  26807. stopAllAnimations(): void;
  26808. /**
  26809. * Gets the current delta time used by animation engine
  26810. */
  26811. deltaTime: number;
  26812. }
  26813. }
  26814. module "babylonjs/Bones/bone" {
  26815. interface Bone {
  26816. /**
  26817. * Copy an animation range from another bone
  26818. * @param source defines the source bone
  26819. * @param rangeName defines the range name to copy
  26820. * @param frameOffset defines the frame offset
  26821. * @param rescaleAsRequired defines if rescaling must be applied if required
  26822. * @param skelDimensionsRatio defines the scaling ratio
  26823. * @returns true if operation was successful
  26824. */
  26825. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  26826. }
  26827. }
  26828. }
  26829. declare module "babylonjs/Animations/animationPropertiesOverride" {
  26830. /**
  26831. * Class used to override all child animations of a given target
  26832. */
  26833. export class AnimationPropertiesOverride {
  26834. /**
  26835. * Gets or sets a value indicating if animation blending must be used
  26836. */
  26837. enableBlending: boolean;
  26838. /**
  26839. * Gets or sets the blending speed to use when enableBlending is true
  26840. */
  26841. blendingSpeed: number;
  26842. /**
  26843. * Gets or sets the default loop mode to use
  26844. */
  26845. loopMode: number;
  26846. }
  26847. }
  26848. declare module "babylonjs/Bones/skeleton" {
  26849. import { Bone } from "babylonjs/Bones/bone";
  26850. import { Observable } from "babylonjs/Misc/observable";
  26851. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  26852. import { Scene } from "babylonjs/scene";
  26853. import { Nullable } from "babylonjs/types";
  26854. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26855. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26856. import { Animatable } from "babylonjs/Animations/animatable";
  26857. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26858. import { Animation } from "babylonjs/Animations/animation";
  26859. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26860. import { IInspectable } from "babylonjs/Misc/iInspectable";
  26861. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26862. /**
  26863. * Class used to handle skinning animations
  26864. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26865. */
  26866. export class Skeleton implements IAnimatable {
  26867. /** defines the skeleton name */
  26868. name: string;
  26869. /** defines the skeleton Id */
  26870. id: string;
  26871. /**
  26872. * Defines the list of child bones
  26873. */
  26874. bones: Bone[];
  26875. /**
  26876. * Defines an estimate of the dimension of the skeleton at rest
  26877. */
  26878. dimensionsAtRest: Vector3;
  26879. /**
  26880. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  26881. */
  26882. needInitialSkinMatrix: boolean;
  26883. /**
  26884. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  26885. */
  26886. overrideMesh: Nullable<AbstractMesh>;
  26887. /**
  26888. * Gets the list of animations attached to this skeleton
  26889. */
  26890. animations: Array<Animation>;
  26891. private _scene;
  26892. private _isDirty;
  26893. private _transformMatrices;
  26894. private _transformMatrixTexture;
  26895. private _meshesWithPoseMatrix;
  26896. private _animatables;
  26897. private _identity;
  26898. private _synchronizedWithMesh;
  26899. private _ranges;
  26900. private _lastAbsoluteTransformsUpdateId;
  26901. private _canUseTextureForBones;
  26902. private _uniqueId;
  26903. /** @hidden */
  26904. _numBonesWithLinkedTransformNode: number;
  26905. /** @hidden */
  26906. _hasWaitingData: Nullable<boolean>;
  26907. /** @hidden */
  26908. _waitingOverrideMeshId: Nullable<string>;
  26909. /**
  26910. * Specifies if the skeleton should be serialized
  26911. */
  26912. doNotSerialize: boolean;
  26913. private _useTextureToStoreBoneMatrices;
  26914. /**
  26915. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  26916. * Please note that this option is not available if the hardware does not support it
  26917. */
  26918. get useTextureToStoreBoneMatrices(): boolean;
  26919. set useTextureToStoreBoneMatrices(value: boolean);
  26920. private _animationPropertiesOverride;
  26921. /**
  26922. * Gets or sets the animation properties override
  26923. */
  26924. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26925. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26926. /**
  26927. * List of inspectable custom properties (used by the Inspector)
  26928. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26929. */
  26930. inspectableCustomProperties: IInspectable[];
  26931. /**
  26932. * An observable triggered before computing the skeleton's matrices
  26933. */
  26934. onBeforeComputeObservable: Observable<Skeleton>;
  26935. /**
  26936. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  26937. */
  26938. get isUsingTextureForMatrices(): boolean;
  26939. /**
  26940. * Gets the unique ID of this skeleton
  26941. */
  26942. get uniqueId(): number;
  26943. /**
  26944. * Creates a new skeleton
  26945. * @param name defines the skeleton name
  26946. * @param id defines the skeleton Id
  26947. * @param scene defines the hosting scene
  26948. */
  26949. constructor(
  26950. /** defines the skeleton name */
  26951. name: string,
  26952. /** defines the skeleton Id */
  26953. id: string, scene: Scene);
  26954. /**
  26955. * Gets the current object class name.
  26956. * @return the class name
  26957. */
  26958. getClassName(): string;
  26959. /**
  26960. * Returns an array containing the root bones
  26961. * @returns an array containing the root bones
  26962. */
  26963. getChildren(): Array<Bone>;
  26964. /**
  26965. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  26966. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  26967. * @returns a Float32Array containing matrices data
  26968. */
  26969. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  26970. /**
  26971. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  26972. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  26973. * @returns a raw texture containing the data
  26974. */
  26975. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  26976. /**
  26977. * Gets the current hosting scene
  26978. * @returns a scene object
  26979. */
  26980. getScene(): Scene;
  26981. /**
  26982. * Gets a string representing the current skeleton data
  26983. * @param fullDetails defines a boolean indicating if we want a verbose version
  26984. * @returns a string representing the current skeleton data
  26985. */
  26986. toString(fullDetails?: boolean): string;
  26987. /**
  26988. * Get bone's index searching by name
  26989. * @param name defines bone's name to search for
  26990. * @return the indice of the bone. Returns -1 if not found
  26991. */
  26992. getBoneIndexByName(name: string): number;
  26993. /**
  26994. * Creater a new animation range
  26995. * @param name defines the name of the range
  26996. * @param from defines the start key
  26997. * @param to defines the end key
  26998. */
  26999. createAnimationRange(name: string, from: number, to: number): void;
  27000. /**
  27001. * Delete a specific animation range
  27002. * @param name defines the name of the range
  27003. * @param deleteFrames defines if frames must be removed as well
  27004. */
  27005. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27006. /**
  27007. * Gets a specific animation range
  27008. * @param name defines the name of the range to look for
  27009. * @returns the requested animation range or null if not found
  27010. */
  27011. getAnimationRange(name: string): Nullable<AnimationRange>;
  27012. /**
  27013. * Gets the list of all animation ranges defined on this skeleton
  27014. * @returns an array
  27015. */
  27016. getAnimationRanges(): Nullable<AnimationRange>[];
  27017. /**
  27018. * Copy animation range from a source skeleton.
  27019. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  27020. * @param source defines the source skeleton
  27021. * @param name defines the name of the range to copy
  27022. * @param rescaleAsRequired defines if rescaling must be applied if required
  27023. * @returns true if operation was successful
  27024. */
  27025. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  27026. /**
  27027. * Forces the skeleton to go to rest pose
  27028. */
  27029. returnToRest(): void;
  27030. private _getHighestAnimationFrame;
  27031. /**
  27032. * Begin a specific animation range
  27033. * @param name defines the name of the range to start
  27034. * @param loop defines if looping must be turned on (false by default)
  27035. * @param speedRatio defines the speed ratio to apply (1 by default)
  27036. * @param onAnimationEnd defines a callback which will be called when animation will end
  27037. * @returns a new animatable
  27038. */
  27039. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27040. /**
  27041. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  27042. * @param skeleton defines the Skeleton containing the animation range to convert
  27043. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  27044. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  27045. * @returns the original skeleton
  27046. */
  27047. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  27048. /** @hidden */
  27049. _markAsDirty(): void;
  27050. /** @hidden */
  27051. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  27052. /** @hidden */
  27053. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  27054. private _computeTransformMatrices;
  27055. /**
  27056. * Build all resources required to render a skeleton
  27057. */
  27058. prepare(): void;
  27059. /**
  27060. * Gets the list of animatables currently running for this skeleton
  27061. * @returns an array of animatables
  27062. */
  27063. getAnimatables(): IAnimatable[];
  27064. /**
  27065. * Clone the current skeleton
  27066. * @param name defines the name of the new skeleton
  27067. * @param id defines the id of the new skeleton
  27068. * @returns the new skeleton
  27069. */
  27070. clone(name: string, id?: string): Skeleton;
  27071. /**
  27072. * Enable animation blending for this skeleton
  27073. * @param blendingSpeed defines the blending speed to apply
  27074. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  27075. */
  27076. enableBlending(blendingSpeed?: number): void;
  27077. /**
  27078. * Releases all resources associated with the current skeleton
  27079. */
  27080. dispose(): void;
  27081. /**
  27082. * Serialize the skeleton in a JSON object
  27083. * @returns a JSON object
  27084. */
  27085. serialize(): any;
  27086. /**
  27087. * Creates a new skeleton from serialized data
  27088. * @param parsedSkeleton defines the serialized data
  27089. * @param scene defines the hosting scene
  27090. * @returns a new skeleton
  27091. */
  27092. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  27093. /**
  27094. * Compute all node absolute transforms
  27095. * @param forceUpdate defines if computation must be done even if cache is up to date
  27096. */
  27097. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  27098. /**
  27099. * Gets the root pose matrix
  27100. * @returns a matrix
  27101. */
  27102. getPoseMatrix(): Nullable<Matrix>;
  27103. /**
  27104. * Sorts bones per internal index
  27105. */
  27106. sortBones(): void;
  27107. private _sortBones;
  27108. /**
  27109. * Set the current local matrix as the restPose for all bones in the skeleton.
  27110. */
  27111. setCurrentPoseAsRest(): void;
  27112. }
  27113. }
  27114. declare module "babylonjs/Bones/bone" {
  27115. import { Skeleton } from "babylonjs/Bones/skeleton";
  27116. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  27117. import { Nullable } from "babylonjs/types";
  27118. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27119. import { TransformNode } from "babylonjs/Meshes/transformNode";
  27120. import { Node } from "babylonjs/node";
  27121. import { Space } from "babylonjs/Maths/math.axis";
  27122. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27123. /**
  27124. * Class used to store bone information
  27125. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  27126. */
  27127. export class Bone extends Node {
  27128. /**
  27129. * defines the bone name
  27130. */
  27131. name: string;
  27132. private static _tmpVecs;
  27133. private static _tmpQuat;
  27134. private static _tmpMats;
  27135. /**
  27136. * Gets the list of child bones
  27137. */
  27138. children: Bone[];
  27139. /** Gets the animations associated with this bone */
  27140. animations: import("babylonjs/Animations/animation").Animation[];
  27141. /**
  27142. * Gets or sets bone length
  27143. */
  27144. length: number;
  27145. /**
  27146. * @hidden Internal only
  27147. * Set this value to map this bone to a different index in the transform matrices
  27148. * Set this value to -1 to exclude the bone from the transform matrices
  27149. */
  27150. _index: Nullable<number>;
  27151. private _skeleton;
  27152. private _localMatrix;
  27153. private _restPose;
  27154. private _bindPose;
  27155. private _baseMatrix;
  27156. private _absoluteTransform;
  27157. private _invertedAbsoluteTransform;
  27158. private _parent;
  27159. private _scalingDeterminant;
  27160. private _worldTransform;
  27161. private _localScaling;
  27162. private _localRotation;
  27163. private _localPosition;
  27164. private _needToDecompose;
  27165. private _needToCompose;
  27166. /** @hidden */
  27167. _linkedTransformNode: Nullable<TransformNode>;
  27168. /** @hidden */
  27169. _waitingTransformNodeId: Nullable<string>;
  27170. /** @hidden */
  27171. get _matrix(): Matrix;
  27172. /** @hidden */
  27173. set _matrix(value: Matrix);
  27174. /**
  27175. * Create a new bone
  27176. * @param name defines the bone name
  27177. * @param skeleton defines the parent skeleton
  27178. * @param parentBone defines the parent (can be null if the bone is the root)
  27179. * @param localMatrix defines the local matrix
  27180. * @param restPose defines the rest pose matrix
  27181. * @param baseMatrix defines the base matrix
  27182. * @param index defines index of the bone in the hiearchy
  27183. */
  27184. constructor(
  27185. /**
  27186. * defines the bone name
  27187. */
  27188. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  27189. /**
  27190. * Gets the current object class name.
  27191. * @return the class name
  27192. */
  27193. getClassName(): string;
  27194. /**
  27195. * Gets the parent skeleton
  27196. * @returns a skeleton
  27197. */
  27198. getSkeleton(): Skeleton;
  27199. /**
  27200. * Gets parent bone
  27201. * @returns a bone or null if the bone is the root of the bone hierarchy
  27202. */
  27203. getParent(): Nullable<Bone>;
  27204. /**
  27205. * Returns an array containing the root bones
  27206. * @returns an array containing the root bones
  27207. */
  27208. getChildren(): Array<Bone>;
  27209. /**
  27210. * Gets the node index in matrix array generated for rendering
  27211. * @returns the node index
  27212. */
  27213. getIndex(): number;
  27214. /**
  27215. * Sets the parent bone
  27216. * @param parent defines the parent (can be null if the bone is the root)
  27217. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  27218. */
  27219. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  27220. /**
  27221. * Gets the local matrix
  27222. * @returns a matrix
  27223. */
  27224. getLocalMatrix(): Matrix;
  27225. /**
  27226. * Gets the base matrix (initial matrix which remains unchanged)
  27227. * @returns a matrix
  27228. */
  27229. getBaseMatrix(): Matrix;
  27230. /**
  27231. * Gets the rest pose matrix
  27232. * @returns a matrix
  27233. */
  27234. getRestPose(): Matrix;
  27235. /**
  27236. * Sets the rest pose matrix
  27237. * @param matrix the local-space rest pose to set for this bone
  27238. */
  27239. setRestPose(matrix: Matrix): void;
  27240. /**
  27241. * Gets the bind pose matrix
  27242. * @returns the bind pose matrix
  27243. */
  27244. getBindPose(): Matrix;
  27245. /**
  27246. * Sets the bind pose matrix
  27247. * @param matrix the local-space bind pose to set for this bone
  27248. */
  27249. setBindPose(matrix: Matrix): void;
  27250. /**
  27251. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  27252. */
  27253. getWorldMatrix(): Matrix;
  27254. /**
  27255. * Sets the local matrix to rest pose matrix
  27256. */
  27257. returnToRest(): void;
  27258. /**
  27259. * Gets the inverse of the absolute transform matrix.
  27260. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  27261. * @returns a matrix
  27262. */
  27263. getInvertedAbsoluteTransform(): Matrix;
  27264. /**
  27265. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  27266. * @returns a matrix
  27267. */
  27268. getAbsoluteTransform(): Matrix;
  27269. /**
  27270. * Links with the given transform node.
  27271. * The local matrix of this bone is copied from the transform node every frame.
  27272. * @param transformNode defines the transform node to link to
  27273. */
  27274. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  27275. /**
  27276. * Gets the node used to drive the bone's transformation
  27277. * @returns a transform node or null
  27278. */
  27279. getTransformNode(): Nullable<TransformNode>;
  27280. /** Gets or sets current position (in local space) */
  27281. get position(): Vector3;
  27282. set position(newPosition: Vector3);
  27283. /** Gets or sets current rotation (in local space) */
  27284. get rotation(): Vector3;
  27285. set rotation(newRotation: Vector3);
  27286. /** Gets or sets current rotation quaternion (in local space) */
  27287. get rotationQuaternion(): Quaternion;
  27288. set rotationQuaternion(newRotation: Quaternion);
  27289. /** Gets or sets current scaling (in local space) */
  27290. get scaling(): Vector3;
  27291. set scaling(newScaling: Vector3);
  27292. /**
  27293. * Gets the animation properties override
  27294. */
  27295. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  27296. private _decompose;
  27297. private _compose;
  27298. /**
  27299. * Update the base and local matrices
  27300. * @param matrix defines the new base or local matrix
  27301. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  27302. * @param updateLocalMatrix defines if the local matrix should be updated
  27303. */
  27304. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  27305. /** @hidden */
  27306. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  27307. /**
  27308. * Flag the bone as dirty (Forcing it to update everything)
  27309. */
  27310. markAsDirty(): void;
  27311. /** @hidden */
  27312. _markAsDirtyAndCompose(): void;
  27313. private _markAsDirtyAndDecompose;
  27314. /**
  27315. * Translate the bone in local or world space
  27316. * @param vec The amount to translate the bone
  27317. * @param space The space that the translation is in
  27318. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27319. */
  27320. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  27321. /**
  27322. * Set the postion of the bone in local or world space
  27323. * @param position The position to set the bone
  27324. * @param space The space that the position is in
  27325. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27326. */
  27327. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  27328. /**
  27329. * Set the absolute position of the bone (world space)
  27330. * @param position The position to set the bone
  27331. * @param mesh The mesh that this bone is attached to
  27332. */
  27333. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  27334. /**
  27335. * Scale the bone on the x, y and z axes (in local space)
  27336. * @param x The amount to scale the bone on the x axis
  27337. * @param y The amount to scale the bone on the y axis
  27338. * @param z The amount to scale the bone on the z axis
  27339. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  27340. */
  27341. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  27342. /**
  27343. * Set the bone scaling in local space
  27344. * @param scale defines the scaling vector
  27345. */
  27346. setScale(scale: Vector3): void;
  27347. /**
  27348. * Gets the current scaling in local space
  27349. * @returns the current scaling vector
  27350. */
  27351. getScale(): Vector3;
  27352. /**
  27353. * Gets the current scaling in local space and stores it in a target vector
  27354. * @param result defines the target vector
  27355. */
  27356. getScaleToRef(result: Vector3): void;
  27357. /**
  27358. * Set the yaw, pitch, and roll of the bone in local or world space
  27359. * @param yaw The rotation of the bone on the y axis
  27360. * @param pitch The rotation of the bone on the x axis
  27361. * @param roll The rotation of the bone on the z axis
  27362. * @param space The space that the axes of rotation are in
  27363. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27364. */
  27365. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  27366. /**
  27367. * Add a rotation to the bone on an axis in local or world space
  27368. * @param axis The axis to rotate the bone on
  27369. * @param amount The amount to rotate the bone
  27370. * @param space The space that the axis is in
  27371. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27372. */
  27373. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  27374. /**
  27375. * Set the rotation of the bone to a particular axis angle in local or world space
  27376. * @param axis The axis to rotate the bone on
  27377. * @param angle The angle that the bone should be rotated to
  27378. * @param space The space that the axis is in
  27379. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27380. */
  27381. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  27382. /**
  27383. * Set the euler rotation of the bone in local or world space
  27384. * @param rotation The euler rotation that the bone should be set to
  27385. * @param space The space that the rotation is in
  27386. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27387. */
  27388. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  27389. /**
  27390. * Set the quaternion rotation of the bone in local or world space
  27391. * @param quat The quaternion rotation that the bone should be set to
  27392. * @param space The space that the rotation is in
  27393. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27394. */
  27395. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  27396. /**
  27397. * Set the rotation matrix of the bone in local or world space
  27398. * @param rotMat The rotation matrix that the bone should be set to
  27399. * @param space The space that the rotation is in
  27400. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27401. */
  27402. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  27403. private _rotateWithMatrix;
  27404. private _getNegativeRotationToRef;
  27405. /**
  27406. * Get the position of the bone in local or world space
  27407. * @param space The space that the returned position is in
  27408. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27409. * @returns The position of the bone
  27410. */
  27411. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  27412. /**
  27413. * Copy the position of the bone to a vector3 in local or world space
  27414. * @param space The space that the returned position is in
  27415. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27416. * @param result The vector3 to copy the position to
  27417. */
  27418. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  27419. /**
  27420. * Get the absolute position of the bone (world space)
  27421. * @param mesh The mesh that this bone is attached to
  27422. * @returns The absolute position of the bone
  27423. */
  27424. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  27425. /**
  27426. * Copy the absolute position of the bone (world space) to the result param
  27427. * @param mesh The mesh that this bone is attached to
  27428. * @param result The vector3 to copy the absolute position to
  27429. */
  27430. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  27431. /**
  27432. * Compute the absolute transforms of this bone and its children
  27433. */
  27434. computeAbsoluteTransforms(): void;
  27435. /**
  27436. * Get the world direction from an axis that is in the local space of the bone
  27437. * @param localAxis The local direction that is used to compute the world direction
  27438. * @param mesh The mesh that this bone is attached to
  27439. * @returns The world direction
  27440. */
  27441. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  27442. /**
  27443. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  27444. * @param localAxis The local direction that is used to compute the world direction
  27445. * @param mesh The mesh that this bone is attached to
  27446. * @param result The vector3 that the world direction will be copied to
  27447. */
  27448. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  27449. /**
  27450. * Get the euler rotation of the bone in local or world space
  27451. * @param space The space that the rotation should be in
  27452. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27453. * @returns The euler rotation
  27454. */
  27455. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  27456. /**
  27457. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  27458. * @param space The space that the rotation should be in
  27459. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27460. * @param result The vector3 that the rotation should be copied to
  27461. */
  27462. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  27463. /**
  27464. * Get the quaternion rotation of the bone in either local or world space
  27465. * @param space The space that the rotation should be in
  27466. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27467. * @returns The quaternion rotation
  27468. */
  27469. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  27470. /**
  27471. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  27472. * @param space The space that the rotation should be in
  27473. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27474. * @param result The quaternion that the rotation should be copied to
  27475. */
  27476. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  27477. /**
  27478. * Get the rotation matrix of the bone in local or world space
  27479. * @param space The space that the rotation should be in
  27480. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27481. * @returns The rotation matrix
  27482. */
  27483. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  27484. /**
  27485. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  27486. * @param space The space that the rotation should be in
  27487. * @param mesh The mesh that this bone is attached to. This is only used in world space
  27488. * @param result The quaternion that the rotation should be copied to
  27489. */
  27490. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  27491. /**
  27492. * Get the world position of a point that is in the local space of the bone
  27493. * @param position The local position
  27494. * @param mesh The mesh that this bone is attached to
  27495. * @returns The world position
  27496. */
  27497. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  27498. /**
  27499. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  27500. * @param position The local position
  27501. * @param mesh The mesh that this bone is attached to
  27502. * @param result The vector3 that the world position should be copied to
  27503. */
  27504. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  27505. /**
  27506. * Get the local position of a point that is in world space
  27507. * @param position The world position
  27508. * @param mesh The mesh that this bone is attached to
  27509. * @returns The local position
  27510. */
  27511. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  27512. /**
  27513. * Get the local position of a point that is in world space and copy it to the result param
  27514. * @param position The world position
  27515. * @param mesh The mesh that this bone is attached to
  27516. * @param result The vector3 that the local position should be copied to
  27517. */
  27518. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  27519. /**
  27520. * Set the current local matrix as the restPose for this bone.
  27521. */
  27522. setCurrentPoseAsRest(): void;
  27523. }
  27524. }
  27525. declare module "babylonjs/Meshes/transformNode" {
  27526. import { DeepImmutable } from "babylonjs/types";
  27527. import { Observable } from "babylonjs/Misc/observable";
  27528. import { Nullable } from "babylonjs/types";
  27529. import { Camera } from "babylonjs/Cameras/camera";
  27530. import { Scene } from "babylonjs/scene";
  27531. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27532. import { Node } from "babylonjs/node";
  27533. import { Bone } from "babylonjs/Bones/bone";
  27534. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27535. import { Space } from "babylonjs/Maths/math.axis";
  27536. /**
  27537. * 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.
  27538. * @see https://doc.babylonjs.com/how_to/transformnode
  27539. */
  27540. export class TransformNode extends Node {
  27541. /**
  27542. * Object will not rotate to face the camera
  27543. */
  27544. static BILLBOARDMODE_NONE: number;
  27545. /**
  27546. * Object will rotate to face the camera but only on the x axis
  27547. */
  27548. static BILLBOARDMODE_X: number;
  27549. /**
  27550. * Object will rotate to face the camera but only on the y axis
  27551. */
  27552. static BILLBOARDMODE_Y: number;
  27553. /**
  27554. * Object will rotate to face the camera but only on the z axis
  27555. */
  27556. static BILLBOARDMODE_Z: number;
  27557. /**
  27558. * Object will rotate to face the camera
  27559. */
  27560. static BILLBOARDMODE_ALL: number;
  27561. /**
  27562. * Object will rotate to face the camera's position instead of orientation
  27563. */
  27564. static BILLBOARDMODE_USE_POSITION: number;
  27565. private static _TmpRotation;
  27566. private static _TmpScaling;
  27567. private static _TmpTranslation;
  27568. private _forward;
  27569. private _forwardInverted;
  27570. private _up;
  27571. private _right;
  27572. private _rightInverted;
  27573. private _position;
  27574. private _rotation;
  27575. private _rotationQuaternion;
  27576. protected _scaling: Vector3;
  27577. protected _isDirty: boolean;
  27578. private _transformToBoneReferal;
  27579. private _isAbsoluteSynced;
  27580. private _billboardMode;
  27581. /**
  27582. * Gets or sets the billboard mode. Default is 0.
  27583. *
  27584. * | Value | Type | Description |
  27585. * | --- | --- | --- |
  27586. * | 0 | BILLBOARDMODE_NONE | |
  27587. * | 1 | BILLBOARDMODE_X | |
  27588. * | 2 | BILLBOARDMODE_Y | |
  27589. * | 4 | BILLBOARDMODE_Z | |
  27590. * | 7 | BILLBOARDMODE_ALL | |
  27591. *
  27592. */
  27593. get billboardMode(): number;
  27594. set billboardMode(value: number);
  27595. private _preserveParentRotationForBillboard;
  27596. /**
  27597. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  27598. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  27599. */
  27600. get preserveParentRotationForBillboard(): boolean;
  27601. set preserveParentRotationForBillboard(value: boolean);
  27602. /**
  27603. * 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
  27604. */
  27605. scalingDeterminant: number;
  27606. private _infiniteDistance;
  27607. /**
  27608. * Gets or sets the distance of the object to max, often used by skybox
  27609. */
  27610. get infiniteDistance(): boolean;
  27611. set infiniteDistance(value: boolean);
  27612. /**
  27613. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  27614. * By default the system will update normals to compensate
  27615. */
  27616. ignoreNonUniformScaling: boolean;
  27617. /**
  27618. * 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
  27619. */
  27620. reIntegrateRotationIntoRotationQuaternion: boolean;
  27621. /** @hidden */
  27622. _poseMatrix: Nullable<Matrix>;
  27623. /** @hidden */
  27624. _localMatrix: Matrix;
  27625. private _usePivotMatrix;
  27626. private _absolutePosition;
  27627. private _absoluteScaling;
  27628. private _absoluteRotationQuaternion;
  27629. private _pivotMatrix;
  27630. private _pivotMatrixInverse;
  27631. /** @hidden */
  27632. _postMultiplyPivotMatrix: boolean;
  27633. protected _isWorldMatrixFrozen: boolean;
  27634. /** @hidden */
  27635. _indexInSceneTransformNodesArray: number;
  27636. /**
  27637. * An event triggered after the world matrix is updated
  27638. */
  27639. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  27640. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  27641. /**
  27642. * Gets a string identifying the name of the class
  27643. * @returns "TransformNode" string
  27644. */
  27645. getClassName(): string;
  27646. /**
  27647. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  27648. */
  27649. get position(): Vector3;
  27650. set position(newPosition: Vector3);
  27651. /**
  27652. * 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)).
  27653. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  27654. */
  27655. get rotation(): Vector3;
  27656. set rotation(newRotation: Vector3);
  27657. /**
  27658. * 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)).
  27659. */
  27660. get scaling(): Vector3;
  27661. set scaling(newScaling: Vector3);
  27662. /**
  27663. * 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).
  27664. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  27665. */
  27666. get rotationQuaternion(): Nullable<Quaternion>;
  27667. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  27668. /**
  27669. * The forward direction of that transform in world space.
  27670. */
  27671. get forward(): Vector3;
  27672. /**
  27673. * The up direction of that transform in world space.
  27674. */
  27675. get up(): Vector3;
  27676. /**
  27677. * The right direction of that transform in world space.
  27678. */
  27679. get right(): Vector3;
  27680. /**
  27681. * Copies the parameter passed Matrix into the mesh Pose matrix.
  27682. * @param matrix the matrix to copy the pose from
  27683. * @returns this TransformNode.
  27684. */
  27685. updatePoseMatrix(matrix: Matrix): TransformNode;
  27686. /**
  27687. * Returns the mesh Pose matrix.
  27688. * @returns the pose matrix
  27689. */
  27690. getPoseMatrix(): Matrix;
  27691. /** @hidden */
  27692. _isSynchronized(): boolean;
  27693. /** @hidden */
  27694. _initCache(): void;
  27695. /**
  27696. * Flag the transform node as dirty (Forcing it to update everything)
  27697. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  27698. * @returns this transform node
  27699. */
  27700. markAsDirty(property: string): TransformNode;
  27701. /**
  27702. * Returns the current mesh absolute position.
  27703. * Returns a Vector3.
  27704. */
  27705. get absolutePosition(): Vector3;
  27706. /**
  27707. * Returns the current mesh absolute scaling.
  27708. * Returns a Vector3.
  27709. */
  27710. get absoluteScaling(): Vector3;
  27711. /**
  27712. * Returns the current mesh absolute rotation.
  27713. * Returns a Quaternion.
  27714. */
  27715. get absoluteRotationQuaternion(): Quaternion;
  27716. /**
  27717. * Sets a new matrix to apply before all other transformation
  27718. * @param matrix defines the transform matrix
  27719. * @returns the current TransformNode
  27720. */
  27721. setPreTransformMatrix(matrix: Matrix): TransformNode;
  27722. /**
  27723. * Sets a new pivot matrix to the current node
  27724. * @param matrix defines the new pivot matrix to use
  27725. * @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
  27726. * @returns the current TransformNode
  27727. */
  27728. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  27729. /**
  27730. * Returns the mesh pivot matrix.
  27731. * Default : Identity.
  27732. * @returns the matrix
  27733. */
  27734. getPivotMatrix(): Matrix;
  27735. /**
  27736. * Instantiate (when possible) or clone that node with its hierarchy
  27737. * @param newParent defines the new parent to use for the instance (or clone)
  27738. * @param options defines options to configure how copy is done
  27739. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  27740. * @returns an instance (or a clone) of the current node with its hiearchy
  27741. */
  27742. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  27743. doNotInstantiate: boolean;
  27744. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  27745. /**
  27746. * Prevents the World matrix to be computed any longer
  27747. * @param newWorldMatrix defines an optional matrix to use as world matrix
  27748. * @returns the TransformNode.
  27749. */
  27750. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  27751. /**
  27752. * Allows back the World matrix computation.
  27753. * @returns the TransformNode.
  27754. */
  27755. unfreezeWorldMatrix(): this;
  27756. /**
  27757. * True if the World matrix has been frozen.
  27758. */
  27759. get isWorldMatrixFrozen(): boolean;
  27760. /**
  27761. * Retuns the mesh absolute position in the World.
  27762. * @returns a Vector3.
  27763. */
  27764. getAbsolutePosition(): Vector3;
  27765. /**
  27766. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  27767. * @param absolutePosition the absolute position to set
  27768. * @returns the TransformNode.
  27769. */
  27770. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27771. /**
  27772. * Sets the mesh position in its local space.
  27773. * @param vector3 the position to set in localspace
  27774. * @returns the TransformNode.
  27775. */
  27776. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  27777. /**
  27778. * Returns the mesh position in the local space from the current World matrix values.
  27779. * @returns a new Vector3.
  27780. */
  27781. getPositionExpressedInLocalSpace(): Vector3;
  27782. /**
  27783. * Translates the mesh along the passed Vector3 in its local space.
  27784. * @param vector3 the distance to translate in localspace
  27785. * @returns the TransformNode.
  27786. */
  27787. locallyTranslate(vector3: Vector3): TransformNode;
  27788. private static _lookAtVectorCache;
  27789. /**
  27790. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  27791. * @param targetPoint the position (must be in same space as current mesh) to look at
  27792. * @param yawCor optional yaw (y-axis) correction in radians
  27793. * @param pitchCor optional pitch (x-axis) correction in radians
  27794. * @param rollCor optional roll (z-axis) correction in radians
  27795. * @param space the choosen space of the target
  27796. * @returns the TransformNode.
  27797. */
  27798. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  27799. /**
  27800. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  27801. * This Vector3 is expressed in the World space.
  27802. * @param localAxis axis to rotate
  27803. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  27804. */
  27805. getDirection(localAxis: Vector3): Vector3;
  27806. /**
  27807. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  27808. * localAxis is expressed in the mesh local space.
  27809. * result is computed in the Wordl space from the mesh World matrix.
  27810. * @param localAxis axis to rotate
  27811. * @param result the resulting transformnode
  27812. * @returns this TransformNode.
  27813. */
  27814. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  27815. /**
  27816. * Sets this transform node rotation to the given local axis.
  27817. * @param localAxis the axis in local space
  27818. * @param yawCor optional yaw (y-axis) correction in radians
  27819. * @param pitchCor optional pitch (x-axis) correction in radians
  27820. * @param rollCor optional roll (z-axis) correction in radians
  27821. * @returns this TransformNode
  27822. */
  27823. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  27824. /**
  27825. * Sets a new pivot point to the current node
  27826. * @param point defines the new pivot point to use
  27827. * @param space defines if the point is in world or local space (local by default)
  27828. * @returns the current TransformNode
  27829. */
  27830. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  27831. /**
  27832. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  27833. * @returns the pivot point
  27834. */
  27835. getPivotPoint(): Vector3;
  27836. /**
  27837. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  27838. * @param result the vector3 to store the result
  27839. * @returns this TransformNode.
  27840. */
  27841. getPivotPointToRef(result: Vector3): TransformNode;
  27842. /**
  27843. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  27844. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  27845. */
  27846. getAbsolutePivotPoint(): Vector3;
  27847. /**
  27848. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  27849. * @param result vector3 to store the result
  27850. * @returns this TransformNode.
  27851. */
  27852. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  27853. /**
  27854. * Defines the passed node as the parent of the current node.
  27855. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  27856. * @see https://doc.babylonjs.com/how_to/parenting
  27857. * @param node the node ot set as the parent
  27858. * @returns this TransformNode.
  27859. */
  27860. setParent(node: Nullable<Node>): TransformNode;
  27861. private _nonUniformScaling;
  27862. /**
  27863. * True if the scaling property of this object is non uniform eg. (1,2,1)
  27864. */
  27865. get nonUniformScaling(): boolean;
  27866. /** @hidden */
  27867. _updateNonUniformScalingState(value: boolean): boolean;
  27868. /**
  27869. * Attach the current TransformNode to another TransformNode associated with a bone
  27870. * @param bone Bone affecting the TransformNode
  27871. * @param affectedTransformNode TransformNode associated with the bone
  27872. * @returns this object
  27873. */
  27874. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  27875. /**
  27876. * Detach the transform node if its associated with a bone
  27877. * @returns this object
  27878. */
  27879. detachFromBone(): TransformNode;
  27880. private static _rotationAxisCache;
  27881. /**
  27882. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  27883. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  27884. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  27885. * The passed axis is also normalized.
  27886. * @param axis the axis to rotate around
  27887. * @param amount the amount to rotate in radians
  27888. * @param space Space to rotate in (Default: local)
  27889. * @returns the TransformNode.
  27890. */
  27891. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27892. /**
  27893. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  27894. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  27895. * The passed axis is also normalized. .
  27896. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  27897. * @param point the point to rotate around
  27898. * @param axis the axis to rotate around
  27899. * @param amount the amount to rotate in radians
  27900. * @returns the TransformNode
  27901. */
  27902. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  27903. /**
  27904. * Translates the mesh along the axis vector for the passed distance in the given space.
  27905. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  27906. * @param axis the axis to translate in
  27907. * @param distance the distance to translate
  27908. * @param space Space to rotate in (Default: local)
  27909. * @returns the TransformNode.
  27910. */
  27911. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27912. /**
  27913. * Adds a rotation step to the mesh current rotation.
  27914. * x, y, z are Euler angles expressed in radians.
  27915. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  27916. * This means this rotation is made in the mesh local space only.
  27917. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  27918. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  27919. * ```javascript
  27920. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  27921. * ```
  27922. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  27923. * 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.
  27924. * @param x Rotation to add
  27925. * @param y Rotation to add
  27926. * @param z Rotation to add
  27927. * @returns the TransformNode.
  27928. */
  27929. addRotation(x: number, y: number, z: number): TransformNode;
  27930. /**
  27931. * @hidden
  27932. */
  27933. protected _getEffectiveParent(): Nullable<Node>;
  27934. /**
  27935. * Computes the world matrix of the node
  27936. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27937. * @returns the world matrix
  27938. */
  27939. computeWorldMatrix(force?: boolean): Matrix;
  27940. /**
  27941. * Resets this nodeTransform's local matrix to Matrix.Identity().
  27942. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  27943. */
  27944. resetLocalMatrix(independentOfChildren?: boolean): void;
  27945. protected _afterComputeWorldMatrix(): void;
  27946. /**
  27947. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  27948. * @param func callback function to add
  27949. *
  27950. * @returns the TransformNode.
  27951. */
  27952. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  27953. /**
  27954. * Removes a registered callback function.
  27955. * @param func callback function to remove
  27956. * @returns the TransformNode.
  27957. */
  27958. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  27959. /**
  27960. * Gets the position of the current mesh in camera space
  27961. * @param camera defines the camera to use
  27962. * @returns a position
  27963. */
  27964. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  27965. /**
  27966. * Returns the distance from the mesh to the active camera
  27967. * @param camera defines the camera to use
  27968. * @returns the distance
  27969. */
  27970. getDistanceToCamera(camera?: Nullable<Camera>): number;
  27971. /**
  27972. * Clone the current transform node
  27973. * @param name Name of the new clone
  27974. * @param newParent New parent for the clone
  27975. * @param doNotCloneChildren Do not clone children hierarchy
  27976. * @returns the new transform node
  27977. */
  27978. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  27979. /**
  27980. * Serializes the objects information.
  27981. * @param currentSerializationObject defines the object to serialize in
  27982. * @returns the serialized object
  27983. */
  27984. serialize(currentSerializationObject?: any): any;
  27985. /**
  27986. * Returns a new TransformNode object parsed from the source provided.
  27987. * @param parsedTransformNode is the source.
  27988. * @param scene the scne the object belongs to
  27989. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  27990. * @returns a new TransformNode object parsed from the source provided.
  27991. */
  27992. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  27993. /**
  27994. * Get all child-transformNodes of this node
  27995. * @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
  27996. * @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
  27997. * @returns an array of TransformNode
  27998. */
  27999. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  28000. /**
  28001. * Releases resources associated with this transform node.
  28002. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28003. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28004. */
  28005. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28006. /**
  28007. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28008. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28009. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28010. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28011. * @returns the current mesh
  28012. */
  28013. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  28014. private _syncAbsoluteScalingAndRotation;
  28015. }
  28016. }
  28017. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  28018. import { Observable } from "babylonjs/Misc/observable";
  28019. import { Nullable } from "babylonjs/types";
  28020. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  28021. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28022. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28023. import { Ray } from "babylonjs/Culling/ray";
  28024. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  28025. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  28026. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  28027. /**
  28028. * Defines the types of pose enabled controllers that are supported
  28029. */
  28030. export enum PoseEnabledControllerType {
  28031. /**
  28032. * HTC Vive
  28033. */
  28034. VIVE = 0,
  28035. /**
  28036. * Oculus Rift
  28037. */
  28038. OCULUS = 1,
  28039. /**
  28040. * Windows mixed reality
  28041. */
  28042. WINDOWS = 2,
  28043. /**
  28044. * Samsung gear VR
  28045. */
  28046. GEAR_VR = 3,
  28047. /**
  28048. * Google Daydream
  28049. */
  28050. DAYDREAM = 4,
  28051. /**
  28052. * Generic
  28053. */
  28054. GENERIC = 5
  28055. }
  28056. /**
  28057. * Defines the MutableGamepadButton interface for the state of a gamepad button
  28058. */
  28059. export interface MutableGamepadButton {
  28060. /**
  28061. * Value of the button/trigger
  28062. */
  28063. value: number;
  28064. /**
  28065. * If the button/trigger is currently touched
  28066. */
  28067. touched: boolean;
  28068. /**
  28069. * If the button/trigger is currently pressed
  28070. */
  28071. pressed: boolean;
  28072. }
  28073. /**
  28074. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  28075. * @hidden
  28076. */
  28077. export interface ExtendedGamepadButton extends GamepadButton {
  28078. /**
  28079. * If the button/trigger is currently pressed
  28080. */
  28081. readonly pressed: boolean;
  28082. /**
  28083. * If the button/trigger is currently touched
  28084. */
  28085. readonly touched: boolean;
  28086. /**
  28087. * Value of the button/trigger
  28088. */
  28089. readonly value: number;
  28090. }
  28091. /** @hidden */
  28092. export interface _GamePadFactory {
  28093. /**
  28094. * Returns whether or not the current gamepad can be created for this type of controller.
  28095. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  28096. * @returns true if it can be created, otherwise false
  28097. */
  28098. canCreate(gamepadInfo: any): boolean;
  28099. /**
  28100. * Creates a new instance of the Gamepad.
  28101. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  28102. * @returns the new gamepad instance
  28103. */
  28104. create(gamepadInfo: any): Gamepad;
  28105. }
  28106. /**
  28107. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  28108. */
  28109. export class PoseEnabledControllerHelper {
  28110. /** @hidden */
  28111. static _ControllerFactories: _GamePadFactory[];
  28112. /** @hidden */
  28113. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  28114. /**
  28115. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  28116. * @param vrGamepad the gamepad to initialized
  28117. * @returns a vr controller of the type the gamepad identified as
  28118. */
  28119. static InitiateController(vrGamepad: any): Gamepad;
  28120. }
  28121. /**
  28122. * Defines the PoseEnabledController object that contains state of a vr capable controller
  28123. */
  28124. export class PoseEnabledController extends Gamepad implements PoseControlled {
  28125. /**
  28126. * If the controller is used in a webXR session
  28127. */
  28128. isXR: boolean;
  28129. private _deviceRoomPosition;
  28130. private _deviceRoomRotationQuaternion;
  28131. /**
  28132. * The device position in babylon space
  28133. */
  28134. devicePosition: Vector3;
  28135. /**
  28136. * The device rotation in babylon space
  28137. */
  28138. deviceRotationQuaternion: Quaternion;
  28139. /**
  28140. * The scale factor of the device in babylon space
  28141. */
  28142. deviceScaleFactor: number;
  28143. /**
  28144. * (Likely devicePosition should be used instead) The device position in its room space
  28145. */
  28146. position: Vector3;
  28147. /**
  28148. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  28149. */
  28150. rotationQuaternion: Quaternion;
  28151. /**
  28152. * The type of controller (Eg. Windows mixed reality)
  28153. */
  28154. controllerType: PoseEnabledControllerType;
  28155. protected _calculatedPosition: Vector3;
  28156. private _calculatedRotation;
  28157. /**
  28158. * The raw pose from the device
  28159. */
  28160. rawPose: DevicePose;
  28161. private _trackPosition;
  28162. private _maxRotationDistFromHeadset;
  28163. private _draggedRoomRotation;
  28164. /**
  28165. * @hidden
  28166. */
  28167. _disableTrackPosition(fixedPosition: Vector3): void;
  28168. /**
  28169. * Internal, the mesh attached to the controller
  28170. * @hidden
  28171. */
  28172. _mesh: Nullable<AbstractMesh>;
  28173. private _poseControlledCamera;
  28174. private _leftHandSystemQuaternion;
  28175. /**
  28176. * Internal, matrix used to convert room space to babylon space
  28177. * @hidden
  28178. */
  28179. _deviceToWorld: Matrix;
  28180. /**
  28181. * Node to be used when casting a ray from the controller
  28182. * @hidden
  28183. */
  28184. _pointingPoseNode: Nullable<TransformNode>;
  28185. /**
  28186. * Name of the child mesh that can be used to cast a ray from the controller
  28187. */
  28188. static readonly POINTING_POSE: string;
  28189. /**
  28190. * Creates a new PoseEnabledController from a gamepad
  28191. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  28192. */
  28193. constructor(browserGamepad: any);
  28194. private _workingMatrix;
  28195. /**
  28196. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  28197. */
  28198. update(): void;
  28199. /**
  28200. * Updates only the pose device and mesh without doing any button event checking
  28201. */
  28202. protected _updatePoseAndMesh(): void;
  28203. /**
  28204. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  28205. * @param poseData raw pose fromthe device
  28206. */
  28207. updateFromDevice(poseData: DevicePose): void;
  28208. /**
  28209. * @hidden
  28210. */
  28211. _meshAttachedObservable: Observable<AbstractMesh>;
  28212. /**
  28213. * Attaches a mesh to the controller
  28214. * @param mesh the mesh to be attached
  28215. */
  28216. attachToMesh(mesh: AbstractMesh): void;
  28217. /**
  28218. * Attaches the controllers mesh to a camera
  28219. * @param camera the camera the mesh should be attached to
  28220. */
  28221. attachToPoseControlledCamera(camera: TargetCamera): void;
  28222. /**
  28223. * Disposes of the controller
  28224. */
  28225. dispose(): void;
  28226. /**
  28227. * The mesh that is attached to the controller
  28228. */
  28229. get mesh(): Nullable<AbstractMesh>;
  28230. /**
  28231. * Gets the ray of the controller in the direction the controller is pointing
  28232. * @param length the length the resulting ray should be
  28233. * @returns a ray in the direction the controller is pointing
  28234. */
  28235. getForwardRay(length?: number): Ray;
  28236. }
  28237. }
  28238. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  28239. import { Observable } from "babylonjs/Misc/observable";
  28240. import { Scene } from "babylonjs/scene";
  28241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28242. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  28243. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  28244. import { Nullable } from "babylonjs/types";
  28245. /**
  28246. * Defines the WebVRController object that represents controllers tracked in 3D space
  28247. */
  28248. export abstract class WebVRController extends PoseEnabledController {
  28249. /**
  28250. * Internal, the default controller model for the controller
  28251. */
  28252. protected _defaultModel: Nullable<AbstractMesh>;
  28253. /**
  28254. * Fired when the trigger state has changed
  28255. */
  28256. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  28257. /**
  28258. * Fired when the main button state has changed
  28259. */
  28260. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  28261. /**
  28262. * Fired when the secondary button state has changed
  28263. */
  28264. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  28265. /**
  28266. * Fired when the pad state has changed
  28267. */
  28268. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  28269. /**
  28270. * Fired when controllers stick values have changed
  28271. */
  28272. onPadValuesChangedObservable: Observable<StickValues>;
  28273. /**
  28274. * Array of button availible on the controller
  28275. */
  28276. protected _buttons: Array<MutableGamepadButton>;
  28277. private _onButtonStateChange;
  28278. /**
  28279. * Fired when a controller button's state has changed
  28280. * @param callback the callback containing the button that was modified
  28281. */
  28282. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  28283. /**
  28284. * X and Y axis corresponding to the controllers joystick
  28285. */
  28286. pad: StickValues;
  28287. /**
  28288. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  28289. */
  28290. hand: string;
  28291. /**
  28292. * The default controller model for the controller
  28293. */
  28294. get defaultModel(): Nullable<AbstractMesh>;
  28295. /**
  28296. * Creates a new WebVRController from a gamepad
  28297. * @param vrGamepad the gamepad that the WebVRController should be created from
  28298. */
  28299. constructor(vrGamepad: any);
  28300. /**
  28301. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  28302. */
  28303. update(): void;
  28304. /**
  28305. * Function to be called when a button is modified
  28306. */
  28307. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  28308. /**
  28309. * Loads a mesh and attaches it to the controller
  28310. * @param scene the scene the mesh should be added to
  28311. * @param meshLoaded callback for when the mesh has been loaded
  28312. */
  28313. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  28314. private _setButtonValue;
  28315. private _changes;
  28316. private _checkChanges;
  28317. /**
  28318. * Disposes of th webVRCOntroller
  28319. */
  28320. dispose(): void;
  28321. }
  28322. }
  28323. declare module "babylonjs/Lights/hemisphericLight" {
  28324. import { Nullable } from "babylonjs/types";
  28325. import { Scene } from "babylonjs/scene";
  28326. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  28327. import { Color3 } from "babylonjs/Maths/math.color";
  28328. import { Effect } from "babylonjs/Materials/effect";
  28329. import { Light } from "babylonjs/Lights/light";
  28330. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  28331. /**
  28332. * The HemisphericLight simulates the ambient environment light,
  28333. * so the passed direction is the light reflection direction, not the incoming direction.
  28334. */
  28335. export class HemisphericLight extends Light {
  28336. /**
  28337. * The groundColor is the light in the opposite direction to the one specified during creation.
  28338. * 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.
  28339. */
  28340. groundColor: Color3;
  28341. /**
  28342. * The light reflection direction, not the incoming direction.
  28343. */
  28344. direction: Vector3;
  28345. /**
  28346. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  28347. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  28348. * The HemisphericLight can't cast shadows.
  28349. * Documentation : https://doc.babylonjs.com/babylon101/lights
  28350. * @param name The friendly name of the light
  28351. * @param direction The direction of the light reflection
  28352. * @param scene The scene the light belongs to
  28353. */
  28354. constructor(name: string, direction: Vector3, scene: Scene);
  28355. protected _buildUniformLayout(): void;
  28356. /**
  28357. * Returns the string "HemisphericLight".
  28358. * @return The class name
  28359. */
  28360. getClassName(): string;
  28361. /**
  28362. * Sets the HemisphericLight direction towards the passed target (Vector3).
  28363. * Returns the updated direction.
  28364. * @param target The target the direction should point to
  28365. * @return The computed direction
  28366. */
  28367. setDirectionToTarget(target: Vector3): Vector3;
  28368. /**
  28369. * Returns the shadow generator associated to the light.
  28370. * @returns Always null for hemispheric lights because it does not support shadows.
  28371. */
  28372. getShadowGenerator(): Nullable<IShadowGenerator>;
  28373. /**
  28374. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  28375. * @param effect The effect to update
  28376. * @param lightIndex The index of the light in the effect to update
  28377. * @returns The hemispheric light
  28378. */
  28379. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  28380. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  28381. /**
  28382. * Computes the world matrix of the node
  28383. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28384. * @param useWasUpdatedFlag defines a reserved property
  28385. * @returns the world matrix
  28386. */
  28387. computeWorldMatrix(): Matrix;
  28388. /**
  28389. * Returns the integer 3.
  28390. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  28391. */
  28392. getTypeID(): number;
  28393. /**
  28394. * Prepares the list of defines specific to the light type.
  28395. * @param defines the list of defines
  28396. * @param lightIndex defines the index of the light for the effect
  28397. */
  28398. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  28399. }
  28400. }
  28401. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  28402. /** @hidden */
  28403. export var vrMultiviewToSingleviewPixelShader: {
  28404. name: string;
  28405. shader: string;
  28406. };
  28407. }
  28408. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  28409. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28410. import { Scene } from "babylonjs/scene";
  28411. /**
  28412. * Renders to multiple views with a single draw call
  28413. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  28414. */
  28415. export class MultiviewRenderTarget extends RenderTargetTexture {
  28416. /**
  28417. * Creates a multiview render target
  28418. * @param scene scene used with the render target
  28419. * @param size the size of the render target (used for each view)
  28420. */
  28421. constructor(scene: Scene, size?: number | {
  28422. width: number;
  28423. height: number;
  28424. } | {
  28425. ratio: number;
  28426. });
  28427. /**
  28428. * @hidden
  28429. * @param faceIndex the face index, if its a cube texture
  28430. */
  28431. _bindFrameBuffer(faceIndex?: number): void;
  28432. /**
  28433. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  28434. * @returns the view count
  28435. */
  28436. getViewCount(): number;
  28437. }
  28438. }
  28439. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  28440. import { Camera } from "babylonjs/Cameras/camera";
  28441. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28442. import { Nullable } from "babylonjs/types";
  28443. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28444. import { Matrix } from "babylonjs/Maths/math.vector";
  28445. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  28446. module "babylonjs/Engines/engine" {
  28447. interface Engine {
  28448. /**
  28449. * Creates a new multiview render target
  28450. * @param width defines the width of the texture
  28451. * @param height defines the height of the texture
  28452. * @returns the created multiview texture
  28453. */
  28454. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  28455. /**
  28456. * Binds a multiview framebuffer to be drawn to
  28457. * @param multiviewTexture texture to bind
  28458. */
  28459. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  28460. }
  28461. }
  28462. module "babylonjs/Cameras/camera" {
  28463. interface Camera {
  28464. /**
  28465. * @hidden
  28466. * 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)
  28467. */
  28468. _useMultiviewToSingleView: boolean;
  28469. /**
  28470. * @hidden
  28471. * 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)
  28472. */
  28473. _multiviewTexture: Nullable<RenderTargetTexture>;
  28474. /**
  28475. * @hidden
  28476. * ensures the multiview texture of the camera exists and has the specified width/height
  28477. * @param width height to set on the multiview texture
  28478. * @param height width to set on the multiview texture
  28479. */
  28480. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  28481. }
  28482. }
  28483. module "babylonjs/scene" {
  28484. interface Scene {
  28485. /** @hidden */
  28486. _transformMatrixR: Matrix;
  28487. /** @hidden */
  28488. _multiviewSceneUbo: Nullable<UniformBuffer>;
  28489. /** @hidden */
  28490. _createMultiviewUbo(): void;
  28491. /** @hidden */
  28492. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  28493. /** @hidden */
  28494. _renderMultiviewToSingleView(camera: Camera): void;
  28495. }
  28496. }
  28497. }
  28498. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  28499. import { Camera } from "babylonjs/Cameras/camera";
  28500. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28501. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  28502. import "babylonjs/Engines/Extensions/engine.multiview";
  28503. /**
  28504. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  28505. * This will not be used for webXR as it supports displaying texture arrays directly
  28506. */
  28507. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  28508. /**
  28509. * Gets a string identifying the name of the class
  28510. * @returns "VRMultiviewToSingleviewPostProcess" string
  28511. */
  28512. getClassName(): string;
  28513. /**
  28514. * Initializes a VRMultiviewToSingleview
  28515. * @param name name of the post process
  28516. * @param camera camera to be applied to
  28517. * @param scaleFactor scaling factor to the size of the output texture
  28518. */
  28519. constructor(name: string, camera: Camera, scaleFactor: number);
  28520. }
  28521. }
  28522. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  28523. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  28524. import { Nullable } from "babylonjs/types";
  28525. import { Size } from "babylonjs/Maths/math.size";
  28526. import { Observable } from "babylonjs/Misc/observable";
  28527. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  28528. /**
  28529. * Interface used to define additional presentation attributes
  28530. */
  28531. export interface IVRPresentationAttributes {
  28532. /**
  28533. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  28534. */
  28535. highRefreshRate: boolean;
  28536. /**
  28537. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  28538. */
  28539. foveationLevel: number;
  28540. }
  28541. module "babylonjs/Engines/engine" {
  28542. interface Engine {
  28543. /** @hidden */
  28544. _vrDisplay: any;
  28545. /** @hidden */
  28546. _vrSupported: boolean;
  28547. /** @hidden */
  28548. _oldSize: Size;
  28549. /** @hidden */
  28550. _oldHardwareScaleFactor: number;
  28551. /** @hidden */
  28552. _vrExclusivePointerMode: boolean;
  28553. /** @hidden */
  28554. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  28555. /** @hidden */
  28556. _onVRDisplayPointerRestricted: () => void;
  28557. /** @hidden */
  28558. _onVRDisplayPointerUnrestricted: () => void;
  28559. /** @hidden */
  28560. _onVrDisplayConnect: Nullable<(display: any) => void>;
  28561. /** @hidden */
  28562. _onVrDisplayDisconnect: Nullable<() => void>;
  28563. /** @hidden */
  28564. _onVrDisplayPresentChange: Nullable<() => void>;
  28565. /**
  28566. * Observable signaled when VR display mode changes
  28567. */
  28568. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  28569. /**
  28570. * Observable signaled when VR request present is complete
  28571. */
  28572. onVRRequestPresentComplete: Observable<boolean>;
  28573. /**
  28574. * Observable signaled when VR request present starts
  28575. */
  28576. onVRRequestPresentStart: Observable<Engine>;
  28577. /**
  28578. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  28579. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  28580. */
  28581. isInVRExclusivePointerMode: boolean;
  28582. /**
  28583. * Gets a boolean indicating if a webVR device was detected
  28584. * @returns true if a webVR device was detected
  28585. */
  28586. isVRDevicePresent(): boolean;
  28587. /**
  28588. * Gets the current webVR device
  28589. * @returns the current webVR device (or null)
  28590. */
  28591. getVRDevice(): any;
  28592. /**
  28593. * Initializes a webVR display and starts listening to display change events
  28594. * The onVRDisplayChangedObservable will be notified upon these changes
  28595. * @returns A promise containing a VRDisplay and if vr is supported
  28596. */
  28597. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  28598. /** @hidden */
  28599. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  28600. /**
  28601. * Gets or sets the presentation attributes used to configure VR rendering
  28602. */
  28603. vrPresentationAttributes?: IVRPresentationAttributes;
  28604. /**
  28605. * Call this function to switch to webVR mode
  28606. * Will do nothing if webVR is not supported or if there is no webVR device
  28607. * @param options the webvr options provided to the camera. mainly used for multiview
  28608. * @see https://doc.babylonjs.com/how_to/webvr_camera
  28609. */
  28610. enableVR(options: WebVROptions): void;
  28611. /** @hidden */
  28612. _onVRFullScreenTriggered(): void;
  28613. }
  28614. }
  28615. }
  28616. declare module "babylonjs/Cameras/VR/webVRCamera" {
  28617. import { Nullable } from "babylonjs/types";
  28618. import { Observable } from "babylonjs/Misc/observable";
  28619. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  28620. import { Scene } from "babylonjs/scene";
  28621. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  28622. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  28623. import { Node } from "babylonjs/node";
  28624. import { Ray } from "babylonjs/Culling/ray";
  28625. import "babylonjs/Cameras/RigModes/webVRRigMode";
  28626. import "babylonjs/Engines/Extensions/engine.webVR";
  28627. /**
  28628. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  28629. * IMPORTANT!! The data is right-hand data.
  28630. * @export
  28631. * @interface DevicePose
  28632. */
  28633. export interface DevicePose {
  28634. /**
  28635. * The position of the device, values in array are [x,y,z].
  28636. */
  28637. readonly position: Nullable<Float32Array>;
  28638. /**
  28639. * The linearVelocity of the device, values in array are [x,y,z].
  28640. */
  28641. readonly linearVelocity: Nullable<Float32Array>;
  28642. /**
  28643. * The linearAcceleration of the device, values in array are [x,y,z].
  28644. */
  28645. readonly linearAcceleration: Nullable<Float32Array>;
  28646. /**
  28647. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  28648. */
  28649. readonly orientation: Nullable<Float32Array>;
  28650. /**
  28651. * The angularVelocity of the device, values in array are [x,y,z].
  28652. */
  28653. readonly angularVelocity: Nullable<Float32Array>;
  28654. /**
  28655. * The angularAcceleration of the device, values in array are [x,y,z].
  28656. */
  28657. readonly angularAcceleration: Nullable<Float32Array>;
  28658. }
  28659. /**
  28660. * Interface representing a pose controlled object in Babylon.
  28661. * A pose controlled object has both regular pose values as well as pose values
  28662. * from an external device such as a VR head mounted display
  28663. */
  28664. export interface PoseControlled {
  28665. /**
  28666. * The position of the object in babylon space.
  28667. */
  28668. position: Vector3;
  28669. /**
  28670. * The rotation quaternion of the object in babylon space.
  28671. */
  28672. rotationQuaternion: Quaternion;
  28673. /**
  28674. * The position of the device in babylon space.
  28675. */
  28676. devicePosition?: Vector3;
  28677. /**
  28678. * The rotation quaternion of the device in babylon space.
  28679. */
  28680. deviceRotationQuaternion: Quaternion;
  28681. /**
  28682. * The raw pose coming from the device.
  28683. */
  28684. rawPose: Nullable<DevicePose>;
  28685. /**
  28686. * The scale of the device to be used when translating from device space to babylon space.
  28687. */
  28688. deviceScaleFactor: number;
  28689. /**
  28690. * Updates the poseControlled values based on the input device pose.
  28691. * @param poseData the pose data to update the object with
  28692. */
  28693. updateFromDevice(poseData: DevicePose): void;
  28694. }
  28695. /**
  28696. * Set of options to customize the webVRCamera
  28697. */
  28698. export interface WebVROptions {
  28699. /**
  28700. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  28701. */
  28702. trackPosition?: boolean;
  28703. /**
  28704. * Sets the scale of the vrDevice in babylon space. (default: 1)
  28705. */
  28706. positionScale?: number;
  28707. /**
  28708. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  28709. */
  28710. displayName?: string;
  28711. /**
  28712. * Should the native controller meshes be initialized. (default: true)
  28713. */
  28714. controllerMeshes?: boolean;
  28715. /**
  28716. * Creating a default HemiLight only on controllers. (default: true)
  28717. */
  28718. defaultLightingOnControllers?: boolean;
  28719. /**
  28720. * If you don't want to use the default VR button of the helper. (default: false)
  28721. */
  28722. useCustomVRButton?: boolean;
  28723. /**
  28724. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  28725. */
  28726. customVRButton?: HTMLButtonElement;
  28727. /**
  28728. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  28729. */
  28730. rayLength?: number;
  28731. /**
  28732. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  28733. */
  28734. defaultHeight?: number;
  28735. /**
  28736. * If multiview should be used if availible (default: false)
  28737. */
  28738. useMultiview?: boolean;
  28739. }
  28740. /**
  28741. * This represents a WebVR camera.
  28742. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  28743. * @example https://doc.babylonjs.com/how_to/webvr_camera
  28744. */
  28745. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  28746. private webVROptions;
  28747. /**
  28748. * @hidden
  28749. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  28750. */
  28751. _vrDevice: any;
  28752. /**
  28753. * The rawPose of the vrDevice.
  28754. */
  28755. rawPose: Nullable<DevicePose>;
  28756. private _onVREnabled;
  28757. private _specsVersion;
  28758. private _attached;
  28759. private _frameData;
  28760. protected _descendants: Array<Node>;
  28761. private _deviceRoomPosition;
  28762. /** @hidden */
  28763. _deviceRoomRotationQuaternion: Quaternion;
  28764. private _standingMatrix;
  28765. /**
  28766. * Represents device position in babylon space.
  28767. */
  28768. devicePosition: Vector3;
  28769. /**
  28770. * Represents device rotation in babylon space.
  28771. */
  28772. deviceRotationQuaternion: Quaternion;
  28773. /**
  28774. * The scale of the device to be used when translating from device space to babylon space.
  28775. */
  28776. deviceScaleFactor: number;
  28777. private _deviceToWorld;
  28778. private _worldToDevice;
  28779. /**
  28780. * References to the webVR controllers for the vrDevice.
  28781. */
  28782. controllers: Array<WebVRController>;
  28783. /**
  28784. * Emits an event when a controller is attached.
  28785. */
  28786. onControllersAttachedObservable: Observable<WebVRController[]>;
  28787. /**
  28788. * Emits an event when a controller's mesh has been loaded;
  28789. */
  28790. onControllerMeshLoadedObservable: Observable<WebVRController>;
  28791. /**
  28792. * Emits an event when the HMD's pose has been updated.
  28793. */
  28794. onPoseUpdatedFromDeviceObservable: Observable<any>;
  28795. private _poseSet;
  28796. /**
  28797. * If the rig cameras be used as parent instead of this camera.
  28798. */
  28799. rigParenting: boolean;
  28800. private _lightOnControllers;
  28801. private _defaultHeight?;
  28802. /**
  28803. * Instantiates a WebVRFreeCamera.
  28804. * @param name The name of the WebVRFreeCamera
  28805. * @param position The starting anchor position for the camera
  28806. * @param scene The scene the camera belongs to
  28807. * @param webVROptions a set of customizable options for the webVRCamera
  28808. */
  28809. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  28810. /**
  28811. * Gets the device distance from the ground in meters.
  28812. * @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.
  28813. */
  28814. deviceDistanceToRoomGround(): number;
  28815. /**
  28816. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  28817. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  28818. */
  28819. useStandingMatrix(callback?: (bool: boolean) => void): void;
  28820. /**
  28821. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  28822. * @returns A promise with a boolean set to if the standing matrix is supported.
  28823. */
  28824. useStandingMatrixAsync(): Promise<boolean>;
  28825. /**
  28826. * Disposes the camera
  28827. */
  28828. dispose(): void;
  28829. /**
  28830. * Gets a vrController by name.
  28831. * @param name The name of the controller to retreive
  28832. * @returns the controller matching the name specified or null if not found
  28833. */
  28834. getControllerByName(name: string): Nullable<WebVRController>;
  28835. private _leftController;
  28836. /**
  28837. * The controller corresponding to the users left hand.
  28838. */
  28839. get leftController(): Nullable<WebVRController>;
  28840. private _rightController;
  28841. /**
  28842. * The controller corresponding to the users right hand.
  28843. */
  28844. get rightController(): Nullable<WebVRController>;
  28845. /**
  28846. * Casts a ray forward from the vrCamera's gaze.
  28847. * @param length Length of the ray (default: 100)
  28848. * @returns the ray corresponding to the gaze
  28849. */
  28850. getForwardRay(length?: number): Ray;
  28851. /**
  28852. * @hidden
  28853. * Updates the camera based on device's frame data
  28854. */
  28855. _checkInputs(): void;
  28856. /**
  28857. * Updates the poseControlled values based on the input device pose.
  28858. * @param poseData Pose coming from the device
  28859. */
  28860. updateFromDevice(poseData: DevicePose): void;
  28861. private _detachIfAttached;
  28862. /**
  28863. * WebVR's attach control will start broadcasting frames to the device.
  28864. * Note that in certain browsers (chrome for example) this function must be called
  28865. * within a user-interaction callback. Example:
  28866. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  28867. *
  28868. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  28869. */
  28870. attachControl(noPreventDefault?: boolean): void;
  28871. /**
  28872. * Detach the current controls from the specified dom element.
  28873. */
  28874. detachControl(): void;
  28875. /**
  28876. * @returns the name of this class
  28877. */
  28878. getClassName(): string;
  28879. /**
  28880. * Calls resetPose on the vrDisplay
  28881. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  28882. */
  28883. resetToCurrentRotation(): void;
  28884. /**
  28885. * @hidden
  28886. * Updates the rig cameras (left and right eye)
  28887. */
  28888. _updateRigCameras(): void;
  28889. private _workingVector;
  28890. private _oneVector;
  28891. private _workingMatrix;
  28892. private updateCacheCalled;
  28893. private _correctPositionIfNotTrackPosition;
  28894. /**
  28895. * @hidden
  28896. * Updates the cached values of the camera
  28897. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  28898. */
  28899. _updateCache(ignoreParentClass?: boolean): void;
  28900. /**
  28901. * @hidden
  28902. * Get current device position in babylon world
  28903. */
  28904. _computeDevicePosition(): void;
  28905. /**
  28906. * Updates the current device position and rotation in the babylon world
  28907. */
  28908. update(): void;
  28909. /**
  28910. * @hidden
  28911. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  28912. * @returns an identity matrix
  28913. */
  28914. _getViewMatrix(): Matrix;
  28915. private _tmpMatrix;
  28916. /**
  28917. * This function is called by the two RIG cameras.
  28918. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  28919. * @hidden
  28920. */
  28921. _getWebVRViewMatrix(): Matrix;
  28922. /** @hidden */
  28923. _getWebVRProjectionMatrix(): Matrix;
  28924. private _onGamepadConnectedObserver;
  28925. private _onGamepadDisconnectedObserver;
  28926. private _updateCacheWhenTrackingDisabledObserver;
  28927. /**
  28928. * Initializes the controllers and their meshes
  28929. */
  28930. initControllers(): void;
  28931. }
  28932. }
  28933. declare module "babylonjs/Materials/materialHelper" {
  28934. import { Nullable } from "babylonjs/types";
  28935. import { Scene } from "babylonjs/scene";
  28936. import { Engine } from "babylonjs/Engines/engine";
  28937. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28938. import { Light } from "babylonjs/Lights/light";
  28939. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  28940. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  28941. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  28942. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28943. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  28944. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  28945. import { Vector4 } from "babylonjs/Maths/math.vector";
  28946. /**
  28947. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  28948. *
  28949. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  28950. *
  28951. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  28952. */
  28953. export class MaterialHelper {
  28954. /**
  28955. * Bind the current view position to an effect.
  28956. * @param effect The effect to be bound
  28957. * @param scene The scene the eyes position is used from
  28958. * @param variableName name of the shader variable that will hold the eye position
  28959. * @param isVector3 true to indicates that variableName is a Vector3 and not a Vector4
  28960. * @return the computed eye position
  28961. */
  28962. static BindEyePosition(effect: Nullable<Effect>, scene: Scene, variableName?: string, isVector3?: boolean): Vector4;
  28963. /**
  28964. * Helps preparing the defines values about the UVs in used in the effect.
  28965. * UVs are shared as much as we can accross channels in the shaders.
  28966. * @param texture The texture we are preparing the UVs for
  28967. * @param defines The defines to update
  28968. * @param key The channel key "diffuse", "specular"... used in the shader
  28969. */
  28970. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  28971. /**
  28972. * Binds a texture matrix value to its corrsponding uniform
  28973. * @param texture The texture to bind the matrix for
  28974. * @param uniformBuffer The uniform buffer receivin the data
  28975. * @param key The channel key "diffuse", "specular"... used in the shader
  28976. */
  28977. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  28978. /**
  28979. * Gets the current status of the fog (should it be enabled?)
  28980. * @param mesh defines the mesh to evaluate for fog support
  28981. * @param scene defines the hosting scene
  28982. * @returns true if fog must be enabled
  28983. */
  28984. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  28985. /**
  28986. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  28987. * @param mesh defines the current mesh
  28988. * @param scene defines the current scene
  28989. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  28990. * @param pointsCloud defines if point cloud rendering has to be turned on
  28991. * @param fogEnabled defines if fog has to be turned on
  28992. * @param alphaTest defines if alpha testing has to be turned on
  28993. * @param defines defines the current list of defines
  28994. */
  28995. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  28996. /**
  28997. * Helper used to prepare the list of defines associated with frame values for shader compilation
  28998. * @param scene defines the current scene
  28999. * @param engine defines the current engine
  29000. * @param defines specifies the list of active defines
  29001. * @param useInstances defines if instances have to be turned on
  29002. * @param useClipPlane defines if clip plane have to be turned on
  29003. * @param useInstances defines if instances have to be turned on
  29004. * @param useThinInstances defines if thin instances have to be turned on
  29005. */
  29006. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  29007. /**
  29008. * Prepares the defines for bones
  29009. * @param mesh The mesh containing the geometry data we will draw
  29010. * @param defines The defines to update
  29011. */
  29012. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  29013. /**
  29014. * Prepares the defines for morph targets
  29015. * @param mesh The mesh containing the geometry data we will draw
  29016. * @param defines The defines to update
  29017. */
  29018. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  29019. /**
  29020. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  29021. * @param mesh The mesh containing the geometry data we will draw
  29022. * @param defines The defines to update
  29023. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  29024. * @param useBones Precise whether bones should be used or not (override mesh info)
  29025. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  29026. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  29027. * @returns false if defines are considered not dirty and have not been checked
  29028. */
  29029. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  29030. /**
  29031. * Prepares the defines related to multiview
  29032. * @param scene The scene we are intending to draw
  29033. * @param defines The defines to update
  29034. */
  29035. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  29036. /**
  29037. * Prepares the defines related to the prepass
  29038. * @param scene The scene we are intending to draw
  29039. * @param defines The defines to update
  29040. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  29041. */
  29042. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  29043. /**
  29044. * Prepares the defines related to the light information passed in parameter
  29045. * @param scene The scene we are intending to draw
  29046. * @param mesh The mesh the effect is compiling for
  29047. * @param light The light the effect is compiling for
  29048. * @param lightIndex The index of the light
  29049. * @param defines The defines to update
  29050. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  29051. * @param state Defines the current state regarding what is needed (normals, etc...)
  29052. */
  29053. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  29054. needNormals: boolean;
  29055. needRebuild: boolean;
  29056. shadowEnabled: boolean;
  29057. specularEnabled: boolean;
  29058. lightmapMode: boolean;
  29059. }): void;
  29060. /**
  29061. * Prepares the defines related to the light information passed in parameter
  29062. * @param scene The scene we are intending to draw
  29063. * @param mesh The mesh the effect is compiling for
  29064. * @param defines The defines to update
  29065. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  29066. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  29067. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  29068. * @returns true if normals will be required for the rest of the effect
  29069. */
  29070. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  29071. /**
  29072. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  29073. * @param lightIndex defines the light index
  29074. * @param uniformsList The uniform list
  29075. * @param samplersList The sampler list
  29076. * @param projectedLightTexture defines if projected texture must be used
  29077. * @param uniformBuffersList defines an optional list of uniform buffers
  29078. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  29079. */
  29080. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  29081. /**
  29082. * Prepares the uniforms and samplers list to be used in the effect
  29083. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  29084. * @param samplersList The sampler list
  29085. * @param defines The defines helping in the list generation
  29086. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  29087. */
  29088. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  29089. /**
  29090. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  29091. * @param defines The defines to update while falling back
  29092. * @param fallbacks The authorized effect fallbacks
  29093. * @param maxSimultaneousLights The maximum number of lights allowed
  29094. * @param rank the current rank of the Effect
  29095. * @returns The newly affected rank
  29096. */
  29097. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  29098. private static _TmpMorphInfluencers;
  29099. /**
  29100. * Prepares the list of attributes required for morph targets according to the effect defines.
  29101. * @param attribs The current list of supported attribs
  29102. * @param mesh The mesh to prepare the morph targets attributes for
  29103. * @param influencers The number of influencers
  29104. */
  29105. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  29106. /**
  29107. * Prepares the list of attributes required for morph targets according to the effect defines.
  29108. * @param attribs The current list of supported attribs
  29109. * @param mesh The mesh to prepare the morph targets attributes for
  29110. * @param defines The current Defines of the effect
  29111. */
  29112. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  29113. /**
  29114. * Prepares the list of attributes required for bones according to the effect defines.
  29115. * @param attribs The current list of supported attribs
  29116. * @param mesh The mesh to prepare the bones attributes for
  29117. * @param defines The current Defines of the effect
  29118. * @param fallbacks The current efffect fallback strategy
  29119. */
  29120. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  29121. /**
  29122. * Check and prepare the list of attributes required for instances according to the effect defines.
  29123. * @param attribs The current list of supported attribs
  29124. * @param defines The current MaterialDefines of the effect
  29125. */
  29126. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  29127. /**
  29128. * Add the list of attributes required for instances to the attribs array.
  29129. * @param attribs The current list of supported attribs
  29130. */
  29131. static PushAttributesForInstances(attribs: string[]): void;
  29132. /**
  29133. * Binds the light information to the effect.
  29134. * @param light The light containing the generator
  29135. * @param effect The effect we are binding the data to
  29136. * @param lightIndex The light index in the effect used to render
  29137. */
  29138. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  29139. /**
  29140. * Binds the lights information from the scene to the effect for the given mesh.
  29141. * @param light Light to bind
  29142. * @param lightIndex Light index
  29143. * @param scene The scene where the light belongs to
  29144. * @param effect The effect we are binding the data to
  29145. * @param useSpecular Defines if specular is supported
  29146. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  29147. */
  29148. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  29149. /**
  29150. * Binds the lights information from the scene to the effect for the given mesh.
  29151. * @param scene The scene the lights belongs to
  29152. * @param mesh The mesh we are binding the information to render
  29153. * @param effect The effect we are binding the data to
  29154. * @param defines The generated defines for the effect
  29155. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  29156. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  29157. */
  29158. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  29159. private static _tempFogColor;
  29160. /**
  29161. * Binds the fog information from the scene to the effect for the given mesh.
  29162. * @param scene The scene the lights belongs to
  29163. * @param mesh The mesh we are binding the information to render
  29164. * @param effect The effect we are binding the data to
  29165. * @param linearSpace Defines if the fog effect is applied in linear space
  29166. */
  29167. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  29168. /**
  29169. * Binds the bones information from the mesh to the effect.
  29170. * @param mesh The mesh we are binding the information to render
  29171. * @param effect The effect we are binding the data to
  29172. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  29173. */
  29174. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  29175. private static _CopyBonesTransformationMatrices;
  29176. /**
  29177. * Binds the morph targets information from the mesh to the effect.
  29178. * @param abstractMesh The mesh we are binding the information to render
  29179. * @param effect The effect we are binding the data to
  29180. */
  29181. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  29182. /**
  29183. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  29184. * @param defines The generated defines used in the effect
  29185. * @param effect The effect we are binding the data to
  29186. * @param scene The scene we are willing to render with logarithmic scale for
  29187. */
  29188. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  29189. /**
  29190. * Binds the clip plane information from the scene to the effect.
  29191. * @param scene The scene the clip plane information are extracted from
  29192. * @param effect The effect we are binding the data to
  29193. */
  29194. static BindClipPlane(effect: Effect, scene: Scene): void;
  29195. }
  29196. }
  29197. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  29198. /** @hidden */
  29199. export var bayerDitherFunctions: {
  29200. name: string;
  29201. shader: string;
  29202. };
  29203. }
  29204. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  29205. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  29206. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  29207. /** @hidden */
  29208. export var shadowMapFragmentDeclaration: {
  29209. name: string;
  29210. shader: string;
  29211. };
  29212. }
  29213. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  29214. /** @hidden */
  29215. export var shadowMapFragment: {
  29216. name: string;
  29217. shader: string;
  29218. };
  29219. }
  29220. declare module "babylonjs/Shaders/shadowMap.fragment" {
  29221. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  29222. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  29223. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  29224. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  29225. /** @hidden */
  29226. export var shadowMapPixelShader: {
  29227. name: string;
  29228. shader: string;
  29229. };
  29230. }
  29231. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  29232. /** @hidden */
  29233. export var shadowMapVertexDeclaration: {
  29234. name: string;
  29235. shader: string;
  29236. };
  29237. }
  29238. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  29239. /** @hidden */
  29240. export var shadowMapVertexNormalBias: {
  29241. name: string;
  29242. shader: string;
  29243. };
  29244. }
  29245. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  29246. /** @hidden */
  29247. export var shadowMapVertexMetric: {
  29248. name: string;
  29249. shader: string;
  29250. };
  29251. }
  29252. declare module "babylonjs/Shaders/shadowMap.vertex" {
  29253. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  29254. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  29255. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  29256. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  29257. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  29258. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  29259. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  29260. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  29261. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  29262. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  29263. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  29264. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  29265. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  29266. /** @hidden */
  29267. export var shadowMapVertexShader: {
  29268. name: string;
  29269. shader: string;
  29270. };
  29271. }
  29272. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  29273. /** @hidden */
  29274. export var depthBoxBlurPixelShader: {
  29275. name: string;
  29276. shader: string;
  29277. };
  29278. }
  29279. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  29280. /** @hidden */
  29281. export var shadowMapFragmentSoftTransparentShadow: {
  29282. name: string;
  29283. shader: string;
  29284. };
  29285. }
  29286. declare module "babylonjs/Meshes/instancedMesh" {
  29287. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  29288. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  29289. import { Camera } from "babylonjs/Cameras/camera";
  29290. import { Node } from "babylonjs/node";
  29291. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29292. import { Mesh } from "babylonjs/Meshes/mesh";
  29293. import { Material } from "babylonjs/Materials/material";
  29294. import { Skeleton } from "babylonjs/Bones/skeleton";
  29295. import { Light } from "babylonjs/Lights/light";
  29296. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29297. /**
  29298. * Creates an instance based on a source mesh.
  29299. */
  29300. export class InstancedMesh extends AbstractMesh {
  29301. private _sourceMesh;
  29302. private _currentLOD;
  29303. /** @hidden */
  29304. _indexInSourceMeshInstanceArray: number;
  29305. constructor(name: string, source: Mesh);
  29306. /**
  29307. * Returns the string "InstancedMesh".
  29308. */
  29309. getClassName(): string;
  29310. /** Gets the list of lights affecting that mesh */
  29311. get lightSources(): Light[];
  29312. _resyncLightSources(): void;
  29313. _resyncLightSource(light: Light): void;
  29314. _removeLightSource(light: Light, dispose: boolean): void;
  29315. /**
  29316. * If the source mesh receives shadows
  29317. */
  29318. get receiveShadows(): boolean;
  29319. /**
  29320. * The material of the source mesh
  29321. */
  29322. get material(): Nullable<Material>;
  29323. /**
  29324. * Visibility of the source mesh
  29325. */
  29326. get visibility(): number;
  29327. /**
  29328. * Skeleton of the source mesh
  29329. */
  29330. get skeleton(): Nullable<Skeleton>;
  29331. /**
  29332. * Rendering ground id of the source mesh
  29333. */
  29334. get renderingGroupId(): number;
  29335. set renderingGroupId(value: number);
  29336. /**
  29337. * Returns the total number of vertices (integer).
  29338. */
  29339. getTotalVertices(): number;
  29340. /**
  29341. * Returns a positive integer : the total number of indices in this mesh geometry.
  29342. * @returns the numner of indices or zero if the mesh has no geometry.
  29343. */
  29344. getTotalIndices(): number;
  29345. /**
  29346. * The source mesh of the instance
  29347. */
  29348. get sourceMesh(): Mesh;
  29349. /**
  29350. * Creates a new InstancedMesh object from the mesh model.
  29351. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29352. * @param name defines the name of the new instance
  29353. * @returns a new InstancedMesh
  29354. */
  29355. createInstance(name: string): InstancedMesh;
  29356. /**
  29357. * Is this node ready to be used/rendered
  29358. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29359. * @return {boolean} is it ready
  29360. */
  29361. isReady(completeCheck?: boolean): boolean;
  29362. /**
  29363. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  29364. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  29365. * @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.
  29366. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  29367. */
  29368. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  29369. /**
  29370. * Sets the vertex data of the mesh geometry for the requested `kind`.
  29371. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  29372. * The `data` are either a numeric array either a Float32Array.
  29373. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  29374. * 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).
  29375. * Note that a new underlying VertexBuffer object is created each call.
  29376. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  29377. *
  29378. * Possible `kind` values :
  29379. * - VertexBuffer.PositionKind
  29380. * - VertexBuffer.UVKind
  29381. * - VertexBuffer.UV2Kind
  29382. * - VertexBuffer.UV3Kind
  29383. * - VertexBuffer.UV4Kind
  29384. * - VertexBuffer.UV5Kind
  29385. * - VertexBuffer.UV6Kind
  29386. * - VertexBuffer.ColorKind
  29387. * - VertexBuffer.MatricesIndicesKind
  29388. * - VertexBuffer.MatricesIndicesExtraKind
  29389. * - VertexBuffer.MatricesWeightsKind
  29390. * - VertexBuffer.MatricesWeightsExtraKind
  29391. *
  29392. * Returns the Mesh.
  29393. */
  29394. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29395. /**
  29396. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  29397. * If the mesh has no geometry, it is simply returned as it is.
  29398. * The `data` are either a numeric array either a Float32Array.
  29399. * No new underlying VertexBuffer object is created.
  29400. * 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.
  29401. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  29402. *
  29403. * Possible `kind` values :
  29404. * - VertexBuffer.PositionKind
  29405. * - VertexBuffer.UVKind
  29406. * - VertexBuffer.UV2Kind
  29407. * - VertexBuffer.UV3Kind
  29408. * - VertexBuffer.UV4Kind
  29409. * - VertexBuffer.UV5Kind
  29410. * - VertexBuffer.UV6Kind
  29411. * - VertexBuffer.ColorKind
  29412. * - VertexBuffer.MatricesIndicesKind
  29413. * - VertexBuffer.MatricesIndicesExtraKind
  29414. * - VertexBuffer.MatricesWeightsKind
  29415. * - VertexBuffer.MatricesWeightsExtraKind
  29416. *
  29417. * Returns the Mesh.
  29418. */
  29419. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  29420. /**
  29421. * Sets the mesh indices.
  29422. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  29423. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  29424. * This method creates a new index buffer each call.
  29425. * Returns the Mesh.
  29426. */
  29427. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  29428. /**
  29429. * Boolean : True if the mesh owns the requested kind of data.
  29430. */
  29431. isVerticesDataPresent(kind: string): boolean;
  29432. /**
  29433. * Returns an array of indices (IndicesArray).
  29434. */
  29435. getIndices(): Nullable<IndicesArray>;
  29436. get _positions(): Nullable<Vector3[]>;
  29437. /**
  29438. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29439. * This means the mesh underlying bounding box and sphere are recomputed.
  29440. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29441. * @returns the current mesh
  29442. */
  29443. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  29444. /** @hidden */
  29445. _preActivate(): InstancedMesh;
  29446. /** @hidden */
  29447. _activate(renderId: number, intermediateRendering: boolean): boolean;
  29448. /** @hidden */
  29449. _postActivate(): void;
  29450. getWorldMatrix(): Matrix;
  29451. get isAnInstance(): boolean;
  29452. /**
  29453. * Returns the current associated LOD AbstractMesh.
  29454. */
  29455. getLOD(camera: Camera): AbstractMesh;
  29456. /** @hidden */
  29457. _preActivateForIntermediateRendering(renderId: number): Mesh;
  29458. /** @hidden */
  29459. _syncSubMeshes(): InstancedMesh;
  29460. /** @hidden */
  29461. _generatePointsArray(): boolean;
  29462. /** @hidden */
  29463. _updateBoundingInfo(): AbstractMesh;
  29464. /**
  29465. * Creates a new InstancedMesh from the current mesh.
  29466. * - name (string) : the cloned mesh name
  29467. * - newParent (optional Node) : the optional Node to parent the clone to.
  29468. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  29469. *
  29470. * Returns the clone.
  29471. */
  29472. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  29473. /**
  29474. * Disposes the InstancedMesh.
  29475. * Returns nothing.
  29476. */
  29477. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29478. }
  29479. module "babylonjs/Meshes/mesh" {
  29480. interface Mesh {
  29481. /**
  29482. * Register a custom buffer that will be instanced
  29483. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  29484. * @param kind defines the buffer kind
  29485. * @param stride defines the stride in floats
  29486. */
  29487. registerInstancedBuffer(kind: string, stride: number): void;
  29488. /**
  29489. * true to use the edge renderer for all instances of this mesh
  29490. */
  29491. edgesShareWithInstances: boolean;
  29492. /** @hidden */
  29493. _userInstancedBuffersStorage: {
  29494. data: {
  29495. [key: string]: Float32Array;
  29496. };
  29497. sizes: {
  29498. [key: string]: number;
  29499. };
  29500. vertexBuffers: {
  29501. [key: string]: Nullable<VertexBuffer>;
  29502. };
  29503. strides: {
  29504. [key: string]: number;
  29505. };
  29506. };
  29507. }
  29508. }
  29509. module "babylonjs/Meshes/abstractMesh" {
  29510. interface AbstractMesh {
  29511. /**
  29512. * Object used to store instanced buffers defined by user
  29513. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  29514. */
  29515. instancedBuffers: {
  29516. [key: string]: any;
  29517. };
  29518. }
  29519. }
  29520. }
  29521. declare module "babylonjs/Materials/shaderMaterial" {
  29522. import { Nullable } from "babylonjs/types";
  29523. import { Scene } from "babylonjs/scene";
  29524. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  29525. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29526. import { Mesh } from "babylonjs/Meshes/mesh";
  29527. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29528. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29529. import { Effect } from "babylonjs/Materials/effect";
  29530. import { Material } from "babylonjs/Materials/material";
  29531. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29532. /**
  29533. * Defines the options associated with the creation of a shader material.
  29534. */
  29535. export interface IShaderMaterialOptions {
  29536. /**
  29537. * Does the material work in alpha blend mode
  29538. */
  29539. needAlphaBlending: boolean;
  29540. /**
  29541. * Does the material work in alpha test mode
  29542. */
  29543. needAlphaTesting: boolean;
  29544. /**
  29545. * The list of attribute names used in the shader
  29546. */
  29547. attributes: string[];
  29548. /**
  29549. * The list of unifrom names used in the shader
  29550. */
  29551. uniforms: string[];
  29552. /**
  29553. * The list of UBO names used in the shader
  29554. */
  29555. uniformBuffers: string[];
  29556. /**
  29557. * The list of sampler names used in the shader
  29558. */
  29559. samplers: string[];
  29560. /**
  29561. * The list of defines used in the shader
  29562. */
  29563. defines: string[];
  29564. }
  29565. /**
  29566. * 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.
  29567. *
  29568. * This returned material effects how the mesh will look based on the code in the shaders.
  29569. *
  29570. * @see https://doc.babylonjs.com/how_to/shader_material
  29571. */
  29572. export class ShaderMaterial extends Material {
  29573. private _shaderPath;
  29574. private _options;
  29575. private _textures;
  29576. private _textureArrays;
  29577. private _floats;
  29578. private _ints;
  29579. private _floatsArrays;
  29580. private _colors3;
  29581. private _colors3Arrays;
  29582. private _colors4;
  29583. private _colors4Arrays;
  29584. private _vectors2;
  29585. private _vectors3;
  29586. private _vectors4;
  29587. private _matrices;
  29588. private _matrixArrays;
  29589. private _matrices3x3;
  29590. private _matrices2x2;
  29591. private _vectors2Arrays;
  29592. private _vectors3Arrays;
  29593. private _vectors4Arrays;
  29594. private _cachedWorldViewMatrix;
  29595. private _cachedWorldViewProjectionMatrix;
  29596. private _renderId;
  29597. private _multiview;
  29598. private _cachedDefines;
  29599. /** Define the Url to load snippets */
  29600. static SnippetUrl: string;
  29601. /** Snippet ID if the material was created from the snippet server */
  29602. snippetId: string;
  29603. /**
  29604. * Instantiate a new shader material.
  29605. * 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.
  29606. * This returned material effects how the mesh will look based on the code in the shaders.
  29607. * @see https://doc.babylonjs.com/how_to/shader_material
  29608. * @param name Define the name of the material in the scene
  29609. * @param scene Define the scene the material belongs to
  29610. * @param shaderPath Defines the route to the shader code in one of three ways:
  29611. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  29612. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  29613. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  29614. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  29615. * @param options Define the options used to create the shader
  29616. */
  29617. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  29618. /**
  29619. * Gets the shader path used to define the shader code
  29620. * It can be modified to trigger a new compilation
  29621. */
  29622. get shaderPath(): any;
  29623. /**
  29624. * Sets the shader path used to define the shader code
  29625. * It can be modified to trigger a new compilation
  29626. */
  29627. set shaderPath(shaderPath: any);
  29628. /**
  29629. * Gets the options used to compile the shader.
  29630. * They can be modified to trigger a new compilation
  29631. */
  29632. get options(): IShaderMaterialOptions;
  29633. /**
  29634. * Gets the current class name of the material e.g. "ShaderMaterial"
  29635. * Mainly use in serialization.
  29636. * @returns the class name
  29637. */
  29638. getClassName(): string;
  29639. /**
  29640. * Specifies if the material will require alpha blending
  29641. * @returns a boolean specifying if alpha blending is needed
  29642. */
  29643. needAlphaBlending(): boolean;
  29644. /**
  29645. * Specifies if this material should be rendered in alpha test mode
  29646. * @returns a boolean specifying if an alpha test is needed.
  29647. */
  29648. needAlphaTesting(): boolean;
  29649. private _checkUniform;
  29650. /**
  29651. * Set a texture in the shader.
  29652. * @param name Define the name of the uniform samplers as defined in the shader
  29653. * @param texture Define the texture to bind to this sampler
  29654. * @return the material itself allowing "fluent" like uniform updates
  29655. */
  29656. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  29657. /**
  29658. * Set a texture array in the shader.
  29659. * @param name Define the name of the uniform sampler array as defined in the shader
  29660. * @param textures Define the list of textures to bind to this sampler
  29661. * @return the material itself allowing "fluent" like uniform updates
  29662. */
  29663. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  29664. /**
  29665. * Set a float in the shader.
  29666. * @param name Define the name of the uniform as defined in the shader
  29667. * @param value Define the value to give to the uniform
  29668. * @return the material itself allowing "fluent" like uniform updates
  29669. */
  29670. setFloat(name: string, value: number): ShaderMaterial;
  29671. /**
  29672. * Set a int in the shader.
  29673. * @param name Define the name of the uniform as defined in the shader
  29674. * @param value Define the value to give to the uniform
  29675. * @return the material itself allowing "fluent" like uniform updates
  29676. */
  29677. setInt(name: string, value: number): ShaderMaterial;
  29678. /**
  29679. * Set an array of floats in the shader.
  29680. * @param name Define the name of the uniform as defined in the shader
  29681. * @param value Define the value to give to the uniform
  29682. * @return the material itself allowing "fluent" like uniform updates
  29683. */
  29684. setFloats(name: string, value: number[]): ShaderMaterial;
  29685. /**
  29686. * Set a vec3 in the shader from a Color3.
  29687. * @param name Define the name of the uniform as defined in the shader
  29688. * @param value Define the value to give to the uniform
  29689. * @return the material itself allowing "fluent" like uniform updates
  29690. */
  29691. setColor3(name: string, value: Color3): ShaderMaterial;
  29692. /**
  29693. * Set a vec3 array in the shader from a Color3 array.
  29694. * @param name Define the name of the uniform as defined in the shader
  29695. * @param value Define the value to give to the uniform
  29696. * @return the material itself allowing "fluent" like uniform updates
  29697. */
  29698. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  29699. /**
  29700. * Set a vec4 in the shader from a Color4.
  29701. * @param name Define the name of the uniform as defined in the shader
  29702. * @param value Define the value to give to the uniform
  29703. * @return the material itself allowing "fluent" like uniform updates
  29704. */
  29705. setColor4(name: string, value: Color4): ShaderMaterial;
  29706. /**
  29707. * Set a vec4 array in the shader from a Color4 array.
  29708. * @param name Define the name of the uniform as defined in the shader
  29709. * @param value Define the value to give to the uniform
  29710. * @return the material itself allowing "fluent" like uniform updates
  29711. */
  29712. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  29713. /**
  29714. * Set a vec2 in the shader from a Vector2.
  29715. * @param name Define the name of the uniform as defined in the shader
  29716. * @param value Define the value to give to the uniform
  29717. * @return the material itself allowing "fluent" like uniform updates
  29718. */
  29719. setVector2(name: string, value: Vector2): ShaderMaterial;
  29720. /**
  29721. * Set a vec3 in the shader from a Vector3.
  29722. * @param name Define the name of the uniform as defined in the shader
  29723. * @param value Define the value to give to the uniform
  29724. * @return the material itself allowing "fluent" like uniform updates
  29725. */
  29726. setVector3(name: string, value: Vector3): ShaderMaterial;
  29727. /**
  29728. * Set a vec4 in the shader from a Vector4.
  29729. * @param name Define the name of the uniform as defined in the shader
  29730. * @param value Define the value to give to the uniform
  29731. * @return the material itself allowing "fluent" like uniform updates
  29732. */
  29733. setVector4(name: string, value: Vector4): ShaderMaterial;
  29734. /**
  29735. * Set a mat4 in the shader from a Matrix.
  29736. * @param name Define the name of the uniform as defined in the shader
  29737. * @param value Define the value to give to the uniform
  29738. * @return the material itself allowing "fluent" like uniform updates
  29739. */
  29740. setMatrix(name: string, value: Matrix): ShaderMaterial;
  29741. /**
  29742. * Set a float32Array in the shader from a matrix array.
  29743. * @param name Define the name of the uniform as defined in the shader
  29744. * @param value Define the value to give to the uniform
  29745. * @return the material itself allowing "fluent" like uniform updates
  29746. */
  29747. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  29748. /**
  29749. * Set a mat3 in the shader from a Float32Array.
  29750. * @param name Define the name of the uniform as defined in the shader
  29751. * @param value Define the value to give to the uniform
  29752. * @return the material itself allowing "fluent" like uniform updates
  29753. */
  29754. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  29755. /**
  29756. * Set a mat2 in the shader from a Float32Array.
  29757. * @param name Define the name of the uniform as defined in the shader
  29758. * @param value Define the value to give to the uniform
  29759. * @return the material itself allowing "fluent" like uniform updates
  29760. */
  29761. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  29762. /**
  29763. * Set a vec2 array in the shader from a number array.
  29764. * @param name Define the name of the uniform as defined in the shader
  29765. * @param value Define the value to give to the uniform
  29766. * @return the material itself allowing "fluent" like uniform updates
  29767. */
  29768. setArray2(name: string, value: number[]): ShaderMaterial;
  29769. /**
  29770. * Set a vec3 array in the shader from a number array.
  29771. * @param name Define the name of the uniform as defined in the shader
  29772. * @param value Define the value to give to the uniform
  29773. * @return the material itself allowing "fluent" like uniform updates
  29774. */
  29775. setArray3(name: string, value: number[]): ShaderMaterial;
  29776. /**
  29777. * Set a vec4 array in the shader from a number array.
  29778. * @param name Define the name of the uniform as defined in the shader
  29779. * @param value Define the value to give to the uniform
  29780. * @return the material itself allowing "fluent" like uniform updates
  29781. */
  29782. setArray4(name: string, value: number[]): ShaderMaterial;
  29783. private _checkCache;
  29784. /**
  29785. * Specifies that the submesh is ready to be used
  29786. * @param mesh defines the mesh to check
  29787. * @param subMesh defines which submesh to check
  29788. * @param useInstances specifies that instances should be used
  29789. * @returns a boolean indicating that the submesh is ready or not
  29790. */
  29791. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29792. /**
  29793. * Checks if the material is ready to render the requested mesh
  29794. * @param mesh Define the mesh to render
  29795. * @param useInstances Define whether or not the material is used with instances
  29796. * @returns true if ready, otherwise false
  29797. */
  29798. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  29799. /**
  29800. * Binds the world matrix to the material
  29801. * @param world defines the world transformation matrix
  29802. * @param effectOverride - If provided, use this effect instead of internal effect
  29803. */
  29804. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  29805. /**
  29806. * Binds the submesh to this material by preparing the effect and shader to draw
  29807. * @param world defines the world transformation matrix
  29808. * @param mesh defines the mesh containing the submesh
  29809. * @param subMesh defines the submesh to bind the material to
  29810. */
  29811. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29812. /**
  29813. * Binds the material to the mesh
  29814. * @param world defines the world transformation matrix
  29815. * @param mesh defines the mesh to bind the material to
  29816. * @param effectOverride - If provided, use this effect instead of internal effect
  29817. */
  29818. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  29819. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  29820. /**
  29821. * Gets the active textures from the material
  29822. * @returns an array of textures
  29823. */
  29824. getActiveTextures(): BaseTexture[];
  29825. /**
  29826. * Specifies if the material uses a texture
  29827. * @param texture defines the texture to check against the material
  29828. * @returns a boolean specifying if the material uses the texture
  29829. */
  29830. hasTexture(texture: BaseTexture): boolean;
  29831. /**
  29832. * Makes a duplicate of the material, and gives it a new name
  29833. * @param name defines the new name for the duplicated material
  29834. * @returns the cloned material
  29835. */
  29836. clone(name: string): ShaderMaterial;
  29837. /**
  29838. * Disposes the material
  29839. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29840. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29841. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29842. */
  29843. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29844. /**
  29845. * Serializes this material in a JSON representation
  29846. * @returns the serialized material object
  29847. */
  29848. serialize(): any;
  29849. /**
  29850. * Creates a shader material from parsed shader material data
  29851. * @param source defines the JSON represnetation of the material
  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 new material
  29855. */
  29856. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  29857. /**
  29858. * Creates a new ShaderMaterial from a snippet saved in a remote file
  29859. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  29860. * @param url defines the url to load from
  29861. * @param scene defines the hosting scene
  29862. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29863. * @returns a promise that will resolve to the new ShaderMaterial
  29864. */
  29865. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  29866. /**
  29867. * Creates a ShaderMaterial from a snippet saved by the Inspector
  29868. * @param snippetId defines the snippet to load
  29869. * @param scene defines the hosting scene
  29870. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29871. * @returns a promise that will resolve to the new ShaderMaterial
  29872. */
  29873. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  29874. }
  29875. }
  29876. declare module "babylonjs/Shaders/color.fragment" {
  29877. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  29878. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  29879. /** @hidden */
  29880. export var colorPixelShader: {
  29881. name: string;
  29882. shader: string;
  29883. };
  29884. }
  29885. declare module "babylonjs/Shaders/color.vertex" {
  29886. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  29887. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  29888. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  29889. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  29890. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  29891. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  29892. /** @hidden */
  29893. export var colorVertexShader: {
  29894. name: string;
  29895. shader: string;
  29896. };
  29897. }
  29898. declare module "babylonjs/Meshes/linesMesh" {
  29899. import { Nullable } from "babylonjs/types";
  29900. import { Scene } from "babylonjs/scene";
  29901. import { Color3 } from "babylonjs/Maths/math.color";
  29902. import { Node } from "babylonjs/node";
  29903. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29904. import { Mesh } from "babylonjs/Meshes/mesh";
  29905. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  29906. import { Effect } from "babylonjs/Materials/effect";
  29907. import { Material } from "babylonjs/Materials/material";
  29908. import "babylonjs/Shaders/color.fragment";
  29909. import "babylonjs/Shaders/color.vertex";
  29910. /**
  29911. * Line mesh
  29912. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  29913. */
  29914. export class LinesMesh extends Mesh {
  29915. /**
  29916. * If vertex color should be applied to the mesh
  29917. */
  29918. readonly useVertexColor?: boolean | undefined;
  29919. /**
  29920. * If vertex alpha should be applied to the mesh
  29921. */
  29922. readonly useVertexAlpha?: boolean | undefined;
  29923. /**
  29924. * Color of the line (Default: White)
  29925. */
  29926. color: Color3;
  29927. /**
  29928. * Alpha of the line (Default: 1)
  29929. */
  29930. alpha: number;
  29931. /**
  29932. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  29933. * This margin is expressed in world space coordinates, so its value may vary.
  29934. * Default value is 0.1
  29935. */
  29936. intersectionThreshold: number;
  29937. private _colorShader;
  29938. private color4;
  29939. /**
  29940. * Creates a new LinesMesh
  29941. * @param name defines the name
  29942. * @param scene defines the hosting scene
  29943. * @param parent defines the parent mesh if any
  29944. * @param source defines the optional source LinesMesh used to clone data from
  29945. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  29946. * When false, achieved by calling a clone(), also passing False.
  29947. * This will make creation of children, recursive.
  29948. * @param useVertexColor defines if this LinesMesh supports vertex color
  29949. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  29950. */
  29951. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  29952. /**
  29953. * If vertex color should be applied to the mesh
  29954. */
  29955. useVertexColor?: boolean | undefined,
  29956. /**
  29957. * If vertex alpha should be applied to the mesh
  29958. */
  29959. useVertexAlpha?: boolean | undefined);
  29960. private _addClipPlaneDefine;
  29961. private _removeClipPlaneDefine;
  29962. isReady(): boolean;
  29963. /**
  29964. * Returns the string "LineMesh"
  29965. */
  29966. getClassName(): string;
  29967. /**
  29968. * @hidden
  29969. */
  29970. get material(): Material;
  29971. /**
  29972. * @hidden
  29973. */
  29974. set material(value: Material);
  29975. /**
  29976. * @hidden
  29977. */
  29978. get checkCollisions(): boolean;
  29979. set checkCollisions(value: boolean);
  29980. /** @hidden */
  29981. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  29982. /** @hidden */
  29983. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  29984. /**
  29985. * Disposes of the line mesh
  29986. * @param doNotRecurse If children should be disposed
  29987. */
  29988. dispose(doNotRecurse?: boolean): void;
  29989. /**
  29990. * Returns a new LineMesh object cloned from the current one.
  29991. */
  29992. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  29993. /**
  29994. * Creates a new InstancedLinesMesh object from the mesh model.
  29995. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29996. * @param name defines the name of the new instance
  29997. * @returns a new InstancedLinesMesh
  29998. */
  29999. createInstance(name: string): InstancedLinesMesh;
  30000. }
  30001. /**
  30002. * Creates an instance based on a source LinesMesh
  30003. */
  30004. export class InstancedLinesMesh extends InstancedMesh {
  30005. /**
  30006. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  30007. * This margin is expressed in world space coordinates, so its value may vary.
  30008. * Initilized with the intersectionThreshold value of the source LinesMesh
  30009. */
  30010. intersectionThreshold: number;
  30011. constructor(name: string, source: LinesMesh);
  30012. /**
  30013. * Returns the string "InstancedLinesMesh".
  30014. */
  30015. getClassName(): string;
  30016. }
  30017. }
  30018. declare module "babylonjs/Shaders/line.fragment" {
  30019. /** @hidden */
  30020. export var linePixelShader: {
  30021. name: string;
  30022. shader: string;
  30023. };
  30024. }
  30025. declare module "babylonjs/Shaders/line.vertex" {
  30026. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  30027. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  30028. /** @hidden */
  30029. export var lineVertexShader: {
  30030. name: string;
  30031. shader: string;
  30032. };
  30033. }
  30034. declare module "babylonjs/Rendering/edgesRenderer" {
  30035. import { Immutable, Nullable } from "babylonjs/types";
  30036. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30037. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30038. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  30039. import { IDisposable } from "babylonjs/scene";
  30040. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  30041. import "babylonjs/Shaders/line.fragment";
  30042. import "babylonjs/Shaders/line.vertex";
  30043. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30044. import { SmartArray } from "babylonjs/Misc/smartArray";
  30045. module "babylonjs/scene" {
  30046. interface Scene {
  30047. /** @hidden */
  30048. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  30049. }
  30050. }
  30051. module "babylonjs/Meshes/abstractMesh" {
  30052. interface AbstractMesh {
  30053. /**
  30054. * Gets the edgesRenderer associated with the mesh
  30055. */
  30056. edgesRenderer: Nullable<EdgesRenderer>;
  30057. }
  30058. }
  30059. module "babylonjs/Meshes/linesMesh" {
  30060. interface LinesMesh {
  30061. /**
  30062. * Enables the edge rendering mode on the mesh.
  30063. * This mode makes the mesh edges visible
  30064. * @param epsilon defines the maximal distance between two angles to detect a face
  30065. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  30066. * @returns the currentAbstractMesh
  30067. * @see https://www.babylonjs-playground.com/#19O9TU#0
  30068. */
  30069. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  30070. }
  30071. }
  30072. module "babylonjs/Meshes/linesMesh" {
  30073. interface InstancedLinesMesh {
  30074. /**
  30075. * Enables the edge rendering mode on the mesh.
  30076. * This mode makes the mesh edges visible
  30077. * @param epsilon defines the maximal distance between two angles to detect a face
  30078. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  30079. * @returns the current InstancedLinesMesh
  30080. * @see https://www.babylonjs-playground.com/#19O9TU#0
  30081. */
  30082. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  30083. }
  30084. }
  30085. /**
  30086. * Defines the minimum contract an Edges renderer should follow.
  30087. */
  30088. export interface IEdgesRenderer extends IDisposable {
  30089. /**
  30090. * Gets or sets a boolean indicating if the edgesRenderer is active
  30091. */
  30092. isEnabled: boolean;
  30093. /**
  30094. * Renders the edges of the attached mesh,
  30095. */
  30096. render(): void;
  30097. /**
  30098. * Checks wether or not the edges renderer is ready to render.
  30099. * @return true if ready, otherwise false.
  30100. */
  30101. isReady(): boolean;
  30102. /**
  30103. * List of instances to render in case the source mesh has instances
  30104. */
  30105. customInstances: SmartArray<Matrix>;
  30106. }
  30107. /**
  30108. * Defines the additional options of the edges renderer
  30109. */
  30110. export interface IEdgesRendererOptions {
  30111. /**
  30112. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  30113. * If not defined, the default value is true
  30114. */
  30115. useAlternateEdgeFinder?: boolean;
  30116. /**
  30117. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  30118. * If not defined, the default value is true.
  30119. * 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)
  30120. * This option is used only if useAlternateEdgeFinder = true
  30121. */
  30122. useFastVertexMerger?: boolean;
  30123. /**
  30124. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  30125. * The default value is 1e-6
  30126. * This option is used only if useAlternateEdgeFinder = true
  30127. */
  30128. epsilonVertexMerge?: number;
  30129. /**
  30130. * 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
  30131. * 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.
  30132. * This option is used only if useAlternateEdgeFinder = true
  30133. */
  30134. applyTessellation?: boolean;
  30135. /**
  30136. * 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
  30137. * The default value is 1e-6
  30138. * This option is used only if useAlternateEdgeFinder = true
  30139. */
  30140. epsilonVertexAligned?: number;
  30141. }
  30142. /**
  30143. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  30144. */
  30145. export class EdgesRenderer implements IEdgesRenderer {
  30146. /**
  30147. * Define the size of the edges with an orthographic camera
  30148. */
  30149. edgesWidthScalerForOrthographic: number;
  30150. /**
  30151. * Define the size of the edges with a perspective camera
  30152. */
  30153. edgesWidthScalerForPerspective: number;
  30154. protected _source: AbstractMesh;
  30155. protected _linesPositions: number[];
  30156. protected _linesNormals: number[];
  30157. protected _linesIndices: number[];
  30158. protected _epsilon: number;
  30159. protected _indicesCount: number;
  30160. protected _lineShader: ShaderMaterial;
  30161. protected _ib: DataBuffer;
  30162. protected _buffers: {
  30163. [key: string]: Nullable<VertexBuffer>;
  30164. };
  30165. protected _buffersForInstances: {
  30166. [key: string]: Nullable<VertexBuffer>;
  30167. };
  30168. protected _checkVerticesInsteadOfIndices: boolean;
  30169. protected _options: Nullable<IEdgesRendererOptions>;
  30170. private _meshRebuildObserver;
  30171. private _meshDisposeObserver;
  30172. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  30173. isEnabled: boolean;
  30174. /** Gets the vertices generated by the edge renderer */
  30175. get linesPositions(): Immutable<Array<number>>;
  30176. /** Gets the normals generated by the edge renderer */
  30177. get linesNormals(): Immutable<Array<number>>;
  30178. /** Gets the indices generated by the edge renderer */
  30179. get linesIndices(): Immutable<Array<number>>;
  30180. /**
  30181. * List of instances to render in case the source mesh has instances
  30182. */
  30183. customInstances: SmartArray<Matrix>;
  30184. private static GetShader;
  30185. /**
  30186. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  30187. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  30188. * @param source Mesh used to create edges
  30189. * @param epsilon sum of angles in adjacency to check for edge
  30190. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  30191. * @param generateEdgesLines - should generate Lines or only prepare resources.
  30192. * @param options The options to apply when generating the edges
  30193. */
  30194. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  30195. protected _prepareRessources(): void;
  30196. /** @hidden */
  30197. _rebuild(): void;
  30198. /**
  30199. * Releases the required resources for the edges renderer
  30200. */
  30201. dispose(): void;
  30202. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  30203. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  30204. /**
  30205. * Checks if the pair of p0 and p1 is en edge
  30206. * @param faceIndex
  30207. * @param edge
  30208. * @param faceNormals
  30209. * @param p0
  30210. * @param p1
  30211. * @private
  30212. */
  30213. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  30214. /**
  30215. * push line into the position, normal and index buffer
  30216. * @protected
  30217. */
  30218. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  30219. /**
  30220. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  30221. */
  30222. private _tessellateTriangle;
  30223. private _generateEdgesLinesAlternate;
  30224. /**
  30225. * Generates lines edges from adjacencjes
  30226. * @private
  30227. */
  30228. _generateEdgesLines(): void;
  30229. /**
  30230. * Checks wether or not the edges renderer is ready to render.
  30231. * @return true if ready, otherwise false.
  30232. */
  30233. isReady(): boolean;
  30234. /**
  30235. * Renders the edges of the attached mesh,
  30236. */
  30237. render(): void;
  30238. }
  30239. /**
  30240. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  30241. */
  30242. export class LineEdgesRenderer extends EdgesRenderer {
  30243. /**
  30244. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  30245. * @param source LineMesh used to generate edges
  30246. * @param epsilon not important (specified angle for edge detection)
  30247. * @param checkVerticesInsteadOfIndices not important for LineMesh
  30248. */
  30249. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  30250. /**
  30251. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  30252. */
  30253. _generateEdgesLines(): void;
  30254. }
  30255. }
  30256. declare module "babylonjs/Rendering/renderingGroup" {
  30257. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  30258. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30259. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30260. import { Nullable } from "babylonjs/types";
  30261. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  30262. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  30263. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  30264. import { Material } from "babylonjs/Materials/material";
  30265. import { Scene } from "babylonjs/scene";
  30266. /**
  30267. * This represents the object necessary to create a rendering group.
  30268. * This is exclusively used and created by the rendering manager.
  30269. * To modify the behavior, you use the available helpers in your scene or meshes.
  30270. * @hidden
  30271. */
  30272. export class RenderingGroup {
  30273. index: number;
  30274. private static _zeroVector;
  30275. private _scene;
  30276. private _opaqueSubMeshes;
  30277. private _transparentSubMeshes;
  30278. private _alphaTestSubMeshes;
  30279. private _depthOnlySubMeshes;
  30280. private _particleSystems;
  30281. private _spriteManagers;
  30282. private _opaqueSortCompareFn;
  30283. private _alphaTestSortCompareFn;
  30284. private _transparentSortCompareFn;
  30285. private _renderOpaque;
  30286. private _renderAlphaTest;
  30287. private _renderTransparent;
  30288. /** @hidden */
  30289. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  30290. onBeforeTransparentRendering: () => void;
  30291. /**
  30292. * Set the opaque sort comparison function.
  30293. * If null the sub meshes will be render in the order they were created
  30294. */
  30295. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  30296. /**
  30297. * Set the alpha test sort comparison function.
  30298. * If null the sub meshes will be render in the order they were created
  30299. */
  30300. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  30301. /**
  30302. * Set the transparent sort comparison function.
  30303. * If null the sub meshes will be render in the order they were created
  30304. */
  30305. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  30306. /**
  30307. * Creates a new rendering group.
  30308. * @param index The rendering group index
  30309. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  30310. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  30311. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  30312. */
  30313. 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>);
  30314. /**
  30315. * Render all the sub meshes contained in the group.
  30316. * @param customRenderFunction Used to override the default render behaviour of the group.
  30317. * @returns true if rendered some submeshes.
  30318. */
  30319. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  30320. /**
  30321. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  30322. * @param subMeshes The submeshes to render
  30323. */
  30324. private renderOpaqueSorted;
  30325. /**
  30326. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  30327. * @param subMeshes The submeshes to render
  30328. */
  30329. private renderAlphaTestSorted;
  30330. /**
  30331. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  30332. * @param subMeshes The submeshes to render
  30333. */
  30334. private renderTransparentSorted;
  30335. /**
  30336. * Renders the submeshes in a specified order.
  30337. * @param subMeshes The submeshes to sort before render
  30338. * @param sortCompareFn The comparison function use to sort
  30339. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  30340. * @param transparent Specifies to activate blending if true
  30341. */
  30342. private static renderSorted;
  30343. /**
  30344. * Renders the submeshes in the order they were dispatched (no sort applied).
  30345. * @param subMeshes The submeshes to render
  30346. */
  30347. private static renderUnsorted;
  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 if in the same alpha index.
  30351. *
  30352. * @param a The first submesh
  30353. * @param b The second submesh
  30354. * @returns The result of the comparison
  30355. */
  30356. static defaultTransparentSortCompare(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 back to front.
  30360. *
  30361. * @param a The first submesh
  30362. * @param b The second submesh
  30363. * @returns The result of the comparison
  30364. */
  30365. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  30366. /**
  30367. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  30368. * are rendered front to back (prevent overdraw).
  30369. *
  30370. * @param a The first submesh
  30371. * @param b The second submesh
  30372. * @returns The result of the comparison
  30373. */
  30374. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  30375. /**
  30376. * Resets the different lists of submeshes to prepare a new frame.
  30377. */
  30378. prepare(): void;
  30379. dispose(): void;
  30380. /**
  30381. * Inserts the submesh in its correct queue depending on its material.
  30382. * @param subMesh The submesh to dispatch
  30383. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  30384. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  30385. */
  30386. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  30387. dispatchSprites(spriteManager: ISpriteManager): void;
  30388. dispatchParticles(particleSystem: IParticleSystem): void;
  30389. private _renderParticles;
  30390. private _renderSprites;
  30391. }
  30392. }
  30393. declare module "babylonjs/Rendering/renderingManager" {
  30394. import { Nullable } from "babylonjs/types";
  30395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30396. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30397. import { SmartArray } from "babylonjs/Misc/smartArray";
  30398. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  30399. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  30400. import { Material } from "babylonjs/Materials/material";
  30401. import { Scene } from "babylonjs/scene";
  30402. import { Camera } from "babylonjs/Cameras/camera";
  30403. /**
  30404. * Interface describing the different options available in the rendering manager
  30405. * regarding Auto Clear between groups.
  30406. */
  30407. export interface IRenderingManagerAutoClearSetup {
  30408. /**
  30409. * Defines whether or not autoclear is enable.
  30410. */
  30411. autoClear: boolean;
  30412. /**
  30413. * Defines whether or not to autoclear the depth buffer.
  30414. */
  30415. depth: boolean;
  30416. /**
  30417. * Defines whether or not to autoclear the stencil buffer.
  30418. */
  30419. stencil: boolean;
  30420. }
  30421. /**
  30422. * This class is used by the onRenderingGroupObservable
  30423. */
  30424. export class RenderingGroupInfo {
  30425. /**
  30426. * The Scene that being rendered
  30427. */
  30428. scene: Scene;
  30429. /**
  30430. * The camera currently used for the rendering pass
  30431. */
  30432. camera: Nullable<Camera>;
  30433. /**
  30434. * The ID of the renderingGroup being processed
  30435. */
  30436. renderingGroupId: number;
  30437. }
  30438. /**
  30439. * This is the manager responsible of all the rendering for meshes sprites and particles.
  30440. * It is enable to manage the different groups as well as the different necessary sort functions.
  30441. * This should not be used directly aside of the few static configurations
  30442. */
  30443. export class RenderingManager {
  30444. /**
  30445. * The max id used for rendering groups (not included)
  30446. */
  30447. static MAX_RENDERINGGROUPS: number;
  30448. /**
  30449. * The min id used for rendering groups (included)
  30450. */
  30451. static MIN_RENDERINGGROUPS: number;
  30452. /**
  30453. * Used to globally prevent autoclearing scenes.
  30454. */
  30455. static AUTOCLEAR: boolean;
  30456. /**
  30457. * @hidden
  30458. */
  30459. _useSceneAutoClearSetup: boolean;
  30460. private _scene;
  30461. private _renderingGroups;
  30462. private _depthStencilBufferAlreadyCleaned;
  30463. private _autoClearDepthStencil;
  30464. private _customOpaqueSortCompareFn;
  30465. private _customAlphaTestSortCompareFn;
  30466. private _customTransparentSortCompareFn;
  30467. private _renderingGroupInfo;
  30468. /**
  30469. * Instantiates a new rendering group for a particular scene
  30470. * @param scene Defines the scene the groups belongs to
  30471. */
  30472. constructor(scene: Scene);
  30473. private _clearDepthStencilBuffer;
  30474. /**
  30475. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  30476. * @hidden
  30477. */
  30478. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  30479. /**
  30480. * Resets the different information of the group to prepare a new frame
  30481. * @hidden
  30482. */
  30483. reset(): void;
  30484. /**
  30485. * Dispose and release the group and its associated resources.
  30486. * @hidden
  30487. */
  30488. dispose(): void;
  30489. /**
  30490. * Clear the info related to rendering groups preventing retention points during dispose.
  30491. */
  30492. freeRenderingGroups(): void;
  30493. private _prepareRenderingGroup;
  30494. /**
  30495. * Add a sprite manager to the rendering manager in order to render it this frame.
  30496. * @param spriteManager Define the sprite manager to render
  30497. */
  30498. dispatchSprites(spriteManager: ISpriteManager): void;
  30499. /**
  30500. * Add a particle system to the rendering manager in order to render it this frame.
  30501. * @param particleSystem Define the particle system to render
  30502. */
  30503. dispatchParticles(particleSystem: IParticleSystem): void;
  30504. /**
  30505. * Add a submesh to the manager in order to render it this frame
  30506. * @param subMesh The submesh to dispatch
  30507. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  30508. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  30509. */
  30510. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  30511. /**
  30512. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  30513. * This allowed control for front to back rendering or reversly depending of the special needs.
  30514. *
  30515. * @param renderingGroupId The rendering group id corresponding to its index
  30516. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  30517. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  30518. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  30519. */
  30520. 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;
  30521. /**
  30522. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  30523. *
  30524. * @param renderingGroupId The rendering group id corresponding to its index
  30525. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  30526. * @param depth Automatically clears depth between groups if true and autoClear is true.
  30527. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  30528. */
  30529. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  30530. /**
  30531. * Gets the current auto clear configuration for one rendering group of the rendering
  30532. * manager.
  30533. * @param index the rendering group index to get the information for
  30534. * @returns The auto clear setup for the requested rendering group
  30535. */
  30536. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  30537. }
  30538. }
  30539. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  30540. import { SmartArray } from "babylonjs/Misc/smartArray";
  30541. import { Nullable } from "babylonjs/types";
  30542. import { Scene } from "babylonjs/scene";
  30543. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  30544. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30545. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30546. import { Mesh } from "babylonjs/Meshes/mesh";
  30547. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  30548. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30549. import { Effect } from "babylonjs/Materials/effect";
  30550. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30551. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30552. import "babylonjs/Shaders/shadowMap.fragment";
  30553. import "babylonjs/Shaders/shadowMap.vertex";
  30554. import "babylonjs/Shaders/depthBoxBlur.fragment";
  30555. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  30556. import { Observable } from "babylonjs/Misc/observable";
  30557. /**
  30558. * Defines the options associated with the creation of a custom shader for a shadow generator.
  30559. */
  30560. export interface ICustomShaderOptions {
  30561. /**
  30562. * Gets or sets the custom shader name to use
  30563. */
  30564. shaderName: string;
  30565. /**
  30566. * The list of attribute names used in the shader
  30567. */
  30568. attributes?: string[];
  30569. /**
  30570. * The list of unifrom names used in the shader
  30571. */
  30572. uniforms?: string[];
  30573. /**
  30574. * The list of sampler names used in the shader
  30575. */
  30576. samplers?: string[];
  30577. /**
  30578. * The list of defines used in the shader
  30579. */
  30580. defines?: string[];
  30581. }
  30582. /**
  30583. * Interface to implement to create a shadow generator compatible with BJS.
  30584. */
  30585. export interface IShadowGenerator {
  30586. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  30587. id: string;
  30588. /**
  30589. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  30590. * @returns The render target texture if present otherwise, null
  30591. */
  30592. getShadowMap(): Nullable<RenderTargetTexture>;
  30593. /**
  30594. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  30595. * @param subMesh The submesh we want to render in the shadow map
  30596. * @param useInstances Defines wether will draw in the map using instances
  30597. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  30598. * @returns true if ready otherwise, false
  30599. */
  30600. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  30601. /**
  30602. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  30603. * @param defines Defines of the material we want to update
  30604. * @param lightIndex Index of the light in the enabled light list of the material
  30605. */
  30606. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  30607. /**
  30608. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  30609. * defined in the generator but impacting the effect).
  30610. * It implies the unifroms available on the materials are the standard BJS ones.
  30611. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  30612. * @param effect The effect we are binfing the information for
  30613. */
  30614. bindShadowLight(lightIndex: string, effect: Effect): void;
  30615. /**
  30616. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  30617. * (eq to shadow prjection matrix * light transform matrix)
  30618. * @returns The transform matrix used to create the shadow map
  30619. */
  30620. getTransformMatrix(): Matrix;
  30621. /**
  30622. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  30623. * Cube and 2D textures for instance.
  30624. */
  30625. recreateShadowMap(): void;
  30626. /**
  30627. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  30628. * @param onCompiled Callback triggered at the and of the effects compilation
  30629. * @param options Sets of optional options forcing the compilation with different modes
  30630. */
  30631. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  30632. useInstances: boolean;
  30633. }>): void;
  30634. /**
  30635. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  30636. * @param options Sets of optional options forcing the compilation with different modes
  30637. * @returns A promise that resolves when the compilation completes
  30638. */
  30639. forceCompilationAsync(options?: Partial<{
  30640. useInstances: boolean;
  30641. }>): Promise<void>;
  30642. /**
  30643. * Serializes the shadow generator setup to a json object.
  30644. * @returns The serialized JSON object
  30645. */
  30646. serialize(): any;
  30647. /**
  30648. * Disposes the Shadow map and related Textures and effects.
  30649. */
  30650. dispose(): void;
  30651. }
  30652. /**
  30653. * Default implementation IShadowGenerator.
  30654. * This is the main object responsible of generating shadows in the framework.
  30655. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  30656. */
  30657. export class ShadowGenerator implements IShadowGenerator {
  30658. private static _Counter;
  30659. /**
  30660. * Name of the shadow generator class
  30661. */
  30662. static CLASSNAME: string;
  30663. /**
  30664. * Shadow generator mode None: no filtering applied.
  30665. */
  30666. static readonly FILTER_NONE: number;
  30667. /**
  30668. * Shadow generator mode ESM: Exponential Shadow Mapping.
  30669. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30670. */
  30671. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  30672. /**
  30673. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  30674. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  30675. */
  30676. static readonly FILTER_POISSONSAMPLING: number;
  30677. /**
  30678. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  30679. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30680. */
  30681. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  30682. /**
  30683. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  30684. * edge artifacts on steep falloff.
  30685. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30686. */
  30687. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  30688. /**
  30689. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  30690. * edge artifacts on steep falloff.
  30691. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30692. */
  30693. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  30694. /**
  30695. * Shadow generator mode PCF: Percentage Closer Filtering
  30696. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  30697. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  30698. */
  30699. static readonly FILTER_PCF: number;
  30700. /**
  30701. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  30702. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  30703. * Contact Hardening
  30704. */
  30705. static readonly FILTER_PCSS: number;
  30706. /**
  30707. * Reserved for PCF and PCSS
  30708. * Highest Quality.
  30709. *
  30710. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  30711. *
  30712. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  30713. */
  30714. static readonly QUALITY_HIGH: number;
  30715. /**
  30716. * Reserved for PCF and PCSS
  30717. * Good tradeoff for quality/perf cross devices
  30718. *
  30719. * Execute PCF on a 3*3 kernel.
  30720. *
  30721. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  30722. */
  30723. static readonly QUALITY_MEDIUM: number;
  30724. /**
  30725. * Reserved for PCF and PCSS
  30726. * The lowest quality but the fastest.
  30727. *
  30728. * Execute PCF on a 1*1 kernel.
  30729. *
  30730. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  30731. */
  30732. static readonly QUALITY_LOW: number;
  30733. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  30734. id: string;
  30735. /** Gets or sets the custom shader name to use */
  30736. customShaderOptions: ICustomShaderOptions;
  30737. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  30738. customAllowRendering: (subMesh: SubMesh) => boolean;
  30739. /**
  30740. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  30741. */
  30742. onBeforeShadowMapRenderObservable: Observable<Effect>;
  30743. /**
  30744. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  30745. */
  30746. onAfterShadowMapRenderObservable: Observable<Effect>;
  30747. /**
  30748. * Observable triggered before a mesh is rendered in the shadow map.
  30749. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  30750. */
  30751. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  30752. /**
  30753. * Observable triggered after a mesh is rendered in the shadow map.
  30754. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  30755. */
  30756. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  30757. protected _bias: number;
  30758. /**
  30759. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  30760. */
  30761. get bias(): number;
  30762. /**
  30763. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  30764. */
  30765. set bias(bias: number);
  30766. protected _normalBias: number;
  30767. /**
  30768. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  30769. */
  30770. get normalBias(): number;
  30771. /**
  30772. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  30773. */
  30774. set normalBias(normalBias: number);
  30775. protected _blurBoxOffset: number;
  30776. /**
  30777. * Gets the blur box offset: offset applied during the blur pass.
  30778. * Only useful if useKernelBlur = false
  30779. */
  30780. get blurBoxOffset(): number;
  30781. /**
  30782. * Sets the blur box offset: offset applied during the blur pass.
  30783. * Only useful if useKernelBlur = false
  30784. */
  30785. set blurBoxOffset(value: number);
  30786. protected _blurScale: number;
  30787. /**
  30788. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  30789. * 2 means half of the size.
  30790. */
  30791. get blurScale(): number;
  30792. /**
  30793. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  30794. * 2 means half of the size.
  30795. */
  30796. set blurScale(value: number);
  30797. protected _blurKernel: number;
  30798. /**
  30799. * Gets the blur kernel: kernel size of the blur pass.
  30800. * Only useful if useKernelBlur = true
  30801. */
  30802. get blurKernel(): number;
  30803. /**
  30804. * Sets the blur kernel: kernel size of the blur pass.
  30805. * Only useful if useKernelBlur = true
  30806. */
  30807. set blurKernel(value: number);
  30808. protected _useKernelBlur: boolean;
  30809. /**
  30810. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  30811. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  30812. */
  30813. get useKernelBlur(): boolean;
  30814. /**
  30815. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  30816. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  30817. */
  30818. set useKernelBlur(value: boolean);
  30819. protected _depthScale: number;
  30820. /**
  30821. * Gets the depth scale used in ESM mode.
  30822. */
  30823. get depthScale(): number;
  30824. /**
  30825. * Sets the depth scale used in ESM mode.
  30826. * This can override the scale stored on the light.
  30827. */
  30828. set depthScale(value: number);
  30829. protected _validateFilter(filter: number): number;
  30830. protected _filter: number;
  30831. /**
  30832. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  30833. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  30834. */
  30835. get filter(): number;
  30836. /**
  30837. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  30838. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  30839. */
  30840. set filter(value: number);
  30841. /**
  30842. * Gets if the current filter is set to Poisson Sampling.
  30843. */
  30844. get usePoissonSampling(): boolean;
  30845. /**
  30846. * Sets the current filter to Poisson Sampling.
  30847. */
  30848. set usePoissonSampling(value: boolean);
  30849. /**
  30850. * Gets if the current filter is set to ESM.
  30851. */
  30852. get useExponentialShadowMap(): boolean;
  30853. /**
  30854. * Sets the current filter is to ESM.
  30855. */
  30856. set useExponentialShadowMap(value: boolean);
  30857. /**
  30858. * Gets if the current filter is set to filtered ESM.
  30859. */
  30860. get useBlurExponentialShadowMap(): boolean;
  30861. /**
  30862. * Gets if the current filter is set to filtered ESM.
  30863. */
  30864. set useBlurExponentialShadowMap(value: boolean);
  30865. /**
  30866. * Gets if the current filter is set to "close ESM" (using the inverse of the
  30867. * exponential to prevent steep falloff artifacts).
  30868. */
  30869. get useCloseExponentialShadowMap(): boolean;
  30870. /**
  30871. * Sets the current filter to "close ESM" (using the inverse of the
  30872. * exponential to prevent steep falloff artifacts).
  30873. */
  30874. set useCloseExponentialShadowMap(value: boolean);
  30875. /**
  30876. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  30877. * exponential to prevent steep falloff artifacts).
  30878. */
  30879. get useBlurCloseExponentialShadowMap(): boolean;
  30880. /**
  30881. * Sets the current filter to filtered "close ESM" (using the inverse of the
  30882. * exponential to prevent steep falloff artifacts).
  30883. */
  30884. set useBlurCloseExponentialShadowMap(value: boolean);
  30885. /**
  30886. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  30887. */
  30888. get usePercentageCloserFiltering(): boolean;
  30889. /**
  30890. * Sets the current filter to "PCF" (percentage closer filtering).
  30891. */
  30892. set usePercentageCloserFiltering(value: boolean);
  30893. protected _filteringQuality: number;
  30894. /**
  30895. * Gets the PCF or PCSS Quality.
  30896. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30897. */
  30898. get filteringQuality(): number;
  30899. /**
  30900. * Sets the PCF or PCSS Quality.
  30901. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30902. */
  30903. set filteringQuality(filteringQuality: number);
  30904. /**
  30905. * Gets if the current filter is set to "PCSS" (contact hardening).
  30906. */
  30907. get useContactHardeningShadow(): boolean;
  30908. /**
  30909. * Sets the current filter to "PCSS" (contact hardening).
  30910. */
  30911. set useContactHardeningShadow(value: boolean);
  30912. protected _contactHardeningLightSizeUVRatio: number;
  30913. /**
  30914. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  30915. * Using a ratio helps keeping shape stability independently of the map size.
  30916. *
  30917. * It does not account for the light projection as it was having too much
  30918. * instability during the light setup or during light position changes.
  30919. *
  30920. * Only valid if useContactHardeningShadow is true.
  30921. */
  30922. get contactHardeningLightSizeUVRatio(): number;
  30923. /**
  30924. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  30925. * Using a ratio helps keeping shape stability independently of the map size.
  30926. *
  30927. * It does not account for the light projection as it was having too much
  30928. * instability during the light setup or during light position changes.
  30929. *
  30930. * Only valid if useContactHardeningShadow is true.
  30931. */
  30932. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  30933. protected _darkness: number;
  30934. /** Gets or sets the actual darkness of a shadow */
  30935. get darkness(): number;
  30936. set darkness(value: number);
  30937. /**
  30938. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  30939. * 0 means strongest and 1 would means no shadow.
  30940. * @returns the darkness.
  30941. */
  30942. getDarkness(): number;
  30943. /**
  30944. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  30945. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  30946. * @returns the shadow generator allowing fluent coding.
  30947. */
  30948. setDarkness(darkness: number): ShadowGenerator;
  30949. protected _transparencyShadow: boolean;
  30950. /** Gets or sets the ability to have transparent shadow */
  30951. get transparencyShadow(): boolean;
  30952. set transparencyShadow(value: boolean);
  30953. /**
  30954. * Sets the ability to have transparent shadow (boolean).
  30955. * @param transparent True if transparent else False
  30956. * @returns the shadow generator allowing fluent coding
  30957. */
  30958. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  30959. /**
  30960. * Enables or disables shadows with varying strength based on the transparency
  30961. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  30962. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  30963. * mesh.visibility * alphaTexture.a
  30964. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  30965. */
  30966. enableSoftTransparentShadow: boolean;
  30967. protected _shadowMap: Nullable<RenderTargetTexture>;
  30968. protected _shadowMap2: Nullable<RenderTargetTexture>;
  30969. /**
  30970. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  30971. * @returns The render target texture if present otherwise, null
  30972. */
  30973. getShadowMap(): Nullable<RenderTargetTexture>;
  30974. /**
  30975. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  30976. * @returns The render target texture if the shadow map is present otherwise, null
  30977. */
  30978. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  30979. /**
  30980. * Gets the class name of that object
  30981. * @returns "ShadowGenerator"
  30982. */
  30983. getClassName(): string;
  30984. /**
  30985. * Helper function to add a mesh and its descendants to the list of shadow casters.
  30986. * @param mesh Mesh to add
  30987. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  30988. * @returns the Shadow Generator itself
  30989. */
  30990. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  30991. /**
  30992. * Helper function to remove a mesh and its descendants from the list of shadow casters
  30993. * @param mesh Mesh to remove
  30994. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  30995. * @returns the Shadow Generator itself
  30996. */
  30997. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  30998. /**
  30999. * Controls the extent to which the shadows fade out at the edge of the frustum
  31000. */
  31001. frustumEdgeFalloff: number;
  31002. protected _light: IShadowLight;
  31003. /**
  31004. * Returns the associated light object.
  31005. * @returns the light generating the shadow
  31006. */
  31007. getLight(): IShadowLight;
  31008. /**
  31009. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  31010. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  31011. * It might on the other hand introduce peter panning.
  31012. */
  31013. forceBackFacesOnly: boolean;
  31014. protected _scene: Scene;
  31015. protected _lightDirection: Vector3;
  31016. protected _viewMatrix: Matrix;
  31017. protected _projectionMatrix: Matrix;
  31018. protected _transformMatrix: Matrix;
  31019. protected _cachedPosition: Vector3;
  31020. protected _cachedDirection: Vector3;
  31021. protected _cachedDefines: string;
  31022. protected _currentRenderID: number;
  31023. protected _boxBlurPostprocess: Nullable<PostProcess>;
  31024. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  31025. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  31026. protected _blurPostProcesses: PostProcess[];
  31027. protected _mapSize: number;
  31028. protected _currentFaceIndex: number;
  31029. protected _currentFaceIndexCache: number;
  31030. protected _textureType: number;
  31031. protected _defaultTextureMatrix: Matrix;
  31032. protected _storedUniqueId: Nullable<number>;
  31033. protected _nameForCustomEffect: string;
  31034. /** @hidden */
  31035. static _SceneComponentInitialization: (scene: Scene) => void;
  31036. /**
  31037. * Gets or sets the size of the texture what stores the shadows
  31038. */
  31039. get mapSize(): number;
  31040. set mapSize(size: number);
  31041. /**
  31042. * Creates a ShadowGenerator object.
  31043. * A ShadowGenerator is the required tool to use the shadows.
  31044. * Each light casting shadows needs to use its own ShadowGenerator.
  31045. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  31046. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  31047. * @param light The light object generating the shadows.
  31048. * @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.
  31049. */
  31050. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  31051. protected _initializeGenerator(): void;
  31052. protected _createTargetRenderTexture(): void;
  31053. protected _initializeShadowMap(): void;
  31054. protected _initializeBlurRTTAndPostProcesses(): void;
  31055. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  31056. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  31057. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  31058. protected _applyFilterValues(): void;
  31059. /**
  31060. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  31061. * @param onCompiled Callback triggered at the and of the effects compilation
  31062. * @param options Sets of optional options forcing the compilation with different modes
  31063. */
  31064. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  31065. useInstances: boolean;
  31066. }>): void;
  31067. /**
  31068. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  31069. * @param options Sets of optional options forcing the compilation with different modes
  31070. * @returns A promise that resolves when the compilation completes
  31071. */
  31072. forceCompilationAsync(options?: Partial<{
  31073. useInstances: boolean;
  31074. }>): Promise<void>;
  31075. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  31076. private _prepareShadowDefines;
  31077. /**
  31078. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  31079. * @param subMesh The submesh we want to render in the shadow map
  31080. * @param useInstances Defines wether will draw in the map using instances
  31081. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  31082. * @returns true if ready otherwise, false
  31083. */
  31084. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  31085. /**
  31086. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  31087. * @param defines Defines of the material we want to update
  31088. * @param lightIndex Index of the light in the enabled light list of the material
  31089. */
  31090. prepareDefines(defines: any, lightIndex: number): void;
  31091. /**
  31092. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  31093. * defined in the generator but impacting the effect).
  31094. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  31095. * @param effect The effect we are binfing the information for
  31096. */
  31097. bindShadowLight(lightIndex: string, effect: Effect): void;
  31098. /**
  31099. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  31100. * (eq to shadow prjection matrix * light transform matrix)
  31101. * @returns The transform matrix used to create the shadow map
  31102. */
  31103. getTransformMatrix(): Matrix;
  31104. /**
  31105. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  31106. * Cube and 2D textures for instance.
  31107. */
  31108. recreateShadowMap(): void;
  31109. protected _disposeBlurPostProcesses(): void;
  31110. protected _disposeRTTandPostProcesses(): void;
  31111. /**
  31112. * Disposes the ShadowGenerator.
  31113. * Returns nothing.
  31114. */
  31115. dispose(): void;
  31116. /**
  31117. * Serializes the shadow generator setup to a json object.
  31118. * @returns The serialized JSON object
  31119. */
  31120. serialize(): any;
  31121. /**
  31122. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  31123. * @param parsedShadowGenerator The JSON object to parse
  31124. * @param scene The scene to create the shadow map for
  31125. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  31126. * @returns The parsed shadow generator
  31127. */
  31128. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  31129. }
  31130. }
  31131. declare module "babylonjs/Materials/shadowDepthWrapper" {
  31132. import { Nullable } from "babylonjs/types";
  31133. import { Scene } from "babylonjs/scene";
  31134. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31135. import { Material } from "babylonjs/Materials/material";
  31136. import { Effect } from "babylonjs/Materials/effect";
  31137. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  31138. /**
  31139. * Options to be used when creating a shadow depth material
  31140. */
  31141. export interface IIOptionShadowDepthMaterial {
  31142. /** Variables in the vertex shader code that need to have their names remapped.
  31143. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  31144. * "var_name" should be either: worldPos or vNormalW
  31145. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  31146. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  31147. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  31148. */
  31149. remappedVariables?: string[];
  31150. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  31151. standalone?: boolean;
  31152. }
  31153. /**
  31154. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  31155. */
  31156. export class ShadowDepthWrapper {
  31157. private _scene;
  31158. private _options?;
  31159. private _baseMaterial;
  31160. private _onEffectCreatedObserver;
  31161. private _subMeshToEffect;
  31162. private _subMeshToDepthEffect;
  31163. private _meshes;
  31164. /** @hidden */
  31165. _matriceNames: any;
  31166. /** Gets the standalone status of the wrapper */
  31167. get standalone(): boolean;
  31168. /** Gets the base material the wrapper is built upon */
  31169. get baseMaterial(): Material;
  31170. /**
  31171. * Instantiate a new shadow depth wrapper.
  31172. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  31173. * generate the shadow depth map. For more information, please refer to the documentation:
  31174. * https://doc.babylonjs.com/babylon101/shadows
  31175. * @param baseMaterial Material to wrap
  31176. * @param scene Define the scene the material belongs to
  31177. * @param options Options used to create the wrapper
  31178. */
  31179. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  31180. /**
  31181. * Gets the effect to use to generate the depth map
  31182. * @param subMesh subMesh to get the effect for
  31183. * @param shadowGenerator shadow generator to get the effect for
  31184. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  31185. */
  31186. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  31187. /**
  31188. * Specifies that the submesh is ready to be used for depth rendering
  31189. * @param subMesh submesh to check
  31190. * @param defines the list of defines to take into account when checking the effect
  31191. * @param shadowGenerator combined with subMesh, it defines the effect to check
  31192. * @param useInstances specifies that instances should be used
  31193. * @returns a boolean indicating that the submesh is ready or not
  31194. */
  31195. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  31196. /**
  31197. * Disposes the resources
  31198. */
  31199. dispose(): void;
  31200. private _makeEffect;
  31201. }
  31202. }
  31203. declare module "babylonjs/Materials/material" {
  31204. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31205. import { SmartArray } from "babylonjs/Misc/smartArray";
  31206. import { Observable } from "babylonjs/Misc/observable";
  31207. import { Nullable } from "babylonjs/types";
  31208. import { Matrix } from "babylonjs/Maths/math.vector";
  31209. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31210. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31211. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31212. import { Effect } from "babylonjs/Materials/effect";
  31213. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31214. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31215. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  31216. import { IInspectable } from "babylonjs/Misc/iInspectable";
  31217. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  31218. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  31219. import { Mesh } from "babylonjs/Meshes/mesh";
  31220. import { Animation } from "babylonjs/Animations/animation";
  31221. import { Scene } from "babylonjs/scene";
  31222. /**
  31223. * Options for compiling materials.
  31224. */
  31225. export interface IMaterialCompilationOptions {
  31226. /**
  31227. * Defines whether clip planes are enabled.
  31228. */
  31229. clipPlane: boolean;
  31230. /**
  31231. * Defines whether instances are enabled.
  31232. */
  31233. useInstances: boolean;
  31234. }
  31235. /**
  31236. * Options passed when calling customShaderNameResolve
  31237. */
  31238. export interface ICustomShaderNameResolveOptions {
  31239. /**
  31240. * 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
  31241. */
  31242. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  31243. }
  31244. /**
  31245. * Base class for the main features of a material in Babylon.js
  31246. */
  31247. export class Material implements IAnimatable {
  31248. /**
  31249. * Returns the triangle fill mode
  31250. */
  31251. static readonly TriangleFillMode: number;
  31252. /**
  31253. * Returns the wireframe mode
  31254. */
  31255. static readonly WireFrameFillMode: number;
  31256. /**
  31257. * Returns the point fill mode
  31258. */
  31259. static readonly PointFillMode: number;
  31260. /**
  31261. * Returns the point list draw mode
  31262. */
  31263. static readonly PointListDrawMode: number;
  31264. /**
  31265. * Returns the line list draw mode
  31266. */
  31267. static readonly LineListDrawMode: number;
  31268. /**
  31269. * Returns the line loop draw mode
  31270. */
  31271. static readonly LineLoopDrawMode: number;
  31272. /**
  31273. * Returns the line strip draw mode
  31274. */
  31275. static readonly LineStripDrawMode: number;
  31276. /**
  31277. * Returns the triangle strip draw mode
  31278. */
  31279. static readonly TriangleStripDrawMode: number;
  31280. /**
  31281. * Returns the triangle fan draw mode
  31282. */
  31283. static readonly TriangleFanDrawMode: number;
  31284. /**
  31285. * Stores the clock-wise side orientation
  31286. */
  31287. static readonly ClockWiseSideOrientation: number;
  31288. /**
  31289. * Stores the counter clock-wise side orientation
  31290. */
  31291. static readonly CounterClockWiseSideOrientation: number;
  31292. /**
  31293. * The dirty texture flag value
  31294. */
  31295. static readonly TextureDirtyFlag: number;
  31296. /**
  31297. * The dirty light flag value
  31298. */
  31299. static readonly LightDirtyFlag: number;
  31300. /**
  31301. * The dirty fresnel flag value
  31302. */
  31303. static readonly FresnelDirtyFlag: number;
  31304. /**
  31305. * The dirty attribute flag value
  31306. */
  31307. static readonly AttributesDirtyFlag: number;
  31308. /**
  31309. * The dirty misc flag value
  31310. */
  31311. static readonly MiscDirtyFlag: number;
  31312. /**
  31313. * The dirty prepass flag value
  31314. */
  31315. static readonly PrePassDirtyFlag: number;
  31316. /**
  31317. * The all dirty flag value
  31318. */
  31319. static readonly AllDirtyFlag: number;
  31320. /**
  31321. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  31322. */
  31323. static readonly MATERIAL_OPAQUE: number;
  31324. /**
  31325. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  31326. */
  31327. static readonly MATERIAL_ALPHATEST: number;
  31328. /**
  31329. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  31330. */
  31331. static readonly MATERIAL_ALPHABLEND: number;
  31332. /**
  31333. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  31334. * They are also discarded below the alpha cutoff threshold to improve performances.
  31335. */
  31336. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  31337. /**
  31338. * The Whiteout method is used to blend normals.
  31339. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  31340. */
  31341. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  31342. /**
  31343. * The Reoriented Normal Mapping method is used to blend normals.
  31344. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  31345. */
  31346. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  31347. /**
  31348. * Custom callback helping to override the default shader used in the material.
  31349. */
  31350. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  31351. /**
  31352. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  31353. */
  31354. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  31355. /**
  31356. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  31357. * This means that the material can keep using a previous shader while a new one is being compiled.
  31358. * This is mostly used when shader parallel compilation is supported (true by default)
  31359. */
  31360. allowShaderHotSwapping: boolean;
  31361. /**
  31362. * The ID of the material
  31363. */
  31364. id: string;
  31365. /**
  31366. * Gets or sets the unique id of the material
  31367. */
  31368. uniqueId: number;
  31369. /**
  31370. * The name of the material
  31371. */
  31372. name: string;
  31373. /**
  31374. * Gets or sets user defined metadata
  31375. */
  31376. metadata: any;
  31377. /**
  31378. * For internal use only. Please do not use.
  31379. */
  31380. reservedDataStore: any;
  31381. /**
  31382. * Specifies if the ready state should be checked on each call
  31383. */
  31384. checkReadyOnEveryCall: boolean;
  31385. /**
  31386. * Specifies if the ready state should be checked once
  31387. */
  31388. checkReadyOnlyOnce: boolean;
  31389. /**
  31390. * The state of the material
  31391. */
  31392. state: string;
  31393. /**
  31394. * If the material can be rendered to several textures with MRT extension
  31395. */
  31396. get canRenderToMRT(): boolean;
  31397. /**
  31398. * The alpha value of the material
  31399. */
  31400. protected _alpha: number;
  31401. /**
  31402. * List of inspectable custom properties (used by the Inspector)
  31403. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  31404. */
  31405. inspectableCustomProperties: IInspectable[];
  31406. /**
  31407. * Sets the alpha value of the material
  31408. */
  31409. set alpha(value: number);
  31410. /**
  31411. * Gets the alpha value of the material
  31412. */
  31413. get alpha(): number;
  31414. /**
  31415. * Specifies if back face culling is enabled
  31416. */
  31417. protected _backFaceCulling: boolean;
  31418. /**
  31419. * Sets the back-face culling state
  31420. */
  31421. set backFaceCulling(value: boolean);
  31422. /**
  31423. * Gets the back-face culling state
  31424. */
  31425. get backFaceCulling(): boolean;
  31426. /**
  31427. * Stores the value for side orientation
  31428. */
  31429. sideOrientation: number;
  31430. /**
  31431. * Callback triggered when the material is compiled
  31432. */
  31433. onCompiled: Nullable<(effect: Effect) => void>;
  31434. /**
  31435. * Callback triggered when an error occurs
  31436. */
  31437. onError: Nullable<(effect: Effect, errors: string) => void>;
  31438. /**
  31439. * Callback triggered to get the render target textures
  31440. */
  31441. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  31442. /**
  31443. * Gets a boolean indicating that current material needs to register RTT
  31444. */
  31445. get hasRenderTargetTextures(): boolean;
  31446. /**
  31447. * Specifies if the material should be serialized
  31448. */
  31449. doNotSerialize: boolean;
  31450. /**
  31451. * @hidden
  31452. */
  31453. _storeEffectOnSubMeshes: boolean;
  31454. /**
  31455. * Stores the animations for the material
  31456. */
  31457. animations: Nullable<Array<Animation>>;
  31458. /**
  31459. * An event triggered when the material is disposed
  31460. */
  31461. onDisposeObservable: Observable<Material>;
  31462. /**
  31463. * An observer which watches for dispose events
  31464. */
  31465. private _onDisposeObserver;
  31466. private _onUnBindObservable;
  31467. /**
  31468. * Called during a dispose event
  31469. */
  31470. set onDispose(callback: () => void);
  31471. private _onBindObservable;
  31472. /**
  31473. * An event triggered when the material is bound
  31474. */
  31475. get onBindObservable(): Observable<AbstractMesh>;
  31476. /**
  31477. * An observer which watches for bind events
  31478. */
  31479. private _onBindObserver;
  31480. /**
  31481. * Called during a bind event
  31482. */
  31483. set onBind(callback: (Mesh: AbstractMesh) => void);
  31484. /**
  31485. * An event triggered when the material is unbound
  31486. */
  31487. get onUnBindObservable(): Observable<Material>;
  31488. protected _onEffectCreatedObservable: Nullable<Observable<{
  31489. effect: Effect;
  31490. subMesh: Nullable<SubMesh>;
  31491. }>>;
  31492. /**
  31493. * An event triggered when the effect is (re)created
  31494. */
  31495. get onEffectCreatedObservable(): Observable<{
  31496. effect: Effect;
  31497. subMesh: Nullable<SubMesh>;
  31498. }>;
  31499. /**
  31500. * Stores the value of the alpha mode
  31501. */
  31502. private _alphaMode;
  31503. /**
  31504. * Sets the value of the alpha mode.
  31505. *
  31506. * | Value | Type | Description |
  31507. * | --- | --- | --- |
  31508. * | 0 | ALPHA_DISABLE | |
  31509. * | 1 | ALPHA_ADD | |
  31510. * | 2 | ALPHA_COMBINE | |
  31511. * | 3 | ALPHA_SUBTRACT | |
  31512. * | 4 | ALPHA_MULTIPLY | |
  31513. * | 5 | ALPHA_MAXIMIZED | |
  31514. * | 6 | ALPHA_ONEONE | |
  31515. * | 7 | ALPHA_PREMULTIPLIED | |
  31516. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  31517. * | 9 | ALPHA_INTERPOLATE | |
  31518. * | 10 | ALPHA_SCREENMODE | |
  31519. *
  31520. */
  31521. set alphaMode(value: number);
  31522. /**
  31523. * Gets the value of the alpha mode
  31524. */
  31525. get alphaMode(): number;
  31526. /**
  31527. * Stores the state of the need depth pre-pass value
  31528. */
  31529. private _needDepthPrePass;
  31530. /**
  31531. * Sets the need depth pre-pass value
  31532. */
  31533. set needDepthPrePass(value: boolean);
  31534. /**
  31535. * Gets the depth pre-pass value
  31536. */
  31537. get needDepthPrePass(): boolean;
  31538. /**
  31539. * Specifies if depth writing should be disabled
  31540. */
  31541. disableDepthWrite: boolean;
  31542. /**
  31543. * Specifies if color writing should be disabled
  31544. */
  31545. disableColorWrite: boolean;
  31546. /**
  31547. * Specifies if depth writing should be forced
  31548. */
  31549. forceDepthWrite: boolean;
  31550. /**
  31551. * Specifies the depth function that should be used. 0 means the default engine function
  31552. */
  31553. depthFunction: number;
  31554. /**
  31555. * Specifies if there should be a separate pass for culling
  31556. */
  31557. separateCullingPass: boolean;
  31558. /**
  31559. * Stores the state specifing if fog should be enabled
  31560. */
  31561. private _fogEnabled;
  31562. /**
  31563. * Sets the state for enabling fog
  31564. */
  31565. set fogEnabled(value: boolean);
  31566. /**
  31567. * Gets the value of the fog enabled state
  31568. */
  31569. get fogEnabled(): boolean;
  31570. /**
  31571. * Stores the size of points
  31572. */
  31573. pointSize: number;
  31574. /**
  31575. * Stores the z offset value
  31576. */
  31577. zOffset: number;
  31578. get wireframe(): boolean;
  31579. /**
  31580. * Sets the state of wireframe mode
  31581. */
  31582. set wireframe(value: boolean);
  31583. /**
  31584. * Gets the value specifying if point clouds are enabled
  31585. */
  31586. get pointsCloud(): boolean;
  31587. /**
  31588. * Sets the state of point cloud mode
  31589. */
  31590. set pointsCloud(value: boolean);
  31591. /**
  31592. * Gets the material fill mode
  31593. */
  31594. get fillMode(): number;
  31595. /**
  31596. * Sets the material fill mode
  31597. */
  31598. set fillMode(value: number);
  31599. /**
  31600. * @hidden
  31601. * Stores the effects for the material
  31602. */
  31603. _effect: Nullable<Effect>;
  31604. /**
  31605. * Specifies if uniform buffers should be used
  31606. */
  31607. private _useUBO;
  31608. /**
  31609. * Stores a reference to the scene
  31610. */
  31611. private _scene;
  31612. private _needToBindSceneUbo;
  31613. /**
  31614. * Stores the fill mode state
  31615. */
  31616. private _fillMode;
  31617. /**
  31618. * Specifies if the depth write state should be cached
  31619. */
  31620. private _cachedDepthWriteState;
  31621. /**
  31622. * Specifies if the color write state should be cached
  31623. */
  31624. private _cachedColorWriteState;
  31625. /**
  31626. * Specifies if the depth function state should be cached
  31627. */
  31628. private _cachedDepthFunctionState;
  31629. /**
  31630. * Stores the uniform buffer
  31631. */
  31632. protected _uniformBuffer: UniformBuffer;
  31633. /** @hidden */
  31634. _indexInSceneMaterialArray: number;
  31635. /** @hidden */
  31636. meshMap: Nullable<{
  31637. [id: string]: AbstractMesh | undefined;
  31638. }>;
  31639. /**
  31640. * Creates a material instance
  31641. * @param name defines the name of the material
  31642. * @param scene defines the scene to reference
  31643. * @param doNotAdd specifies if the material should be added to the scene
  31644. */
  31645. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  31646. /**
  31647. * Returns a string representation of the current material
  31648. * @param fullDetails defines a boolean indicating which levels of logging is desired
  31649. * @returns a string with material information
  31650. */
  31651. toString(fullDetails?: boolean): string;
  31652. /**
  31653. * Gets the class name of the material
  31654. * @returns a string with the class name of the material
  31655. */
  31656. getClassName(): string;
  31657. /**
  31658. * Specifies if updates for the material been locked
  31659. */
  31660. get isFrozen(): boolean;
  31661. /**
  31662. * Locks updates for the material
  31663. */
  31664. freeze(): void;
  31665. /**
  31666. * Unlocks updates for the material
  31667. */
  31668. unfreeze(): void;
  31669. /**
  31670. * Specifies if the material is ready to be used
  31671. * @param mesh defines the mesh to check
  31672. * @param useInstances specifies if instances should be used
  31673. * @returns a boolean indicating if the material is ready to be used
  31674. */
  31675. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  31676. /**
  31677. * Specifies that the submesh is ready to be used
  31678. * @param mesh defines the mesh to check
  31679. * @param subMesh defines which submesh to check
  31680. * @param useInstances specifies that instances should be used
  31681. * @returns a boolean indicating that the submesh is ready or not
  31682. */
  31683. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31684. /**
  31685. * Returns the material effect
  31686. * @returns the effect associated with the material
  31687. */
  31688. getEffect(): Nullable<Effect>;
  31689. /**
  31690. * Returns the current scene
  31691. * @returns a Scene
  31692. */
  31693. getScene(): Scene;
  31694. /**
  31695. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  31696. */
  31697. protected _forceAlphaTest: boolean;
  31698. /**
  31699. * The transparency mode of the material.
  31700. */
  31701. protected _transparencyMode: Nullable<number>;
  31702. /**
  31703. * Gets the current transparency mode.
  31704. */
  31705. get transparencyMode(): Nullable<number>;
  31706. /**
  31707. * Sets the transparency mode of the material.
  31708. *
  31709. * | Value | Type | Description |
  31710. * | ----- | ----------------------------------- | ----------- |
  31711. * | 0 | OPAQUE | |
  31712. * | 1 | ALPHATEST | |
  31713. * | 2 | ALPHABLEND | |
  31714. * | 3 | ALPHATESTANDBLEND | |
  31715. *
  31716. */
  31717. set transparencyMode(value: Nullable<number>);
  31718. /**
  31719. * Returns true if alpha blending should be disabled.
  31720. */
  31721. protected get _disableAlphaBlending(): boolean;
  31722. /**
  31723. * Specifies whether or not this material should be rendered in alpha blend mode.
  31724. * @returns a boolean specifying if alpha blending is needed
  31725. */
  31726. needAlphaBlending(): boolean;
  31727. /**
  31728. * Specifies if the mesh will require alpha blending
  31729. * @param mesh defines the mesh to check
  31730. * @returns a boolean specifying if alpha blending is needed for the mesh
  31731. */
  31732. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  31733. /**
  31734. * Specifies whether or not this material should be rendered in alpha test mode.
  31735. * @returns a boolean specifying if an alpha test is needed.
  31736. */
  31737. needAlphaTesting(): boolean;
  31738. /**
  31739. * Specifies if material alpha testing should be turned on for the mesh
  31740. * @param mesh defines the mesh to check
  31741. */
  31742. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  31743. /**
  31744. * Gets the texture used for the alpha test
  31745. * @returns the texture to use for alpha testing
  31746. */
  31747. getAlphaTestTexture(): Nullable<BaseTexture>;
  31748. /**
  31749. * Marks the material to indicate that it needs to be re-calculated
  31750. */
  31751. markDirty(): void;
  31752. /** @hidden */
  31753. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  31754. /**
  31755. * Binds the material to the mesh
  31756. * @param world defines the world transformation matrix
  31757. * @param mesh defines the mesh to bind the material to
  31758. */
  31759. bind(world: Matrix, mesh?: Mesh): void;
  31760. /**
  31761. * Binds the submesh to the material
  31762. * @param world defines the world transformation matrix
  31763. * @param mesh defines the mesh containing the submesh
  31764. * @param subMesh defines the submesh to bind the material to
  31765. */
  31766. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  31767. /**
  31768. * Binds the world matrix to the material
  31769. * @param world defines the world transformation matrix
  31770. */
  31771. bindOnlyWorldMatrix(world: Matrix): void;
  31772. /**
  31773. * Update the scene ubo before it can be used in rendering processing
  31774. * @param scene the scene to retrieve the ubo from
  31775. * @returns the scene UniformBuffer
  31776. */
  31777. finalizeSceneUbo(scene: Scene): UniformBuffer;
  31778. /**
  31779. * Binds the scene's uniform buffer to the effect.
  31780. * @param effect defines the effect to bind to the scene uniform buffer
  31781. * @param sceneUbo defines the uniform buffer storing scene data
  31782. */
  31783. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  31784. /**
  31785. * Binds the view matrix to the effect
  31786. * @param effect defines the effect to bind the view matrix to
  31787. */
  31788. bindView(effect: Effect): void;
  31789. /**
  31790. * Binds the view projection and projection matrices to the effect
  31791. * @param effect defines the effect to bind the view projection and projection matrices to
  31792. */
  31793. bindViewProjection(effect: Effect): void;
  31794. /**
  31795. * Binds the view matrix to the effect
  31796. * @param effect defines the effect to bind the view matrix to
  31797. * @param variableName name of the shader variable that will hold the eye position
  31798. */
  31799. bindEyePosition(effect: Effect, variableName?: string): void;
  31800. /**
  31801. * Processes to execute after binding the material to a mesh
  31802. * @param mesh defines the rendered mesh
  31803. */
  31804. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  31805. /**
  31806. * Unbinds the material from the mesh
  31807. */
  31808. unbind(): void;
  31809. /**
  31810. * Gets the active textures from the material
  31811. * @returns an array of textures
  31812. */
  31813. getActiveTextures(): BaseTexture[];
  31814. /**
  31815. * Specifies if the material uses a texture
  31816. * @param texture defines the texture to check against the material
  31817. * @returns a boolean specifying if the material uses the texture
  31818. */
  31819. hasTexture(texture: BaseTexture): boolean;
  31820. /**
  31821. * Makes a duplicate of the material, and gives it a new name
  31822. * @param name defines the new name for the duplicated material
  31823. * @returns the cloned material
  31824. */
  31825. clone(name: string): Nullable<Material>;
  31826. /**
  31827. * Gets the meshes bound to the material
  31828. * @returns an array of meshes bound to the material
  31829. */
  31830. getBindedMeshes(): AbstractMesh[];
  31831. /**
  31832. * Force shader compilation
  31833. * @param mesh defines the mesh associated with this material
  31834. * @param onCompiled defines a function to execute once the material is compiled
  31835. * @param options defines the options to configure the compilation
  31836. * @param onError defines a function to execute if the material fails compiling
  31837. */
  31838. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  31839. /**
  31840. * Force shader compilation
  31841. * @param mesh defines the mesh that will use this material
  31842. * @param options defines additional options for compiling the shaders
  31843. * @returns a promise that resolves when the compilation completes
  31844. */
  31845. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  31846. private static readonly _AllDirtyCallBack;
  31847. private static readonly _ImageProcessingDirtyCallBack;
  31848. private static readonly _TextureDirtyCallBack;
  31849. private static readonly _FresnelDirtyCallBack;
  31850. private static readonly _MiscDirtyCallBack;
  31851. private static readonly _PrePassDirtyCallBack;
  31852. private static readonly _LightsDirtyCallBack;
  31853. private static readonly _AttributeDirtyCallBack;
  31854. private static _FresnelAndMiscDirtyCallBack;
  31855. private static _TextureAndMiscDirtyCallBack;
  31856. private static readonly _DirtyCallbackArray;
  31857. private static readonly _RunDirtyCallBacks;
  31858. /**
  31859. * Marks a define in the material to indicate that it needs to be re-computed
  31860. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  31861. */
  31862. markAsDirty(flag: number): void;
  31863. /**
  31864. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  31865. * @param func defines a function which checks material defines against the submeshes
  31866. */
  31867. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  31868. /**
  31869. * Indicates that the scene should check if the rendering now needs a prepass
  31870. */
  31871. protected _markScenePrePassDirty(): void;
  31872. /**
  31873. * Indicates that we need to re-calculated for all submeshes
  31874. */
  31875. protected _markAllSubMeshesAsAllDirty(): void;
  31876. /**
  31877. * Indicates that image processing needs to be re-calculated for all submeshes
  31878. */
  31879. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  31880. /**
  31881. * Indicates that textures need to be re-calculated for all submeshes
  31882. */
  31883. protected _markAllSubMeshesAsTexturesDirty(): void;
  31884. /**
  31885. * Indicates that fresnel needs to be re-calculated for all submeshes
  31886. */
  31887. protected _markAllSubMeshesAsFresnelDirty(): void;
  31888. /**
  31889. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  31890. */
  31891. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  31892. /**
  31893. * Indicates that lights need to be re-calculated for all submeshes
  31894. */
  31895. protected _markAllSubMeshesAsLightsDirty(): void;
  31896. /**
  31897. * Indicates that attributes need to be re-calculated for all submeshes
  31898. */
  31899. protected _markAllSubMeshesAsAttributesDirty(): void;
  31900. /**
  31901. * Indicates that misc needs to be re-calculated for all submeshes
  31902. */
  31903. protected _markAllSubMeshesAsMiscDirty(): void;
  31904. /**
  31905. * Indicates that prepass needs to be re-calculated for all submeshes
  31906. */
  31907. protected _markAllSubMeshesAsPrePassDirty(): void;
  31908. /**
  31909. * Indicates that textures and misc need to be re-calculated for all submeshes
  31910. */
  31911. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  31912. /**
  31913. * Sets the required values to the prepass renderer.
  31914. * @param prePassRenderer defines the prepass renderer to setup.
  31915. * @returns true if the pre pass is needed.
  31916. */
  31917. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  31918. /**
  31919. * Disposes the material
  31920. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  31921. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  31922. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  31923. */
  31924. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  31925. /** @hidden */
  31926. private releaseVertexArrayObject;
  31927. /**
  31928. * Serializes this material
  31929. * @returns the serialized material object
  31930. */
  31931. serialize(): any;
  31932. /**
  31933. * Creates a material from parsed material data
  31934. * @param parsedMaterial defines parsed material data
  31935. * @param scene defines the hosting scene
  31936. * @param rootUrl defines the root URL to use to load textures
  31937. * @returns a new material
  31938. */
  31939. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  31940. }
  31941. }
  31942. declare module "babylonjs/Materials/multiMaterial" {
  31943. import { Nullable } from "babylonjs/types";
  31944. import { Scene } from "babylonjs/scene";
  31945. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31946. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31947. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31948. import { Material } from "babylonjs/Materials/material";
  31949. /**
  31950. * A multi-material is used to apply different materials to different parts of the same object without the need of
  31951. * separate meshes. This can be use to improve performances.
  31952. * @see https://doc.babylonjs.com/how_to/multi_materials
  31953. */
  31954. export class MultiMaterial extends Material {
  31955. private _subMaterials;
  31956. /**
  31957. * Gets or Sets the list of Materials used within the multi material.
  31958. * They need to be ordered according to the submeshes order in the associated mesh
  31959. */
  31960. get subMaterials(): Nullable<Material>[];
  31961. set subMaterials(value: Nullable<Material>[]);
  31962. /**
  31963. * Function used to align with Node.getChildren()
  31964. * @returns the list of Materials used within the multi material
  31965. */
  31966. getChildren(): Nullable<Material>[];
  31967. /**
  31968. * Instantiates a new Multi Material
  31969. * A multi-material is used to apply different materials to different parts of the same object without the need of
  31970. * separate meshes. This can be use to improve performances.
  31971. * @see https://doc.babylonjs.com/how_to/multi_materials
  31972. * @param name Define the name in the scene
  31973. * @param scene Define the scene the material belongs to
  31974. */
  31975. constructor(name: string, scene: Scene);
  31976. private _hookArray;
  31977. /**
  31978. * Get one of the submaterial by its index in the submaterials array
  31979. * @param index The index to look the sub material at
  31980. * @returns The Material if the index has been defined
  31981. */
  31982. getSubMaterial(index: number): Nullable<Material>;
  31983. /**
  31984. * Get the list of active textures for the whole sub materials list.
  31985. * @returns All the textures that will be used during the rendering
  31986. */
  31987. getActiveTextures(): BaseTexture[];
  31988. /**
  31989. * Specifies if any sub-materials of this multi-material use a given texture.
  31990. * @param texture Defines the texture to check against this multi-material's sub-materials.
  31991. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  31992. */
  31993. hasTexture(texture: BaseTexture): boolean;
  31994. /**
  31995. * Gets the current class name of the material e.g. "MultiMaterial"
  31996. * Mainly use in serialization.
  31997. * @returns the class name
  31998. */
  31999. getClassName(): string;
  32000. /**
  32001. * Checks if the material is ready to render the requested sub mesh
  32002. * @param mesh Define the mesh the submesh belongs to
  32003. * @param subMesh Define the sub mesh to look readyness for
  32004. * @param useInstances Define whether or not the material is used with instances
  32005. * @returns true if ready, otherwise false
  32006. */
  32007. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  32008. /**
  32009. * Clones the current material and its related sub materials
  32010. * @param name Define the name of the newly cloned material
  32011. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  32012. * @returns the cloned material
  32013. */
  32014. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  32015. /**
  32016. * Serializes the materials into a JSON representation.
  32017. * @returns the JSON representation
  32018. */
  32019. serialize(): any;
  32020. /**
  32021. * Dispose the material and release its associated resources
  32022. * @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)
  32023. * @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)
  32024. * @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)
  32025. */
  32026. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  32027. /**
  32028. * Creates a MultiMaterial from parsed MultiMaterial data.
  32029. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  32030. * @param scene defines the hosting scene
  32031. * @returns a new MultiMaterial
  32032. */
  32033. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  32034. }
  32035. }
  32036. declare module "babylonjs/Meshes/subMesh" {
  32037. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  32038. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  32039. import { Engine } from "babylonjs/Engines/engine";
  32040. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  32041. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32042. import { Effect } from "babylonjs/Materials/effect";
  32043. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  32044. import { Plane } from "babylonjs/Maths/math.plane";
  32045. import { Collider } from "babylonjs/Collisions/collider";
  32046. import { Material } from "babylonjs/Materials/material";
  32047. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  32048. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32049. import { Mesh } from "babylonjs/Meshes/mesh";
  32050. import { Ray } from "babylonjs/Culling/ray";
  32051. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32052. /** @hidden */
  32053. export interface ICustomEffect {
  32054. effect: Effect;
  32055. defines: string;
  32056. }
  32057. /**
  32058. * Defines a subdivision inside a mesh
  32059. */
  32060. export class SubMesh implements ICullable {
  32061. /** the material index to use */
  32062. materialIndex: number;
  32063. /** vertex index start */
  32064. verticesStart: number;
  32065. /** vertices count */
  32066. verticesCount: number;
  32067. /** index start */
  32068. indexStart: number;
  32069. /** indices count */
  32070. indexCount: number;
  32071. /** @hidden */
  32072. _materialDefines: Nullable<MaterialDefines>;
  32073. /** @hidden */
  32074. _materialEffect: Nullable<Effect>;
  32075. /** @hidden */
  32076. _effectOverride: Nullable<Effect>;
  32077. private _customEffects;
  32078. /**
  32079. * Gets material defines used by the effect associated to the sub mesh
  32080. */
  32081. get materialDefines(): Nullable<MaterialDefines>;
  32082. /**
  32083. * Sets material defines used by the effect associated to the sub mesh
  32084. */
  32085. set materialDefines(defines: Nullable<MaterialDefines>);
  32086. /** @hidden */
  32087. _getCustomEffect(name: string, createIfNotExisting?: boolean): Nullable<ICustomEffect>;
  32088. /** @hidden */
  32089. _removeCustomEffect(name: string): void;
  32090. /**
  32091. * Gets associated effect
  32092. */
  32093. get effect(): Nullable<Effect>;
  32094. /**
  32095. * Sets associated effect (effect used to render this submesh)
  32096. * @param effect defines the effect to associate with
  32097. * @param defines defines the set of defines used to compile this effect
  32098. */
  32099. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  32100. /** @hidden */
  32101. _linesIndexCount: number;
  32102. private _mesh;
  32103. private _renderingMesh;
  32104. private _boundingInfo;
  32105. private _linesIndexBuffer;
  32106. /** @hidden */
  32107. _lastColliderWorldVertices: Nullable<Vector3[]>;
  32108. /** @hidden */
  32109. _trianglePlanes: Plane[];
  32110. /** @hidden */
  32111. _lastColliderTransformMatrix: Nullable<Matrix>;
  32112. /** @hidden */
  32113. _renderId: number;
  32114. /** @hidden */
  32115. _alphaIndex: number;
  32116. /** @hidden */
  32117. _distanceToCamera: number;
  32118. /** @hidden */
  32119. _id: number;
  32120. private _currentMaterial;
  32121. /**
  32122. * Add a new submesh to a mesh
  32123. * @param materialIndex defines the material index to use
  32124. * @param verticesStart defines vertex index start
  32125. * @param verticesCount defines vertices count
  32126. * @param indexStart defines index start
  32127. * @param indexCount defines indices count
  32128. * @param mesh defines the parent mesh
  32129. * @param renderingMesh defines an optional rendering mesh
  32130. * @param createBoundingBox defines if bounding box should be created for this submesh
  32131. * @returns the new submesh
  32132. */
  32133. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  32134. /**
  32135. * Creates a new submesh
  32136. * @param materialIndex defines the material index to use
  32137. * @param verticesStart defines vertex index start
  32138. * @param verticesCount defines vertices count
  32139. * @param indexStart defines index start
  32140. * @param indexCount defines indices count
  32141. * @param mesh defines the parent mesh
  32142. * @param renderingMesh defines an optional rendering mesh
  32143. * @param createBoundingBox defines if bounding box should be created for this submesh
  32144. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  32145. */
  32146. constructor(
  32147. /** the material index to use */
  32148. materialIndex: number,
  32149. /** vertex index start */
  32150. verticesStart: number,
  32151. /** vertices count */
  32152. verticesCount: number,
  32153. /** index start */
  32154. indexStart: number,
  32155. /** indices count */
  32156. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  32157. /**
  32158. * Returns true if this submesh covers the entire parent mesh
  32159. * @ignorenaming
  32160. */
  32161. get IsGlobal(): boolean;
  32162. /**
  32163. * Returns the submesh BoudingInfo object
  32164. * @returns current bounding info (or mesh's one if the submesh is global)
  32165. */
  32166. getBoundingInfo(): BoundingInfo;
  32167. /**
  32168. * Sets the submesh BoundingInfo
  32169. * @param boundingInfo defines the new bounding info to use
  32170. * @returns the SubMesh
  32171. */
  32172. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  32173. /**
  32174. * Returns the mesh of the current submesh
  32175. * @return the parent mesh
  32176. */
  32177. getMesh(): AbstractMesh;
  32178. /**
  32179. * Returns the rendering mesh of the submesh
  32180. * @returns the rendering mesh (could be different from parent mesh)
  32181. */
  32182. getRenderingMesh(): Mesh;
  32183. /**
  32184. * Returns the replacement mesh of the submesh
  32185. * @returns the replacement mesh (could be different from parent mesh)
  32186. */
  32187. getReplacementMesh(): Nullable<AbstractMesh>;
  32188. /**
  32189. * Returns the effective mesh of the submesh
  32190. * @returns the effective mesh (could be different from parent mesh)
  32191. */
  32192. getEffectiveMesh(): AbstractMesh;
  32193. /**
  32194. * Returns the submesh material
  32195. * @returns null or the current material
  32196. */
  32197. getMaterial(): Nullable<Material>;
  32198. private _IsMultiMaterial;
  32199. /**
  32200. * Sets a new updated BoundingInfo object to the submesh
  32201. * @param data defines an optional position array to use to determine the bounding info
  32202. * @returns the SubMesh
  32203. */
  32204. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  32205. /** @hidden */
  32206. _checkCollision(collider: Collider): boolean;
  32207. /**
  32208. * Updates the submesh BoundingInfo
  32209. * @param world defines the world matrix to use to update the bounding info
  32210. * @returns the submesh
  32211. */
  32212. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  32213. /**
  32214. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  32215. * @param frustumPlanes defines the frustum planes
  32216. * @returns true if the submesh is intersecting with the frustum
  32217. */
  32218. isInFrustum(frustumPlanes: Plane[]): boolean;
  32219. /**
  32220. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  32221. * @param frustumPlanes defines the frustum planes
  32222. * @returns true if the submesh is inside the frustum
  32223. */
  32224. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32225. /**
  32226. * Renders the submesh
  32227. * @param enableAlphaMode defines if alpha needs to be used
  32228. * @returns the submesh
  32229. */
  32230. render(enableAlphaMode: boolean): SubMesh;
  32231. /**
  32232. * @hidden
  32233. */
  32234. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  32235. /**
  32236. * Checks if the submesh intersects with a ray
  32237. * @param ray defines the ray to test
  32238. * @returns true is the passed ray intersects the submesh bounding box
  32239. */
  32240. canIntersects(ray: Ray): boolean;
  32241. /**
  32242. * Intersects current submesh with a ray
  32243. * @param ray defines the ray to test
  32244. * @param positions defines mesh's positions array
  32245. * @param indices defines mesh's indices array
  32246. * @param fastCheck defines if the first intersection will be used (and not the closest)
  32247. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32248. * @returns intersection info or null if no intersection
  32249. */
  32250. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  32251. /** @hidden */
  32252. private _intersectLines;
  32253. /** @hidden */
  32254. private _intersectUnIndexedLines;
  32255. /** @hidden */
  32256. private _intersectTriangles;
  32257. /** @hidden */
  32258. private _intersectUnIndexedTriangles;
  32259. /** @hidden */
  32260. _rebuild(): void;
  32261. /**
  32262. * Creates a new submesh from the passed mesh
  32263. * @param newMesh defines the new hosting mesh
  32264. * @param newRenderingMesh defines an optional rendering mesh
  32265. * @returns the new submesh
  32266. */
  32267. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  32268. /**
  32269. * Release associated resources
  32270. */
  32271. dispose(): void;
  32272. /**
  32273. * Gets the class name
  32274. * @returns the string "SubMesh".
  32275. */
  32276. getClassName(): string;
  32277. /**
  32278. * Creates a new submesh from indices data
  32279. * @param materialIndex the index of the main mesh material
  32280. * @param startIndex the index where to start the copy in the mesh indices array
  32281. * @param indexCount the number of indices to copy then from the startIndex
  32282. * @param mesh the main mesh to create the submesh from
  32283. * @param renderingMesh the optional rendering mesh
  32284. * @returns a new submesh
  32285. */
  32286. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  32287. }
  32288. }
  32289. declare module "babylonjs/Loading/sceneLoaderFlags" {
  32290. /**
  32291. * Class used to represent data loading progression
  32292. */
  32293. export class SceneLoaderFlags {
  32294. private static _ForceFullSceneLoadingForIncremental;
  32295. private static _ShowLoadingScreen;
  32296. private static _CleanBoneMatrixWeights;
  32297. private static _loggingLevel;
  32298. /**
  32299. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  32300. */
  32301. static get ForceFullSceneLoadingForIncremental(): boolean;
  32302. static set ForceFullSceneLoadingForIncremental(value: boolean);
  32303. /**
  32304. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  32305. */
  32306. static get ShowLoadingScreen(): boolean;
  32307. static set ShowLoadingScreen(value: boolean);
  32308. /**
  32309. * Defines the current logging level (while loading the scene)
  32310. * @ignorenaming
  32311. */
  32312. static get loggingLevel(): number;
  32313. static set loggingLevel(value: number);
  32314. /**
  32315. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  32316. */
  32317. static get CleanBoneMatrixWeights(): boolean;
  32318. static set CleanBoneMatrixWeights(value: boolean);
  32319. }
  32320. }
  32321. declare module "babylonjs/Meshes/geometry" {
  32322. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  32323. import { Scene } from "babylonjs/scene";
  32324. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  32325. import { Engine } from "babylonjs/Engines/engine";
  32326. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  32327. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  32328. import { Effect } from "babylonjs/Materials/effect";
  32329. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32330. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  32331. import { Mesh } from "babylonjs/Meshes/mesh";
  32332. /**
  32333. * Class used to store geometry data (vertex buffers + index buffer)
  32334. */
  32335. export class Geometry implements IGetSetVerticesData {
  32336. /**
  32337. * Gets or sets the ID of the geometry
  32338. */
  32339. id: string;
  32340. /**
  32341. * Gets or sets the unique ID of the geometry
  32342. */
  32343. uniqueId: number;
  32344. /**
  32345. * Gets the delay loading state of the geometry (none by default which means not delayed)
  32346. */
  32347. delayLoadState: number;
  32348. /**
  32349. * Gets the file containing the data to load when running in delay load state
  32350. */
  32351. delayLoadingFile: Nullable<string>;
  32352. /**
  32353. * Callback called when the geometry is updated
  32354. */
  32355. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  32356. private _scene;
  32357. private _engine;
  32358. private _meshes;
  32359. private _totalVertices;
  32360. /** @hidden */
  32361. _indices: IndicesArray;
  32362. /** @hidden */
  32363. _vertexBuffers: {
  32364. [key: string]: VertexBuffer;
  32365. };
  32366. private _isDisposed;
  32367. private _extend;
  32368. private _boundingBias;
  32369. /** @hidden */
  32370. _delayInfo: Array<string>;
  32371. private _indexBuffer;
  32372. private _indexBufferIsUpdatable;
  32373. /** @hidden */
  32374. _boundingInfo: Nullable<BoundingInfo>;
  32375. /** @hidden */
  32376. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  32377. /** @hidden */
  32378. _softwareSkinningFrameId: number;
  32379. private _vertexArrayObjects;
  32380. private _updatable;
  32381. /** @hidden */
  32382. _positions: Nullable<Vector3[]>;
  32383. private _positionsCache;
  32384. /**
  32385. * 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
  32386. */
  32387. get boundingBias(): Vector2;
  32388. /**
  32389. * 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
  32390. */
  32391. set boundingBias(value: Vector2);
  32392. /**
  32393. * Static function used to attach a new empty geometry to a mesh
  32394. * @param mesh defines the mesh to attach the geometry to
  32395. * @returns the new Geometry
  32396. */
  32397. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  32398. /** Get the list of meshes using this geometry */
  32399. get meshes(): Mesh[];
  32400. /**
  32401. * 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
  32402. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  32403. */
  32404. useBoundingInfoFromGeometry: boolean;
  32405. /**
  32406. * Creates a new geometry
  32407. * @param id defines the unique ID
  32408. * @param scene defines the hosting scene
  32409. * @param vertexData defines the VertexData used to get geometry data
  32410. * @param updatable defines if geometry must be updatable (false by default)
  32411. * @param mesh defines the mesh that will be associated with the geometry
  32412. */
  32413. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  32414. /**
  32415. * Gets the current extend of the geometry
  32416. */
  32417. get extend(): {
  32418. minimum: Vector3;
  32419. maximum: Vector3;
  32420. };
  32421. /**
  32422. * Gets the hosting scene
  32423. * @returns the hosting Scene
  32424. */
  32425. getScene(): Scene;
  32426. /**
  32427. * Gets the hosting engine
  32428. * @returns the hosting Engine
  32429. */
  32430. getEngine(): Engine;
  32431. /**
  32432. * Defines if the geometry is ready to use
  32433. * @returns true if the geometry is ready to be used
  32434. */
  32435. isReady(): boolean;
  32436. /**
  32437. * Gets a value indicating that the geometry should not be serialized
  32438. */
  32439. get doNotSerialize(): boolean;
  32440. /** @hidden */
  32441. _rebuild(): void;
  32442. /**
  32443. * Affects all geometry data in one call
  32444. * @param vertexData defines the geometry data
  32445. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  32446. */
  32447. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  32448. /**
  32449. * Set specific vertex data
  32450. * @param kind defines the data kind (Position, normal, etc...)
  32451. * @param data defines the vertex data to use
  32452. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  32453. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  32454. */
  32455. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  32456. /**
  32457. * Removes a specific vertex data
  32458. * @param kind defines the data kind (Position, normal, etc...)
  32459. */
  32460. removeVerticesData(kind: string): void;
  32461. /**
  32462. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  32463. * @param buffer defines the vertex buffer to use
  32464. * @param totalVertices defines the total number of vertices for position kind (could be null)
  32465. */
  32466. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  32467. /**
  32468. * Update a specific vertex buffer
  32469. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  32470. * It will do nothing if the buffer is not updatable
  32471. * @param kind defines the data kind (Position, normal, etc...)
  32472. * @param data defines the data to use
  32473. * @param offset defines the offset in the target buffer where to store the data
  32474. * @param useBytes set to true if the offset is in bytes
  32475. */
  32476. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  32477. /**
  32478. * Update a specific vertex buffer
  32479. * This function will create a new buffer if the current one is not updatable
  32480. * @param kind defines the data kind (Position, normal, etc...)
  32481. * @param data defines the data to use
  32482. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  32483. */
  32484. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  32485. private _updateBoundingInfo;
  32486. /** @hidden */
  32487. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  32488. /**
  32489. * Gets total number of vertices
  32490. * @returns the total number of vertices
  32491. */
  32492. getTotalVertices(): number;
  32493. /**
  32494. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  32495. * @param kind defines the data kind (Position, normal, etc...)
  32496. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  32497. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  32498. * @returns a float array containing vertex data
  32499. */
  32500. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  32501. /**
  32502. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  32503. * @param kind defines the data kind (Position, normal, etc...)
  32504. * @returns true if the vertex buffer with the specified kind is updatable
  32505. */
  32506. isVertexBufferUpdatable(kind: string): boolean;
  32507. /**
  32508. * Gets a specific vertex buffer
  32509. * @param kind defines the data kind (Position, normal, etc...)
  32510. * @returns a VertexBuffer
  32511. */
  32512. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  32513. /**
  32514. * Returns all vertex buffers
  32515. * @return an object holding all vertex buffers indexed by kind
  32516. */
  32517. getVertexBuffers(): Nullable<{
  32518. [key: string]: VertexBuffer;
  32519. }>;
  32520. /**
  32521. * Gets a boolean indicating if specific vertex buffer is present
  32522. * @param kind defines the data kind (Position, normal, etc...)
  32523. * @returns true if data is present
  32524. */
  32525. isVerticesDataPresent(kind: string): boolean;
  32526. /**
  32527. * Gets a list of all attached data kinds (Position, normal, etc...)
  32528. * @returns a list of string containing all kinds
  32529. */
  32530. getVerticesDataKinds(): string[];
  32531. /**
  32532. * Update index buffer
  32533. * @param indices defines the indices to store in the index buffer
  32534. * @param offset defines the offset in the target buffer where to store the data
  32535. * @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)
  32536. */
  32537. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  32538. /**
  32539. * Creates a new index buffer
  32540. * @param indices defines the indices to store in the index buffer
  32541. * @param totalVertices defines the total number of vertices (could be null)
  32542. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  32543. */
  32544. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  32545. /**
  32546. * Return the total number of indices
  32547. * @returns the total number of indices
  32548. */
  32549. getTotalIndices(): number;
  32550. /**
  32551. * Gets the index buffer array
  32552. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  32553. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  32554. * @returns the index buffer array
  32555. */
  32556. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  32557. /**
  32558. * Gets the index buffer
  32559. * @return the index buffer
  32560. */
  32561. getIndexBuffer(): Nullable<DataBuffer>;
  32562. /** @hidden */
  32563. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  32564. /**
  32565. * Release the associated resources for a specific mesh
  32566. * @param mesh defines the source mesh
  32567. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  32568. */
  32569. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  32570. /**
  32571. * Apply current geometry to a given mesh
  32572. * @param mesh defines the mesh to apply geometry to
  32573. */
  32574. applyToMesh(mesh: Mesh): void;
  32575. private _updateExtend;
  32576. private _applyToMesh;
  32577. private notifyUpdate;
  32578. /**
  32579. * Load the geometry if it was flagged as delay loaded
  32580. * @param scene defines the hosting scene
  32581. * @param onLoaded defines a callback called when the geometry is loaded
  32582. */
  32583. load(scene: Scene, onLoaded?: () => void): void;
  32584. private _queueLoad;
  32585. /**
  32586. * Invert the geometry to move from a right handed system to a left handed one.
  32587. */
  32588. toLeftHanded(): void;
  32589. /** @hidden */
  32590. _resetPointsArrayCache(): void;
  32591. /** @hidden */
  32592. _generatePointsArray(): boolean;
  32593. /**
  32594. * Gets a value indicating if the geometry is disposed
  32595. * @returns true if the geometry was disposed
  32596. */
  32597. isDisposed(): boolean;
  32598. private _disposeVertexArrayObjects;
  32599. /**
  32600. * Free all associated resources
  32601. */
  32602. dispose(): void;
  32603. /**
  32604. * Clone the current geometry into a new geometry
  32605. * @param id defines the unique ID of the new geometry
  32606. * @returns a new geometry object
  32607. */
  32608. copy(id: string): Geometry;
  32609. /**
  32610. * Serialize the current geometry info (and not the vertices data) into a JSON object
  32611. * @return a JSON representation of the current geometry data (without the vertices data)
  32612. */
  32613. serialize(): any;
  32614. private toNumberArray;
  32615. /**
  32616. * Serialize all vertices data into a JSON oject
  32617. * @returns a JSON representation of the current geometry data
  32618. */
  32619. serializeVerticeData(): any;
  32620. /**
  32621. * Extracts a clone of a mesh geometry
  32622. * @param mesh defines the source mesh
  32623. * @param id defines the unique ID of the new geometry object
  32624. * @returns the new geometry object
  32625. */
  32626. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  32627. /**
  32628. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  32629. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32630. * Be aware Math.random() could cause collisions, but:
  32631. * "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"
  32632. * @returns a string containing a new GUID
  32633. */
  32634. static RandomId(): string;
  32635. /** @hidden */
  32636. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  32637. private static _CleanMatricesWeights;
  32638. /**
  32639. * Create a new geometry from persisted data (Using .babylon file format)
  32640. * @param parsedVertexData defines the persisted data
  32641. * @param scene defines the hosting scene
  32642. * @param rootUrl defines the root url to use to load assets (like delayed data)
  32643. * @returns the new geometry object
  32644. */
  32645. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  32646. }
  32647. }
  32648. declare module "babylonjs/Morph/morphTarget" {
  32649. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  32650. import { Observable } from "babylonjs/Misc/observable";
  32651. import { Nullable, FloatArray } from "babylonjs/types";
  32652. import { Scene } from "babylonjs/scene";
  32653. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32654. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32655. /**
  32656. * Defines a target to use with MorphTargetManager
  32657. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32658. */
  32659. export class MorphTarget implements IAnimatable {
  32660. /** defines the name of the target */
  32661. name: string;
  32662. /**
  32663. * Gets or sets the list of animations
  32664. */
  32665. animations: import("babylonjs/Animations/animation").Animation[];
  32666. private _scene;
  32667. private _positions;
  32668. private _normals;
  32669. private _tangents;
  32670. private _uvs;
  32671. private _influence;
  32672. private _uniqueId;
  32673. /**
  32674. * Observable raised when the influence changes
  32675. */
  32676. onInfluenceChanged: Observable<boolean>;
  32677. /** @hidden */
  32678. _onDataLayoutChanged: Observable<void>;
  32679. /**
  32680. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  32681. */
  32682. get influence(): number;
  32683. set influence(influence: number);
  32684. /**
  32685. * Gets or sets the id of the morph Target
  32686. */
  32687. id: string;
  32688. private _animationPropertiesOverride;
  32689. /**
  32690. * Gets or sets the animation properties override
  32691. */
  32692. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  32693. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  32694. /**
  32695. * Creates a new MorphTarget
  32696. * @param name defines the name of the target
  32697. * @param influence defines the influence to use
  32698. * @param scene defines the scene the morphtarget belongs to
  32699. */
  32700. constructor(
  32701. /** defines the name of the target */
  32702. name: string, influence?: number, scene?: Nullable<Scene>);
  32703. /**
  32704. * Gets the unique ID of this manager
  32705. */
  32706. get uniqueId(): number;
  32707. /**
  32708. * Gets a boolean defining if the target contains position data
  32709. */
  32710. get hasPositions(): boolean;
  32711. /**
  32712. * Gets a boolean defining if the target contains normal data
  32713. */
  32714. get hasNormals(): boolean;
  32715. /**
  32716. * Gets a boolean defining if the target contains tangent data
  32717. */
  32718. get hasTangents(): boolean;
  32719. /**
  32720. * Gets a boolean defining if the target contains texture coordinates data
  32721. */
  32722. get hasUVs(): boolean;
  32723. /**
  32724. * Affects position data to this target
  32725. * @param data defines the position data to use
  32726. */
  32727. setPositions(data: Nullable<FloatArray>): void;
  32728. /**
  32729. * Gets the position data stored in this target
  32730. * @returns a FloatArray containing the position data (or null if not present)
  32731. */
  32732. getPositions(): Nullable<FloatArray>;
  32733. /**
  32734. * Affects normal data to this target
  32735. * @param data defines the normal data to use
  32736. */
  32737. setNormals(data: Nullable<FloatArray>): void;
  32738. /**
  32739. * Gets the normal data stored in this target
  32740. * @returns a FloatArray containing the normal data (or null if not present)
  32741. */
  32742. getNormals(): Nullable<FloatArray>;
  32743. /**
  32744. * Affects tangent data to this target
  32745. * @param data defines the tangent data to use
  32746. */
  32747. setTangents(data: Nullable<FloatArray>): void;
  32748. /**
  32749. * Gets the tangent data stored in this target
  32750. * @returns a FloatArray containing the tangent data (or null if not present)
  32751. */
  32752. getTangents(): Nullable<FloatArray>;
  32753. /**
  32754. * Affects texture coordinates data to this target
  32755. * @param data defines the texture coordinates data to use
  32756. */
  32757. setUVs(data: Nullable<FloatArray>): void;
  32758. /**
  32759. * Gets the texture coordinates data stored in this target
  32760. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  32761. */
  32762. getUVs(): Nullable<FloatArray>;
  32763. /**
  32764. * Clone the current target
  32765. * @returns a new MorphTarget
  32766. */
  32767. clone(): MorphTarget;
  32768. /**
  32769. * Serializes the current target into a Serialization object
  32770. * @returns the serialized object
  32771. */
  32772. serialize(): any;
  32773. /**
  32774. * Returns the string "MorphTarget"
  32775. * @returns "MorphTarget"
  32776. */
  32777. getClassName(): string;
  32778. /**
  32779. * Creates a new target from serialized data
  32780. * @param serializationObject defines the serialized data to use
  32781. * @returns a new MorphTarget
  32782. */
  32783. static Parse(serializationObject: any): MorphTarget;
  32784. /**
  32785. * Creates a MorphTarget from mesh data
  32786. * @param mesh defines the source mesh
  32787. * @param name defines the name to use for the new target
  32788. * @param influence defines the influence to attach to the target
  32789. * @returns a new MorphTarget
  32790. */
  32791. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  32792. }
  32793. }
  32794. declare module "babylonjs/Morph/morphTargetManager" {
  32795. import { Nullable } from "babylonjs/types";
  32796. import { Scene } from "babylonjs/scene";
  32797. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32798. /**
  32799. * This class is used to deform meshes using morphing between different targets
  32800. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32801. */
  32802. export class MorphTargetManager {
  32803. private _targets;
  32804. private _targetInfluenceChangedObservers;
  32805. private _targetDataLayoutChangedObservers;
  32806. private _activeTargets;
  32807. private _scene;
  32808. private _influences;
  32809. private _supportsNormals;
  32810. private _supportsTangents;
  32811. private _supportsUVs;
  32812. private _vertexCount;
  32813. private _uniqueId;
  32814. private _tempInfluences;
  32815. /**
  32816. * Gets or sets a boolean indicating if normals must be morphed
  32817. */
  32818. enableNormalMorphing: boolean;
  32819. /**
  32820. * Gets or sets a boolean indicating if tangents must be morphed
  32821. */
  32822. enableTangentMorphing: boolean;
  32823. /**
  32824. * Gets or sets a boolean indicating if UV must be morphed
  32825. */
  32826. enableUVMorphing: boolean;
  32827. /**
  32828. * Creates a new MorphTargetManager
  32829. * @param scene defines the current scene
  32830. */
  32831. constructor(scene?: Nullable<Scene>);
  32832. /**
  32833. * Gets the unique ID of this manager
  32834. */
  32835. get uniqueId(): number;
  32836. /**
  32837. * Gets the number of vertices handled by this manager
  32838. */
  32839. get vertexCount(): number;
  32840. /**
  32841. * Gets a boolean indicating if this manager supports morphing of normals
  32842. */
  32843. get supportsNormals(): boolean;
  32844. /**
  32845. * Gets a boolean indicating if this manager supports morphing of tangents
  32846. */
  32847. get supportsTangents(): boolean;
  32848. /**
  32849. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  32850. */
  32851. get supportsUVs(): boolean;
  32852. /**
  32853. * Gets the number of targets stored in this manager
  32854. */
  32855. get numTargets(): number;
  32856. /**
  32857. * Gets the number of influencers (ie. the number of targets with influences > 0)
  32858. */
  32859. get numInfluencers(): number;
  32860. /**
  32861. * Gets the list of influences (one per target)
  32862. */
  32863. get influences(): Float32Array;
  32864. /**
  32865. * Gets the active target at specified index. An active target is a target with an influence > 0
  32866. * @param index defines the index to check
  32867. * @returns the requested target
  32868. */
  32869. getActiveTarget(index: number): MorphTarget;
  32870. /**
  32871. * Gets the target at specified index
  32872. * @param index defines the index to check
  32873. * @returns the requested target
  32874. */
  32875. getTarget(index: number): MorphTarget;
  32876. /**
  32877. * Add a new target to this manager
  32878. * @param target defines the target to add
  32879. */
  32880. addTarget(target: MorphTarget): void;
  32881. /**
  32882. * Removes a target from the manager
  32883. * @param target defines the target to remove
  32884. */
  32885. removeTarget(target: MorphTarget): void;
  32886. /**
  32887. * Clone the current manager
  32888. * @returns a new MorphTargetManager
  32889. */
  32890. clone(): MorphTargetManager;
  32891. /**
  32892. * Serializes the current manager into a Serialization object
  32893. * @returns the serialized object
  32894. */
  32895. serialize(): any;
  32896. private _syncActiveTargets;
  32897. /**
  32898. * Syncrhonize the targets with all the meshes using this morph target manager
  32899. */
  32900. synchronize(): void;
  32901. /**
  32902. * Creates a new MorphTargetManager from serialized data
  32903. * @param serializationObject defines the serialized data
  32904. * @param scene defines the hosting scene
  32905. * @returns the new MorphTargetManager
  32906. */
  32907. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  32908. }
  32909. }
  32910. declare module "babylonjs/Meshes/meshLODLevel" {
  32911. import { Mesh } from "babylonjs/Meshes/mesh";
  32912. import { Nullable } from "babylonjs/types";
  32913. /**
  32914. * Class used to represent a specific level of detail of a mesh
  32915. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32916. */
  32917. export class MeshLODLevel {
  32918. /** Defines the distance where this level should start being displayed */
  32919. distance: number;
  32920. /** Defines the mesh to use to render this level */
  32921. mesh: Nullable<Mesh>;
  32922. /**
  32923. * Creates a new LOD level
  32924. * @param distance defines the distance where this level should star being displayed
  32925. * @param mesh defines the mesh to use to render this level
  32926. */
  32927. constructor(
  32928. /** Defines the distance where this level should start being displayed */
  32929. distance: number,
  32930. /** Defines the mesh to use to render this level */
  32931. mesh: Nullable<Mesh>);
  32932. }
  32933. }
  32934. declare module "babylonjs/Misc/canvasGenerator" {
  32935. /**
  32936. * Helper class used to generate a canvas to manipulate images
  32937. */
  32938. export class CanvasGenerator {
  32939. /**
  32940. * Create a new canvas (or offscreen canvas depending on the context)
  32941. * @param width defines the expected width
  32942. * @param height defines the expected height
  32943. * @return a new canvas or offscreen canvas
  32944. */
  32945. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  32946. }
  32947. }
  32948. declare module "babylonjs/Meshes/groundMesh" {
  32949. import { Scene } from "babylonjs/scene";
  32950. import { Vector3 } from "babylonjs/Maths/math.vector";
  32951. import { Mesh } from "babylonjs/Meshes/mesh";
  32952. /**
  32953. * Mesh representing the gorund
  32954. */
  32955. export class GroundMesh extends Mesh {
  32956. /** If octree should be generated */
  32957. generateOctree: boolean;
  32958. private _heightQuads;
  32959. /** @hidden */
  32960. _subdivisionsX: number;
  32961. /** @hidden */
  32962. _subdivisionsY: number;
  32963. /** @hidden */
  32964. _width: number;
  32965. /** @hidden */
  32966. _height: number;
  32967. /** @hidden */
  32968. _minX: number;
  32969. /** @hidden */
  32970. _maxX: number;
  32971. /** @hidden */
  32972. _minZ: number;
  32973. /** @hidden */
  32974. _maxZ: number;
  32975. constructor(name: string, scene: Scene);
  32976. /**
  32977. * "GroundMesh"
  32978. * @returns "GroundMesh"
  32979. */
  32980. getClassName(): string;
  32981. /**
  32982. * The minimum of x and y subdivisions
  32983. */
  32984. get subdivisions(): number;
  32985. /**
  32986. * X subdivisions
  32987. */
  32988. get subdivisionsX(): number;
  32989. /**
  32990. * Y subdivisions
  32991. */
  32992. get subdivisionsY(): number;
  32993. /**
  32994. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  32995. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  32996. * @param chunksCount the number of subdivisions for x and y
  32997. * @param octreeBlocksSize (Default: 32)
  32998. */
  32999. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  33000. /**
  33001. * Returns a height (y) value in the Worl system :
  33002. * the ground altitude at the coordinates (x, z) expressed in the World system.
  33003. * @param x x coordinate
  33004. * @param z z coordinate
  33005. * @returns the ground y position if (x, z) are outside the ground surface.
  33006. */
  33007. getHeightAtCoordinates(x: number, z: number): number;
  33008. /**
  33009. * Returns a normalized vector (Vector3) orthogonal to the ground
  33010. * at the ground coordinates (x, z) expressed in the World system.
  33011. * @param x x coordinate
  33012. * @param z z coordinate
  33013. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  33014. */
  33015. getNormalAtCoordinates(x: number, z: number): Vector3;
  33016. /**
  33017. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  33018. * at the ground coordinates (x, z) expressed in the World system.
  33019. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  33020. * @param x x coordinate
  33021. * @param z z coordinate
  33022. * @param ref vector to store the result
  33023. * @returns the GroundMesh.
  33024. */
  33025. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  33026. /**
  33027. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  33028. * if the ground has been updated.
  33029. * This can be used in the render loop.
  33030. * @returns the GroundMesh.
  33031. */
  33032. updateCoordinateHeights(): GroundMesh;
  33033. private _getFacetAt;
  33034. private _initHeightQuads;
  33035. private _computeHeightQuads;
  33036. /**
  33037. * Serializes this ground mesh
  33038. * @param serializationObject object to write serialization to
  33039. */
  33040. serialize(serializationObject: any): void;
  33041. /**
  33042. * Parses a serialized ground mesh
  33043. * @param parsedMesh the serialized mesh
  33044. * @param scene the scene to create the ground mesh in
  33045. * @returns the created ground mesh
  33046. */
  33047. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  33048. }
  33049. }
  33050. declare module "babylonjs/Physics/physicsJoint" {
  33051. import { Vector3 } from "babylonjs/Maths/math.vector";
  33052. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  33053. /**
  33054. * Interface for Physics-Joint data
  33055. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33056. */
  33057. export interface PhysicsJointData {
  33058. /**
  33059. * The main pivot of the joint
  33060. */
  33061. mainPivot?: Vector3;
  33062. /**
  33063. * The connected pivot of the joint
  33064. */
  33065. connectedPivot?: Vector3;
  33066. /**
  33067. * The main axis of the joint
  33068. */
  33069. mainAxis?: Vector3;
  33070. /**
  33071. * The connected axis of the joint
  33072. */
  33073. connectedAxis?: Vector3;
  33074. /**
  33075. * The collision of the joint
  33076. */
  33077. collision?: boolean;
  33078. /**
  33079. * Native Oimo/Cannon/Energy data
  33080. */
  33081. nativeParams?: any;
  33082. }
  33083. /**
  33084. * This is a holder class for the physics joint created by the physics plugin
  33085. * It holds a set of functions to control the underlying joint
  33086. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33087. */
  33088. export class PhysicsJoint {
  33089. /**
  33090. * The type of the physics joint
  33091. */
  33092. type: number;
  33093. /**
  33094. * The data for the physics joint
  33095. */
  33096. jointData: PhysicsJointData;
  33097. private _physicsJoint;
  33098. protected _physicsPlugin: IPhysicsEnginePlugin;
  33099. /**
  33100. * Initializes the physics joint
  33101. * @param type The type of the physics joint
  33102. * @param jointData The data for the physics joint
  33103. */
  33104. constructor(
  33105. /**
  33106. * The type of the physics joint
  33107. */
  33108. type: number,
  33109. /**
  33110. * The data for the physics joint
  33111. */
  33112. jointData: PhysicsJointData);
  33113. /**
  33114. * Gets the physics joint
  33115. */
  33116. get physicsJoint(): any;
  33117. /**
  33118. * Sets the physics joint
  33119. */
  33120. set physicsJoint(newJoint: any);
  33121. /**
  33122. * Sets the physics plugin
  33123. */
  33124. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  33125. /**
  33126. * Execute a function that is physics-plugin specific.
  33127. * @param {Function} func the function that will be executed.
  33128. * It accepts two parameters: the physics world and the physics joint
  33129. */
  33130. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  33131. /**
  33132. * Distance-Joint type
  33133. */
  33134. static DistanceJoint: number;
  33135. /**
  33136. * Hinge-Joint type
  33137. */
  33138. static HingeJoint: number;
  33139. /**
  33140. * Ball-and-Socket joint type
  33141. */
  33142. static BallAndSocketJoint: number;
  33143. /**
  33144. * Wheel-Joint type
  33145. */
  33146. static WheelJoint: number;
  33147. /**
  33148. * Slider-Joint type
  33149. */
  33150. static SliderJoint: number;
  33151. /**
  33152. * Prismatic-Joint type
  33153. */
  33154. static PrismaticJoint: number;
  33155. /**
  33156. * Universal-Joint type
  33157. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  33158. */
  33159. static UniversalJoint: number;
  33160. /**
  33161. * Hinge-Joint 2 type
  33162. */
  33163. static Hinge2Joint: number;
  33164. /**
  33165. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  33166. */
  33167. static PointToPointJoint: number;
  33168. /**
  33169. * Spring-Joint type
  33170. */
  33171. static SpringJoint: number;
  33172. /**
  33173. * Lock-Joint type
  33174. */
  33175. static LockJoint: number;
  33176. }
  33177. /**
  33178. * A class representing a physics distance joint
  33179. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33180. */
  33181. export class DistanceJoint extends PhysicsJoint {
  33182. /**
  33183. *
  33184. * @param jointData The data for the Distance-Joint
  33185. */
  33186. constructor(jointData: DistanceJointData);
  33187. /**
  33188. * Update the predefined distance.
  33189. * @param maxDistance The maximum preferred distance
  33190. * @param minDistance The minimum preferred distance
  33191. */
  33192. updateDistance(maxDistance: number, minDistance?: number): void;
  33193. }
  33194. /**
  33195. * Represents a Motor-Enabled Joint
  33196. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33197. */
  33198. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  33199. /**
  33200. * Initializes the Motor-Enabled Joint
  33201. * @param type The type of the joint
  33202. * @param jointData The physica joint data for the joint
  33203. */
  33204. constructor(type: number, jointData: PhysicsJointData);
  33205. /**
  33206. * Set the motor values.
  33207. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33208. * @param force the force to apply
  33209. * @param maxForce max force for this motor.
  33210. */
  33211. setMotor(force?: number, maxForce?: number): void;
  33212. /**
  33213. * Set the motor's limits.
  33214. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33215. * @param upperLimit The upper limit of the motor
  33216. * @param lowerLimit The lower limit of the motor
  33217. */
  33218. setLimit(upperLimit: number, lowerLimit?: number): void;
  33219. }
  33220. /**
  33221. * This class represents a single physics Hinge-Joint
  33222. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33223. */
  33224. export class HingeJoint extends MotorEnabledJoint {
  33225. /**
  33226. * Initializes the Hinge-Joint
  33227. * @param jointData The joint data for the Hinge-Joint
  33228. */
  33229. constructor(jointData: PhysicsJointData);
  33230. /**
  33231. * Set the motor values.
  33232. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33233. * @param {number} force the force to apply
  33234. * @param {number} maxForce max force for this motor.
  33235. */
  33236. setMotor(force?: number, maxForce?: number): void;
  33237. /**
  33238. * Set the motor's limits.
  33239. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33240. * @param upperLimit The upper limit of the motor
  33241. * @param lowerLimit The lower limit of the motor
  33242. */
  33243. setLimit(upperLimit: number, lowerLimit?: number): void;
  33244. }
  33245. /**
  33246. * This class represents a dual hinge physics joint (same as wheel joint)
  33247. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33248. */
  33249. export class Hinge2Joint extends MotorEnabledJoint {
  33250. /**
  33251. * Initializes the Hinge2-Joint
  33252. * @param jointData The joint data for the Hinge2-Joint
  33253. */
  33254. constructor(jointData: PhysicsJointData);
  33255. /**
  33256. * Set the motor values.
  33257. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33258. * @param {number} targetSpeed the speed the motor is to reach
  33259. * @param {number} maxForce max force for this motor.
  33260. * @param {motorIndex} the motor's index, 0 or 1.
  33261. */
  33262. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  33263. /**
  33264. * Set the motor limits.
  33265. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33266. * @param {number} upperLimit the upper limit
  33267. * @param {number} lowerLimit lower limit
  33268. * @param {motorIndex} the motor's index, 0 or 1.
  33269. */
  33270. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  33271. }
  33272. /**
  33273. * Interface for a motor enabled joint
  33274. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33275. */
  33276. export interface IMotorEnabledJoint {
  33277. /**
  33278. * Physics joint
  33279. */
  33280. physicsJoint: any;
  33281. /**
  33282. * Sets the motor of the motor-enabled joint
  33283. * @param force The force of the motor
  33284. * @param maxForce The maximum force of the motor
  33285. * @param motorIndex The index of the motor
  33286. */
  33287. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  33288. /**
  33289. * Sets the limit of the motor
  33290. * @param upperLimit The upper limit of the motor
  33291. * @param lowerLimit The lower limit of the motor
  33292. * @param motorIndex The index of the motor
  33293. */
  33294. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  33295. }
  33296. /**
  33297. * Joint data for a Distance-Joint
  33298. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33299. */
  33300. export interface DistanceJointData extends PhysicsJointData {
  33301. /**
  33302. * Max distance the 2 joint objects can be apart
  33303. */
  33304. maxDistance: number;
  33305. }
  33306. /**
  33307. * Joint data from a spring joint
  33308. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33309. */
  33310. export interface SpringJointData extends PhysicsJointData {
  33311. /**
  33312. * Length of the spring
  33313. */
  33314. length: number;
  33315. /**
  33316. * Stiffness of the spring
  33317. */
  33318. stiffness: number;
  33319. /**
  33320. * Damping of the spring
  33321. */
  33322. damping: number;
  33323. /** this callback will be called when applying the force to the impostors. */
  33324. forceApplicationCallback: () => void;
  33325. }
  33326. }
  33327. declare module "babylonjs/Physics/physicsRaycastResult" {
  33328. import { Vector3 } from "babylonjs/Maths/math.vector";
  33329. /**
  33330. * Holds the data for the raycast result
  33331. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33332. */
  33333. export class PhysicsRaycastResult {
  33334. private _hasHit;
  33335. private _hitDistance;
  33336. private _hitNormalWorld;
  33337. private _hitPointWorld;
  33338. private _rayFromWorld;
  33339. private _rayToWorld;
  33340. /**
  33341. * Gets if there was a hit
  33342. */
  33343. get hasHit(): boolean;
  33344. /**
  33345. * Gets the distance from the hit
  33346. */
  33347. get hitDistance(): number;
  33348. /**
  33349. * Gets the hit normal/direction in the world
  33350. */
  33351. get hitNormalWorld(): Vector3;
  33352. /**
  33353. * Gets the hit point in the world
  33354. */
  33355. get hitPointWorld(): Vector3;
  33356. /**
  33357. * Gets the ray "start point" of the ray in the world
  33358. */
  33359. get rayFromWorld(): Vector3;
  33360. /**
  33361. * Gets the ray "end point" of the ray in the world
  33362. */
  33363. get rayToWorld(): Vector3;
  33364. /**
  33365. * Sets the hit data (normal & point in world space)
  33366. * @param hitNormalWorld defines the normal in world space
  33367. * @param hitPointWorld defines the point in world space
  33368. */
  33369. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  33370. /**
  33371. * Sets the distance from the start point to the hit point
  33372. * @param distance
  33373. */
  33374. setHitDistance(distance: number): void;
  33375. /**
  33376. * Calculates the distance manually
  33377. */
  33378. calculateHitDistance(): void;
  33379. /**
  33380. * Resets all the values to default
  33381. * @param from The from point on world space
  33382. * @param to The to point on world space
  33383. */
  33384. reset(from?: Vector3, to?: Vector3): void;
  33385. }
  33386. /**
  33387. * Interface for the size containing width and height
  33388. */
  33389. interface IXYZ {
  33390. /**
  33391. * X
  33392. */
  33393. x: number;
  33394. /**
  33395. * Y
  33396. */
  33397. y: number;
  33398. /**
  33399. * Z
  33400. */
  33401. z: number;
  33402. }
  33403. }
  33404. declare module "babylonjs/Physics/IPhysicsEngine" {
  33405. import { Nullable } from "babylonjs/types";
  33406. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  33407. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33408. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  33409. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  33410. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  33411. /**
  33412. * Interface used to describe a physics joint
  33413. */
  33414. export interface PhysicsImpostorJoint {
  33415. /** Defines the main impostor to which the joint is linked */
  33416. mainImpostor: PhysicsImpostor;
  33417. /** Defines the impostor that is connected to the main impostor using this joint */
  33418. connectedImpostor: PhysicsImpostor;
  33419. /** Defines the joint itself */
  33420. joint: PhysicsJoint;
  33421. }
  33422. /** @hidden */
  33423. export interface IPhysicsEnginePlugin {
  33424. world: any;
  33425. name: string;
  33426. setGravity(gravity: Vector3): void;
  33427. setTimeStep(timeStep: number): void;
  33428. getTimeStep(): number;
  33429. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  33430. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  33431. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  33432. generatePhysicsBody(impostor: PhysicsImpostor): void;
  33433. removePhysicsBody(impostor: PhysicsImpostor): void;
  33434. generateJoint(joint: PhysicsImpostorJoint): void;
  33435. removeJoint(joint: PhysicsImpostorJoint): void;
  33436. isSupported(): boolean;
  33437. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  33438. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  33439. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  33440. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  33441. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  33442. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  33443. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  33444. getBodyMass(impostor: PhysicsImpostor): number;
  33445. getBodyFriction(impostor: PhysicsImpostor): number;
  33446. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  33447. getBodyRestitution(impostor: PhysicsImpostor): number;
  33448. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  33449. getBodyPressure?(impostor: PhysicsImpostor): number;
  33450. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  33451. getBodyStiffness?(impostor: PhysicsImpostor): number;
  33452. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  33453. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  33454. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  33455. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  33456. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  33457. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  33458. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  33459. sleepBody(impostor: PhysicsImpostor): void;
  33460. wakeUpBody(impostor: PhysicsImpostor): void;
  33461. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  33462. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  33463. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  33464. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  33465. getRadius(impostor: PhysicsImpostor): number;
  33466. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  33467. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  33468. dispose(): void;
  33469. }
  33470. /**
  33471. * Interface used to define a physics engine
  33472. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33473. */
  33474. export interface IPhysicsEngine {
  33475. /**
  33476. * Gets the gravity vector used by the simulation
  33477. */
  33478. gravity: Vector3;
  33479. /**
  33480. * Sets the gravity vector used by the simulation
  33481. * @param gravity defines the gravity vector to use
  33482. */
  33483. setGravity(gravity: Vector3): void;
  33484. /**
  33485. * Set the time step of the physics engine.
  33486. * Default is 1/60.
  33487. * To slow it down, enter 1/600 for example.
  33488. * To speed it up, 1/30
  33489. * @param newTimeStep the new timestep to apply to this world.
  33490. */
  33491. setTimeStep(newTimeStep: number): void;
  33492. /**
  33493. * Get the time step of the physics engine.
  33494. * @returns the current time step
  33495. */
  33496. getTimeStep(): number;
  33497. /**
  33498. * Set the sub time step of the physics engine.
  33499. * Default is 0 meaning there is no sub steps
  33500. * To increase physics resolution precision, set a small value (like 1 ms)
  33501. * @param subTimeStep defines the new sub timestep used for physics resolution.
  33502. */
  33503. setSubTimeStep(subTimeStep: number): void;
  33504. /**
  33505. * Get the sub time step of the physics engine.
  33506. * @returns the current sub time step
  33507. */
  33508. getSubTimeStep(): number;
  33509. /**
  33510. * Release all resources
  33511. */
  33512. dispose(): void;
  33513. /**
  33514. * Gets the name of the current physics plugin
  33515. * @returns the name of the plugin
  33516. */
  33517. getPhysicsPluginName(): string;
  33518. /**
  33519. * Adding a new impostor for the impostor tracking.
  33520. * This will be done by the impostor itself.
  33521. * @param impostor the impostor to add
  33522. */
  33523. addImpostor(impostor: PhysicsImpostor): void;
  33524. /**
  33525. * Remove an impostor from the engine.
  33526. * This impostor and its mesh will not longer be updated by the physics engine.
  33527. * @param impostor the impostor to remove
  33528. */
  33529. removeImpostor(impostor: PhysicsImpostor): void;
  33530. /**
  33531. * Add a joint to the physics engine
  33532. * @param mainImpostor defines the main impostor to which the joint is added.
  33533. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  33534. * @param joint defines the joint that will connect both impostors.
  33535. */
  33536. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33537. /**
  33538. * Removes a joint from the simulation
  33539. * @param mainImpostor defines the impostor used with the joint
  33540. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  33541. * @param joint defines the joint to remove
  33542. */
  33543. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33544. /**
  33545. * Gets the current plugin used to run the simulation
  33546. * @returns current plugin
  33547. */
  33548. getPhysicsPlugin(): IPhysicsEnginePlugin;
  33549. /**
  33550. * Gets the list of physic impostors
  33551. * @returns an array of PhysicsImpostor
  33552. */
  33553. getImpostors(): Array<PhysicsImpostor>;
  33554. /**
  33555. * Gets the impostor for a physics enabled object
  33556. * @param object defines the object impersonated by the impostor
  33557. * @returns the PhysicsImpostor or null if not found
  33558. */
  33559. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33560. /**
  33561. * Gets the impostor for a physics body object
  33562. * @param body defines physics body used by the impostor
  33563. * @returns the PhysicsImpostor or null if not found
  33564. */
  33565. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  33566. /**
  33567. * Does a raycast in the physics world
  33568. * @param from when should the ray start?
  33569. * @param to when should the ray end?
  33570. * @returns PhysicsRaycastResult
  33571. */
  33572. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  33573. /**
  33574. * Called by the scene. No need to call it.
  33575. * @param delta defines the timespam between frames
  33576. */
  33577. _step(delta: number): void;
  33578. }
  33579. }
  33580. declare module "babylonjs/Physics/physicsImpostor" {
  33581. import { Nullable, IndicesArray } from "babylonjs/types";
  33582. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  33583. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33584. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33585. import { Scene } from "babylonjs/scene";
  33586. import { Bone } from "babylonjs/Bones/bone";
  33587. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  33588. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  33589. import { Space } from "babylonjs/Maths/math.axis";
  33590. /**
  33591. * The interface for the physics imposter parameters
  33592. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33593. */
  33594. export interface PhysicsImpostorParameters {
  33595. /**
  33596. * The mass of the physics imposter
  33597. */
  33598. mass: number;
  33599. /**
  33600. * The friction of the physics imposter
  33601. */
  33602. friction?: number;
  33603. /**
  33604. * The coefficient of restitution of the physics imposter
  33605. */
  33606. restitution?: number;
  33607. /**
  33608. * The native options of the physics imposter
  33609. */
  33610. nativeOptions?: any;
  33611. /**
  33612. * Specifies if the parent should be ignored
  33613. */
  33614. ignoreParent?: boolean;
  33615. /**
  33616. * Specifies if bi-directional transformations should be disabled
  33617. */
  33618. disableBidirectionalTransformation?: boolean;
  33619. /**
  33620. * The pressure inside the physics imposter, soft object only
  33621. */
  33622. pressure?: number;
  33623. /**
  33624. * The stiffness the physics imposter, soft object only
  33625. */
  33626. stiffness?: number;
  33627. /**
  33628. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  33629. */
  33630. velocityIterations?: number;
  33631. /**
  33632. * The number of iterations used in maintaining consistent vertex positions, soft object only
  33633. */
  33634. positionIterations?: number;
  33635. /**
  33636. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  33637. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  33638. * Add to fix multiple points
  33639. */
  33640. fixedPoints?: number;
  33641. /**
  33642. * The collision margin around a soft object
  33643. */
  33644. margin?: number;
  33645. /**
  33646. * The collision margin around a soft object
  33647. */
  33648. damping?: number;
  33649. /**
  33650. * The path for a rope based on an extrusion
  33651. */
  33652. path?: any;
  33653. /**
  33654. * The shape of an extrusion used for a rope based on an extrusion
  33655. */
  33656. shape?: any;
  33657. }
  33658. /**
  33659. * Interface for a physics-enabled object
  33660. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33661. */
  33662. export interface IPhysicsEnabledObject {
  33663. /**
  33664. * The position of the physics-enabled object
  33665. */
  33666. position: Vector3;
  33667. /**
  33668. * The rotation of the physics-enabled object
  33669. */
  33670. rotationQuaternion: Nullable<Quaternion>;
  33671. /**
  33672. * The scale of the physics-enabled object
  33673. */
  33674. scaling: Vector3;
  33675. /**
  33676. * The rotation of the physics-enabled object
  33677. */
  33678. rotation?: Vector3;
  33679. /**
  33680. * The parent of the physics-enabled object
  33681. */
  33682. parent?: any;
  33683. /**
  33684. * The bounding info of the physics-enabled object
  33685. * @returns The bounding info of the physics-enabled object
  33686. */
  33687. getBoundingInfo(): BoundingInfo;
  33688. /**
  33689. * Computes the world matrix
  33690. * @param force Specifies if the world matrix should be computed by force
  33691. * @returns A world matrix
  33692. */
  33693. computeWorldMatrix(force: boolean): Matrix;
  33694. /**
  33695. * Gets the world matrix
  33696. * @returns A world matrix
  33697. */
  33698. getWorldMatrix?(): Matrix;
  33699. /**
  33700. * Gets the child meshes
  33701. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  33702. * @returns An array of abstract meshes
  33703. */
  33704. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  33705. /**
  33706. * Gets the vertex data
  33707. * @param kind The type of vertex data
  33708. * @returns A nullable array of numbers, or a float32 array
  33709. */
  33710. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  33711. /**
  33712. * Gets the indices from the mesh
  33713. * @returns A nullable array of index arrays
  33714. */
  33715. getIndices?(): Nullable<IndicesArray>;
  33716. /**
  33717. * Gets the scene from the mesh
  33718. * @returns the indices array or null
  33719. */
  33720. getScene?(): Scene;
  33721. /**
  33722. * Gets the absolute position from the mesh
  33723. * @returns the absolute position
  33724. */
  33725. getAbsolutePosition(): Vector3;
  33726. /**
  33727. * Gets the absolute pivot point from the mesh
  33728. * @returns the absolute pivot point
  33729. */
  33730. getAbsolutePivotPoint(): Vector3;
  33731. /**
  33732. * Rotates the mesh
  33733. * @param axis The axis of rotation
  33734. * @param amount The amount of rotation
  33735. * @param space The space of the rotation
  33736. * @returns The rotation transform node
  33737. */
  33738. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  33739. /**
  33740. * Translates the mesh
  33741. * @param axis The axis of translation
  33742. * @param distance The distance of translation
  33743. * @param space The space of the translation
  33744. * @returns The transform node
  33745. */
  33746. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  33747. /**
  33748. * Sets the absolute position of the mesh
  33749. * @param absolutePosition The absolute position of the mesh
  33750. * @returns The transform node
  33751. */
  33752. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  33753. /**
  33754. * Gets the class name of the mesh
  33755. * @returns The class name
  33756. */
  33757. getClassName(): string;
  33758. }
  33759. /**
  33760. * Represents a physics imposter
  33761. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33762. */
  33763. export class PhysicsImpostor {
  33764. /**
  33765. * The physics-enabled object used as the physics imposter
  33766. */
  33767. object: IPhysicsEnabledObject;
  33768. /**
  33769. * The type of the physics imposter
  33770. */
  33771. type: number;
  33772. private _options;
  33773. private _scene?;
  33774. /**
  33775. * The default object size of the imposter
  33776. */
  33777. static DEFAULT_OBJECT_SIZE: Vector3;
  33778. /**
  33779. * The identity quaternion of the imposter
  33780. */
  33781. static IDENTITY_QUATERNION: Quaternion;
  33782. /** @hidden */
  33783. _pluginData: any;
  33784. private _physicsEngine;
  33785. private _physicsBody;
  33786. private _bodyUpdateRequired;
  33787. private _onBeforePhysicsStepCallbacks;
  33788. private _onAfterPhysicsStepCallbacks;
  33789. /** @hidden */
  33790. _onPhysicsCollideCallbacks: Array<{
  33791. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  33792. otherImpostors: Array<PhysicsImpostor>;
  33793. }>;
  33794. private _deltaPosition;
  33795. private _deltaRotation;
  33796. private _deltaRotationConjugated;
  33797. /** @hidden */
  33798. _isFromLine: boolean;
  33799. private _parent;
  33800. private _isDisposed;
  33801. private static _tmpVecs;
  33802. private static _tmpQuat;
  33803. /**
  33804. * Specifies if the physics imposter is disposed
  33805. */
  33806. get isDisposed(): boolean;
  33807. /**
  33808. * Gets the mass of the physics imposter
  33809. */
  33810. get mass(): number;
  33811. set mass(value: number);
  33812. /**
  33813. * Gets the coefficient of friction
  33814. */
  33815. get friction(): number;
  33816. /**
  33817. * Sets the coefficient of friction
  33818. */
  33819. set friction(value: number);
  33820. /**
  33821. * Gets the coefficient of restitution
  33822. */
  33823. get restitution(): number;
  33824. /**
  33825. * Sets the coefficient of restitution
  33826. */
  33827. set restitution(value: number);
  33828. /**
  33829. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  33830. */
  33831. get pressure(): number;
  33832. /**
  33833. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  33834. */
  33835. set pressure(value: number);
  33836. /**
  33837. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33838. */
  33839. get stiffness(): number;
  33840. /**
  33841. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33842. */
  33843. set stiffness(value: number);
  33844. /**
  33845. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33846. */
  33847. get velocityIterations(): number;
  33848. /**
  33849. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33850. */
  33851. set velocityIterations(value: number);
  33852. /**
  33853. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33854. */
  33855. get positionIterations(): number;
  33856. /**
  33857. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33858. */
  33859. set positionIterations(value: number);
  33860. /**
  33861. * The unique id of the physics imposter
  33862. * set by the physics engine when adding this impostor to the array
  33863. */
  33864. uniqueId: number;
  33865. /**
  33866. * @hidden
  33867. */
  33868. soft: boolean;
  33869. /**
  33870. * @hidden
  33871. */
  33872. segments: number;
  33873. private _joints;
  33874. /**
  33875. * Initializes the physics imposter
  33876. * @param object The physics-enabled object used as the physics imposter
  33877. * @param type The type of the physics imposter
  33878. * @param _options The options for the physics imposter
  33879. * @param _scene The Babylon scene
  33880. */
  33881. constructor(
  33882. /**
  33883. * The physics-enabled object used as the physics imposter
  33884. */
  33885. object: IPhysicsEnabledObject,
  33886. /**
  33887. * The type of the physics imposter
  33888. */
  33889. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33890. /**
  33891. * This function will completly initialize this impostor.
  33892. * It will create a new body - but only if this mesh has no parent.
  33893. * If it has, this impostor will not be used other than to define the impostor
  33894. * of the child mesh.
  33895. * @hidden
  33896. */
  33897. _init(): void;
  33898. private _getPhysicsParent;
  33899. /**
  33900. * Should a new body be generated.
  33901. * @returns boolean specifying if body initialization is required
  33902. */
  33903. isBodyInitRequired(): boolean;
  33904. /**
  33905. * Sets the updated scaling
  33906. * @param updated Specifies if the scaling is updated
  33907. */
  33908. setScalingUpdated(): void;
  33909. /**
  33910. * Force a regeneration of this or the parent's impostor's body.
  33911. * Use under cautious - This will remove all joints already implemented.
  33912. */
  33913. forceUpdate(): void;
  33914. /**
  33915. * Gets the body that holds this impostor. Either its own, or its parent.
  33916. */
  33917. get physicsBody(): any;
  33918. /**
  33919. * Get the parent of the physics imposter
  33920. * @returns Physics imposter or null
  33921. */
  33922. get parent(): Nullable<PhysicsImpostor>;
  33923. /**
  33924. * Sets the parent of the physics imposter
  33925. */
  33926. set parent(value: Nullable<PhysicsImpostor>);
  33927. /**
  33928. * Set the physics body. Used mainly by the physics engine/plugin
  33929. */
  33930. set physicsBody(physicsBody: any);
  33931. /**
  33932. * Resets the update flags
  33933. */
  33934. resetUpdateFlags(): void;
  33935. /**
  33936. * Gets the object extend size
  33937. * @returns the object extend size
  33938. */
  33939. getObjectExtendSize(): Vector3;
  33940. /**
  33941. * Gets the object center
  33942. * @returns The object center
  33943. */
  33944. getObjectCenter(): Vector3;
  33945. /**
  33946. * Get a specific parameter from the options parameters
  33947. * @param paramName The object parameter name
  33948. * @returns The object parameter
  33949. */
  33950. getParam(paramName: string): any;
  33951. /**
  33952. * Sets a specific parameter in the options given to the physics plugin
  33953. * @param paramName The parameter name
  33954. * @param value The value of the parameter
  33955. */
  33956. setParam(paramName: string, value: number): void;
  33957. /**
  33958. * Specifically change the body's mass option. Won't recreate the physics body object
  33959. * @param mass The mass of the physics imposter
  33960. */
  33961. setMass(mass: number): void;
  33962. /**
  33963. * Gets the linear velocity
  33964. * @returns linear velocity or null
  33965. */
  33966. getLinearVelocity(): Nullable<Vector3>;
  33967. /**
  33968. * Sets the linear velocity
  33969. * @param velocity linear velocity or null
  33970. */
  33971. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33972. /**
  33973. * Gets the angular velocity
  33974. * @returns angular velocity or null
  33975. */
  33976. getAngularVelocity(): Nullable<Vector3>;
  33977. /**
  33978. * Sets the angular velocity
  33979. * @param velocity The velocity or null
  33980. */
  33981. setAngularVelocity(velocity: Nullable<Vector3>): void;
  33982. /**
  33983. * Execute a function with the physics plugin native code
  33984. * Provide a function the will have two variables - the world object and the physics body object
  33985. * @param func The function to execute with the physics plugin native code
  33986. */
  33987. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  33988. /**
  33989. * Register a function that will be executed before the physics world is stepping forward
  33990. * @param func The function to execute before the physics world is stepped forward
  33991. */
  33992. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33993. /**
  33994. * Unregister a function that will be executed before the physics world is stepping forward
  33995. * @param func The function to execute before the physics world is stepped forward
  33996. */
  33997. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33998. /**
  33999. * Register a function that will be executed after the physics step
  34000. * @param func The function to execute after physics step
  34001. */
  34002. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  34003. /**
  34004. * Unregisters a function that will be executed after the physics step
  34005. * @param func The function to execute after physics step
  34006. */
  34007. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  34008. /**
  34009. * register a function that will be executed when this impostor collides against a different body
  34010. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  34011. * @param func Callback that is executed on collision
  34012. */
  34013. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  34014. /**
  34015. * Unregisters the physics imposter on contact
  34016. * @param collideAgainst The physics object to collide against
  34017. * @param func Callback to execute on collision
  34018. */
  34019. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  34020. private _tmpQuat;
  34021. private _tmpQuat2;
  34022. /**
  34023. * Get the parent rotation
  34024. * @returns The parent rotation
  34025. */
  34026. getParentsRotation(): Quaternion;
  34027. /**
  34028. * this function is executed by the physics engine.
  34029. */
  34030. beforeStep: () => void;
  34031. /**
  34032. * this function is executed by the physics engine
  34033. */
  34034. afterStep: () => void;
  34035. /**
  34036. * Legacy collision detection event support
  34037. */
  34038. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  34039. /**
  34040. * event and body object due to cannon's event-based architecture.
  34041. */
  34042. onCollide: (e: {
  34043. body: any;
  34044. point: Nullable<Vector3>;
  34045. }) => void;
  34046. /**
  34047. * Apply a force
  34048. * @param force The force to apply
  34049. * @param contactPoint The contact point for the force
  34050. * @returns The physics imposter
  34051. */
  34052. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  34053. /**
  34054. * Apply an impulse
  34055. * @param force The impulse force
  34056. * @param contactPoint The contact point for the impulse force
  34057. * @returns The physics imposter
  34058. */
  34059. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  34060. /**
  34061. * A help function to create a joint
  34062. * @param otherImpostor A physics imposter used to create a joint
  34063. * @param jointType The type of joint
  34064. * @param jointData The data for the joint
  34065. * @returns The physics imposter
  34066. */
  34067. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  34068. /**
  34069. * Add a joint to this impostor with a different impostor
  34070. * @param otherImpostor A physics imposter used to add a joint
  34071. * @param joint The joint to add
  34072. * @returns The physics imposter
  34073. */
  34074. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  34075. /**
  34076. * Add an anchor to a cloth impostor
  34077. * @param otherImpostor rigid impostor to anchor to
  34078. * @param width ratio across width from 0 to 1
  34079. * @param height ratio up height from 0 to 1
  34080. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  34081. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  34082. * @returns impostor the soft imposter
  34083. */
  34084. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  34085. /**
  34086. * Add a hook to a rope impostor
  34087. * @param otherImpostor rigid impostor to anchor to
  34088. * @param length ratio across rope from 0 to 1
  34089. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  34090. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  34091. * @returns impostor the rope imposter
  34092. */
  34093. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  34094. /**
  34095. * Will keep this body still, in a sleep mode.
  34096. * @returns the physics imposter
  34097. */
  34098. sleep(): PhysicsImpostor;
  34099. /**
  34100. * Wake the body up.
  34101. * @returns The physics imposter
  34102. */
  34103. wakeUp(): PhysicsImpostor;
  34104. /**
  34105. * Clones the physics imposter
  34106. * @param newObject The physics imposter clones to this physics-enabled object
  34107. * @returns A nullable physics imposter
  34108. */
  34109. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  34110. /**
  34111. * Disposes the physics imposter
  34112. */
  34113. dispose(): void;
  34114. /**
  34115. * Sets the delta position
  34116. * @param position The delta position amount
  34117. */
  34118. setDeltaPosition(position: Vector3): void;
  34119. /**
  34120. * Sets the delta rotation
  34121. * @param rotation The delta rotation amount
  34122. */
  34123. setDeltaRotation(rotation: Quaternion): void;
  34124. /**
  34125. * Gets the box size of the physics imposter and stores the result in the input parameter
  34126. * @param result Stores the box size
  34127. * @returns The physics imposter
  34128. */
  34129. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  34130. /**
  34131. * Gets the radius of the physics imposter
  34132. * @returns Radius of the physics imposter
  34133. */
  34134. getRadius(): number;
  34135. /**
  34136. * Sync a bone with this impostor
  34137. * @param bone The bone to sync to the impostor.
  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. */
  34143. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  34144. /**
  34145. * Sync impostor to a bone
  34146. * @param bone The bone that the impostor will be synced to.
  34147. * @param boneMesh The mesh that the bone is influencing.
  34148. * @param jointPivot The pivot of the joint / bone in local space.
  34149. * @param distToJoint Optional distance from the impostor to the joint.
  34150. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  34151. * @param boneAxis Optional vector3 axis the bone is aligned with
  34152. */
  34153. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  34154. /**
  34155. * No-Imposter type
  34156. */
  34157. static NoImpostor: number;
  34158. /**
  34159. * Sphere-Imposter type
  34160. */
  34161. static SphereImpostor: number;
  34162. /**
  34163. * Box-Imposter type
  34164. */
  34165. static BoxImpostor: number;
  34166. /**
  34167. * Plane-Imposter type
  34168. */
  34169. static PlaneImpostor: number;
  34170. /**
  34171. * Mesh-imposter type
  34172. */
  34173. static MeshImpostor: number;
  34174. /**
  34175. * Capsule-Impostor type (Ammo.js plugin only)
  34176. */
  34177. static CapsuleImpostor: number;
  34178. /**
  34179. * Cylinder-Imposter type
  34180. */
  34181. static CylinderImpostor: number;
  34182. /**
  34183. * Particle-Imposter type
  34184. */
  34185. static ParticleImpostor: number;
  34186. /**
  34187. * Heightmap-Imposter type
  34188. */
  34189. static HeightmapImpostor: number;
  34190. /**
  34191. * ConvexHull-Impostor type (Ammo.js plugin only)
  34192. */
  34193. static ConvexHullImpostor: number;
  34194. /**
  34195. * Custom-Imposter type (Ammo.js plugin only)
  34196. */
  34197. static CustomImpostor: number;
  34198. /**
  34199. * Rope-Imposter type
  34200. */
  34201. static RopeImpostor: number;
  34202. /**
  34203. * Cloth-Imposter type
  34204. */
  34205. static ClothImpostor: number;
  34206. /**
  34207. * Softbody-Imposter type
  34208. */
  34209. static SoftbodyImpostor: number;
  34210. }
  34211. }
  34212. declare module "babylonjs/Meshes/mesh" {
  34213. import { Observable } from "babylonjs/Misc/observable";
  34214. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34215. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  34216. import { Camera } from "babylonjs/Cameras/camera";
  34217. import { Scene } from "babylonjs/scene";
  34218. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  34219. import { Color4 } from "babylonjs/Maths/math.color";
  34220. import { Engine } from "babylonjs/Engines/engine";
  34221. import { Node } from "babylonjs/node";
  34222. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  34223. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  34224. import { Buffer } from "babylonjs/Meshes/buffer";
  34225. import { Geometry } from "babylonjs/Meshes/geometry";
  34226. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34227. import { SubMesh } from "babylonjs/Meshes/subMesh";
  34228. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  34229. import { Effect } from "babylonjs/Materials/effect";
  34230. import { Material } from "babylonjs/Materials/material";
  34231. import { Skeleton } from "babylonjs/Bones/skeleton";
  34232. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34233. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  34234. import { Path3D } from "babylonjs/Maths/math.path";
  34235. import { Plane } from "babylonjs/Maths/math.plane";
  34236. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34237. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  34238. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  34239. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  34240. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  34241. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  34242. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  34243. /**
  34244. * @hidden
  34245. **/
  34246. export class _CreationDataStorage {
  34247. closePath?: boolean;
  34248. closeArray?: boolean;
  34249. idx: number[];
  34250. dashSize: number;
  34251. gapSize: number;
  34252. path3D: Path3D;
  34253. pathArray: Vector3[][];
  34254. arc: number;
  34255. radius: number;
  34256. cap: number;
  34257. tessellation: number;
  34258. }
  34259. /**
  34260. * @hidden
  34261. **/
  34262. class _InstanceDataStorage {
  34263. visibleInstances: any;
  34264. batchCache: _InstancesBatch;
  34265. instancesBufferSize: number;
  34266. instancesBuffer: Nullable<Buffer>;
  34267. instancesData: Float32Array;
  34268. overridenInstanceCount: number;
  34269. isFrozen: boolean;
  34270. previousBatch: Nullable<_InstancesBatch>;
  34271. hardwareInstancedRendering: boolean;
  34272. sideOrientation: number;
  34273. manualUpdate: boolean;
  34274. previousRenderId: number;
  34275. }
  34276. /**
  34277. * @hidden
  34278. **/
  34279. export class _InstancesBatch {
  34280. mustReturn: boolean;
  34281. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  34282. renderSelf: boolean[];
  34283. hardwareInstancedRendering: boolean[];
  34284. }
  34285. /**
  34286. * @hidden
  34287. **/
  34288. class _ThinInstanceDataStorage {
  34289. instancesCount: number;
  34290. matrixBuffer: Nullable<Buffer>;
  34291. matrixBufferSize: number;
  34292. matrixData: Nullable<Float32Array>;
  34293. boundingVectors: Array<Vector3>;
  34294. worldMatrices: Nullable<Matrix[]>;
  34295. }
  34296. /**
  34297. * Class used to represent renderable models
  34298. */
  34299. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  34300. /**
  34301. * Mesh side orientation : usually the external or front surface
  34302. */
  34303. static readonly FRONTSIDE: number;
  34304. /**
  34305. * Mesh side orientation : usually the internal or back surface
  34306. */
  34307. static readonly BACKSIDE: number;
  34308. /**
  34309. * Mesh side orientation : both internal and external or front and back surfaces
  34310. */
  34311. static readonly DOUBLESIDE: number;
  34312. /**
  34313. * Mesh side orientation : by default, `FRONTSIDE`
  34314. */
  34315. static readonly DEFAULTSIDE: number;
  34316. /**
  34317. * Mesh cap setting : no cap
  34318. */
  34319. static readonly NO_CAP: number;
  34320. /**
  34321. * Mesh cap setting : one cap at the beginning of the mesh
  34322. */
  34323. static readonly CAP_START: number;
  34324. /**
  34325. * Mesh cap setting : one cap at the end of the mesh
  34326. */
  34327. static readonly CAP_END: number;
  34328. /**
  34329. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  34330. */
  34331. static readonly CAP_ALL: number;
  34332. /**
  34333. * Mesh pattern setting : no flip or rotate
  34334. */
  34335. static readonly NO_FLIP: number;
  34336. /**
  34337. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  34338. */
  34339. static readonly FLIP_TILE: number;
  34340. /**
  34341. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  34342. */
  34343. static readonly ROTATE_TILE: number;
  34344. /**
  34345. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  34346. */
  34347. static readonly FLIP_ROW: number;
  34348. /**
  34349. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  34350. */
  34351. static readonly ROTATE_ROW: number;
  34352. /**
  34353. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  34354. */
  34355. static readonly FLIP_N_ROTATE_TILE: number;
  34356. /**
  34357. * Mesh pattern setting : rotate pattern and rotate
  34358. */
  34359. static readonly FLIP_N_ROTATE_ROW: number;
  34360. /**
  34361. * Mesh tile positioning : part tiles same on left/right or top/bottom
  34362. */
  34363. static readonly CENTER: number;
  34364. /**
  34365. * Mesh tile positioning : part tiles on left
  34366. */
  34367. static readonly LEFT: number;
  34368. /**
  34369. * Mesh tile positioning : part tiles on right
  34370. */
  34371. static readonly RIGHT: number;
  34372. /**
  34373. * Mesh tile positioning : part tiles on top
  34374. */
  34375. static readonly TOP: number;
  34376. /**
  34377. * Mesh tile positioning : part tiles on bottom
  34378. */
  34379. static readonly BOTTOM: number;
  34380. /**
  34381. * Gets the default side orientation.
  34382. * @param orientation the orientation to value to attempt to get
  34383. * @returns the default orientation
  34384. * @hidden
  34385. */
  34386. static _GetDefaultSideOrientation(orientation?: number): number;
  34387. private _internalMeshDataInfo;
  34388. get computeBonesUsingShaders(): boolean;
  34389. set computeBonesUsingShaders(value: boolean);
  34390. /**
  34391. * An event triggered before rendering the mesh
  34392. */
  34393. get onBeforeRenderObservable(): Observable<Mesh>;
  34394. /**
  34395. * An event triggered before binding the mesh
  34396. */
  34397. get onBeforeBindObservable(): Observable<Mesh>;
  34398. /**
  34399. * An event triggered after rendering the mesh
  34400. */
  34401. get onAfterRenderObservable(): Observable<Mesh>;
  34402. /**
  34403. * An event triggered before drawing the mesh
  34404. */
  34405. get onBeforeDrawObservable(): Observable<Mesh>;
  34406. private _onBeforeDrawObserver;
  34407. /**
  34408. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  34409. */
  34410. set onBeforeDraw(callback: () => void);
  34411. get hasInstances(): boolean;
  34412. get hasThinInstances(): boolean;
  34413. /**
  34414. * Gets the delay loading state of the mesh (when delay loading is turned on)
  34415. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  34416. */
  34417. delayLoadState: number;
  34418. /**
  34419. * Gets the list of instances created from this mesh
  34420. * it is not supposed to be modified manually.
  34421. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  34422. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  34423. */
  34424. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  34425. /**
  34426. * Gets the file containing delay loading data for this mesh
  34427. */
  34428. delayLoadingFile: string;
  34429. /** @hidden */
  34430. _binaryInfo: any;
  34431. /**
  34432. * User defined function used to change how LOD level selection is done
  34433. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34434. */
  34435. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  34436. /**
  34437. * Gets or sets the morph target manager
  34438. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  34439. */
  34440. get morphTargetManager(): Nullable<MorphTargetManager>;
  34441. set morphTargetManager(value: Nullable<MorphTargetManager>);
  34442. /** @hidden */
  34443. _creationDataStorage: Nullable<_CreationDataStorage>;
  34444. /** @hidden */
  34445. _geometry: Nullable<Geometry>;
  34446. /** @hidden */
  34447. _delayInfo: Array<string>;
  34448. /** @hidden */
  34449. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  34450. /** @hidden */
  34451. _instanceDataStorage: _InstanceDataStorage;
  34452. /** @hidden */
  34453. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  34454. private _effectiveMaterial;
  34455. /** @hidden */
  34456. _shouldGenerateFlatShading: boolean;
  34457. /** @hidden */
  34458. _originalBuilderSideOrientation: number;
  34459. /**
  34460. * Use this property to change the original side orientation defined at construction time
  34461. */
  34462. overrideMaterialSideOrientation: Nullable<number>;
  34463. /**
  34464. * Gets the source mesh (the one used to clone this one from)
  34465. */
  34466. get source(): Nullable<Mesh>;
  34467. /**
  34468. * Gets the list of clones of this mesh
  34469. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  34470. * Note that useClonedMeshMap=true is the default setting
  34471. */
  34472. get cloneMeshMap(): Nullable<{
  34473. [id: string]: Mesh | undefined;
  34474. }>;
  34475. /**
  34476. * Gets or sets a boolean indicating that this mesh does not use index buffer
  34477. */
  34478. get isUnIndexed(): boolean;
  34479. set isUnIndexed(value: boolean);
  34480. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  34481. get worldMatrixInstancedBuffer(): Float32Array;
  34482. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  34483. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  34484. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  34485. /**
  34486. * @constructor
  34487. * @param name The value used by scene.getMeshByName() to do a lookup.
  34488. * @param scene The scene to add this mesh to.
  34489. * @param parent The parent of this mesh, if it has one
  34490. * @param source An optional Mesh from which geometry is shared, cloned.
  34491. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  34492. * When false, achieved by calling a clone(), also passing False.
  34493. * This will make creation of children, recursive.
  34494. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  34495. */
  34496. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  34497. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  34498. doNotInstantiate: boolean;
  34499. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  34500. /**
  34501. * Gets the class name
  34502. * @returns the string "Mesh".
  34503. */
  34504. getClassName(): string;
  34505. /** @hidden */
  34506. get _isMesh(): boolean;
  34507. /**
  34508. * Returns a description of this mesh
  34509. * @param fullDetails define if full details about this mesh must be used
  34510. * @returns a descriptive string representing this mesh
  34511. */
  34512. toString(fullDetails?: boolean): string;
  34513. /** @hidden */
  34514. _unBindEffect(): void;
  34515. /**
  34516. * Gets a boolean indicating if this mesh has LOD
  34517. */
  34518. get hasLODLevels(): boolean;
  34519. /**
  34520. * Gets the list of MeshLODLevel associated with the current mesh
  34521. * @returns an array of MeshLODLevel
  34522. */
  34523. getLODLevels(): MeshLODLevel[];
  34524. private _sortLODLevels;
  34525. /**
  34526. * Add a mesh as LOD level triggered at the given distance.
  34527. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34528. * @param distance The distance from the center of the object to show this level
  34529. * @param mesh The mesh to be added as LOD level (can be null)
  34530. * @return This mesh (for chaining)
  34531. */
  34532. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  34533. /**
  34534. * Returns the LOD level mesh at the passed distance or null if not found.
  34535. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34536. * @param distance The distance from the center of the object to show this level
  34537. * @returns a Mesh or `null`
  34538. */
  34539. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  34540. /**
  34541. * Remove a mesh from the LOD array
  34542. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34543. * @param mesh defines the mesh to be removed
  34544. * @return This mesh (for chaining)
  34545. */
  34546. removeLODLevel(mesh: Mesh): Mesh;
  34547. /**
  34548. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  34549. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34550. * @param camera defines the camera to use to compute distance
  34551. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  34552. * @return This mesh (for chaining)
  34553. */
  34554. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  34555. /**
  34556. * Gets the mesh internal Geometry object
  34557. */
  34558. get geometry(): Nullable<Geometry>;
  34559. /**
  34560. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  34561. * @returns the total number of vertices
  34562. */
  34563. getTotalVertices(): number;
  34564. /**
  34565. * Returns the content of an associated vertex buffer
  34566. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  34567. * - VertexBuffer.PositionKind
  34568. * - VertexBuffer.UVKind
  34569. * - VertexBuffer.UV2Kind
  34570. * - VertexBuffer.UV3Kind
  34571. * - VertexBuffer.UV4Kind
  34572. * - VertexBuffer.UV5Kind
  34573. * - VertexBuffer.UV6Kind
  34574. * - VertexBuffer.ColorKind
  34575. * - VertexBuffer.MatricesIndicesKind
  34576. * - VertexBuffer.MatricesIndicesExtraKind
  34577. * - VertexBuffer.MatricesWeightsKind
  34578. * - VertexBuffer.MatricesWeightsExtraKind
  34579. * @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
  34580. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  34581. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  34582. */
  34583. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  34584. /**
  34585. * Returns the mesh VertexBuffer object from the requested `kind`
  34586. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  34587. * - VertexBuffer.PositionKind
  34588. * - VertexBuffer.NormalKind
  34589. * - VertexBuffer.UVKind
  34590. * - VertexBuffer.UV2Kind
  34591. * - VertexBuffer.UV3Kind
  34592. * - VertexBuffer.UV4Kind
  34593. * - VertexBuffer.UV5Kind
  34594. * - VertexBuffer.UV6Kind
  34595. * - VertexBuffer.ColorKind
  34596. * - VertexBuffer.MatricesIndicesKind
  34597. * - VertexBuffer.MatricesIndicesExtraKind
  34598. * - VertexBuffer.MatricesWeightsKind
  34599. * - VertexBuffer.MatricesWeightsExtraKind
  34600. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  34601. */
  34602. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  34603. /**
  34604. * Tests if a specific vertex buffer is associated with this mesh
  34605. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  34606. * - VertexBuffer.PositionKind
  34607. * - VertexBuffer.NormalKind
  34608. * - VertexBuffer.UVKind
  34609. * - VertexBuffer.UV2Kind
  34610. * - VertexBuffer.UV3Kind
  34611. * - VertexBuffer.UV4Kind
  34612. * - VertexBuffer.UV5Kind
  34613. * - VertexBuffer.UV6Kind
  34614. * - VertexBuffer.ColorKind
  34615. * - VertexBuffer.MatricesIndicesKind
  34616. * - VertexBuffer.MatricesIndicesExtraKind
  34617. * - VertexBuffer.MatricesWeightsKind
  34618. * - VertexBuffer.MatricesWeightsExtraKind
  34619. * @returns a boolean
  34620. */
  34621. isVerticesDataPresent(kind: string): boolean;
  34622. /**
  34623. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  34624. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  34625. * - VertexBuffer.PositionKind
  34626. * - VertexBuffer.UVKind
  34627. * - VertexBuffer.UV2Kind
  34628. * - VertexBuffer.UV3Kind
  34629. * - VertexBuffer.UV4Kind
  34630. * - VertexBuffer.UV5Kind
  34631. * - VertexBuffer.UV6Kind
  34632. * - VertexBuffer.ColorKind
  34633. * - VertexBuffer.MatricesIndicesKind
  34634. * - VertexBuffer.MatricesIndicesExtraKind
  34635. * - VertexBuffer.MatricesWeightsKind
  34636. * - VertexBuffer.MatricesWeightsExtraKind
  34637. * @returns a boolean
  34638. */
  34639. isVertexBufferUpdatable(kind: string): boolean;
  34640. /**
  34641. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  34642. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  34643. * - VertexBuffer.PositionKind
  34644. * - VertexBuffer.NormalKind
  34645. * - VertexBuffer.UVKind
  34646. * - VertexBuffer.UV2Kind
  34647. * - VertexBuffer.UV3Kind
  34648. * - VertexBuffer.UV4Kind
  34649. * - VertexBuffer.UV5Kind
  34650. * - VertexBuffer.UV6Kind
  34651. * - VertexBuffer.ColorKind
  34652. * - VertexBuffer.MatricesIndicesKind
  34653. * - VertexBuffer.MatricesIndicesExtraKind
  34654. * - VertexBuffer.MatricesWeightsKind
  34655. * - VertexBuffer.MatricesWeightsExtraKind
  34656. * @returns an array of strings
  34657. */
  34658. getVerticesDataKinds(): string[];
  34659. /**
  34660. * Returns a positive integer : the total number of indices in this mesh geometry.
  34661. * @returns the numner of indices or zero if the mesh has no geometry.
  34662. */
  34663. getTotalIndices(): number;
  34664. /**
  34665. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34666. * @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.
  34667. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34668. * @returns the indices array or an empty array if the mesh has no geometry
  34669. */
  34670. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34671. get isBlocked(): boolean;
  34672. /**
  34673. * Determine if the current mesh is ready to be rendered
  34674. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34675. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  34676. * @returns true if all associated assets are ready (material, textures, shaders)
  34677. */
  34678. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  34679. /**
  34680. * 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.
  34681. */
  34682. get areNormalsFrozen(): boolean;
  34683. /**
  34684. * 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.
  34685. * @returns the current mesh
  34686. */
  34687. freezeNormals(): Mesh;
  34688. /**
  34689. * 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
  34690. * @returns the current mesh
  34691. */
  34692. unfreezeNormals(): Mesh;
  34693. /**
  34694. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  34695. */
  34696. set overridenInstanceCount(count: number);
  34697. /** @hidden */
  34698. _preActivate(): Mesh;
  34699. /** @hidden */
  34700. _preActivateForIntermediateRendering(renderId: number): Mesh;
  34701. /** @hidden */
  34702. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  34703. protected _afterComputeWorldMatrix(): void;
  34704. /** @hidden */
  34705. _postActivate(): void;
  34706. /**
  34707. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  34708. * This means the mesh underlying bounding box and sphere are recomputed.
  34709. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  34710. * @returns the current mesh
  34711. */
  34712. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  34713. /** @hidden */
  34714. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  34715. /**
  34716. * This function will subdivide the mesh into multiple submeshes
  34717. * @param count defines the expected number of submeshes
  34718. */
  34719. subdivide(count: number): void;
  34720. /**
  34721. * Copy a FloatArray into a specific associated vertex buffer
  34722. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34723. * - VertexBuffer.PositionKind
  34724. * - VertexBuffer.UVKind
  34725. * - VertexBuffer.UV2Kind
  34726. * - VertexBuffer.UV3Kind
  34727. * - VertexBuffer.UV4Kind
  34728. * - VertexBuffer.UV5Kind
  34729. * - VertexBuffer.UV6Kind
  34730. * - VertexBuffer.ColorKind
  34731. * - VertexBuffer.MatricesIndicesKind
  34732. * - VertexBuffer.MatricesIndicesExtraKind
  34733. * - VertexBuffer.MatricesWeightsKind
  34734. * - VertexBuffer.MatricesWeightsExtraKind
  34735. * @param data defines the data source
  34736. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  34737. * @param stride defines the data stride size (can be null)
  34738. * @returns the current mesh
  34739. */
  34740. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  34741. /**
  34742. * Delete a vertex buffer associated with this mesh
  34743. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  34744. * - VertexBuffer.PositionKind
  34745. * - VertexBuffer.UVKind
  34746. * - VertexBuffer.UV2Kind
  34747. * - VertexBuffer.UV3Kind
  34748. * - VertexBuffer.UV4Kind
  34749. * - VertexBuffer.UV5Kind
  34750. * - VertexBuffer.UV6Kind
  34751. * - VertexBuffer.ColorKind
  34752. * - VertexBuffer.MatricesIndicesKind
  34753. * - VertexBuffer.MatricesIndicesExtraKind
  34754. * - VertexBuffer.MatricesWeightsKind
  34755. * - VertexBuffer.MatricesWeightsExtraKind
  34756. */
  34757. removeVerticesData(kind: string): void;
  34758. /**
  34759. * Flags an associated vertex buffer as updatable
  34760. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  34761. * - VertexBuffer.PositionKind
  34762. * - VertexBuffer.UVKind
  34763. * - VertexBuffer.UV2Kind
  34764. * - VertexBuffer.UV3Kind
  34765. * - VertexBuffer.UV4Kind
  34766. * - VertexBuffer.UV5Kind
  34767. * - VertexBuffer.UV6Kind
  34768. * - VertexBuffer.ColorKind
  34769. * - VertexBuffer.MatricesIndicesKind
  34770. * - VertexBuffer.MatricesIndicesExtraKind
  34771. * - VertexBuffer.MatricesWeightsKind
  34772. * - VertexBuffer.MatricesWeightsExtraKind
  34773. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  34774. */
  34775. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  34776. /**
  34777. * Sets the mesh global Vertex Buffer
  34778. * @param buffer defines the buffer to use
  34779. * @returns the current mesh
  34780. */
  34781. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  34782. /**
  34783. * Update a specific associated vertex buffer
  34784. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34785. * - VertexBuffer.PositionKind
  34786. * - VertexBuffer.UVKind
  34787. * - VertexBuffer.UV2Kind
  34788. * - VertexBuffer.UV3Kind
  34789. * - VertexBuffer.UV4Kind
  34790. * - VertexBuffer.UV5Kind
  34791. * - VertexBuffer.UV6Kind
  34792. * - VertexBuffer.ColorKind
  34793. * - VertexBuffer.MatricesIndicesKind
  34794. * - VertexBuffer.MatricesIndicesExtraKind
  34795. * - VertexBuffer.MatricesWeightsKind
  34796. * - VertexBuffer.MatricesWeightsExtraKind
  34797. * @param data defines the data source
  34798. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34799. * @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)
  34800. * @returns the current mesh
  34801. */
  34802. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  34803. /**
  34804. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  34805. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  34806. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  34807. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  34808. * @returns the current mesh
  34809. */
  34810. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  34811. /**
  34812. * Creates a un-shared specific occurence of the geometry for the mesh.
  34813. * @returns the current mesh
  34814. */
  34815. makeGeometryUnique(): Mesh;
  34816. /**
  34817. * Set the index buffer of this mesh
  34818. * @param indices defines the source data
  34819. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  34820. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  34821. * @returns the current mesh
  34822. */
  34823. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  34824. /**
  34825. * Update the current index buffer
  34826. * @param indices defines the source data
  34827. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  34828. * @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)
  34829. * @returns the current mesh
  34830. */
  34831. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  34832. /**
  34833. * Invert the geometry to move from a right handed system to a left handed one.
  34834. * @returns the current mesh
  34835. */
  34836. toLeftHanded(): Mesh;
  34837. /** @hidden */
  34838. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  34839. /** @hidden */
  34840. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  34841. /**
  34842. * Registers for this mesh a javascript function called just before the rendering process
  34843. * @param func defines the function to call before rendering this mesh
  34844. * @returns the current mesh
  34845. */
  34846. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34847. /**
  34848. * Disposes a previously registered javascript function called before the rendering
  34849. * @param func defines the function to remove
  34850. * @returns the current mesh
  34851. */
  34852. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34853. /**
  34854. * Registers for this mesh a javascript function called just after the rendering is complete
  34855. * @param func defines the function to call after rendering this mesh
  34856. * @returns the current mesh
  34857. */
  34858. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34859. /**
  34860. * Disposes a previously registered javascript function called after the rendering.
  34861. * @param func defines the function to remove
  34862. * @returns the current mesh
  34863. */
  34864. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34865. /** @hidden */
  34866. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  34867. /** @hidden */
  34868. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  34869. /** @hidden */
  34870. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  34871. /** @hidden */
  34872. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  34873. /** @hidden */
  34874. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  34875. /** @hidden */
  34876. _rebuild(): void;
  34877. /** @hidden */
  34878. _freeze(): void;
  34879. /** @hidden */
  34880. _unFreeze(): void;
  34881. /**
  34882. * 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
  34883. * @param subMesh defines the subMesh to render
  34884. * @param enableAlphaMode defines if alpha mode can be changed
  34885. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  34886. * @returns the current mesh
  34887. */
  34888. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  34889. private _onBeforeDraw;
  34890. /**
  34891. * Renormalize the mesh and patch it up if there are no weights
  34892. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  34893. * However in the case of zero weights then we set just a single influence to 1.
  34894. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  34895. */
  34896. cleanMatrixWeights(): void;
  34897. private normalizeSkinFourWeights;
  34898. private normalizeSkinWeightsAndExtra;
  34899. /**
  34900. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  34901. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  34902. * the user know there was an issue with importing the mesh
  34903. * @returns a validation object with skinned, valid and report string
  34904. */
  34905. validateSkinning(): {
  34906. skinned: boolean;
  34907. valid: boolean;
  34908. report: string;
  34909. };
  34910. /** @hidden */
  34911. _checkDelayState(): Mesh;
  34912. private _queueLoad;
  34913. /**
  34914. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  34915. * A mesh is in the frustum if its bounding box intersects the frustum
  34916. * @param frustumPlanes defines the frustum to test
  34917. * @returns true if the mesh is in the frustum planes
  34918. */
  34919. isInFrustum(frustumPlanes: Plane[]): boolean;
  34920. /**
  34921. * Sets the mesh material by the material or multiMaterial `id` property
  34922. * @param id is a string identifying the material or the multiMaterial
  34923. * @returns the current mesh
  34924. */
  34925. setMaterialByID(id: string): Mesh;
  34926. /**
  34927. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  34928. * @returns an array of IAnimatable
  34929. */
  34930. getAnimatables(): IAnimatable[];
  34931. /**
  34932. * Modifies the mesh geometry according to the passed transformation matrix.
  34933. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  34934. * The mesh normals are modified using the same transformation.
  34935. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34936. * @param transform defines the transform matrix to use
  34937. * @see https://doc.babylonjs.com/resources/baking_transformations
  34938. * @returns the current mesh
  34939. */
  34940. bakeTransformIntoVertices(transform: Matrix): Mesh;
  34941. /**
  34942. * Modifies the mesh geometry according to its own current World Matrix.
  34943. * The mesh World Matrix is then reset.
  34944. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  34945. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34946. * @see https://doc.babylonjs.com/resources/baking_transformations
  34947. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  34948. * @returns the current mesh
  34949. */
  34950. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  34951. /** @hidden */
  34952. get _positions(): Nullable<Vector3[]>;
  34953. /** @hidden */
  34954. _resetPointsArrayCache(): Mesh;
  34955. /** @hidden */
  34956. _generatePointsArray(): boolean;
  34957. /**
  34958. * Returns a new Mesh object generated from the current mesh properties.
  34959. * This method must not get confused with createInstance()
  34960. * @param name is a string, the name given to the new mesh
  34961. * @param newParent can be any Node object (default `null`)
  34962. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  34963. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  34964. * @returns a new mesh
  34965. */
  34966. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  34967. /**
  34968. * Releases resources associated with this mesh.
  34969. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34970. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34971. */
  34972. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34973. /** @hidden */
  34974. _disposeInstanceSpecificData(): void;
  34975. /** @hidden */
  34976. _disposeThinInstanceSpecificData(): void;
  34977. /**
  34978. * Modifies the mesh geometry according to a displacement map.
  34979. * 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.
  34980. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34981. * @param url is a string, the URL from the image file is to be downloaded.
  34982. * @param minHeight is the lower limit of the displacement.
  34983. * @param maxHeight is the upper limit of the displacement.
  34984. * @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.
  34985. * @param uvOffset is an optional vector2 used to offset UV.
  34986. * @param uvScale is an optional vector2 used to scale UV.
  34987. * @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.
  34988. * @returns the Mesh.
  34989. */
  34990. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34991. /**
  34992. * Modifies the mesh geometry according to a displacementMap buffer.
  34993. * 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.
  34994. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34995. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  34996. * @param heightMapWidth is the width of the buffer image.
  34997. * @param heightMapHeight is the height of the buffer image.
  34998. * @param minHeight is the lower limit of the displacement.
  34999. * @param maxHeight is the upper limit of the displacement.
  35000. * @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.
  35001. * @param uvOffset is an optional vector2 used to offset UV.
  35002. * @param uvScale is an optional vector2 used to scale UV.
  35003. * @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.
  35004. * @returns the Mesh.
  35005. */
  35006. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  35007. /**
  35008. * Modify the mesh to get a flat shading rendering.
  35009. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  35010. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  35011. * @returns current mesh
  35012. */
  35013. convertToFlatShadedMesh(): Mesh;
  35014. /**
  35015. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  35016. * In other words, more vertices, no more indices and a single bigger VBO.
  35017. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  35018. * @returns current mesh
  35019. */
  35020. convertToUnIndexedMesh(): Mesh;
  35021. /**
  35022. * Inverses facet orientations.
  35023. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  35024. * @param flipNormals will also inverts the normals
  35025. * @returns current mesh
  35026. */
  35027. flipFaces(flipNormals?: boolean): Mesh;
  35028. /**
  35029. * Increase the number of facets and hence vertices in a mesh
  35030. * Vertex normals are interpolated from existing vertex normals
  35031. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  35032. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  35033. */
  35034. increaseVertices(numberPerEdge: number): void;
  35035. /**
  35036. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  35037. * This will undo any application of covertToFlatShadedMesh
  35038. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  35039. */
  35040. forceSharedVertices(): void;
  35041. /** @hidden */
  35042. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  35043. /** @hidden */
  35044. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  35045. /**
  35046. * Creates a new InstancedMesh object from the mesh model.
  35047. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  35048. * @param name defines the name of the new instance
  35049. * @returns a new InstancedMesh
  35050. */
  35051. createInstance(name: string): InstancedMesh;
  35052. /**
  35053. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  35054. * After this call, all the mesh instances have the same submeshes than the current mesh.
  35055. * @returns the current mesh
  35056. */
  35057. synchronizeInstances(): Mesh;
  35058. /**
  35059. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  35060. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  35061. * This should be used together with the simplification to avoid disappearing triangles.
  35062. * @param successCallback an optional success callback to be called after the optimization finished.
  35063. * @returns the current mesh
  35064. */
  35065. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  35066. /**
  35067. * Serialize current mesh
  35068. * @param serializationObject defines the object which will receive the serialization data
  35069. */
  35070. serialize(serializationObject: any): void;
  35071. /** @hidden */
  35072. _syncGeometryWithMorphTargetManager(): void;
  35073. /** @hidden */
  35074. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  35075. /**
  35076. * Returns a new Mesh object parsed from the source provided.
  35077. * @param parsedMesh is the source
  35078. * @param scene defines the hosting scene
  35079. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  35080. * @returns a new Mesh
  35081. */
  35082. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  35083. /**
  35084. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  35085. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  35086. * @param name defines the name of the mesh to create
  35087. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  35088. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  35089. * @param closePath creates a seam between the first and the last points of each path of the path array
  35090. * @param offset is taken in account only if the `pathArray` is containing a single path
  35091. * @param scene defines the hosting scene
  35092. * @param updatable defines if the mesh must be flagged as updatable
  35093. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35094. * @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)
  35095. * @returns a new Mesh
  35096. */
  35097. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  35098. /**
  35099. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  35100. * @param name defines the name of the mesh to create
  35101. * @param radius sets the radius size (float) of the polygon (default 0.5)
  35102. * @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
  35103. * @param scene defines the hosting scene
  35104. * @param updatable defines if the mesh must be flagged as updatable
  35105. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35106. * @returns a new Mesh
  35107. */
  35108. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  35109. /**
  35110. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  35111. * @param name defines the name of the mesh to create
  35112. * @param size sets the size (float) of each box side (default 1)
  35113. * @param scene defines the hosting scene
  35114. * @param updatable defines if the mesh must be flagged as updatable
  35115. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35116. * @returns a new Mesh
  35117. */
  35118. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  35119. /**
  35120. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  35121. * @param name defines the name of the mesh to create
  35122. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  35123. * @param diameter sets the diameter size (float) of the sphere (default 1)
  35124. * @param scene defines the hosting scene
  35125. * @param updatable defines if the mesh must be flagged as updatable
  35126. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35127. * @returns a new Mesh
  35128. */
  35129. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  35130. /**
  35131. * Creates a hemisphere 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 segments sets the sphere number of horizontal stripes (positive integer, default 32)
  35134. * @param diameter sets the diameter size (float) of the sphere (default 1)
  35135. * @param scene defines the hosting scene
  35136. * @returns a new Mesh
  35137. */
  35138. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  35139. /**
  35140. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  35141. * @param name defines the name of the mesh to create
  35142. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  35143. * @param diameterTop set the top cap diameter (floats, default 1)
  35144. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  35145. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  35146. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  35147. * @param scene defines the hosting scene
  35148. * @param updatable defines if the mesh must be flagged as updatable
  35149. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35150. * @returns a new Mesh
  35151. */
  35152. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  35153. /**
  35154. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  35155. * @param name defines the name of the mesh to create
  35156. * @param diameter sets the diameter size (float) of the torus (default 1)
  35157. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  35158. * @param tessellation sets the number of torus sides (postive integer, default 16)
  35159. * @param scene defines the hosting scene
  35160. * @param updatable defines if the mesh must be flagged as updatable
  35161. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35162. * @returns a new Mesh
  35163. */
  35164. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  35165. /**
  35166. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  35167. * @param name defines the name of the mesh to create
  35168. * @param radius sets the global radius size (float) of the torus knot (default 2)
  35169. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  35170. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  35171. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  35172. * @param p the number of windings on X axis (positive integers, default 2)
  35173. * @param q the number of windings on Y axis (positive integers, default 3)
  35174. * @param scene defines the hosting scene
  35175. * @param updatable defines if the mesh must be flagged as updatable
  35176. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35177. * @returns a new Mesh
  35178. */
  35179. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  35180. /**
  35181. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  35182. * @param name defines the name of the mesh to create
  35183. * @param points is an array successive Vector3
  35184. * @param scene defines the hosting scene
  35185. * @param updatable defines if the mesh must be flagged as updatable
  35186. * @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).
  35187. * @returns a new Mesh
  35188. */
  35189. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  35190. /**
  35191. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  35192. * @param name defines the name of the mesh to create
  35193. * @param points is an array successive Vector3
  35194. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  35195. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  35196. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  35197. * @param scene defines the hosting scene
  35198. * @param updatable defines if the mesh must be flagged as updatable
  35199. * @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)
  35200. * @returns a new Mesh
  35201. */
  35202. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  35203. /**
  35204. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  35205. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  35206. * 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.
  35207. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35208. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  35209. * Remember you can only change the shape positions, not their number when updating a polygon.
  35210. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  35211. * @param name defines the name of the mesh to create
  35212. * @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
  35213. * @param scene defines the hosting scene
  35214. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  35215. * @param updatable defines if the mesh must be flagged as updatable
  35216. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35217. * @param earcutInjection can be used to inject your own earcut reference
  35218. * @returns a new Mesh
  35219. */
  35220. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  35221. /**
  35222. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  35223. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  35224. * @param name defines the name of the mesh to create
  35225. * @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
  35226. * @param depth defines the height of extrusion
  35227. * @param scene defines the hosting scene
  35228. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  35229. * @param updatable defines if the mesh must be flagged as updatable
  35230. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35231. * @param earcutInjection can be used to inject your own earcut reference
  35232. * @returns a new Mesh
  35233. */
  35234. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  35235. /**
  35236. * Creates an extruded shape mesh.
  35237. * 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
  35238. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  35239. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  35240. * @param name defines the name of the mesh to create
  35241. * @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
  35242. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  35243. * @param scale is the value to scale the shape
  35244. * @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
  35245. * @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
  35246. * @param scene defines the hosting scene
  35247. * @param updatable defines if the mesh must be flagged as updatable
  35248. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35249. * @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)
  35250. * @returns a new Mesh
  35251. */
  35252. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  35253. /**
  35254. * Creates an custom extruded shape mesh.
  35255. * The custom extrusion is a parametric shape.
  35256. * It has no predefined shape. Its final shape will depend on the input parameters.
  35257. * Please consider using the same method from the MeshBuilder class instead
  35258. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  35259. * @param name defines the name of the mesh to create
  35260. * @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
  35261. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  35262. * @param scaleFunction is a custom Javascript function called on each path point
  35263. * @param rotationFunction is a custom Javascript function called on each path point
  35264. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  35265. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  35266. * @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
  35267. * @param scene defines the hosting scene
  35268. * @param updatable defines if the mesh must be flagged as updatable
  35269. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35270. * @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)
  35271. * @returns a new Mesh
  35272. */
  35273. 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;
  35274. /**
  35275. * Creates lathe mesh.
  35276. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  35277. * Please consider using the same method from the MeshBuilder class instead
  35278. * @param name defines the name of the mesh to create
  35279. * @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
  35280. * @param radius is the radius value of the lathe
  35281. * @param tessellation is the side number of the lathe.
  35282. * @param scene defines the hosting scene
  35283. * @param updatable defines if the mesh must be flagged as updatable
  35284. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35285. * @returns a new Mesh
  35286. */
  35287. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  35288. /**
  35289. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  35290. * @param name defines the name of the mesh to create
  35291. * @param size sets the size (float) of both sides of the plane at once (default 1)
  35292. * @param scene defines the hosting scene
  35293. * @param updatable defines if the mesh must be flagged as updatable
  35294. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35295. * @returns a new Mesh
  35296. */
  35297. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  35298. /**
  35299. * Creates a ground mesh.
  35300. * Please consider using the same method from the MeshBuilder class instead
  35301. * @param name defines the name of the mesh to create
  35302. * @param width set the width of the ground
  35303. * @param height set the height of the ground
  35304. * @param subdivisions sets the number of subdivisions per side
  35305. * @param scene defines the hosting scene
  35306. * @param updatable defines if the mesh must be flagged as updatable
  35307. * @returns a new Mesh
  35308. */
  35309. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  35310. /**
  35311. * Creates a tiled ground mesh.
  35312. * Please consider using the same method from the MeshBuilder class instead
  35313. * @param name defines the name of the mesh to create
  35314. * @param xmin set the ground minimum X coordinate
  35315. * @param zmin set the ground minimum Y coordinate
  35316. * @param xmax set the ground maximum X coordinate
  35317. * @param zmax set the ground maximum Z coordinate
  35318. * @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
  35319. * @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
  35320. * @param scene defines the hosting scene
  35321. * @param updatable defines if the mesh must be flagged as updatable
  35322. * @returns a new Mesh
  35323. */
  35324. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  35325. w: number;
  35326. h: number;
  35327. }, precision: {
  35328. w: number;
  35329. h: number;
  35330. }, scene: Scene, updatable?: boolean): Mesh;
  35331. /**
  35332. * Creates a ground mesh from a height map.
  35333. * Please consider using the same method from the MeshBuilder class instead
  35334. * @see https://doc.babylonjs.com/babylon101/height_map
  35335. * @param name defines the name of the mesh to create
  35336. * @param url sets the URL of the height map image resource
  35337. * @param width set the ground width size
  35338. * @param height set the ground height size
  35339. * @param subdivisions sets the number of subdivision per side
  35340. * @param minHeight is the minimum altitude on the ground
  35341. * @param maxHeight is the maximum altitude on the ground
  35342. * @param scene defines the hosting scene
  35343. * @param updatable defines if the mesh must be flagged as updatable
  35344. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  35345. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  35346. * @returns a new Mesh
  35347. */
  35348. 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;
  35349. /**
  35350. * Creates a tube mesh.
  35351. * The tube is a parametric shape.
  35352. * It has no predefined shape. Its final shape will depend on the input parameters.
  35353. * Please consider using the same method from the MeshBuilder class instead
  35354. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  35355. * @param name defines the name of the mesh to create
  35356. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  35357. * @param radius sets the tube radius size
  35358. * @param tessellation is the number of sides on the tubular surface
  35359. * @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
  35360. * @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
  35361. * @param scene defines the hosting scene
  35362. * @param updatable defines if the mesh must be flagged as updatable
  35363. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35364. * @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)
  35365. * @returns a new Mesh
  35366. */
  35367. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  35368. (i: number, distance: number): number;
  35369. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  35370. /**
  35371. * Creates a polyhedron mesh.
  35372. * Please consider using the same method from the MeshBuilder class instead.
  35373. * * 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
  35374. * * The parameter `size` (positive float, default 1) sets the polygon size
  35375. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  35376. * * 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`
  35377. * * 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
  35378. * * 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)`)
  35379. * * 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
  35380. * * 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
  35381. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35382. * * 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
  35383. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35384. * @param name defines the name of the mesh to create
  35385. * @param options defines the options used to create the mesh
  35386. * @param scene defines the hosting scene
  35387. * @returns a new Mesh
  35388. */
  35389. static CreatePolyhedron(name: string, options: {
  35390. type?: number;
  35391. size?: number;
  35392. sizeX?: number;
  35393. sizeY?: number;
  35394. sizeZ?: number;
  35395. custom?: any;
  35396. faceUV?: Vector4[];
  35397. faceColors?: Color4[];
  35398. updatable?: boolean;
  35399. sideOrientation?: number;
  35400. }, scene: Scene): Mesh;
  35401. /**
  35402. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  35403. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  35404. * * 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`)
  35405. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  35406. * * 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
  35407. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35408. * * 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
  35409. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35410. * @param name defines the name of the mesh
  35411. * @param options defines the options used to create the mesh
  35412. * @param scene defines the hosting scene
  35413. * @returns a new Mesh
  35414. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  35415. */
  35416. static CreateIcoSphere(name: string, options: {
  35417. radius?: number;
  35418. flat?: boolean;
  35419. subdivisions?: number;
  35420. sideOrientation?: number;
  35421. updatable?: boolean;
  35422. }, scene: Scene): Mesh;
  35423. /**
  35424. * Creates a decal mesh.
  35425. * Please consider using the same method from the MeshBuilder class instead.
  35426. * A decal is a mesh usually applied as a model onto the surface of another mesh
  35427. * @param name defines the name of the mesh
  35428. * @param sourceMesh defines the mesh receiving the decal
  35429. * @param position sets the position of the decal in world coordinates
  35430. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  35431. * @param size sets the decal scaling
  35432. * @param angle sets the angle to rotate the decal
  35433. * @returns a new Mesh
  35434. */
  35435. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  35436. /** Creates a Capsule Mesh
  35437. * @param name defines the name of the mesh.
  35438. * @param options the constructors options used to shape the mesh.
  35439. * @param scene defines the scene the mesh is scoped to.
  35440. * @returns the capsule mesh
  35441. * @see https://doc.babylonjs.com/how_to/capsule_shape
  35442. */
  35443. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  35444. /**
  35445. * Prepare internal position array for software CPU skinning
  35446. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  35447. */
  35448. setPositionsForCPUSkinning(): Float32Array;
  35449. /**
  35450. * Prepare internal normal array for software CPU skinning
  35451. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  35452. */
  35453. setNormalsForCPUSkinning(): Float32Array;
  35454. /**
  35455. * Updates the vertex buffer by applying transformation from the bones
  35456. * @param skeleton defines the skeleton to apply to current mesh
  35457. * @returns the current mesh
  35458. */
  35459. applySkeleton(skeleton: Skeleton): Mesh;
  35460. /**
  35461. * 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
  35462. * @param meshes defines the list of meshes to scan
  35463. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  35464. */
  35465. static MinMax(meshes: AbstractMesh[]): {
  35466. min: Vector3;
  35467. max: Vector3;
  35468. };
  35469. /**
  35470. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  35471. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  35472. * @returns a vector3
  35473. */
  35474. static Center(meshesOrMinMaxVector: {
  35475. min: Vector3;
  35476. max: Vector3;
  35477. } | AbstractMesh[]): Vector3;
  35478. /**
  35479. * Merge the array of meshes into a single mesh for performance reasons.
  35480. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  35481. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  35482. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  35483. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  35484. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  35485. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  35486. * @returns a new mesh
  35487. */
  35488. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  35489. /** @hidden */
  35490. addInstance(instance: InstancedMesh): void;
  35491. /** @hidden */
  35492. removeInstance(instance: InstancedMesh): void;
  35493. }
  35494. }
  35495. declare module "babylonjs/Meshes/Builders/capsuleBuilder" {
  35496. import { Vector3 } from "babylonjs/Maths/math.vector";
  35497. import { Mesh } from "babylonjs/Meshes/mesh";
  35498. /**
  35499. * The options Interface for creating a Capsule Mesh
  35500. */
  35501. export interface ICreateCapsuleOptions {
  35502. /** The Orientation of the capsule. Default : Vector3.Up() */
  35503. orientation?: Vector3;
  35504. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  35505. subdivisions: number;
  35506. /** Number of cylindrical segments on the capsule. */
  35507. tessellation: number;
  35508. /** Height or Length of the capsule. */
  35509. height: number;
  35510. /** Radius of the capsule. */
  35511. radius: number;
  35512. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  35513. capSubdivisions: number;
  35514. /** Overwrite for the top radius. */
  35515. radiusTop?: number;
  35516. /** Overwrite for the bottom radius. */
  35517. radiusBottom?: number;
  35518. /** Overwrite for the top capSubdivisions. */
  35519. topCapSubdivisions?: number;
  35520. /** Overwrite for the bottom capSubdivisions. */
  35521. bottomCapSubdivisions?: number;
  35522. }
  35523. /**
  35524. * Class containing static functions to help procedurally build meshes
  35525. */
  35526. export class CapsuleBuilder {
  35527. /**
  35528. * Creates a capsule or a pill mesh
  35529. * @param name defines the name of the mesh
  35530. * @param options The constructors options.
  35531. * @param scene The scene the mesh is scoped to.
  35532. * @returns Capsule Mesh
  35533. */
  35534. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  35535. }
  35536. }
  35537. declare module "babylonjs/Meshes/mesh.vertexData" {
  35538. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  35539. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  35540. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  35541. import { Geometry } from "babylonjs/Meshes/geometry";
  35542. import { Mesh } from "babylonjs/Meshes/mesh";
  35543. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  35544. /**
  35545. * Define an interface for all classes that will get and set the data on vertices
  35546. */
  35547. export interface IGetSetVerticesData {
  35548. /**
  35549. * Gets a boolean indicating if specific vertex data is present
  35550. * @param kind defines the vertex data kind to use
  35551. * @returns true is data kind is present
  35552. */
  35553. isVerticesDataPresent(kind: string): boolean;
  35554. /**
  35555. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  35556. * @param kind defines the data kind (Position, normal, etc...)
  35557. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  35558. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  35559. * @returns a float array containing vertex data
  35560. */
  35561. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  35562. /**
  35563. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  35564. * @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.
  35565. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  35566. * @returns the indices array or an empty array if the mesh has no geometry
  35567. */
  35568. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  35569. /**
  35570. * Set specific vertex data
  35571. * @param kind defines the data kind (Position, normal, etc...)
  35572. * @param data defines the vertex data to use
  35573. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  35574. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  35575. */
  35576. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  35577. /**
  35578. * Update a specific associated vertex buffer
  35579. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  35580. * - VertexBuffer.PositionKind
  35581. * - VertexBuffer.UVKind
  35582. * - VertexBuffer.UV2Kind
  35583. * - VertexBuffer.UV3Kind
  35584. * - VertexBuffer.UV4Kind
  35585. * - VertexBuffer.UV5Kind
  35586. * - VertexBuffer.UV6Kind
  35587. * - VertexBuffer.ColorKind
  35588. * - VertexBuffer.MatricesIndicesKind
  35589. * - VertexBuffer.MatricesIndicesExtraKind
  35590. * - VertexBuffer.MatricesWeightsKind
  35591. * - VertexBuffer.MatricesWeightsExtraKind
  35592. * @param data defines the data source
  35593. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  35594. * @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)
  35595. */
  35596. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  35597. /**
  35598. * Creates a new index buffer
  35599. * @param indices defines the indices to store in the index buffer
  35600. * @param totalVertices defines the total number of vertices (could be null)
  35601. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  35602. */
  35603. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  35604. }
  35605. /**
  35606. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  35607. */
  35608. export class VertexData {
  35609. /**
  35610. * Mesh side orientation : usually the external or front surface
  35611. */
  35612. static readonly FRONTSIDE: number;
  35613. /**
  35614. * Mesh side orientation : usually the internal or back surface
  35615. */
  35616. static readonly BACKSIDE: number;
  35617. /**
  35618. * Mesh side orientation : both internal and external or front and back surfaces
  35619. */
  35620. static readonly DOUBLESIDE: number;
  35621. /**
  35622. * Mesh side orientation : by default, `FRONTSIDE`
  35623. */
  35624. static readonly DEFAULTSIDE: number;
  35625. /**
  35626. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  35627. */
  35628. positions: Nullable<FloatArray>;
  35629. /**
  35630. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  35631. */
  35632. normals: Nullable<FloatArray>;
  35633. /**
  35634. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  35635. */
  35636. tangents: Nullable<FloatArray>;
  35637. /**
  35638. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  35639. */
  35640. uvs: Nullable<FloatArray>;
  35641. /**
  35642. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  35643. */
  35644. uvs2: Nullable<FloatArray>;
  35645. /**
  35646. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  35647. */
  35648. uvs3: Nullable<FloatArray>;
  35649. /**
  35650. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  35651. */
  35652. uvs4: Nullable<FloatArray>;
  35653. /**
  35654. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  35655. */
  35656. uvs5: Nullable<FloatArray>;
  35657. /**
  35658. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  35659. */
  35660. uvs6: Nullable<FloatArray>;
  35661. /**
  35662. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  35663. */
  35664. colors: Nullable<FloatArray>;
  35665. /**
  35666. * 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).
  35667. */
  35668. matricesIndices: Nullable<FloatArray>;
  35669. /**
  35670. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  35671. */
  35672. matricesWeights: Nullable<FloatArray>;
  35673. /**
  35674. * An array extending the number of possible indices
  35675. */
  35676. matricesIndicesExtra: Nullable<FloatArray>;
  35677. /**
  35678. * An array extending the number of possible weights when the number of indices is extended
  35679. */
  35680. matricesWeightsExtra: Nullable<FloatArray>;
  35681. /**
  35682. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  35683. */
  35684. indices: Nullable<IndicesArray>;
  35685. /**
  35686. * Uses the passed data array to set the set the values for the specified kind of data
  35687. * @param data a linear array of floating numbers
  35688. * @param kind the type of data that is being set, eg positions, colors etc
  35689. */
  35690. set(data: FloatArray, kind: string): void;
  35691. /**
  35692. * Associates the vertexData to the passed Mesh.
  35693. * Sets it as updatable or not (default `false`)
  35694. * @param mesh the mesh the vertexData is applied to
  35695. * @param updatable when used and having the value true allows new data to update the vertexData
  35696. * @returns the VertexData
  35697. */
  35698. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  35699. /**
  35700. * Associates the vertexData to the passed Geometry.
  35701. * Sets it as updatable or not (default `false`)
  35702. * @param geometry the geometry the vertexData is applied to
  35703. * @param updatable when used and having the value true allows new data to update the vertexData
  35704. * @returns VertexData
  35705. */
  35706. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  35707. /**
  35708. * Updates the associated mesh
  35709. * @param mesh the mesh to be updated
  35710. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  35711. * @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
  35712. * @returns VertexData
  35713. */
  35714. updateMesh(mesh: Mesh): VertexData;
  35715. /**
  35716. * Updates the associated geometry
  35717. * @param geometry the geometry to be updated
  35718. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  35719. * @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
  35720. * @returns VertexData.
  35721. */
  35722. updateGeometry(geometry: Geometry): VertexData;
  35723. private _applyTo;
  35724. private _update;
  35725. /**
  35726. * Transforms each position and each normal of the vertexData according to the passed Matrix
  35727. * @param matrix the transforming matrix
  35728. * @returns the VertexData
  35729. */
  35730. transform(matrix: Matrix): VertexData;
  35731. /**
  35732. * Merges the passed VertexData into the current one
  35733. * @param other the VertexData to be merged into the current one
  35734. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  35735. * @returns the modified VertexData
  35736. */
  35737. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  35738. private _mergeElement;
  35739. private _validate;
  35740. /**
  35741. * Serializes the VertexData
  35742. * @returns a serialized object
  35743. */
  35744. serialize(): any;
  35745. /**
  35746. * Extracts the vertexData from a mesh
  35747. * @param mesh the mesh from which to extract the VertexData
  35748. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  35749. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  35750. * @returns the object VertexData associated to the passed mesh
  35751. */
  35752. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  35753. /**
  35754. * Extracts the vertexData from the geometry
  35755. * @param geometry the geometry from which to extract the VertexData
  35756. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  35757. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  35758. * @returns the object VertexData associated to the passed mesh
  35759. */
  35760. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  35761. private static _ExtractFrom;
  35762. /**
  35763. * Creates the VertexData for a Ribbon
  35764. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  35765. * * pathArray array of paths, each of which an array of successive Vector3
  35766. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  35767. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  35768. * * 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
  35769. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35770. * * 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)
  35771. * * 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)
  35772. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  35773. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  35774. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  35775. * @returns the VertexData of the ribbon
  35776. */
  35777. static CreateRibbon(options: {
  35778. pathArray: Vector3[][];
  35779. closeArray?: boolean;
  35780. closePath?: boolean;
  35781. offset?: number;
  35782. sideOrientation?: number;
  35783. frontUVs?: Vector4;
  35784. backUVs?: Vector4;
  35785. invertUV?: boolean;
  35786. uvs?: Vector2[];
  35787. colors?: Color4[];
  35788. }): VertexData;
  35789. /**
  35790. * Creates the VertexData for a box
  35791. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35792. * * size sets the width, height and depth of the box to the value of size, optional default 1
  35793. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  35794. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  35795. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  35796. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  35797. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  35798. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35799. * * 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)
  35800. * * 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)
  35801. * @returns the VertexData of the box
  35802. */
  35803. static CreateBox(options: {
  35804. size?: number;
  35805. width?: number;
  35806. height?: number;
  35807. depth?: number;
  35808. faceUV?: Vector4[];
  35809. faceColors?: Color4[];
  35810. sideOrientation?: number;
  35811. frontUVs?: Vector4;
  35812. backUVs?: Vector4;
  35813. }): VertexData;
  35814. /**
  35815. * Creates the VertexData for a tiled box
  35816. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35817. * * faceTiles sets the pattern, tile size and number of tiles for a face
  35818. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  35819. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  35820. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35821. * @returns the VertexData of the box
  35822. */
  35823. static CreateTiledBox(options: {
  35824. pattern?: number;
  35825. width?: number;
  35826. height?: number;
  35827. depth?: number;
  35828. tileSize?: number;
  35829. tileWidth?: number;
  35830. tileHeight?: number;
  35831. alignHorizontal?: number;
  35832. alignVertical?: number;
  35833. faceUV?: Vector4[];
  35834. faceColors?: Color4[];
  35835. sideOrientation?: number;
  35836. }): VertexData;
  35837. /**
  35838. * Creates the VertexData for a tiled plane
  35839. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35840. * * pattern a limited pattern arrangement depending on the number
  35841. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  35842. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  35843. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  35844. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35845. * * 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)
  35846. * * 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)
  35847. * @returns the VertexData of the tiled plane
  35848. */
  35849. static CreateTiledPlane(options: {
  35850. pattern?: number;
  35851. tileSize?: number;
  35852. tileWidth?: number;
  35853. tileHeight?: number;
  35854. size?: number;
  35855. width?: number;
  35856. height?: number;
  35857. alignHorizontal?: number;
  35858. alignVertical?: number;
  35859. sideOrientation?: number;
  35860. frontUVs?: Vector4;
  35861. backUVs?: Vector4;
  35862. }): VertexData;
  35863. /**
  35864. * Creates the VertexData for an ellipsoid, defaults to a sphere
  35865. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35866. * * segments sets the number of horizontal strips optional, default 32
  35867. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  35868. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  35869. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  35870. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  35871. * * 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
  35872. * * 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
  35873. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35874. * * 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)
  35875. * * 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)
  35876. * @returns the VertexData of the ellipsoid
  35877. */
  35878. static CreateSphere(options: {
  35879. segments?: number;
  35880. diameter?: number;
  35881. diameterX?: number;
  35882. diameterY?: number;
  35883. diameterZ?: number;
  35884. arc?: number;
  35885. slice?: number;
  35886. sideOrientation?: number;
  35887. frontUVs?: Vector4;
  35888. backUVs?: Vector4;
  35889. }): VertexData;
  35890. /**
  35891. * Creates the VertexData for a cylinder, cone or prism
  35892. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35893. * * height sets the height (y direction) of the cylinder, optional, default 2
  35894. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  35895. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  35896. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  35897. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  35898. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  35899. * * 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
  35900. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  35901. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  35902. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  35903. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  35904. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35905. * * 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)
  35906. * * 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)
  35907. * @returns the VertexData of the cylinder, cone or prism
  35908. */
  35909. static CreateCylinder(options: {
  35910. height?: number;
  35911. diameterTop?: number;
  35912. diameterBottom?: number;
  35913. diameter?: number;
  35914. tessellation?: number;
  35915. subdivisions?: number;
  35916. arc?: number;
  35917. faceColors?: Color4[];
  35918. faceUV?: Vector4[];
  35919. hasRings?: boolean;
  35920. enclose?: boolean;
  35921. sideOrientation?: number;
  35922. frontUVs?: Vector4;
  35923. backUVs?: Vector4;
  35924. }): VertexData;
  35925. /**
  35926. * Creates the VertexData for a torus
  35927. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35928. * * diameter the diameter of the torus, optional default 1
  35929. * * thickness the diameter of the tube forming the torus, optional default 0.5
  35930. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  35931. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35932. * * 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)
  35933. * * 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)
  35934. * @returns the VertexData of the torus
  35935. */
  35936. static CreateTorus(options: {
  35937. diameter?: number;
  35938. thickness?: number;
  35939. tessellation?: number;
  35940. sideOrientation?: number;
  35941. frontUVs?: Vector4;
  35942. backUVs?: Vector4;
  35943. }): VertexData;
  35944. /**
  35945. * Creates the VertexData of the LineSystem
  35946. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  35947. * - lines an array of lines, each line being an array of successive Vector3
  35948. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  35949. * @returns the VertexData of the LineSystem
  35950. */
  35951. static CreateLineSystem(options: {
  35952. lines: Vector3[][];
  35953. colors?: Nullable<Color4[][]>;
  35954. }): VertexData;
  35955. /**
  35956. * Create the VertexData for a DashedLines
  35957. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  35958. * - points an array successive Vector3
  35959. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  35960. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  35961. * - dashNb the intended total number of dashes, optional, default 200
  35962. * @returns the VertexData for the DashedLines
  35963. */
  35964. static CreateDashedLines(options: {
  35965. points: Vector3[];
  35966. dashSize?: number;
  35967. gapSize?: number;
  35968. dashNb?: number;
  35969. }): VertexData;
  35970. /**
  35971. * Creates the VertexData for a Ground
  35972. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  35973. * - width the width (x direction) of the ground, optional, default 1
  35974. * - height the height (z direction) of the ground, optional, default 1
  35975. * - subdivisions the number of subdivisions per side, optional, default 1
  35976. * @returns the VertexData of the Ground
  35977. */
  35978. static CreateGround(options: {
  35979. width?: number;
  35980. height?: number;
  35981. subdivisions?: number;
  35982. subdivisionsX?: number;
  35983. subdivisionsY?: number;
  35984. }): VertexData;
  35985. /**
  35986. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  35987. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  35988. * * xmin the ground minimum X coordinate, optional, default -1
  35989. * * zmin the ground minimum Z coordinate, optional, default -1
  35990. * * xmax the ground maximum X coordinate, optional, default 1
  35991. * * zmax the ground maximum Z coordinate, optional, default 1
  35992. * * 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}
  35993. * * 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}
  35994. * @returns the VertexData of the TiledGround
  35995. */
  35996. static CreateTiledGround(options: {
  35997. xmin: number;
  35998. zmin: number;
  35999. xmax: number;
  36000. zmax: number;
  36001. subdivisions?: {
  36002. w: number;
  36003. h: number;
  36004. };
  36005. precision?: {
  36006. w: number;
  36007. h: number;
  36008. };
  36009. }): VertexData;
  36010. /**
  36011. * Creates the VertexData of the Ground designed from a heightmap
  36012. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  36013. * * width the width (x direction) of the ground
  36014. * * height the height (z direction) of the ground
  36015. * * subdivisions the number of subdivisions per side
  36016. * * minHeight the minimum altitude on the ground, optional, default 0
  36017. * * maxHeight the maximum altitude on the ground, optional default 1
  36018. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  36019. * * buffer the array holding the image color data
  36020. * * bufferWidth the width of image
  36021. * * bufferHeight the height of image
  36022. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  36023. * @returns the VertexData of the Ground designed from a heightmap
  36024. */
  36025. static CreateGroundFromHeightMap(options: {
  36026. width: number;
  36027. height: number;
  36028. subdivisions: number;
  36029. minHeight: number;
  36030. maxHeight: number;
  36031. colorFilter: Color3;
  36032. buffer: Uint8Array;
  36033. bufferWidth: number;
  36034. bufferHeight: number;
  36035. alphaFilter: number;
  36036. }): VertexData;
  36037. /**
  36038. * Creates the VertexData for a Plane
  36039. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  36040. * * size sets the width and height of the plane to the value of size, optional default 1
  36041. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  36042. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  36043. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  36044. * * 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)
  36045. * * 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)
  36046. * @returns the VertexData of the box
  36047. */
  36048. static CreatePlane(options: {
  36049. size?: number;
  36050. width?: number;
  36051. height?: number;
  36052. sideOrientation?: number;
  36053. frontUVs?: Vector4;
  36054. backUVs?: Vector4;
  36055. }): VertexData;
  36056. /**
  36057. * Creates the VertexData of the Disc or regular Polygon
  36058. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  36059. * * radius the radius of the disc, optional default 0.5
  36060. * * tessellation the number of polygon sides, optional, default 64
  36061. * * 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
  36062. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  36063. * * 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)
  36064. * * 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)
  36065. * @returns the VertexData of the box
  36066. */
  36067. static CreateDisc(options: {
  36068. radius?: number;
  36069. tessellation?: number;
  36070. arc?: number;
  36071. sideOrientation?: number;
  36072. frontUVs?: Vector4;
  36073. backUVs?: Vector4;
  36074. }): VertexData;
  36075. /**
  36076. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  36077. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  36078. * @param polygon a mesh built from polygonTriangulation.build()
  36079. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  36080. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  36081. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  36082. * @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)
  36083. * @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)
  36084. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  36085. * @returns the VertexData of the Polygon
  36086. */
  36087. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  36088. /**
  36089. * Creates the VertexData of the IcoSphere
  36090. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  36091. * * radius the radius of the IcoSphere, optional default 1
  36092. * * radiusX allows stretching in the x direction, optional, default radius
  36093. * * radiusY allows stretching in the y direction, optional, default radius
  36094. * * radiusZ allows stretching in the z direction, optional, default radius
  36095. * * flat when true creates a flat shaded mesh, optional, default true
  36096. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  36097. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  36098. * * 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)
  36099. * * 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)
  36100. * @returns the VertexData of the IcoSphere
  36101. */
  36102. static CreateIcoSphere(options: {
  36103. radius?: number;
  36104. radiusX?: number;
  36105. radiusY?: number;
  36106. radiusZ?: number;
  36107. flat?: boolean;
  36108. subdivisions?: number;
  36109. sideOrientation?: number;
  36110. frontUVs?: Vector4;
  36111. backUVs?: Vector4;
  36112. }): VertexData;
  36113. /**
  36114. * Creates the VertexData for a Polyhedron
  36115. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  36116. * * type provided types are:
  36117. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  36118. * * 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)
  36119. * * size the size of the IcoSphere, optional default 1
  36120. * * sizeX allows stretching in the x direction, optional, default size
  36121. * * sizeY allows stretching in the y direction, optional, default size
  36122. * * sizeZ allows stretching in the z direction, optional, default size
  36123. * * 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
  36124. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  36125. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  36126. * * flat when true creates a flat shaded mesh, optional, default true
  36127. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  36128. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  36129. * * 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)
  36130. * * 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)
  36131. * @returns the VertexData of the Polyhedron
  36132. */
  36133. static CreatePolyhedron(options: {
  36134. type?: number;
  36135. size?: number;
  36136. sizeX?: number;
  36137. sizeY?: number;
  36138. sizeZ?: number;
  36139. custom?: any;
  36140. faceUV?: Vector4[];
  36141. faceColors?: Color4[];
  36142. flat?: boolean;
  36143. sideOrientation?: number;
  36144. frontUVs?: Vector4;
  36145. backUVs?: Vector4;
  36146. }): VertexData;
  36147. /**
  36148. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  36149. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  36150. * @returns the VertexData of the Capsule
  36151. */
  36152. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  36153. /**
  36154. * Creates the VertexData for a TorusKnot
  36155. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  36156. * * radius the radius of the torus knot, optional, default 2
  36157. * * tube the thickness of the tube, optional, default 0.5
  36158. * * radialSegments the number of sides on each tube segments, optional, default 32
  36159. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  36160. * * p the number of windings around the z axis, optional, default 2
  36161. * * q the number of windings around the x axis, optional, default 3
  36162. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  36163. * * 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)
  36164. * * 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)
  36165. * @returns the VertexData of the Torus Knot
  36166. */
  36167. static CreateTorusKnot(options: {
  36168. radius?: number;
  36169. tube?: number;
  36170. radialSegments?: number;
  36171. tubularSegments?: number;
  36172. p?: number;
  36173. q?: number;
  36174. sideOrientation?: number;
  36175. frontUVs?: Vector4;
  36176. backUVs?: Vector4;
  36177. }): VertexData;
  36178. /**
  36179. * Compute normals for given positions and indices
  36180. * @param positions an array of vertex positions, [...., x, y, z, ......]
  36181. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  36182. * @param normals an array of vertex normals, [...., x, y, z, ......]
  36183. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  36184. * * facetNormals : optional array of facet normals (vector3)
  36185. * * facetPositions : optional array of facet positions (vector3)
  36186. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  36187. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  36188. * * bInfo : optional bounding info, required for facetPartitioning computation
  36189. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  36190. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  36191. * * useRightHandedSystem: optional boolean to for right handed system computation
  36192. * * depthSort : optional boolean to enable the facet depth sort computation
  36193. * * distanceTo : optional Vector3 to compute the facet depth from this location
  36194. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  36195. */
  36196. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  36197. facetNormals?: any;
  36198. facetPositions?: any;
  36199. facetPartitioning?: any;
  36200. ratio?: number;
  36201. bInfo?: any;
  36202. bbSize?: Vector3;
  36203. subDiv?: any;
  36204. useRightHandedSystem?: boolean;
  36205. depthSort?: boolean;
  36206. distanceTo?: Vector3;
  36207. depthSortedFacets?: any;
  36208. }): void;
  36209. /** @hidden */
  36210. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  36211. /**
  36212. * Applies VertexData created from the imported parameters to the geometry
  36213. * @param parsedVertexData the parsed data from an imported file
  36214. * @param geometry the geometry to apply the VertexData to
  36215. */
  36216. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  36217. }
  36218. }
  36219. declare module "babylonjs/Meshes/Builders/discBuilder" {
  36220. import { Nullable } from "babylonjs/types";
  36221. import { Scene } from "babylonjs/scene";
  36222. import { Vector4 } from "babylonjs/Maths/math.vector";
  36223. import { Mesh } from "babylonjs/Meshes/mesh";
  36224. /**
  36225. * Class containing static functions to help procedurally build meshes
  36226. */
  36227. export class DiscBuilder {
  36228. /**
  36229. * Creates a plane polygonal mesh. By default, this is a disc
  36230. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  36231. * * 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
  36232. * * 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
  36233. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36234. * * 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
  36235. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36236. * @param name defines the name of the mesh
  36237. * @param options defines the options used to create the mesh
  36238. * @param scene defines the hosting scene
  36239. * @returns the plane polygonal mesh
  36240. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  36241. */
  36242. static CreateDisc(name: string, options: {
  36243. radius?: number;
  36244. tessellation?: number;
  36245. arc?: number;
  36246. updatable?: boolean;
  36247. sideOrientation?: number;
  36248. frontUVs?: Vector4;
  36249. backUVs?: Vector4;
  36250. }, scene?: Nullable<Scene>): Mesh;
  36251. }
  36252. }
  36253. declare module "babylonjs/Particles/solidParticleSystem" {
  36254. import { Nullable } from "babylonjs/types";
  36255. import { Mesh } from "babylonjs/Meshes/mesh";
  36256. import { Scene, IDisposable } from "babylonjs/scene";
  36257. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  36258. import { Material } from "babylonjs/Materials/material";
  36259. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36260. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36261. /**
  36262. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  36263. *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.
  36264. * The SPS is also a particle system. It provides some methods to manage the particles.
  36265. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  36266. *
  36267. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  36268. */
  36269. export class SolidParticleSystem implements IDisposable {
  36270. /**
  36271. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  36272. * Example : var p = SPS.particles[i];
  36273. */
  36274. particles: SolidParticle[];
  36275. /**
  36276. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  36277. */
  36278. nbParticles: number;
  36279. /**
  36280. * If the particles must ever face the camera (default false). Useful for planar particles.
  36281. */
  36282. billboard: boolean;
  36283. /**
  36284. * Recompute normals when adding a shape
  36285. */
  36286. recomputeNormals: boolean;
  36287. /**
  36288. * This a counter ofr your own usage. It's not set by any SPS functions.
  36289. */
  36290. counter: number;
  36291. /**
  36292. * The SPS name. This name is also given to the underlying mesh.
  36293. */
  36294. name: string;
  36295. /**
  36296. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  36297. */
  36298. mesh: Mesh;
  36299. /**
  36300. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  36301. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  36302. */
  36303. vars: any;
  36304. /**
  36305. * This array is populated when the SPS is set as 'pickable'.
  36306. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  36307. * Each element of this array is an object `{idx: int, faceId: int}`.
  36308. * `idx` is the picked particle index in the `SPS.particles` array
  36309. * `faceId` is the picked face index counted within this particle.
  36310. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  36311. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  36312. * Use the method SPS.pickedParticle(pickingInfo) instead.
  36313. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  36314. */
  36315. pickedParticles: {
  36316. idx: number;
  36317. faceId: number;
  36318. }[];
  36319. /**
  36320. * This array is populated when the SPS is set as 'pickable'
  36321. * Each key of this array is a submesh index.
  36322. * Each element of this array is a second array defined like this :
  36323. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  36324. * Each element of this second array is an object `{idx: int, faceId: int}`.
  36325. * `idx` is the picked particle index in the `SPS.particles` array
  36326. * `faceId` is the picked face index counted within this particle.
  36327. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  36328. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  36329. */
  36330. pickedBySubMesh: {
  36331. idx: number;
  36332. faceId: number;
  36333. }[][];
  36334. /**
  36335. * This array is populated when `enableDepthSort` is set to true.
  36336. * Each element of this array is an instance of the class DepthSortedParticle.
  36337. */
  36338. depthSortedParticles: DepthSortedParticle[];
  36339. /**
  36340. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  36341. * @hidden
  36342. */
  36343. _bSphereOnly: boolean;
  36344. /**
  36345. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  36346. * @hidden
  36347. */
  36348. _bSphereRadiusFactor: number;
  36349. private _scene;
  36350. private _positions;
  36351. private _indices;
  36352. private _normals;
  36353. private _colors;
  36354. private _uvs;
  36355. private _indices32;
  36356. private _positions32;
  36357. private _normals32;
  36358. private _fixedNormal32;
  36359. private _colors32;
  36360. private _uvs32;
  36361. private _index;
  36362. private _updatable;
  36363. private _pickable;
  36364. private _isVisibilityBoxLocked;
  36365. private _alwaysVisible;
  36366. private _depthSort;
  36367. private _expandable;
  36368. private _shapeCounter;
  36369. private _copy;
  36370. private _color;
  36371. private _computeParticleColor;
  36372. private _computeParticleTexture;
  36373. private _computeParticleRotation;
  36374. private _computeParticleVertex;
  36375. private _computeBoundingBox;
  36376. private _depthSortParticles;
  36377. private _camera;
  36378. private _mustUnrotateFixedNormals;
  36379. private _particlesIntersect;
  36380. private _needs32Bits;
  36381. private _isNotBuilt;
  36382. private _lastParticleId;
  36383. private _idxOfId;
  36384. private _multimaterialEnabled;
  36385. private _useModelMaterial;
  36386. private _indicesByMaterial;
  36387. private _materialIndexes;
  36388. private _depthSortFunction;
  36389. private _materialSortFunction;
  36390. private _materials;
  36391. private _multimaterial;
  36392. private _materialIndexesById;
  36393. private _defaultMaterial;
  36394. private _autoUpdateSubMeshes;
  36395. private _tmpVertex;
  36396. /**
  36397. * Creates a SPS (Solid Particle System) object.
  36398. * @param name (String) is the SPS name, this will be the underlying mesh name.
  36399. * @param scene (Scene) is the scene in which the SPS is added.
  36400. * @param options defines the options of the sps e.g.
  36401. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  36402. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  36403. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  36404. * * 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.
  36405. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  36406. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  36407. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  36408. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  36409. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  36410. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  36411. */
  36412. constructor(name: string, scene: Scene, options?: {
  36413. updatable?: boolean;
  36414. isPickable?: boolean;
  36415. enableDepthSort?: boolean;
  36416. particleIntersection?: boolean;
  36417. boundingSphereOnly?: boolean;
  36418. bSphereRadiusFactor?: number;
  36419. expandable?: boolean;
  36420. useModelMaterial?: boolean;
  36421. enableMultiMaterial?: boolean;
  36422. });
  36423. /**
  36424. * Builds the SPS underlying mesh. Returns a standard Mesh.
  36425. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  36426. * @returns the created mesh
  36427. */
  36428. buildMesh(): Mesh;
  36429. /**
  36430. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  36431. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  36432. * Thus the particles generated from `digest()` have their property `position` set yet.
  36433. * @param mesh ( Mesh ) is the mesh to be digested
  36434. * @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
  36435. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  36436. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  36437. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  36438. * @returns the current SPS
  36439. */
  36440. digest(mesh: Mesh, options?: {
  36441. facetNb?: number;
  36442. number?: number;
  36443. delta?: number;
  36444. storage?: [];
  36445. }): SolidParticleSystem;
  36446. /**
  36447. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  36448. * @hidden
  36449. */
  36450. private _unrotateFixedNormals;
  36451. /**
  36452. * Resets the temporary working copy particle
  36453. * @hidden
  36454. */
  36455. private _resetCopy;
  36456. /**
  36457. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  36458. * @param p the current index in the positions array to be updated
  36459. * @param ind the current index in the indices array
  36460. * @param shape a Vector3 array, the shape geometry
  36461. * @param positions the positions array to be updated
  36462. * @param meshInd the shape indices array
  36463. * @param indices the indices array to be updated
  36464. * @param meshUV the shape uv array
  36465. * @param uvs the uv array to be updated
  36466. * @param meshCol the shape color array
  36467. * @param colors the color array to be updated
  36468. * @param meshNor the shape normals array
  36469. * @param normals the normals array to be updated
  36470. * @param idx the particle index
  36471. * @param idxInShape the particle index in its shape
  36472. * @param options the addShape() method passed options
  36473. * @model the particle model
  36474. * @hidden
  36475. */
  36476. private _meshBuilder;
  36477. /**
  36478. * Returns a shape Vector3 array from positions float array
  36479. * @param positions float array
  36480. * @returns a vector3 array
  36481. * @hidden
  36482. */
  36483. private _posToShape;
  36484. /**
  36485. * Returns a shapeUV array from a float uvs (array deep copy)
  36486. * @param uvs as a float array
  36487. * @returns a shapeUV array
  36488. * @hidden
  36489. */
  36490. private _uvsToShapeUV;
  36491. /**
  36492. * Adds a new particle object in the particles array
  36493. * @param idx particle index in particles array
  36494. * @param id particle id
  36495. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  36496. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  36497. * @param model particle ModelShape object
  36498. * @param shapeId model shape identifier
  36499. * @param idxInShape index of the particle in the current model
  36500. * @param bInfo model bounding info object
  36501. * @param storage target storage array, if any
  36502. * @hidden
  36503. */
  36504. private _addParticle;
  36505. /**
  36506. * Adds some particles to the SPS from the model shape. Returns the shape id.
  36507. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  36508. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  36509. * @param nb (positive integer) the number of particles to be created from this model
  36510. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  36511. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  36512. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  36513. * @returns the number of shapes in the system
  36514. */
  36515. addShape(mesh: Mesh, nb: number, options?: {
  36516. positionFunction?: any;
  36517. vertexFunction?: any;
  36518. storage?: [];
  36519. }): number;
  36520. /**
  36521. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  36522. * @hidden
  36523. */
  36524. private _rebuildParticle;
  36525. /**
  36526. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  36527. * @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.
  36528. * @returns the SPS.
  36529. */
  36530. rebuildMesh(reset?: boolean): SolidParticleSystem;
  36531. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  36532. * Returns an array with the removed particles.
  36533. * 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.
  36534. * The SPS can't be empty so at least one particle needs to remain in place.
  36535. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  36536. * @param start index of the first particle to remove
  36537. * @param end index of the last particle to remove (included)
  36538. * @returns an array populated with the removed particles
  36539. */
  36540. removeParticles(start: number, end: number): SolidParticle[];
  36541. /**
  36542. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  36543. * @param solidParticleArray an array populated with Solid Particles objects
  36544. * @returns the SPS
  36545. */
  36546. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  36547. /**
  36548. * Creates a new particle and modifies the SPS mesh geometry :
  36549. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  36550. * - calls _addParticle() to populate the particle array
  36551. * factorized code from addShape() and insertParticlesFromArray()
  36552. * @param idx particle index in the particles array
  36553. * @param i particle index in its shape
  36554. * @param modelShape particle ModelShape object
  36555. * @param shape shape vertex array
  36556. * @param meshInd shape indices array
  36557. * @param meshUV shape uv array
  36558. * @param meshCol shape color array
  36559. * @param meshNor shape normals array
  36560. * @param bbInfo shape bounding info
  36561. * @param storage target particle storage
  36562. * @options addShape() passed options
  36563. * @hidden
  36564. */
  36565. private _insertNewParticle;
  36566. /**
  36567. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  36568. * This method calls `updateParticle()` for each particle of the SPS.
  36569. * For an animated SPS, it is usually called within the render loop.
  36570. * 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.
  36571. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  36572. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  36573. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  36574. * @returns the SPS.
  36575. */
  36576. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  36577. /**
  36578. * Disposes the SPS.
  36579. */
  36580. dispose(): void;
  36581. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  36582. * idx is the particle index in the SPS
  36583. * faceId is the picked face index counted within this particle.
  36584. * Returns null if the pickInfo can't identify a picked particle.
  36585. * @param pickingInfo (PickingInfo object)
  36586. * @returns {idx: number, faceId: number} or null
  36587. */
  36588. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  36589. idx: number;
  36590. faceId: number;
  36591. }>;
  36592. /**
  36593. * Returns a SolidParticle object from its identifier : particle.id
  36594. * @param id (integer) the particle Id
  36595. * @returns the searched particle or null if not found in the SPS.
  36596. */
  36597. getParticleById(id: number): Nullable<SolidParticle>;
  36598. /**
  36599. * Returns a new array populated with the particles having the passed shapeId.
  36600. * @param shapeId (integer) the shape identifier
  36601. * @returns a new solid particle array
  36602. */
  36603. getParticlesByShapeId(shapeId: number): SolidParticle[];
  36604. /**
  36605. * Populates the passed array "ref" with the particles having the passed shapeId.
  36606. * @param shapeId the shape identifier
  36607. * @returns the SPS
  36608. * @param ref
  36609. */
  36610. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  36611. /**
  36612. * Computes the required SubMeshes according the materials assigned to the particles.
  36613. * @returns the solid particle system.
  36614. * Does nothing if called before the SPS mesh is built.
  36615. */
  36616. computeSubMeshes(): SolidParticleSystem;
  36617. /**
  36618. * Sorts the solid particles by material when MultiMaterial is enabled.
  36619. * Updates the indices32 array.
  36620. * Updates the indicesByMaterial array.
  36621. * Updates the mesh indices array.
  36622. * @returns the SPS
  36623. * @hidden
  36624. */
  36625. private _sortParticlesByMaterial;
  36626. /**
  36627. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  36628. * @hidden
  36629. */
  36630. private _setMaterialIndexesById;
  36631. /**
  36632. * Returns an array with unique values of Materials from the passed array
  36633. * @param array the material array to be checked and filtered
  36634. * @hidden
  36635. */
  36636. private _filterUniqueMaterialId;
  36637. /**
  36638. * Sets a new Standard Material as _defaultMaterial if not already set.
  36639. * @hidden
  36640. */
  36641. private _setDefaultMaterial;
  36642. /**
  36643. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  36644. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36645. * @returns the SPS.
  36646. */
  36647. refreshVisibleSize(): SolidParticleSystem;
  36648. /**
  36649. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  36650. * @param size the size (float) of the visibility box
  36651. * note : this doesn't lock the SPS mesh bounding box.
  36652. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36653. */
  36654. setVisibilityBox(size: number): void;
  36655. /**
  36656. * Gets whether the SPS as always visible or not
  36657. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36658. */
  36659. get isAlwaysVisible(): boolean;
  36660. /**
  36661. * Sets the SPS as always visible or not
  36662. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36663. */
  36664. set isAlwaysVisible(val: boolean);
  36665. /**
  36666. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  36667. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36668. */
  36669. set isVisibilityBoxLocked(val: boolean);
  36670. /**
  36671. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  36672. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36673. */
  36674. get isVisibilityBoxLocked(): boolean;
  36675. /**
  36676. * Tells to `setParticles()` to compute the particle rotations or not.
  36677. * Default value : true. The SPS is faster when it's set to false.
  36678. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  36679. */
  36680. set computeParticleRotation(val: boolean);
  36681. /**
  36682. * Tells to `setParticles()` to compute the particle colors or not.
  36683. * Default value : true. The SPS is faster when it's set to false.
  36684. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  36685. */
  36686. set computeParticleColor(val: boolean);
  36687. set computeParticleTexture(val: boolean);
  36688. /**
  36689. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  36690. * Default value : false. The SPS is faster when it's set to false.
  36691. * Note : the particle custom vertex positions aren't stored values.
  36692. */
  36693. set computeParticleVertex(val: boolean);
  36694. /**
  36695. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  36696. */
  36697. set computeBoundingBox(val: boolean);
  36698. /**
  36699. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  36700. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  36701. * Default : `true`
  36702. */
  36703. set depthSortParticles(val: boolean);
  36704. /**
  36705. * Gets if `setParticles()` computes the particle rotations or not.
  36706. * Default value : true. The SPS is faster when it's set to false.
  36707. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  36708. */
  36709. get computeParticleRotation(): boolean;
  36710. /**
  36711. * Gets if `setParticles()` computes the particle colors or not.
  36712. * Default value : true. The SPS is faster when it's set to false.
  36713. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  36714. */
  36715. get computeParticleColor(): boolean;
  36716. /**
  36717. * Gets if `setParticles()` computes the particle textures or not.
  36718. * Default value : true. The SPS is faster when it's set to false.
  36719. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  36720. */
  36721. get computeParticleTexture(): boolean;
  36722. /**
  36723. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  36724. * Default value : false. The SPS is faster when it's set to false.
  36725. * Note : the particle custom vertex positions aren't stored values.
  36726. */
  36727. get computeParticleVertex(): boolean;
  36728. /**
  36729. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  36730. */
  36731. get computeBoundingBox(): boolean;
  36732. /**
  36733. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  36734. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  36735. * Default : `true`
  36736. */
  36737. get depthSortParticles(): boolean;
  36738. /**
  36739. * Gets if the SPS is created as expandable at construction time.
  36740. * Default : `false`
  36741. */
  36742. get expandable(): boolean;
  36743. /**
  36744. * Gets if the SPS supports the Multi Materials
  36745. */
  36746. get multimaterialEnabled(): boolean;
  36747. /**
  36748. * Gets if the SPS uses the model materials for its own multimaterial.
  36749. */
  36750. get useModelMaterial(): boolean;
  36751. /**
  36752. * The SPS used material array.
  36753. */
  36754. get materials(): Material[];
  36755. /**
  36756. * Sets the SPS MultiMaterial from the passed materials.
  36757. * Note : the passed array is internally copied and not used then by reference.
  36758. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  36759. */
  36760. setMultiMaterial(materials: Material[]): void;
  36761. /**
  36762. * The SPS computed multimaterial object
  36763. */
  36764. get multimaterial(): MultiMaterial;
  36765. set multimaterial(mm: MultiMaterial);
  36766. /**
  36767. * If the subMeshes must be updated on the next call to setParticles()
  36768. */
  36769. get autoUpdateSubMeshes(): boolean;
  36770. set autoUpdateSubMeshes(val: boolean);
  36771. /**
  36772. * This function does nothing. It may be overwritten to set all the particle first values.
  36773. * The SPS doesn't call this function, you may have to call it by your own.
  36774. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36775. */
  36776. initParticles(): void;
  36777. /**
  36778. * This function does nothing. It may be overwritten to recycle a particle.
  36779. * The SPS doesn't call this function, you may have to call it by your own.
  36780. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36781. * @param particle The particle to recycle
  36782. * @returns the recycled particle
  36783. */
  36784. recycleParticle(particle: SolidParticle): SolidParticle;
  36785. /**
  36786. * Updates a particle : this function should be overwritten by the user.
  36787. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  36788. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36789. * @example : just set a particle position or velocity and recycle conditions
  36790. * @param particle The particle to update
  36791. * @returns the updated particle
  36792. */
  36793. updateParticle(particle: SolidParticle): SolidParticle;
  36794. /**
  36795. * Updates a vertex of a particle : it can be overwritten by the user.
  36796. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  36797. * @param particle the current particle
  36798. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  36799. * @param pt the index of the current vertex in the particle shape
  36800. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  36801. * @example : just set a vertex particle position or color
  36802. * @returns the sps
  36803. */
  36804. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  36805. /**
  36806. * This will be called before any other treatment by `setParticles()` and 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. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36813. /**
  36814. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  36815. * This will be passed three parameters.
  36816. * This does nothing and may be overwritten by the user.
  36817. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36818. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36819. * @param update the boolean update value actually passed to setParticles()
  36820. */
  36821. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36822. }
  36823. }
  36824. declare module "babylonjs/Particles/solidParticle" {
  36825. import { Nullable } from "babylonjs/types";
  36826. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  36827. import { Color4 } from "babylonjs/Maths/math.color";
  36828. import { Mesh } from "babylonjs/Meshes/mesh";
  36829. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  36830. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  36831. import { Plane } from "babylonjs/Maths/math.plane";
  36832. import { Material } from "babylonjs/Materials/material";
  36833. /**
  36834. * Represents one particle of a solid particle system.
  36835. */
  36836. export class SolidParticle {
  36837. /**
  36838. * particle global index
  36839. */
  36840. idx: number;
  36841. /**
  36842. * particle identifier
  36843. */
  36844. id: number;
  36845. /**
  36846. * The color of the particle
  36847. */
  36848. color: Nullable<Color4>;
  36849. /**
  36850. * The world space position of the particle.
  36851. */
  36852. position: Vector3;
  36853. /**
  36854. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  36855. */
  36856. rotation: Vector3;
  36857. /**
  36858. * The world space rotation quaternion of the particle.
  36859. */
  36860. rotationQuaternion: Nullable<Quaternion>;
  36861. /**
  36862. * The scaling of the particle.
  36863. */
  36864. scaling: Vector3;
  36865. /**
  36866. * The uvs of the particle.
  36867. */
  36868. uvs: Vector4;
  36869. /**
  36870. * The current speed of the particle.
  36871. */
  36872. velocity: Vector3;
  36873. /**
  36874. * The pivot point in the particle local space.
  36875. */
  36876. pivot: Vector3;
  36877. /**
  36878. * Must the particle be translated from its pivot point in its local space ?
  36879. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  36880. * Default : false
  36881. */
  36882. translateFromPivot: boolean;
  36883. /**
  36884. * Is the particle active or not ?
  36885. */
  36886. alive: boolean;
  36887. /**
  36888. * Is the particle visible or not ?
  36889. */
  36890. isVisible: boolean;
  36891. /**
  36892. * Index of this particle in the global "positions" array (Internal use)
  36893. * @hidden
  36894. */
  36895. _pos: number;
  36896. /**
  36897. * @hidden Index of this particle in the global "indices" array (Internal use)
  36898. */
  36899. _ind: number;
  36900. /**
  36901. * @hidden ModelShape of this particle (Internal use)
  36902. */
  36903. _model: ModelShape;
  36904. /**
  36905. * ModelShape id of this particle
  36906. */
  36907. shapeId: number;
  36908. /**
  36909. * Index of the particle in its shape id
  36910. */
  36911. idxInShape: number;
  36912. /**
  36913. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  36914. */
  36915. _modelBoundingInfo: BoundingInfo;
  36916. /**
  36917. * @hidden Particle BoundingInfo object (Internal use)
  36918. */
  36919. _boundingInfo: BoundingInfo;
  36920. /**
  36921. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  36922. */
  36923. _sps: SolidParticleSystem;
  36924. /**
  36925. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  36926. */
  36927. _stillInvisible: boolean;
  36928. /**
  36929. * @hidden Last computed particle rotation matrix
  36930. */
  36931. _rotationMatrix: number[];
  36932. /**
  36933. * Parent particle Id, if any.
  36934. * Default null.
  36935. */
  36936. parentId: Nullable<number>;
  36937. /**
  36938. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  36939. */
  36940. materialIndex: Nullable<number>;
  36941. /**
  36942. * Custom object or properties.
  36943. */
  36944. props: Nullable<any>;
  36945. /**
  36946. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  36947. * The possible values are :
  36948. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36949. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36950. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36951. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36952. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36953. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  36954. * */
  36955. cullingStrategy: number;
  36956. /**
  36957. * @hidden Internal global position in the SPS.
  36958. */
  36959. _globalPosition: Vector3;
  36960. /**
  36961. * Creates a Solid Particle object.
  36962. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  36963. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  36964. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  36965. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  36966. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  36967. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  36968. * @param shapeId (integer) is the model shape identifier in the SPS.
  36969. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  36970. * @param sps defines the sps it is associated to
  36971. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  36972. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  36973. */
  36974. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  36975. /**
  36976. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  36977. * @param target the particle target
  36978. * @returns the current particle
  36979. */
  36980. copyToRef(target: SolidParticle): SolidParticle;
  36981. /**
  36982. * Legacy support, changed scale to scaling
  36983. */
  36984. get scale(): Vector3;
  36985. /**
  36986. * Legacy support, changed scale to scaling
  36987. */
  36988. set scale(scale: Vector3);
  36989. /**
  36990. * Legacy support, changed quaternion to rotationQuaternion
  36991. */
  36992. get quaternion(): Nullable<Quaternion>;
  36993. /**
  36994. * Legacy support, changed quaternion to rotationQuaternion
  36995. */
  36996. set quaternion(q: Nullable<Quaternion>);
  36997. /**
  36998. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  36999. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  37000. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  37001. * @returns true if it intersects
  37002. */
  37003. intersectsMesh(target: Mesh | SolidParticle): boolean;
  37004. /**
  37005. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  37006. * A particle is in the frustum if its bounding box intersects the frustum
  37007. * @param frustumPlanes defines the frustum to test
  37008. * @returns true if the particle is in the frustum planes
  37009. */
  37010. isInFrustum(frustumPlanes: Plane[]): boolean;
  37011. /**
  37012. * get the rotation matrix of the particle
  37013. * @hidden
  37014. */
  37015. getRotationMatrix(m: Matrix): void;
  37016. }
  37017. /**
  37018. * Represents the shape of the model used by one particle of a solid particle system.
  37019. * SPS internal tool, don't use it manually.
  37020. */
  37021. export class ModelShape {
  37022. /**
  37023. * The shape id
  37024. * @hidden
  37025. */
  37026. shapeID: number;
  37027. /**
  37028. * flat array of model positions (internal use)
  37029. * @hidden
  37030. */
  37031. _shape: Vector3[];
  37032. /**
  37033. * flat array of model UVs (internal use)
  37034. * @hidden
  37035. */
  37036. _shapeUV: number[];
  37037. /**
  37038. * color array of the model
  37039. * @hidden
  37040. */
  37041. _shapeColors: number[];
  37042. /**
  37043. * indices array of the model
  37044. * @hidden
  37045. */
  37046. _indices: number[];
  37047. /**
  37048. * normals array of the model
  37049. * @hidden
  37050. */
  37051. _normals: number[];
  37052. /**
  37053. * length of the shape in the model indices array (internal use)
  37054. * @hidden
  37055. */
  37056. _indicesLength: number;
  37057. /**
  37058. * Custom position function (internal use)
  37059. * @hidden
  37060. */
  37061. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  37062. /**
  37063. * Custom vertex function (internal use)
  37064. * @hidden
  37065. */
  37066. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  37067. /**
  37068. * Model material (internal use)
  37069. * @hidden
  37070. */
  37071. _material: Nullable<Material>;
  37072. /**
  37073. * 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.
  37074. * SPS internal tool, don't use it manually.
  37075. * @hidden
  37076. */
  37077. 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>);
  37078. }
  37079. /**
  37080. * Represents a Depth Sorted Particle in the solid particle system.
  37081. * @hidden
  37082. */
  37083. export class DepthSortedParticle {
  37084. /**
  37085. * Particle index
  37086. */
  37087. idx: number;
  37088. /**
  37089. * Index of the particle in the "indices" array
  37090. */
  37091. ind: number;
  37092. /**
  37093. * Length of the particle shape in the "indices" array
  37094. */
  37095. indicesLength: number;
  37096. /**
  37097. * Squared distance from the particle to the camera
  37098. */
  37099. sqDistance: number;
  37100. /**
  37101. * Material index when used with MultiMaterials
  37102. */
  37103. materialIndex: number;
  37104. /**
  37105. * Creates a new sorted particle
  37106. * @param materialIndex
  37107. */
  37108. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  37109. }
  37110. /**
  37111. * Represents a solid particle vertex
  37112. */
  37113. export class SolidParticleVertex {
  37114. /**
  37115. * Vertex position
  37116. */
  37117. position: Vector3;
  37118. /**
  37119. * Vertex color
  37120. */
  37121. color: Color4;
  37122. /**
  37123. * Vertex UV
  37124. */
  37125. uv: Vector2;
  37126. /**
  37127. * Creates a new solid particle vertex
  37128. */
  37129. constructor();
  37130. /** Vertex x coordinate */
  37131. get x(): number;
  37132. set x(val: number);
  37133. /** Vertex y coordinate */
  37134. get y(): number;
  37135. set y(val: number);
  37136. /** Vertex z coordinate */
  37137. get z(): number;
  37138. set z(val: number);
  37139. }
  37140. }
  37141. declare module "babylonjs/Collisions/meshCollisionData" {
  37142. import { Collider } from "babylonjs/Collisions/collider";
  37143. import { Vector3 } from "babylonjs/Maths/math.vector";
  37144. import { Nullable } from "babylonjs/types";
  37145. import { Observer } from "babylonjs/Misc/observable";
  37146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37147. /**
  37148. * @hidden
  37149. */
  37150. export class _MeshCollisionData {
  37151. _checkCollisions: boolean;
  37152. _collisionMask: number;
  37153. _collisionGroup: number;
  37154. _surroundingMeshes: Nullable<AbstractMesh[]>;
  37155. _collider: Nullable<Collider>;
  37156. _oldPositionForCollisions: Vector3;
  37157. _diffPositionForCollisions: Vector3;
  37158. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  37159. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  37160. _collisionResponse: boolean;
  37161. }
  37162. }
  37163. declare module "babylonjs/Meshes/abstractMesh" {
  37164. import { Observable } from "babylonjs/Misc/observable";
  37165. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  37166. import { Camera } from "babylonjs/Cameras/camera";
  37167. import { Scene, IDisposable } from "babylonjs/scene";
  37168. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37169. import { Node } from "babylonjs/node";
  37170. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  37171. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37172. import { SubMesh } from "babylonjs/Meshes/subMesh";
  37173. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  37174. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  37175. import { Material } from "babylonjs/Materials/material";
  37176. import { Light } from "babylonjs/Lights/light";
  37177. import { Skeleton } from "babylonjs/Bones/skeleton";
  37178. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  37179. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  37180. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37181. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  37182. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  37183. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  37184. import { Plane } from "babylonjs/Maths/math.plane";
  37185. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  37186. import { Ray } from "babylonjs/Culling/ray";
  37187. import { Collider } from "babylonjs/Collisions/collider";
  37188. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  37189. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  37190. import { IEdgesRendererOptions } from "babylonjs/Rendering/edgesRenderer";
  37191. /** @hidden */
  37192. class _FacetDataStorage {
  37193. facetPositions: Vector3[];
  37194. facetNormals: Vector3[];
  37195. facetPartitioning: number[][];
  37196. facetNb: number;
  37197. partitioningSubdivisions: number;
  37198. partitioningBBoxRatio: number;
  37199. facetDataEnabled: boolean;
  37200. facetParameters: any;
  37201. bbSize: Vector3;
  37202. subDiv: {
  37203. max: number;
  37204. X: number;
  37205. Y: number;
  37206. Z: number;
  37207. };
  37208. facetDepthSort: boolean;
  37209. facetDepthSortEnabled: boolean;
  37210. depthSortedIndices: IndicesArray;
  37211. depthSortedFacets: {
  37212. ind: number;
  37213. sqDistance: number;
  37214. }[];
  37215. facetDepthSortFunction: (f1: {
  37216. ind: number;
  37217. sqDistance: number;
  37218. }, f2: {
  37219. ind: number;
  37220. sqDistance: number;
  37221. }) => number;
  37222. facetDepthSortFrom: Vector3;
  37223. facetDepthSortOrigin: Vector3;
  37224. invertedMatrix: Matrix;
  37225. }
  37226. /**
  37227. * @hidden
  37228. **/
  37229. class _InternalAbstractMeshDataInfo {
  37230. _hasVertexAlpha: boolean;
  37231. _useVertexColors: boolean;
  37232. _numBoneInfluencers: number;
  37233. _applyFog: boolean;
  37234. _receiveShadows: boolean;
  37235. _facetData: _FacetDataStorage;
  37236. _visibility: number;
  37237. _skeleton: Nullable<Skeleton>;
  37238. _layerMask: number;
  37239. _computeBonesUsingShaders: boolean;
  37240. _isActive: boolean;
  37241. _onlyForInstances: boolean;
  37242. _isActiveIntermediate: boolean;
  37243. _onlyForInstancesIntermediate: boolean;
  37244. _actAsRegularMesh: boolean;
  37245. _currentLOD: Nullable<AbstractMesh>;
  37246. _currentLODIsUpToDate: boolean;
  37247. }
  37248. /**
  37249. * Class used to store all common mesh properties
  37250. */
  37251. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  37252. /** No occlusion */
  37253. static OCCLUSION_TYPE_NONE: number;
  37254. /** Occlusion set to optimisitic */
  37255. static OCCLUSION_TYPE_OPTIMISTIC: number;
  37256. /** Occlusion set to strict */
  37257. static OCCLUSION_TYPE_STRICT: number;
  37258. /** Use an accurante occlusion algorithm */
  37259. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  37260. /** Use a conservative occlusion algorithm */
  37261. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  37262. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  37263. * Test order :
  37264. * Is the bounding sphere outside the frustum ?
  37265. * If not, are the bounding box vertices outside the frustum ?
  37266. * It not, then the cullable object is in the frustum.
  37267. */
  37268. static readonly CULLINGSTRATEGY_STANDARD: number;
  37269. /** Culling strategy : Bounding Sphere Only.
  37270. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  37271. * It's also less accurate than the standard because some not visible objects can still be selected.
  37272. * Test : is the bounding sphere outside the frustum ?
  37273. * If not, then the cullable object is in the frustum.
  37274. */
  37275. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  37276. /** Culling strategy : Optimistic Inclusion.
  37277. * This in an inclusion test first, then the standard exclusion test.
  37278. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  37279. * 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.
  37280. * Anyway, it's as accurate as the standard strategy.
  37281. * Test :
  37282. * Is the cullable object bounding sphere center in the frustum ?
  37283. * If not, apply the default culling strategy.
  37284. */
  37285. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  37286. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  37287. * This in an inclusion test first, then the bounding sphere only exclusion test.
  37288. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  37289. * 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.
  37290. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  37291. * Test :
  37292. * Is the cullable object bounding sphere center in the frustum ?
  37293. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  37294. */
  37295. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  37296. /**
  37297. * No billboard
  37298. */
  37299. static get BILLBOARDMODE_NONE(): number;
  37300. /** Billboard on X axis */
  37301. static get BILLBOARDMODE_X(): number;
  37302. /** Billboard on Y axis */
  37303. static get BILLBOARDMODE_Y(): number;
  37304. /** Billboard on Z axis */
  37305. static get BILLBOARDMODE_Z(): number;
  37306. /** Billboard on all axes */
  37307. static get BILLBOARDMODE_ALL(): number;
  37308. /** Billboard on using position instead of orientation */
  37309. static get BILLBOARDMODE_USE_POSITION(): number;
  37310. /** @hidden */
  37311. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  37312. /**
  37313. * The culling strategy to use to check whether the mesh must be rendered or not.
  37314. * This value can be changed at any time and will be used on the next render mesh selection.
  37315. * The possible values are :
  37316. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  37317. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  37318. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  37319. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  37320. * Please read each static variable documentation to get details about the culling process.
  37321. * */
  37322. cullingStrategy: number;
  37323. /**
  37324. * Gets the number of facets in the mesh
  37325. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  37326. */
  37327. get facetNb(): number;
  37328. /**
  37329. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  37330. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  37331. */
  37332. get partitioningSubdivisions(): number;
  37333. set partitioningSubdivisions(nb: number);
  37334. /**
  37335. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  37336. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  37337. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  37338. */
  37339. get partitioningBBoxRatio(): number;
  37340. set partitioningBBoxRatio(ratio: number);
  37341. /**
  37342. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  37343. * Works only for updatable meshes.
  37344. * Doesn't work with multi-materials
  37345. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  37346. */
  37347. get mustDepthSortFacets(): boolean;
  37348. set mustDepthSortFacets(sort: boolean);
  37349. /**
  37350. * The location (Vector3) where the facet depth sort must be computed from.
  37351. * By default, the active camera position.
  37352. * Used only when facet depth sort is enabled
  37353. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  37354. */
  37355. get facetDepthSortFrom(): Vector3;
  37356. set facetDepthSortFrom(location: Vector3);
  37357. /**
  37358. * gets a boolean indicating if facetData is enabled
  37359. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  37360. */
  37361. get isFacetDataEnabled(): boolean;
  37362. /** @hidden */
  37363. _updateNonUniformScalingState(value: boolean): boolean;
  37364. /**
  37365. * An event triggered when this mesh collides with another one
  37366. */
  37367. onCollideObservable: Observable<AbstractMesh>;
  37368. /** Set a function to call when this mesh collides with another one */
  37369. set onCollide(callback: () => void);
  37370. /**
  37371. * An event triggered when the collision's position changes
  37372. */
  37373. onCollisionPositionChangeObservable: Observable<Vector3>;
  37374. /** Set a function to call when the collision's position changes */
  37375. set onCollisionPositionChange(callback: () => void);
  37376. /**
  37377. * An event triggered when material is changed
  37378. */
  37379. onMaterialChangedObservable: Observable<AbstractMesh>;
  37380. /**
  37381. * Gets or sets the orientation for POV movement & rotation
  37382. */
  37383. definedFacingForward: boolean;
  37384. /** @hidden */
  37385. _occlusionQuery: Nullable<WebGLQuery>;
  37386. /** @hidden */
  37387. _renderingGroup: Nullable<RenderingGroup>;
  37388. /**
  37389. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  37390. */
  37391. get visibility(): number;
  37392. /**
  37393. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  37394. */
  37395. set visibility(value: number);
  37396. /** Gets or sets the alpha index used to sort transparent meshes
  37397. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  37398. */
  37399. alphaIndex: number;
  37400. /**
  37401. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  37402. */
  37403. isVisible: boolean;
  37404. /**
  37405. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  37406. */
  37407. isPickable: boolean;
  37408. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  37409. showSubMeshesBoundingBox: boolean;
  37410. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  37411. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  37412. */
  37413. isBlocker: boolean;
  37414. /**
  37415. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  37416. */
  37417. enablePointerMoveEvents: boolean;
  37418. private _renderingGroupId;
  37419. /**
  37420. * Specifies the rendering group id for this mesh (0 by default)
  37421. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  37422. */
  37423. get renderingGroupId(): number;
  37424. set renderingGroupId(value: number);
  37425. private _material;
  37426. /** Gets or sets current material */
  37427. get material(): Nullable<Material>;
  37428. set material(value: Nullable<Material>);
  37429. /**
  37430. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  37431. * @see https://doc.babylonjs.com/babylon101/shadows
  37432. */
  37433. get receiveShadows(): boolean;
  37434. set receiveShadows(value: boolean);
  37435. /** Defines color to use when rendering outline */
  37436. outlineColor: Color3;
  37437. /** Define width to use when rendering outline */
  37438. outlineWidth: number;
  37439. /** Defines color to use when rendering overlay */
  37440. overlayColor: Color3;
  37441. /** Defines alpha to use when rendering overlay */
  37442. overlayAlpha: number;
  37443. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  37444. get hasVertexAlpha(): boolean;
  37445. set hasVertexAlpha(value: boolean);
  37446. /** 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) */
  37447. get useVertexColors(): boolean;
  37448. set useVertexColors(value: boolean);
  37449. /**
  37450. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  37451. */
  37452. get computeBonesUsingShaders(): boolean;
  37453. set computeBonesUsingShaders(value: boolean);
  37454. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  37455. get numBoneInfluencers(): number;
  37456. set numBoneInfluencers(value: number);
  37457. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  37458. get applyFog(): boolean;
  37459. set applyFog(value: boolean);
  37460. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  37461. useOctreeForRenderingSelection: boolean;
  37462. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  37463. useOctreeForPicking: boolean;
  37464. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  37465. useOctreeForCollisions: boolean;
  37466. /**
  37467. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  37468. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  37469. */
  37470. get layerMask(): number;
  37471. set layerMask(value: number);
  37472. /**
  37473. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  37474. */
  37475. alwaysSelectAsActiveMesh: boolean;
  37476. /**
  37477. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  37478. */
  37479. doNotSyncBoundingInfo: boolean;
  37480. /**
  37481. * Gets or sets the current action manager
  37482. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  37483. */
  37484. actionManager: Nullable<AbstractActionManager>;
  37485. private _meshCollisionData;
  37486. /**
  37487. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  37488. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37489. */
  37490. ellipsoid: Vector3;
  37491. /**
  37492. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  37493. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37494. */
  37495. ellipsoidOffset: Vector3;
  37496. /**
  37497. * Gets or sets a collision mask used to mask collisions (default is -1).
  37498. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  37499. */
  37500. get collisionMask(): number;
  37501. set collisionMask(mask: number);
  37502. /**
  37503. * Gets or sets a collision response flag (default is true).
  37504. * when collisionResponse is false, events are still triggered but colliding entity has no response
  37505. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  37506. * to respond to the collision.
  37507. */
  37508. get collisionResponse(): boolean;
  37509. set collisionResponse(response: boolean);
  37510. /**
  37511. * Gets or sets the current collision group mask (-1 by default).
  37512. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  37513. */
  37514. get collisionGroup(): number;
  37515. set collisionGroup(mask: number);
  37516. /**
  37517. * Gets or sets current surrounding meshes (null by default).
  37518. *
  37519. * By default collision detection is tested against every mesh in the scene.
  37520. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  37521. * meshes will be tested for the collision.
  37522. *
  37523. * Note: if set to an empty array no collision will happen when this mesh is moved.
  37524. */
  37525. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  37526. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  37527. /**
  37528. * Defines edge width used when edgesRenderer is enabled
  37529. * @see https://www.babylonjs-playground.com/#10OJSG#13
  37530. */
  37531. edgesWidth: number;
  37532. /**
  37533. * Defines edge color used when edgesRenderer is enabled
  37534. * @see https://www.babylonjs-playground.com/#10OJSG#13
  37535. */
  37536. edgesColor: Color4;
  37537. /** @hidden */
  37538. _edgesRenderer: Nullable<IEdgesRenderer>;
  37539. /** @hidden */
  37540. _masterMesh: Nullable<AbstractMesh>;
  37541. /** @hidden */
  37542. _boundingInfo: Nullable<BoundingInfo>;
  37543. /** @hidden */
  37544. _renderId: number;
  37545. /**
  37546. * Gets or sets the list of subMeshes
  37547. * @see https://doc.babylonjs.com/how_to/multi_materials
  37548. */
  37549. subMeshes: SubMesh[];
  37550. /** @hidden */
  37551. _intersectionsInProgress: AbstractMesh[];
  37552. /** @hidden */
  37553. _unIndexed: boolean;
  37554. /** @hidden */
  37555. _lightSources: Light[];
  37556. /** Gets the list of lights affecting that mesh */
  37557. get lightSources(): Light[];
  37558. /** @hidden */
  37559. get _positions(): Nullable<Vector3[]>;
  37560. /** @hidden */
  37561. _waitingData: {
  37562. lods: Nullable<any>;
  37563. actions: Nullable<any>;
  37564. freezeWorldMatrix: Nullable<boolean>;
  37565. };
  37566. /** @hidden */
  37567. _bonesTransformMatrices: Nullable<Float32Array>;
  37568. /** @hidden */
  37569. _transformMatrixTexture: Nullable<RawTexture>;
  37570. /**
  37571. * Gets or sets a skeleton to apply skining transformations
  37572. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37573. */
  37574. set skeleton(value: Nullable<Skeleton>);
  37575. get skeleton(): Nullable<Skeleton>;
  37576. /**
  37577. * An event triggered when the mesh is rebuilt.
  37578. */
  37579. onRebuildObservable: Observable<AbstractMesh>;
  37580. /**
  37581. * The current mesh unifom buffer.
  37582. * @hidden Internal use only.
  37583. */
  37584. _uniformBuffer: UniformBuffer;
  37585. /**
  37586. * Creates a new AbstractMesh
  37587. * @param name defines the name of the mesh
  37588. * @param scene defines the hosting scene
  37589. */
  37590. constructor(name: string, scene?: Nullable<Scene>);
  37591. protected _buildUniformLayout(): void;
  37592. /**
  37593. * Transfer the mesh values to its UBO.
  37594. * @param world The world matrix associated with the mesh
  37595. */
  37596. transferToEffect(world: Matrix): void;
  37597. /**
  37598. * Gets the mesh uniform buffer.
  37599. * @return the uniform buffer of the mesh.
  37600. */
  37601. getMeshUniformBuffer(): UniformBuffer;
  37602. /**
  37603. * Returns the string "AbstractMesh"
  37604. * @returns "AbstractMesh"
  37605. */
  37606. getClassName(): string;
  37607. /**
  37608. * Gets a string representation of the current mesh
  37609. * @param fullDetails defines a boolean indicating if full details must be included
  37610. * @returns a string representation of the current mesh
  37611. */
  37612. toString(fullDetails?: boolean): string;
  37613. /**
  37614. * @hidden
  37615. */
  37616. protected _getEffectiveParent(): Nullable<Node>;
  37617. /** @hidden */
  37618. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  37619. /** @hidden */
  37620. _rebuild(): void;
  37621. /** @hidden */
  37622. _resyncLightSources(): void;
  37623. /** @hidden */
  37624. _resyncLightSource(light: Light): void;
  37625. /** @hidden */
  37626. _unBindEffect(): void;
  37627. /** @hidden */
  37628. _removeLightSource(light: Light, dispose: boolean): void;
  37629. private _markSubMeshesAsDirty;
  37630. /** @hidden */
  37631. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  37632. /** @hidden */
  37633. _markSubMeshesAsAttributesDirty(): void;
  37634. /** @hidden */
  37635. _markSubMeshesAsMiscDirty(): void;
  37636. /**
  37637. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  37638. */
  37639. get scaling(): Vector3;
  37640. set scaling(newScaling: Vector3);
  37641. /**
  37642. * Returns true if the mesh is blocked. Implemented by child classes
  37643. */
  37644. get isBlocked(): boolean;
  37645. /**
  37646. * Returns the mesh itself by default. Implemented by child classes
  37647. * @param camera defines the camera to use to pick the right LOD level
  37648. * @returns the currentAbstractMesh
  37649. */
  37650. getLOD(camera: Camera): Nullable<AbstractMesh>;
  37651. /**
  37652. * Returns 0 by default. Implemented by child classes
  37653. * @returns an integer
  37654. */
  37655. getTotalVertices(): number;
  37656. /**
  37657. * Returns a positive integer : the total number of indices in this mesh geometry.
  37658. * @returns the numner of indices or zero if the mesh has no geometry.
  37659. */
  37660. getTotalIndices(): number;
  37661. /**
  37662. * Returns null by default. Implemented by child classes
  37663. * @returns null
  37664. */
  37665. getIndices(): Nullable<IndicesArray>;
  37666. /**
  37667. * Returns the array of the requested vertex data kind. Implemented by child classes
  37668. * @param kind defines the vertex data kind to use
  37669. * @returns null
  37670. */
  37671. getVerticesData(kind: string): Nullable<FloatArray>;
  37672. /**
  37673. * Sets the vertex data of the mesh geometry for the requested `kind`.
  37674. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  37675. * Note that a new underlying VertexBuffer object is created each call.
  37676. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  37677. * @param kind defines vertex data kind:
  37678. * * VertexBuffer.PositionKind
  37679. * * VertexBuffer.UVKind
  37680. * * VertexBuffer.UV2Kind
  37681. * * VertexBuffer.UV3Kind
  37682. * * VertexBuffer.UV4Kind
  37683. * * VertexBuffer.UV5Kind
  37684. * * VertexBuffer.UV6Kind
  37685. * * VertexBuffer.ColorKind
  37686. * * VertexBuffer.MatricesIndicesKind
  37687. * * VertexBuffer.MatricesIndicesExtraKind
  37688. * * VertexBuffer.MatricesWeightsKind
  37689. * * VertexBuffer.MatricesWeightsExtraKind
  37690. * @param data defines the data source
  37691. * @param updatable defines if the data must be flagged as updatable (or static)
  37692. * @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
  37693. * @returns the current mesh
  37694. */
  37695. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  37696. /**
  37697. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  37698. * If the mesh has no geometry, it is simply returned as it is.
  37699. * @param kind defines vertex data kind:
  37700. * * VertexBuffer.PositionKind
  37701. * * VertexBuffer.UVKind
  37702. * * VertexBuffer.UV2Kind
  37703. * * VertexBuffer.UV3Kind
  37704. * * VertexBuffer.UV4Kind
  37705. * * VertexBuffer.UV5Kind
  37706. * * VertexBuffer.UV6Kind
  37707. * * VertexBuffer.ColorKind
  37708. * * VertexBuffer.MatricesIndicesKind
  37709. * * VertexBuffer.MatricesIndicesExtraKind
  37710. * * VertexBuffer.MatricesWeightsKind
  37711. * * VertexBuffer.MatricesWeightsExtraKind
  37712. * @param data defines the data source
  37713. * @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
  37714. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  37715. * @returns the current mesh
  37716. */
  37717. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  37718. /**
  37719. * Sets the mesh indices,
  37720. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  37721. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  37722. * @param totalVertices Defines the total number of vertices
  37723. * @returns the current mesh
  37724. */
  37725. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  37726. /**
  37727. * Gets a boolean indicating if specific vertex data is present
  37728. * @param kind defines the vertex data kind to use
  37729. * @returns true is data kind is present
  37730. */
  37731. isVerticesDataPresent(kind: string): boolean;
  37732. /**
  37733. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  37734. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  37735. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  37736. * @returns a BoundingInfo
  37737. */
  37738. getBoundingInfo(): BoundingInfo;
  37739. /**
  37740. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  37741. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  37742. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  37743. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  37744. * @returns the current mesh
  37745. */
  37746. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  37747. /**
  37748. * Overwrite the current bounding info
  37749. * @param boundingInfo defines the new bounding info
  37750. * @returns the current mesh
  37751. */
  37752. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  37753. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  37754. get useBones(): boolean;
  37755. /** @hidden */
  37756. _preActivate(): void;
  37757. /** @hidden */
  37758. _preActivateForIntermediateRendering(renderId: number): void;
  37759. /** @hidden */
  37760. _activate(renderId: number, intermediateRendering: boolean): boolean;
  37761. /** @hidden */
  37762. _postActivate(): void;
  37763. /** @hidden */
  37764. _freeze(): void;
  37765. /** @hidden */
  37766. _unFreeze(): void;
  37767. /**
  37768. * Gets the current world matrix
  37769. * @returns a Matrix
  37770. */
  37771. getWorldMatrix(): Matrix;
  37772. /** @hidden */
  37773. _getWorldMatrixDeterminant(): number;
  37774. /**
  37775. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  37776. */
  37777. get isAnInstance(): boolean;
  37778. /**
  37779. * Gets a boolean indicating if this mesh has instances
  37780. */
  37781. get hasInstances(): boolean;
  37782. /**
  37783. * Gets a boolean indicating if this mesh has thin instances
  37784. */
  37785. get hasThinInstances(): boolean;
  37786. /**
  37787. * Perform relative position change from the point of view of behind the front of the mesh.
  37788. * This is performed taking into account the meshes current rotation, so you do not have to care.
  37789. * Supports definition of mesh facing forward or backward
  37790. * @param amountRight defines the distance on the right axis
  37791. * @param amountUp defines the distance on the up axis
  37792. * @param amountForward defines the distance on the forward axis
  37793. * @returns the current mesh
  37794. */
  37795. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  37796. /**
  37797. * Calculate relative position change from the point of view of behind the front of the mesh.
  37798. * This is performed taking into account the meshes current rotation, so you do not have to care.
  37799. * Supports definition of mesh facing forward or backward
  37800. * @param amountRight defines the distance on the right axis
  37801. * @param amountUp defines the distance on the up axis
  37802. * @param amountForward defines the distance on the forward axis
  37803. * @returns the new displacement vector
  37804. */
  37805. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  37806. /**
  37807. * Perform 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 current mesh
  37813. */
  37814. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  37815. /**
  37816. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  37817. * Supports definition of mesh facing forward or backward.
  37818. * @param flipBack defines the flip
  37819. * @param twirlClockwise defines the twirl
  37820. * @param tiltRight defines the tilt
  37821. * @returns the new rotation vector
  37822. */
  37823. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  37824. /**
  37825. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  37826. * This means the mesh underlying bounding box and sphere are recomputed.
  37827. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  37828. * @returns the current mesh
  37829. */
  37830. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  37831. /** @hidden */
  37832. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  37833. /** @hidden */
  37834. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  37835. /** @hidden */
  37836. _updateBoundingInfo(): AbstractMesh;
  37837. /** @hidden */
  37838. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  37839. /** @hidden */
  37840. protected _afterComputeWorldMatrix(): void;
  37841. /** @hidden */
  37842. get _effectiveMesh(): AbstractMesh;
  37843. /**
  37844. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  37845. * A mesh is in the frustum if its bounding box intersects the frustum
  37846. * @param frustumPlanes defines the frustum to test
  37847. * @returns true if the mesh is in the frustum planes
  37848. */
  37849. isInFrustum(frustumPlanes: Plane[]): boolean;
  37850. /**
  37851. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  37852. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  37853. * @param frustumPlanes defines the frustum to test
  37854. * @returns true if the mesh is completely in the frustum planes
  37855. */
  37856. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  37857. /**
  37858. * True if the mesh intersects another mesh or a SolidParticle object
  37859. * @param mesh defines a target mesh or SolidParticle to test
  37860. * @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)
  37861. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  37862. * @returns true if there is an intersection
  37863. */
  37864. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  37865. /**
  37866. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  37867. * @param point defines the point to test
  37868. * @returns true if there is an intersection
  37869. */
  37870. intersectsPoint(point: Vector3): boolean;
  37871. /**
  37872. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  37873. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37874. */
  37875. get checkCollisions(): boolean;
  37876. set checkCollisions(collisionEnabled: boolean);
  37877. /**
  37878. * Gets Collider object used to compute collisions (not physics)
  37879. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37880. */
  37881. get collider(): Nullable<Collider>;
  37882. /**
  37883. * Move the mesh using collision engine
  37884. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37885. * @param displacement defines the requested displacement vector
  37886. * @returns the current mesh
  37887. */
  37888. moveWithCollisions(displacement: Vector3): AbstractMesh;
  37889. private _onCollisionPositionChange;
  37890. /** @hidden */
  37891. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  37892. /** @hidden */
  37893. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  37894. /** @hidden */
  37895. _checkCollision(collider: Collider): AbstractMesh;
  37896. /** @hidden */
  37897. _generatePointsArray(): boolean;
  37898. /**
  37899. * Checks if the passed Ray intersects with the mesh
  37900. * @param ray defines the ray to use
  37901. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  37902. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37903. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  37904. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  37905. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  37906. * @returns the picking info
  37907. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  37908. */
  37909. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  37910. /**
  37911. * Clones the current mesh
  37912. * @param name defines the mesh name
  37913. * @param newParent defines the new mesh parent
  37914. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  37915. * @returns the new mesh
  37916. */
  37917. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  37918. /**
  37919. * Disposes all the submeshes of the current meshnp
  37920. * @returns the current mesh
  37921. */
  37922. releaseSubMeshes(): AbstractMesh;
  37923. /**
  37924. * Releases resources associated with this abstract mesh.
  37925. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37926. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37927. */
  37928. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37929. /**
  37930. * Adds the passed mesh as a child to the current mesh
  37931. * @param mesh defines the child mesh
  37932. * @returns the current mesh
  37933. */
  37934. addChild(mesh: AbstractMesh): AbstractMesh;
  37935. /**
  37936. * Removes the passed mesh from the current mesh children list
  37937. * @param mesh defines the child mesh
  37938. * @returns the current mesh
  37939. */
  37940. removeChild(mesh: AbstractMesh): AbstractMesh;
  37941. /** @hidden */
  37942. private _initFacetData;
  37943. /**
  37944. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  37945. * This method can be called within the render loop.
  37946. * 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
  37947. * @returns the current mesh
  37948. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37949. */
  37950. updateFacetData(): AbstractMesh;
  37951. /**
  37952. * Returns the facetLocalNormals array.
  37953. * The normals are expressed in the mesh local spac
  37954. * @returns an array of Vector3
  37955. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37956. */
  37957. getFacetLocalNormals(): Vector3[];
  37958. /**
  37959. * Returns the facetLocalPositions array.
  37960. * The facet positions are expressed in the mesh local space
  37961. * @returns an array of Vector3
  37962. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37963. */
  37964. getFacetLocalPositions(): Vector3[];
  37965. /**
  37966. * Returns the facetLocalPartioning array
  37967. * @returns an array of array of numbers
  37968. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37969. */
  37970. getFacetLocalPartitioning(): number[][];
  37971. /**
  37972. * Returns the i-th facet position in the world system.
  37973. * This method allocates a new Vector3 per call
  37974. * @param i defines the facet index
  37975. * @returns a new Vector3
  37976. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37977. */
  37978. getFacetPosition(i: number): Vector3;
  37979. /**
  37980. * Sets the reference Vector3 with the i-th facet position in the world system
  37981. * @param i defines the facet index
  37982. * @param ref defines the target vector
  37983. * @returns the current mesh
  37984. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37985. */
  37986. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  37987. /**
  37988. * Returns the i-th facet normal in the world system.
  37989. * This method allocates a new Vector3 per call
  37990. * @param i defines the facet index
  37991. * @returns a new Vector3
  37992. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37993. */
  37994. getFacetNormal(i: number): Vector3;
  37995. /**
  37996. * Sets the reference Vector3 with the i-th facet normal in the world system
  37997. * @param i defines the facet index
  37998. * @param ref defines the target vector
  37999. * @returns the current mesh
  38000. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38001. */
  38002. getFacetNormalToRef(i: number, ref: Vector3): this;
  38003. /**
  38004. * 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)
  38005. * @param x defines x coordinate
  38006. * @param y defines y coordinate
  38007. * @param z defines z coordinate
  38008. * @returns the array of facet indexes
  38009. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38010. */
  38011. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  38012. /**
  38013. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  38014. * @param projected sets as the (x,y,z) world projection on the facet
  38015. * @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
  38016. * @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
  38017. * @param x defines x coordinate
  38018. * @param y defines y coordinate
  38019. * @param z defines z coordinate
  38020. * @returns the face index if found (or null instead)
  38021. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38022. */
  38023. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  38024. /**
  38025. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  38026. * @param projected sets as the (x,y,z) local projection on the facet
  38027. * @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
  38028. * @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
  38029. * @param x defines x coordinate
  38030. * @param y defines y coordinate
  38031. * @param z defines z coordinate
  38032. * @returns the face index if found (or null instead)
  38033. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38034. */
  38035. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  38036. /**
  38037. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  38038. * @returns the parameters
  38039. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38040. */
  38041. getFacetDataParameters(): any;
  38042. /**
  38043. * Disables the feature FacetData and frees the related memory
  38044. * @returns the current mesh
  38045. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  38046. */
  38047. disableFacetData(): AbstractMesh;
  38048. /**
  38049. * Updates the AbstractMesh indices array
  38050. * @param indices defines the data source
  38051. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  38052. * @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)
  38053. * @returns the current mesh
  38054. */
  38055. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  38056. /**
  38057. * Creates new normals data for the mesh
  38058. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  38059. * @returns the current mesh
  38060. */
  38061. createNormals(updatable: boolean): AbstractMesh;
  38062. /**
  38063. * Align the mesh with a normal
  38064. * @param normal defines the normal to use
  38065. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  38066. * @returns the current mesh
  38067. */
  38068. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  38069. /** @hidden */
  38070. _checkOcclusionQuery(): boolean;
  38071. /**
  38072. * Disables the mesh edge rendering mode
  38073. * @returns the currentAbstractMesh
  38074. */
  38075. disableEdgesRendering(): AbstractMesh;
  38076. /**
  38077. * Enables the edge rendering mode on the mesh.
  38078. * This mode makes the mesh edges visible
  38079. * @param epsilon defines the maximal distance between two angles to detect a face
  38080. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  38081. * @param options options to the edge renderer
  38082. * @returns the currentAbstractMesh
  38083. * @see https://www.babylonjs-playground.com/#19O9TU#0
  38084. */
  38085. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  38086. /**
  38087. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  38088. * @returns an array of particle systems in the scene that use the mesh as an emitter
  38089. */
  38090. getConnectedParticleSystems(): IParticleSystem[];
  38091. }
  38092. }
  38093. declare module "babylonjs/Actions/actionEvent" {
  38094. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38095. import { Nullable } from "babylonjs/types";
  38096. import { Sprite } from "babylonjs/Sprites/sprite";
  38097. import { Scene } from "babylonjs/scene";
  38098. import { Vector2 } from "babylonjs/Maths/math.vector";
  38099. /**
  38100. * Interface used to define ActionEvent
  38101. */
  38102. export interface IActionEvent {
  38103. /** The mesh or sprite that triggered the action */
  38104. source: any;
  38105. /** The X mouse cursor position at the time of the event */
  38106. pointerX: number;
  38107. /** The Y mouse cursor position at the time of the event */
  38108. pointerY: number;
  38109. /** The mesh that is currently pointed at (can be null) */
  38110. meshUnderPointer: Nullable<AbstractMesh>;
  38111. /** the original (browser) event that triggered the ActionEvent */
  38112. sourceEvent?: any;
  38113. /** additional data for the event */
  38114. additionalData?: any;
  38115. }
  38116. /**
  38117. * ActionEvent is the event being sent when an action is triggered.
  38118. */
  38119. export class ActionEvent implements IActionEvent {
  38120. /** The mesh or sprite that triggered the action */
  38121. source: any;
  38122. /** The X mouse cursor position at the time of the event */
  38123. pointerX: number;
  38124. /** The Y mouse cursor position at the time of the event */
  38125. pointerY: number;
  38126. /** The mesh that is currently pointed at (can be null) */
  38127. meshUnderPointer: Nullable<AbstractMesh>;
  38128. /** the original (browser) event that triggered the ActionEvent */
  38129. sourceEvent?: any;
  38130. /** additional data for the event */
  38131. additionalData?: any;
  38132. /**
  38133. * Creates a new ActionEvent
  38134. * @param source The mesh or sprite that triggered the action
  38135. * @param pointerX The X mouse cursor position at the time of the event
  38136. * @param pointerY The Y mouse cursor position at the time of the event
  38137. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  38138. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  38139. * @param additionalData additional data for the event
  38140. */
  38141. constructor(
  38142. /** The mesh or sprite that triggered the action */
  38143. source: any,
  38144. /** The X mouse cursor position at the time of the event */
  38145. pointerX: number,
  38146. /** The Y mouse cursor position at the time of the event */
  38147. pointerY: number,
  38148. /** The mesh that is currently pointed at (can be null) */
  38149. meshUnderPointer: Nullable<AbstractMesh>,
  38150. /** the original (browser) event that triggered the ActionEvent */
  38151. sourceEvent?: any,
  38152. /** additional data for the event */
  38153. additionalData?: any);
  38154. /**
  38155. * Helper function to auto-create an ActionEvent from a source mesh.
  38156. * @param source The source mesh that triggered the event
  38157. * @param evt The original (browser) event
  38158. * @param additionalData additional data for the event
  38159. * @returns the new ActionEvent
  38160. */
  38161. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  38162. /**
  38163. * Helper function to auto-create an ActionEvent from a source sprite
  38164. * @param source The source sprite that triggered the event
  38165. * @param scene Scene associated with the sprite
  38166. * @param evt The original (browser) event
  38167. * @param additionalData additional data for the event
  38168. * @returns the new ActionEvent
  38169. */
  38170. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  38171. /**
  38172. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  38173. * @param scene the scene where the event occurred
  38174. * @param evt The original (browser) event
  38175. * @returns the new ActionEvent
  38176. */
  38177. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  38178. /**
  38179. * Helper function to auto-create an ActionEvent from a primitive
  38180. * @param prim defines the target primitive
  38181. * @param pointerPos defines the pointer position
  38182. * @param evt The original (browser) event
  38183. * @param additionalData additional data for the event
  38184. * @returns the new ActionEvent
  38185. */
  38186. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  38187. }
  38188. }
  38189. declare module "babylonjs/Actions/abstractActionManager" {
  38190. import { IDisposable } from "babylonjs/scene";
  38191. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  38192. import { IAction } from "babylonjs/Actions/action";
  38193. import { Nullable } from "babylonjs/types";
  38194. /**
  38195. * Abstract class used to decouple action Manager from scene and meshes.
  38196. * Do not instantiate.
  38197. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  38198. */
  38199. export abstract class AbstractActionManager implements IDisposable {
  38200. /** Gets the list of active triggers */
  38201. static Triggers: {
  38202. [key: string]: number;
  38203. };
  38204. /** Gets the cursor to use when hovering items */
  38205. hoverCursor: string;
  38206. /** Gets the list of actions */
  38207. actions: IAction[];
  38208. /**
  38209. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  38210. */
  38211. isRecursive: boolean;
  38212. /**
  38213. * Releases all associated resources
  38214. */
  38215. abstract dispose(): void;
  38216. /**
  38217. * Does this action manager has pointer triggers
  38218. */
  38219. abstract get hasPointerTriggers(): boolean;
  38220. /**
  38221. * Does this action manager has pick triggers
  38222. */
  38223. abstract get hasPickTriggers(): boolean;
  38224. /**
  38225. * Process a specific trigger
  38226. * @param trigger defines the trigger to process
  38227. * @param evt defines the event details to be processed
  38228. */
  38229. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  38230. /**
  38231. * Does this action manager handles actions of any of the given triggers
  38232. * @param triggers defines the triggers to be tested
  38233. * @return a boolean indicating whether one (or more) of the triggers is handled
  38234. */
  38235. abstract hasSpecificTriggers(triggers: number[]): boolean;
  38236. /**
  38237. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  38238. * speed.
  38239. * @param triggerA defines the trigger to be tested
  38240. * @param triggerB defines the trigger to be tested
  38241. * @return a boolean indicating whether one (or more) of the triggers is handled
  38242. */
  38243. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  38244. /**
  38245. * Does this action manager handles actions of a given trigger
  38246. * @param trigger defines the trigger to be tested
  38247. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  38248. * @return whether the trigger is handled
  38249. */
  38250. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  38251. /**
  38252. * Serialize this manager to a JSON object
  38253. * @param name defines the property name to store this manager
  38254. * @returns a JSON representation of this manager
  38255. */
  38256. abstract serialize(name: string): any;
  38257. /**
  38258. * Registers an action to this action manager
  38259. * @param action defines the action to be registered
  38260. * @return the action amended (prepared) after registration
  38261. */
  38262. abstract registerAction(action: IAction): Nullable<IAction>;
  38263. /**
  38264. * Unregisters an action to this action manager
  38265. * @param action defines the action to be unregistered
  38266. * @return a boolean indicating whether the action has been unregistered
  38267. */
  38268. abstract unregisterAction(action: IAction): Boolean;
  38269. /**
  38270. * Does exist one action manager with at least one trigger
  38271. **/
  38272. static get HasTriggers(): boolean;
  38273. /**
  38274. * Does exist one action manager with at least one pick trigger
  38275. **/
  38276. static get HasPickTriggers(): boolean;
  38277. /**
  38278. * Does exist one action manager that handles actions of a given trigger
  38279. * @param trigger defines the trigger to be tested
  38280. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  38281. **/
  38282. static HasSpecificTrigger(trigger: number): boolean;
  38283. }
  38284. }
  38285. declare module "babylonjs/node" {
  38286. import { Scene } from "babylonjs/scene";
  38287. import { Nullable } from "babylonjs/types";
  38288. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  38289. import { Engine } from "babylonjs/Engines/engine";
  38290. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  38291. import { Observable } from "babylonjs/Misc/observable";
  38292. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  38293. import { IInspectable } from "babylonjs/Misc/iInspectable";
  38294. import { Animatable } from "babylonjs/Animations/animatable";
  38295. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  38296. import { Animation } from "babylonjs/Animations/animation";
  38297. import { AnimationRange } from "babylonjs/Animations/animationRange";
  38298. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38299. /**
  38300. * Defines how a node can be built from a string name.
  38301. */
  38302. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  38303. /**
  38304. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  38305. */
  38306. export class Node implements IBehaviorAware<Node> {
  38307. /** @hidden */
  38308. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  38309. private static _NodeConstructors;
  38310. /**
  38311. * Add a new node constructor
  38312. * @param type defines the type name of the node to construct
  38313. * @param constructorFunc defines the constructor function
  38314. */
  38315. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  38316. /**
  38317. * Returns a node constructor based on type name
  38318. * @param type defines the type name
  38319. * @param name defines the new node name
  38320. * @param scene defines the hosting scene
  38321. * @param options defines optional options to transmit to constructors
  38322. * @returns the new constructor or null
  38323. */
  38324. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  38325. /**
  38326. * Gets or sets the name of the node
  38327. */
  38328. name: string;
  38329. /**
  38330. * Gets or sets the id of the node
  38331. */
  38332. id: string;
  38333. /**
  38334. * Gets or sets the unique id of the node
  38335. */
  38336. uniqueId: number;
  38337. /**
  38338. * Gets or sets a string used to store user defined state for the node
  38339. */
  38340. state: string;
  38341. /**
  38342. * Gets or sets an object used to store user defined information for the node
  38343. */
  38344. metadata: any;
  38345. /**
  38346. * For internal use only. Please do not use.
  38347. */
  38348. reservedDataStore: any;
  38349. /**
  38350. * List of inspectable custom properties (used by the Inspector)
  38351. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  38352. */
  38353. inspectableCustomProperties: IInspectable[];
  38354. private _doNotSerialize;
  38355. /**
  38356. * Gets or sets a boolean used to define if the node must be serialized
  38357. */
  38358. get doNotSerialize(): boolean;
  38359. set doNotSerialize(value: boolean);
  38360. /** @hidden */
  38361. _isDisposed: boolean;
  38362. /**
  38363. * Gets a list of Animations associated with the node
  38364. */
  38365. animations: import("babylonjs/Animations/animation").Animation[];
  38366. protected _ranges: {
  38367. [name: string]: Nullable<AnimationRange>;
  38368. };
  38369. /**
  38370. * Callback raised when the node is ready to be used
  38371. */
  38372. onReady: Nullable<(node: Node) => void>;
  38373. private _isEnabled;
  38374. private _isParentEnabled;
  38375. private _isReady;
  38376. /** @hidden */
  38377. _currentRenderId: number;
  38378. private _parentUpdateId;
  38379. /** @hidden */
  38380. _childUpdateId: number;
  38381. /** @hidden */
  38382. _waitingParentId: Nullable<string>;
  38383. /** @hidden */
  38384. _scene: Scene;
  38385. /** @hidden */
  38386. _cache: any;
  38387. private _parentNode;
  38388. private _children;
  38389. /** @hidden */
  38390. _worldMatrix: Matrix;
  38391. /** @hidden */
  38392. _worldMatrixDeterminant: number;
  38393. /** @hidden */
  38394. _worldMatrixDeterminantIsDirty: boolean;
  38395. /** @hidden */
  38396. private _sceneRootNodesIndex;
  38397. /**
  38398. * Gets a boolean indicating if the node has been disposed
  38399. * @returns true if the node was disposed
  38400. */
  38401. isDisposed(): boolean;
  38402. /**
  38403. * Gets or sets the parent of the node (without keeping the current position in the scene)
  38404. * @see https://doc.babylonjs.com/how_to/parenting
  38405. */
  38406. set parent(parent: Nullable<Node>);
  38407. get parent(): Nullable<Node>;
  38408. /** @hidden */
  38409. _addToSceneRootNodes(): void;
  38410. /** @hidden */
  38411. _removeFromSceneRootNodes(): void;
  38412. private _animationPropertiesOverride;
  38413. /**
  38414. * Gets or sets the animation properties override
  38415. */
  38416. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  38417. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  38418. /**
  38419. * Gets a string identifying the name of the class
  38420. * @returns "Node" string
  38421. */
  38422. getClassName(): string;
  38423. /** @hidden */
  38424. readonly _isNode: boolean;
  38425. /**
  38426. * An event triggered when the mesh is disposed
  38427. */
  38428. onDisposeObservable: Observable<Node>;
  38429. private _onDisposeObserver;
  38430. /**
  38431. * Sets a callback that will be raised when the node will be disposed
  38432. */
  38433. set onDispose(callback: () => void);
  38434. /**
  38435. * Creates a new Node
  38436. * @param name the name and id to be given to this node
  38437. * @param scene the scene this node will be added to
  38438. */
  38439. constructor(name: string, scene?: Nullable<Scene>);
  38440. /**
  38441. * Gets the scene of the node
  38442. * @returns a scene
  38443. */
  38444. getScene(): Scene;
  38445. /**
  38446. * Gets the engine of the node
  38447. * @returns a Engine
  38448. */
  38449. getEngine(): Engine;
  38450. private _behaviors;
  38451. /**
  38452. * Attach a behavior to the node
  38453. * @see https://doc.babylonjs.com/features/behaviour
  38454. * @param behavior defines the behavior to attach
  38455. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  38456. * @returns the current Node
  38457. */
  38458. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  38459. /**
  38460. * Remove an attached behavior
  38461. * @see https://doc.babylonjs.com/features/behaviour
  38462. * @param behavior defines the behavior to attach
  38463. * @returns the current Node
  38464. */
  38465. removeBehavior(behavior: Behavior<Node>): Node;
  38466. /**
  38467. * Gets the list of attached behaviors
  38468. * @see https://doc.babylonjs.com/features/behaviour
  38469. */
  38470. get behaviors(): Behavior<Node>[];
  38471. /**
  38472. * Gets an attached behavior by name
  38473. * @param name defines the name of the behavior to look for
  38474. * @see https://doc.babylonjs.com/features/behaviour
  38475. * @returns null if behavior was not found else the requested behavior
  38476. */
  38477. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  38478. /**
  38479. * Returns the latest update of the World matrix
  38480. * @returns a Matrix
  38481. */
  38482. getWorldMatrix(): Matrix;
  38483. /** @hidden */
  38484. _getWorldMatrixDeterminant(): number;
  38485. /**
  38486. * Returns directly the latest state of the mesh World matrix.
  38487. * A Matrix is returned.
  38488. */
  38489. get worldMatrixFromCache(): Matrix;
  38490. /** @hidden */
  38491. _initCache(): void;
  38492. /** @hidden */
  38493. updateCache(force?: boolean): void;
  38494. /** @hidden */
  38495. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  38496. /** @hidden */
  38497. _updateCache(ignoreParentClass?: boolean): void;
  38498. /** @hidden */
  38499. _isSynchronized(): boolean;
  38500. /** @hidden */
  38501. _markSyncedWithParent(): void;
  38502. /** @hidden */
  38503. isSynchronizedWithParent(): boolean;
  38504. /** @hidden */
  38505. isSynchronized(): boolean;
  38506. /**
  38507. * Is this node ready to be used/rendered
  38508. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  38509. * @return true if the node is ready
  38510. */
  38511. isReady(completeCheck?: boolean): boolean;
  38512. /**
  38513. * Is this node enabled?
  38514. * 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
  38515. * @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
  38516. * @return whether this node (and its parent) is enabled
  38517. */
  38518. isEnabled(checkAncestors?: boolean): boolean;
  38519. /** @hidden */
  38520. protected _syncParentEnabledState(): void;
  38521. /**
  38522. * Set the enabled state of this node
  38523. * @param value defines the new enabled state
  38524. */
  38525. setEnabled(value: boolean): void;
  38526. /**
  38527. * Is this node a descendant of the given node?
  38528. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  38529. * @param ancestor defines the parent node to inspect
  38530. * @returns a boolean indicating if this node is a descendant of the given node
  38531. */
  38532. isDescendantOf(ancestor: Node): boolean;
  38533. /** @hidden */
  38534. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  38535. /**
  38536. * Will return all nodes that have this node as ascendant
  38537. * @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
  38538. * @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
  38539. * @return all children nodes of all types
  38540. */
  38541. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  38542. /**
  38543. * Get all child-meshes of this node
  38544. * @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)
  38545. * @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
  38546. * @returns an array of AbstractMesh
  38547. */
  38548. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  38549. /**
  38550. * Get all direct children of this node
  38551. * @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
  38552. * @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)
  38553. * @returns an array of Node
  38554. */
  38555. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  38556. /** @hidden */
  38557. _setReady(state: boolean): void;
  38558. /**
  38559. * Get an animation by name
  38560. * @param name defines the name of the animation to look for
  38561. * @returns null if not found else the requested animation
  38562. */
  38563. getAnimationByName(name: string): Nullable<Animation>;
  38564. /**
  38565. * Creates an animation range for this node
  38566. * @param name defines the name of the range
  38567. * @param from defines the starting key
  38568. * @param to defines the end key
  38569. */
  38570. createAnimationRange(name: string, from: number, to: number): void;
  38571. /**
  38572. * Delete a specific animation range
  38573. * @param name defines the name of the range to delete
  38574. * @param deleteFrames defines if animation frames from the range must be deleted as well
  38575. */
  38576. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  38577. /**
  38578. * Get an animation range by name
  38579. * @param name defines the name of the animation range to look for
  38580. * @returns null if not found else the requested animation range
  38581. */
  38582. getAnimationRange(name: string): Nullable<AnimationRange>;
  38583. /**
  38584. * Gets the list of all animation ranges defined on this node
  38585. * @returns an array
  38586. */
  38587. getAnimationRanges(): Nullable<AnimationRange>[];
  38588. /**
  38589. * Will start the animation sequence
  38590. * @param name defines the range frames for animation sequence
  38591. * @param loop defines if the animation should loop (false by default)
  38592. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  38593. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  38594. * @returns the object created for this animation. If range does not exist, it will return null
  38595. */
  38596. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  38597. /**
  38598. * Serialize animation ranges into a JSON compatible object
  38599. * @returns serialization object
  38600. */
  38601. serializeAnimationRanges(): any;
  38602. /**
  38603. * Computes the world matrix of the node
  38604. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  38605. * @returns the world matrix
  38606. */
  38607. computeWorldMatrix(force?: boolean): Matrix;
  38608. /**
  38609. * Releases resources associated with this node.
  38610. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  38611. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  38612. */
  38613. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  38614. /**
  38615. * Parse animation range data from a serialization object and store them into a given node
  38616. * @param node defines where to store the animation ranges
  38617. * @param parsedNode defines the serialization object to read data from
  38618. * @param scene defines the hosting scene
  38619. */
  38620. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  38621. /**
  38622. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  38623. * @param includeDescendants Include bounding info from descendants as well (true by default)
  38624. * @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
  38625. * @returns the new bounding vectors
  38626. */
  38627. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  38628. min: Vector3;
  38629. max: Vector3;
  38630. };
  38631. }
  38632. }
  38633. declare module "babylonjs/Animations/animation" {
  38634. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  38635. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  38636. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  38637. import { Nullable } from "babylonjs/types";
  38638. import { Scene } from "babylonjs/scene";
  38639. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  38640. import { AnimationRange } from "babylonjs/Animations/animationRange";
  38641. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  38642. import { Node } from "babylonjs/node";
  38643. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  38644. import { Size } from "babylonjs/Maths/math.size";
  38645. import { Animatable } from "babylonjs/Animations/animatable";
  38646. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  38647. /**
  38648. * @hidden
  38649. */
  38650. export class _IAnimationState {
  38651. key: number;
  38652. repeatCount: number;
  38653. workValue?: any;
  38654. loopMode?: number;
  38655. offsetValue?: any;
  38656. highLimitValue?: any;
  38657. }
  38658. /**
  38659. * Class used to store any kind of animation
  38660. */
  38661. export class Animation {
  38662. /**Name of the animation */
  38663. name: string;
  38664. /**Property to animate */
  38665. targetProperty: string;
  38666. /**The frames per second of the animation */
  38667. framePerSecond: number;
  38668. /**The data type of the animation */
  38669. dataType: number;
  38670. /**The loop mode of the animation */
  38671. loopMode?: number | undefined;
  38672. /**Specifies if blending should be enabled */
  38673. enableBlending?: boolean | undefined;
  38674. /**
  38675. * Use matrix interpolation instead of using direct key value when animating matrices
  38676. */
  38677. static AllowMatricesInterpolation: boolean;
  38678. /**
  38679. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  38680. */
  38681. static AllowMatrixDecomposeForInterpolation: boolean;
  38682. /** Define the Url to load snippets */
  38683. static SnippetUrl: string;
  38684. /** Snippet ID if the animation was created from the snippet server */
  38685. snippetId: string;
  38686. /**
  38687. * Stores the key frames of the animation
  38688. */
  38689. private _keys;
  38690. /**
  38691. * Stores the easing function of the animation
  38692. */
  38693. private _easingFunction;
  38694. /**
  38695. * @hidden Internal use only
  38696. */
  38697. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  38698. /**
  38699. * The set of event that will be linked to this animation
  38700. */
  38701. private _events;
  38702. /**
  38703. * Stores an array of target property paths
  38704. */
  38705. targetPropertyPath: string[];
  38706. /**
  38707. * Stores the blending speed of the animation
  38708. */
  38709. blendingSpeed: number;
  38710. /**
  38711. * Stores the animation ranges for the animation
  38712. */
  38713. private _ranges;
  38714. /**
  38715. * @hidden Internal use
  38716. */
  38717. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  38718. /**
  38719. * Sets up an animation
  38720. * @param property The property to animate
  38721. * @param animationType The animation type to apply
  38722. * @param framePerSecond The frames per second of the animation
  38723. * @param easingFunction The easing function used in the animation
  38724. * @returns The created animation
  38725. */
  38726. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  38727. /**
  38728. * Create and start an animation on a node
  38729. * @param name defines the name of the global animation that will be run on all nodes
  38730. * @param node defines the root node where the animation will take place
  38731. * @param targetProperty defines property to animate
  38732. * @param framePerSecond defines the number of frame per second yo use
  38733. * @param totalFrame defines the number of frames in total
  38734. * @param from defines the initial value
  38735. * @param to defines the final value
  38736. * @param loopMode defines which loop mode you want to use (off by default)
  38737. * @param easingFunction defines the easing function to use (linear by default)
  38738. * @param onAnimationEnd defines the callback to call when animation end
  38739. * @returns the animatable created for this animation
  38740. */
  38741. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  38742. /**
  38743. * Create and start an animation on a node and its descendants
  38744. * @param name defines the name of the global animation that will be run on all nodes
  38745. * @param node defines the root node where the animation will take place
  38746. * @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
  38747. * @param targetProperty defines property to animate
  38748. * @param framePerSecond defines the number of frame per second to use
  38749. * @param totalFrame defines the number of frames in total
  38750. * @param from defines the initial value
  38751. * @param to defines the final value
  38752. * @param loopMode defines which loop mode you want to use (off by default)
  38753. * @param easingFunction defines the easing function to use (linear by default)
  38754. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  38755. * @returns the list of animatables created for all nodes
  38756. * @example https://www.babylonjs-playground.com/#MH0VLI
  38757. */
  38758. 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[]>;
  38759. /**
  38760. * Creates a new animation, merges it with the existing animations and starts it
  38761. * @param name Name of the animation
  38762. * @param node Node which contains the scene that begins the animations
  38763. * @param targetProperty Specifies which property to animate
  38764. * @param framePerSecond The frames per second of the animation
  38765. * @param totalFrame The total number of frames
  38766. * @param from The frame at the beginning of the animation
  38767. * @param to The frame at the end of the animation
  38768. * @param loopMode Specifies the loop mode of the animation
  38769. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  38770. * @param onAnimationEnd Callback to run once the animation is complete
  38771. * @returns Nullable animation
  38772. */
  38773. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  38774. /**
  38775. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  38776. * @param sourceAnimation defines the Animation containing keyframes to convert
  38777. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  38778. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  38779. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  38780. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  38781. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  38782. */
  38783. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  38784. /**
  38785. * Transition property of an host to the target Value
  38786. * @param property The property to transition
  38787. * @param targetValue The target Value of the property
  38788. * @param host The object where the property to animate belongs
  38789. * @param scene Scene used to run the animation
  38790. * @param frameRate Framerate (in frame/s) to use
  38791. * @param transition The transition type we want to use
  38792. * @param duration The duration of the animation, in milliseconds
  38793. * @param onAnimationEnd Callback trigger at the end of the animation
  38794. * @returns Nullable animation
  38795. */
  38796. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  38797. /**
  38798. * Return the array of runtime animations currently using this animation
  38799. */
  38800. get runtimeAnimations(): RuntimeAnimation[];
  38801. /**
  38802. * Specifies if any of the runtime animations are currently running
  38803. */
  38804. get hasRunningRuntimeAnimations(): boolean;
  38805. /**
  38806. * Initializes the animation
  38807. * @param name Name of the animation
  38808. * @param targetProperty Property to animate
  38809. * @param framePerSecond The frames per second of the animation
  38810. * @param dataType The data type of the animation
  38811. * @param loopMode The loop mode of the animation
  38812. * @param enableBlending Specifies if blending should be enabled
  38813. */
  38814. constructor(
  38815. /**Name of the animation */
  38816. name: string,
  38817. /**Property to animate */
  38818. targetProperty: string,
  38819. /**The frames per second of the animation */
  38820. framePerSecond: number,
  38821. /**The data type of the animation */
  38822. dataType: number,
  38823. /**The loop mode of the animation */
  38824. loopMode?: number | undefined,
  38825. /**Specifies if blending should be enabled */
  38826. enableBlending?: boolean | undefined);
  38827. /**
  38828. * Converts the animation to a string
  38829. * @param fullDetails support for multiple levels of logging within scene loading
  38830. * @returns String form of the animation
  38831. */
  38832. toString(fullDetails?: boolean): string;
  38833. /**
  38834. * Add an event to this animation
  38835. * @param event Event to add
  38836. */
  38837. addEvent(event: AnimationEvent): void;
  38838. /**
  38839. * Remove all events found at the given frame
  38840. * @param frame The frame to remove events from
  38841. */
  38842. removeEvents(frame: number): void;
  38843. /**
  38844. * Retrieves all the events from the animation
  38845. * @returns Events from the animation
  38846. */
  38847. getEvents(): AnimationEvent[];
  38848. /**
  38849. * Creates an animation range
  38850. * @param name Name of the animation range
  38851. * @param from Starting frame of the animation range
  38852. * @param to Ending frame of the animation
  38853. */
  38854. createRange(name: string, from: number, to: number): void;
  38855. /**
  38856. * Deletes an animation range by name
  38857. * @param name Name of the animation range to delete
  38858. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  38859. */
  38860. deleteRange(name: string, deleteFrames?: boolean): void;
  38861. /**
  38862. * Gets the animation range by name, or null if not defined
  38863. * @param name Name of the animation range
  38864. * @returns Nullable animation range
  38865. */
  38866. getRange(name: string): Nullable<AnimationRange>;
  38867. /**
  38868. * Gets the key frames from the animation
  38869. * @returns The key frames of the animation
  38870. */
  38871. getKeys(): Array<IAnimationKey>;
  38872. /**
  38873. * Gets the highest frame rate of the animation
  38874. * @returns Highest frame rate of the animation
  38875. */
  38876. getHighestFrame(): number;
  38877. /**
  38878. * Gets the easing function of the animation
  38879. * @returns Easing function of the animation
  38880. */
  38881. getEasingFunction(): IEasingFunction;
  38882. /**
  38883. * Sets the easing function of the animation
  38884. * @param easingFunction A custom mathematical formula for animation
  38885. */
  38886. setEasingFunction(easingFunction: EasingFunction): void;
  38887. /**
  38888. * Interpolates a scalar linearly
  38889. * @param startValue Start value of the animation curve
  38890. * @param endValue End value of the animation curve
  38891. * @param gradient Scalar amount to interpolate
  38892. * @returns Interpolated scalar value
  38893. */
  38894. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  38895. /**
  38896. * Interpolates a scalar cubically
  38897. * @param startValue Start value of the animation curve
  38898. * @param outTangent End tangent of the animation
  38899. * @param endValue End value of the animation curve
  38900. * @param inTangent Start tangent of the animation curve
  38901. * @param gradient Scalar amount to interpolate
  38902. * @returns Interpolated scalar value
  38903. */
  38904. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  38905. /**
  38906. * Interpolates a quaternion using a spherical linear interpolation
  38907. * @param startValue Start value of the animation curve
  38908. * @param endValue End value of the animation curve
  38909. * @param gradient Scalar amount to interpolate
  38910. * @returns Interpolated quaternion value
  38911. */
  38912. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  38913. /**
  38914. * Interpolates a quaternion cubically
  38915. * @param startValue Start value of the animation curve
  38916. * @param outTangent End tangent of the animation curve
  38917. * @param endValue End value of the animation curve
  38918. * @param inTangent Start tangent of the animation curve
  38919. * @param gradient Scalar amount to interpolate
  38920. * @returns Interpolated quaternion value
  38921. */
  38922. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  38923. /**
  38924. * Interpolates a Vector3 linearl
  38925. * @param startValue Start value of the animation curve
  38926. * @param endValue End value of the animation curve
  38927. * @param gradient Scalar amount to interpolate
  38928. * @returns Interpolated scalar value
  38929. */
  38930. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  38931. /**
  38932. * Interpolates a Vector3 cubically
  38933. * @param startValue Start value of the animation curve
  38934. * @param outTangent End tangent of the animation
  38935. * @param endValue End value of the animation curve
  38936. * @param inTangent Start tangent of the animation curve
  38937. * @param gradient Scalar amount to interpolate
  38938. * @returns InterpolatedVector3 value
  38939. */
  38940. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  38941. /**
  38942. * Interpolates a Vector2 linearly
  38943. * @param startValue Start value of the animation curve
  38944. * @param endValue End value of the animation curve
  38945. * @param gradient Scalar amount to interpolate
  38946. * @returns Interpolated Vector2 value
  38947. */
  38948. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  38949. /**
  38950. * Interpolates a Vector2 cubically
  38951. * @param startValue Start value of the animation curve
  38952. * @param outTangent End tangent of the animation
  38953. * @param endValue End value of the animation curve
  38954. * @param inTangent Start tangent of the animation curve
  38955. * @param gradient Scalar amount to interpolate
  38956. * @returns Interpolated Vector2 value
  38957. */
  38958. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  38959. /**
  38960. * Interpolates a size linearly
  38961. * @param startValue Start value of the animation curve
  38962. * @param endValue End value of the animation curve
  38963. * @param gradient Scalar amount to interpolate
  38964. * @returns Interpolated Size value
  38965. */
  38966. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  38967. /**
  38968. * Interpolates a Color3 linearly
  38969. * @param startValue Start value of the animation curve
  38970. * @param endValue End value of the animation curve
  38971. * @param gradient Scalar amount to interpolate
  38972. * @returns Interpolated Color3 value
  38973. */
  38974. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  38975. /**
  38976. * Interpolates a Color4 linearly
  38977. * @param startValue Start value of the animation curve
  38978. * @param endValue End value of the animation curve
  38979. * @param gradient Scalar amount to interpolate
  38980. * @returns Interpolated Color3 value
  38981. */
  38982. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  38983. /**
  38984. * @hidden Internal use only
  38985. */
  38986. _getKeyValue(value: any): any;
  38987. /**
  38988. * @hidden Internal use only
  38989. */
  38990. _interpolate(currentFrame: number, state: _IAnimationState): any;
  38991. /**
  38992. * Defines the function to use to interpolate matrices
  38993. * @param startValue defines the start matrix
  38994. * @param endValue defines the end matrix
  38995. * @param gradient defines the gradient between both matrices
  38996. * @param result defines an optional target matrix where to store the interpolation
  38997. * @returns the interpolated matrix
  38998. */
  38999. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  39000. /**
  39001. * Makes a copy of the animation
  39002. * @returns Cloned animation
  39003. */
  39004. clone(): Animation;
  39005. /**
  39006. * Sets the key frames of the animation
  39007. * @param values The animation key frames to set
  39008. */
  39009. setKeys(values: Array<IAnimationKey>): void;
  39010. /**
  39011. * Serializes the animation to an object
  39012. * @returns Serialized object
  39013. */
  39014. serialize(): any;
  39015. /**
  39016. * Float animation type
  39017. */
  39018. static readonly ANIMATIONTYPE_FLOAT: number;
  39019. /**
  39020. * Vector3 animation type
  39021. */
  39022. static readonly ANIMATIONTYPE_VECTOR3: number;
  39023. /**
  39024. * Quaternion animation type
  39025. */
  39026. static readonly ANIMATIONTYPE_QUATERNION: number;
  39027. /**
  39028. * Matrix animation type
  39029. */
  39030. static readonly ANIMATIONTYPE_MATRIX: number;
  39031. /**
  39032. * Color3 animation type
  39033. */
  39034. static readonly ANIMATIONTYPE_COLOR3: number;
  39035. /**
  39036. * Color3 animation type
  39037. */
  39038. static readonly ANIMATIONTYPE_COLOR4: number;
  39039. /**
  39040. * Vector2 animation type
  39041. */
  39042. static readonly ANIMATIONTYPE_VECTOR2: number;
  39043. /**
  39044. * Size animation type
  39045. */
  39046. static readonly ANIMATIONTYPE_SIZE: number;
  39047. /**
  39048. * Relative Loop Mode
  39049. */
  39050. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  39051. /**
  39052. * Cycle Loop Mode
  39053. */
  39054. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  39055. /**
  39056. * Constant Loop Mode
  39057. */
  39058. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  39059. /** @hidden */
  39060. static _UniversalLerp(left: any, right: any, amount: number): any;
  39061. /**
  39062. * Parses an animation object and creates an animation
  39063. * @param parsedAnimation Parsed animation object
  39064. * @returns Animation object
  39065. */
  39066. static Parse(parsedAnimation: any): Animation;
  39067. /**
  39068. * Appends the serialized animations from the source animations
  39069. * @param source Source containing the animations
  39070. * @param destination Target to store the animations
  39071. */
  39072. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  39073. /**
  39074. * Creates a new animation or an array of animations from a snippet saved in a remote file
  39075. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  39076. * @param url defines the url to load from
  39077. * @returns a promise that will resolve to the new animation or an array of animations
  39078. */
  39079. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  39080. /**
  39081. * Creates an animation or an array of animations from a snippet saved by the Inspector
  39082. * @param snippetId defines the snippet to load
  39083. * @returns a promise that will resolve to the new animation or a new array of animations
  39084. */
  39085. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  39086. }
  39087. }
  39088. declare module "babylonjs/Animations/animatable.interface" {
  39089. import { Nullable } from "babylonjs/types";
  39090. import { Animation } from "babylonjs/Animations/animation";
  39091. /**
  39092. * Interface containing an array of animations
  39093. */
  39094. export interface IAnimatable {
  39095. /**
  39096. * Array of animations
  39097. */
  39098. animations: Nullable<Array<Animation>>;
  39099. }
  39100. }
  39101. declare module "babylonjs/Misc/decorators" {
  39102. import { Nullable } from "babylonjs/types";
  39103. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  39104. import { Scene } from "babylonjs/scene";
  39105. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39106. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  39107. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39108. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39109. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  39110. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39111. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39112. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39113. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39114. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39115. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39116. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39117. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39118. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39119. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39120. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39121. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39122. /**
  39123. * Decorator used to define property that can be serialized as reference to a camera
  39124. * @param sourceName defines the name of the property to decorate
  39125. */
  39126. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  39127. /**
  39128. * Class used to help serialization objects
  39129. */
  39130. export class SerializationHelper {
  39131. /** @hidden */
  39132. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  39133. /** @hidden */
  39134. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  39135. /** @hidden */
  39136. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  39137. /** @hidden */
  39138. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  39139. /**
  39140. * Appends the serialized animations from the source animations
  39141. * @param source Source containing the animations
  39142. * @param destination Target to store the animations
  39143. */
  39144. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  39145. /**
  39146. * Static function used to serialized a specific entity
  39147. * @param entity defines the entity to serialize
  39148. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  39149. * @returns a JSON compatible object representing the serialization of the entity
  39150. */
  39151. static Serialize<T>(entity: T, serializationObject?: any): any;
  39152. /**
  39153. * Creates a new entity from a serialization data object
  39154. * @param creationFunction defines a function used to instanciated the new entity
  39155. * @param source defines the source serialization data
  39156. * @param scene defines the hosting scene
  39157. * @param rootUrl defines the root url for resources
  39158. * @returns a new entity
  39159. */
  39160. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  39161. /**
  39162. * Clones an object
  39163. * @param creationFunction defines the function used to instanciate the new object
  39164. * @param source defines the source object
  39165. * @returns the cloned object
  39166. */
  39167. static Clone<T>(creationFunction: () => T, source: T): T;
  39168. /**
  39169. * Instanciates a new object based on a source one (some data will be shared between both object)
  39170. * @param creationFunction defines the function used to instanciate the new object
  39171. * @param source defines the source object
  39172. * @returns the new object
  39173. */
  39174. static Instanciate<T>(creationFunction: () => T, source: T): T;
  39175. }
  39176. }
  39177. declare module "babylonjs/Cameras/camera" {
  39178. import { SmartArray } from "babylonjs/Misc/smartArray";
  39179. import { Observable } from "babylonjs/Misc/observable";
  39180. import { Nullable } from "babylonjs/types";
  39181. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39182. import { Scene } from "babylonjs/scene";
  39183. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  39184. import { Node } from "babylonjs/node";
  39185. import { Mesh } from "babylonjs/Meshes/mesh";
  39186. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39187. import { ICullable } from "babylonjs/Culling/boundingInfo";
  39188. import { Viewport } from "babylonjs/Maths/math.viewport";
  39189. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39190. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39191. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39192. import { Ray } from "babylonjs/Culling/ray";
  39193. /**
  39194. * This is the base class of all the camera used in the application.
  39195. * @see https://doc.babylonjs.com/features/cameras
  39196. */
  39197. export class Camera extends Node {
  39198. /** @hidden */
  39199. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  39200. /**
  39201. * This is the default projection mode used by the cameras.
  39202. * It helps recreating a feeling of perspective and better appreciate depth.
  39203. * This is the best way to simulate real life cameras.
  39204. */
  39205. static readonly PERSPECTIVE_CAMERA: number;
  39206. /**
  39207. * This helps creating camera with an orthographic mode.
  39208. * 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.
  39209. */
  39210. static readonly ORTHOGRAPHIC_CAMERA: number;
  39211. /**
  39212. * This is the default FOV mode for perspective cameras.
  39213. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  39214. */
  39215. static readonly FOVMODE_VERTICAL_FIXED: number;
  39216. /**
  39217. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  39218. */
  39219. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  39220. /**
  39221. * This specifies ther is no need for a camera rig.
  39222. * Basically only one eye is rendered corresponding to the camera.
  39223. */
  39224. static readonly RIG_MODE_NONE: number;
  39225. /**
  39226. * Simulates a camera Rig with one blue eye and one red eye.
  39227. * This can be use with 3d blue and red glasses.
  39228. */
  39229. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  39230. /**
  39231. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  39232. */
  39233. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  39234. /**
  39235. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  39236. */
  39237. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  39238. /**
  39239. * Defines that both eyes of the camera will be rendered over under each other.
  39240. */
  39241. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  39242. /**
  39243. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  39244. */
  39245. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  39246. /**
  39247. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  39248. */
  39249. static readonly RIG_MODE_VR: number;
  39250. /**
  39251. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  39252. */
  39253. static readonly RIG_MODE_WEBVR: number;
  39254. /**
  39255. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  39256. */
  39257. static readonly RIG_MODE_CUSTOM: number;
  39258. /**
  39259. * Defines if by default attaching controls should prevent the default javascript event to continue.
  39260. */
  39261. static ForceAttachControlToAlwaysPreventDefault: boolean;
  39262. /**
  39263. * Define the input manager associated with the camera.
  39264. */
  39265. inputs: CameraInputsManager<Camera>;
  39266. /** @hidden */
  39267. _position: Vector3;
  39268. /**
  39269. * Define the current local position of the camera in the scene
  39270. */
  39271. get position(): Vector3;
  39272. set position(newPosition: Vector3);
  39273. protected _upVector: Vector3;
  39274. /**
  39275. * The vector the camera should consider as up.
  39276. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  39277. */
  39278. set upVector(vec: Vector3);
  39279. get upVector(): Vector3;
  39280. /**
  39281. * Define the current limit on the left side for an orthographic camera
  39282. * In scene unit
  39283. */
  39284. orthoLeft: Nullable<number>;
  39285. /**
  39286. * Define the current limit on the right side for an orthographic camera
  39287. * In scene unit
  39288. */
  39289. orthoRight: Nullable<number>;
  39290. /**
  39291. * Define the current limit on the bottom side for an orthographic camera
  39292. * In scene unit
  39293. */
  39294. orthoBottom: Nullable<number>;
  39295. /**
  39296. * Define the current limit on the top side for an orthographic camera
  39297. * In scene unit
  39298. */
  39299. orthoTop: Nullable<number>;
  39300. /**
  39301. * Field Of View is set in Radians. (default is 0.8)
  39302. */
  39303. fov: number;
  39304. /**
  39305. * Define the minimum distance the camera can see from.
  39306. * This is important to note that the depth buffer are not infinite and the closer it starts
  39307. * the more your scene might encounter depth fighting issue.
  39308. */
  39309. minZ: number;
  39310. /**
  39311. * Define the maximum distance the camera can see to.
  39312. * This is important to note that the depth buffer are not infinite and the further it end
  39313. * the more your scene might encounter depth fighting issue.
  39314. */
  39315. maxZ: number;
  39316. /**
  39317. * Define the default inertia of the camera.
  39318. * This helps giving a smooth feeling to the camera movement.
  39319. */
  39320. inertia: number;
  39321. /**
  39322. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  39323. */
  39324. mode: number;
  39325. /**
  39326. * Define whether the camera is intermediate.
  39327. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  39328. */
  39329. isIntermediate: boolean;
  39330. /**
  39331. * Define the viewport of the camera.
  39332. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  39333. */
  39334. viewport: Viewport;
  39335. /**
  39336. * Restricts the camera to viewing objects with the same layerMask.
  39337. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  39338. */
  39339. layerMask: number;
  39340. /**
  39341. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  39342. */
  39343. fovMode: number;
  39344. /**
  39345. * Rig mode of the camera.
  39346. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  39347. * This is normally controlled byt the camera themselves as internal use.
  39348. */
  39349. cameraRigMode: number;
  39350. /**
  39351. * Defines the distance between both "eyes" in case of a RIG
  39352. */
  39353. interaxialDistance: number;
  39354. /**
  39355. * Defines if stereoscopic rendering is done side by side or over under.
  39356. */
  39357. isStereoscopicSideBySide: boolean;
  39358. /**
  39359. * 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
  39360. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  39361. * else in the scene. (Eg. security camera)
  39362. *
  39363. * 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)
  39364. */
  39365. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  39366. /**
  39367. * When set, the camera will render to this render target instead of the default canvas
  39368. *
  39369. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  39370. */
  39371. outputRenderTarget: Nullable<RenderTargetTexture>;
  39372. /**
  39373. * Observable triggered when the camera view matrix has changed.
  39374. */
  39375. onViewMatrixChangedObservable: Observable<Camera>;
  39376. /**
  39377. * Observable triggered when the camera Projection matrix has changed.
  39378. */
  39379. onProjectionMatrixChangedObservable: Observable<Camera>;
  39380. /**
  39381. * Observable triggered when the inputs have been processed.
  39382. */
  39383. onAfterCheckInputsObservable: Observable<Camera>;
  39384. /**
  39385. * Observable triggered when reset has been called and applied to the camera.
  39386. */
  39387. onRestoreStateObservable: Observable<Camera>;
  39388. /**
  39389. * Is this camera a part of a rig system?
  39390. */
  39391. isRigCamera: boolean;
  39392. /**
  39393. * If isRigCamera set to true this will be set with the parent camera.
  39394. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  39395. */
  39396. rigParent?: Camera;
  39397. /** @hidden */
  39398. _cameraRigParams: any;
  39399. /** @hidden */
  39400. _rigCameras: Camera[];
  39401. /** @hidden */
  39402. _rigPostProcess: Nullable<PostProcess>;
  39403. protected _webvrViewMatrix: Matrix;
  39404. /** @hidden */
  39405. _skipRendering: boolean;
  39406. /** @hidden */
  39407. _projectionMatrix: Matrix;
  39408. /** @hidden */
  39409. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  39410. /** @hidden */
  39411. _activeMeshes: SmartArray<AbstractMesh>;
  39412. protected _globalPosition: Vector3;
  39413. /** @hidden */
  39414. _computedViewMatrix: Matrix;
  39415. private _doNotComputeProjectionMatrix;
  39416. private _transformMatrix;
  39417. private _frustumPlanes;
  39418. private _refreshFrustumPlanes;
  39419. private _storedFov;
  39420. private _stateStored;
  39421. /**
  39422. * Instantiates a new camera object.
  39423. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  39424. * @see https://doc.babylonjs.com/features/cameras
  39425. * @param name Defines the name of the camera in the scene
  39426. * @param position Defines the position of the camera
  39427. * @param scene Defines the scene the camera belongs too
  39428. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  39429. */
  39430. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39431. /**
  39432. * Store current camera state (fov, position, etc..)
  39433. * @returns the camera
  39434. */
  39435. storeState(): Camera;
  39436. /**
  39437. * Restores the camera state values if it has been stored. You must call storeState() first
  39438. */
  39439. protected _restoreStateValues(): boolean;
  39440. /**
  39441. * Restored camera state. You must call storeState() first.
  39442. * @returns true if restored and false otherwise
  39443. */
  39444. restoreState(): boolean;
  39445. /**
  39446. * Gets the class name of the camera.
  39447. * @returns the class name
  39448. */
  39449. getClassName(): string;
  39450. /** @hidden */
  39451. readonly _isCamera: boolean;
  39452. /**
  39453. * Gets a string representation of the camera useful for debug purpose.
  39454. * @param fullDetails Defines that a more verboe level of logging is required
  39455. * @returns the string representation
  39456. */
  39457. toString(fullDetails?: boolean): string;
  39458. /**
  39459. * Gets the current world space position of the camera.
  39460. */
  39461. get globalPosition(): Vector3;
  39462. /**
  39463. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  39464. * @returns the active meshe list
  39465. */
  39466. getActiveMeshes(): SmartArray<AbstractMesh>;
  39467. /**
  39468. * Check whether a mesh is part of the current active mesh list of the camera
  39469. * @param mesh Defines the mesh to check
  39470. * @returns true if active, false otherwise
  39471. */
  39472. isActiveMesh(mesh: Mesh): boolean;
  39473. /**
  39474. * Is this camera ready to be used/rendered
  39475. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  39476. * @return true if the camera is ready
  39477. */
  39478. isReady(completeCheck?: boolean): boolean;
  39479. /** @hidden */
  39480. _initCache(): void;
  39481. /** @hidden */
  39482. _updateCache(ignoreParentClass?: boolean): void;
  39483. /** @hidden */
  39484. _isSynchronized(): boolean;
  39485. /** @hidden */
  39486. _isSynchronizedViewMatrix(): boolean;
  39487. /** @hidden */
  39488. _isSynchronizedProjectionMatrix(): boolean;
  39489. /**
  39490. * Attach the input controls to a specific dom element to get the input from.
  39491. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39492. */
  39493. attachControl(noPreventDefault?: boolean): void;
  39494. /**
  39495. * Attach the input controls to a specific dom element to get the input from.
  39496. * @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
  39497. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39498. * BACK COMPAT SIGNATURE ONLY.
  39499. */
  39500. attachControl(ignored: any, noPreventDefault?: boolean): void;
  39501. /**
  39502. * Detach the current controls from the specified dom element.
  39503. */
  39504. detachControl(): void;
  39505. /**
  39506. * Detach the current controls from the specified dom element.
  39507. * @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
  39508. */
  39509. detachControl(ignored: any): void;
  39510. /**
  39511. * Update the camera state according to the different inputs gathered during the frame.
  39512. */
  39513. update(): void;
  39514. /** @hidden */
  39515. _checkInputs(): void;
  39516. /** @hidden */
  39517. get rigCameras(): Camera[];
  39518. /**
  39519. * Gets the post process used by the rig cameras
  39520. */
  39521. get rigPostProcess(): Nullable<PostProcess>;
  39522. /**
  39523. * Internal, gets the first post proces.
  39524. * @returns the first post process to be run on this camera.
  39525. */
  39526. _getFirstPostProcess(): Nullable<PostProcess>;
  39527. private _cascadePostProcessesToRigCams;
  39528. /**
  39529. * Attach a post process to the camera.
  39530. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  39531. * @param postProcess The post process to attach to the camera
  39532. * @param insertAt The position of the post process in case several of them are in use in the scene
  39533. * @returns the position the post process has been inserted at
  39534. */
  39535. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  39536. /**
  39537. * Detach a post process to the camera.
  39538. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  39539. * @param postProcess The post process to detach from the camera
  39540. */
  39541. detachPostProcess(postProcess: PostProcess): void;
  39542. /**
  39543. * Gets the current world matrix of the camera
  39544. */
  39545. getWorldMatrix(): Matrix;
  39546. /** @hidden */
  39547. _getViewMatrix(): Matrix;
  39548. /**
  39549. * Gets the current view matrix of the camera.
  39550. * @param force forces the camera to recompute the matrix without looking at the cached state
  39551. * @returns the view matrix
  39552. */
  39553. getViewMatrix(force?: boolean): Matrix;
  39554. /**
  39555. * Freeze the projection matrix.
  39556. * It will prevent the cache check of the camera projection compute and can speed up perf
  39557. * if no parameter of the camera are meant to change
  39558. * @param projection Defines manually a projection if necessary
  39559. */
  39560. freezeProjectionMatrix(projection?: Matrix): void;
  39561. /**
  39562. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  39563. */
  39564. unfreezeProjectionMatrix(): void;
  39565. /**
  39566. * Gets the current projection matrix of the camera.
  39567. * @param force forces the camera to recompute the matrix without looking at the cached state
  39568. * @returns the projection matrix
  39569. */
  39570. getProjectionMatrix(force?: boolean): Matrix;
  39571. /**
  39572. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  39573. * @returns a Matrix
  39574. */
  39575. getTransformationMatrix(): Matrix;
  39576. private _updateFrustumPlanes;
  39577. /**
  39578. * Checks if a cullable object (mesh...) is in the camera frustum
  39579. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  39580. * @param target The object to check
  39581. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  39582. * @returns true if the object is in frustum otherwise false
  39583. */
  39584. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  39585. /**
  39586. * Checks if a cullable object (mesh...) is in the camera frustum
  39587. * Unlike isInFrustum this cheks the full bounding box
  39588. * @param target The object to check
  39589. * @returns true if the object is in frustum otherwise false
  39590. */
  39591. isCompletelyInFrustum(target: ICullable): boolean;
  39592. /**
  39593. * Gets a ray in the forward direction from the camera.
  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. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  39600. /**
  39601. * Gets a ray in the forward direction from the camera.
  39602. * @param refRay the ray to (re)use when setting the values
  39603. * @param length Defines the length of the ray to create
  39604. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  39605. * @param origin Defines the start point of the ray which defaults to the camera position
  39606. * @returns the forward ray
  39607. */
  39608. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  39609. /**
  39610. * Releases resources associated with this node.
  39611. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  39612. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  39613. */
  39614. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  39615. /** @hidden */
  39616. _isLeftCamera: boolean;
  39617. /**
  39618. * Gets the left camera of a rig setup in case of Rigged Camera
  39619. */
  39620. get isLeftCamera(): boolean;
  39621. /** @hidden */
  39622. _isRightCamera: boolean;
  39623. /**
  39624. * Gets the right camera of a rig setup in case of Rigged Camera
  39625. */
  39626. get isRightCamera(): boolean;
  39627. /**
  39628. * Gets the left camera of a rig setup in case of Rigged Camera
  39629. */
  39630. get leftCamera(): Nullable<FreeCamera>;
  39631. /**
  39632. * Gets the right camera of a rig setup in case of Rigged Camera
  39633. */
  39634. get rightCamera(): Nullable<FreeCamera>;
  39635. /**
  39636. * Gets the left camera target of a rig setup in case of Rigged Camera
  39637. * @returns the target position
  39638. */
  39639. getLeftTarget(): Nullable<Vector3>;
  39640. /**
  39641. * Gets the right camera target of a rig setup in case of Rigged Camera
  39642. * @returns the target position
  39643. */
  39644. getRightTarget(): Nullable<Vector3>;
  39645. /**
  39646. * @hidden
  39647. */
  39648. setCameraRigMode(mode: number, rigParams: any): void;
  39649. /** @hidden */
  39650. static _setStereoscopicRigMode(camera: Camera): void;
  39651. /** @hidden */
  39652. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  39653. /** @hidden */
  39654. static _setVRRigMode(camera: Camera, rigParams: any): void;
  39655. /** @hidden */
  39656. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  39657. /** @hidden */
  39658. _getVRProjectionMatrix(): Matrix;
  39659. protected _updateCameraRotationMatrix(): void;
  39660. protected _updateWebVRCameraRotationMatrix(): void;
  39661. /**
  39662. * This function MUST be overwritten by the different WebVR cameras available.
  39663. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  39664. * @hidden
  39665. */
  39666. _getWebVRProjectionMatrix(): Matrix;
  39667. /**
  39668. * This function MUST be overwritten by the different WebVR cameras available.
  39669. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  39670. * @hidden
  39671. */
  39672. _getWebVRViewMatrix(): Matrix;
  39673. /** @hidden */
  39674. setCameraRigParameter(name: string, value: any): void;
  39675. /**
  39676. * needs to be overridden by children so sub has required properties to be copied
  39677. * @hidden
  39678. */
  39679. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  39680. /**
  39681. * May need to be overridden by children
  39682. * @hidden
  39683. */
  39684. _updateRigCameras(): void;
  39685. /** @hidden */
  39686. _setupInputs(): void;
  39687. /**
  39688. * Serialiaze the camera setup to a json represention
  39689. * @returns the JSON representation
  39690. */
  39691. serialize(): any;
  39692. /**
  39693. * Clones the current camera.
  39694. * @param name The cloned camera name
  39695. * @returns the cloned camera
  39696. */
  39697. clone(name: string): Camera;
  39698. /**
  39699. * Gets the direction of the camera relative to a given local axis.
  39700. * @param localAxis Defines the reference axis to provide a relative direction.
  39701. * @return the direction
  39702. */
  39703. getDirection(localAxis: Vector3): Vector3;
  39704. /**
  39705. * Returns the current camera absolute rotation
  39706. */
  39707. get absoluteRotation(): Quaternion;
  39708. /**
  39709. * Gets the direction of the camera relative to a given local axis into a passed vector.
  39710. * @param localAxis Defines the reference axis to provide a relative direction.
  39711. * @param result Defines the vector to store the result in
  39712. */
  39713. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  39714. /**
  39715. * Gets a camera constructor for a given camera type
  39716. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  39717. * @param name The name of the camera the result will be able to instantiate
  39718. * @param scene The scene the result will construct the camera in
  39719. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  39720. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  39721. * @returns a factory method to construc the camera
  39722. */
  39723. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  39724. /**
  39725. * Compute the world matrix of the camera.
  39726. * @returns the camera world matrix
  39727. */
  39728. computeWorldMatrix(): Matrix;
  39729. /**
  39730. * Parse a JSON and creates the camera from the parsed information
  39731. * @param parsedCamera The JSON to parse
  39732. * @param scene The scene to instantiate the camera in
  39733. * @returns the newly constructed camera
  39734. */
  39735. static Parse(parsedCamera: any, scene: Scene): Camera;
  39736. }
  39737. }
  39738. declare module "babylonjs/PostProcesses/postProcessManager" {
  39739. import { Nullable } from "babylonjs/types";
  39740. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39741. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39742. import { Scene } from "babylonjs/scene";
  39743. /**
  39744. * PostProcessManager is used to manage one or more post processes or post process pipelines
  39745. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  39746. */
  39747. export class PostProcessManager {
  39748. private _scene;
  39749. private _indexBuffer;
  39750. private _vertexBuffers;
  39751. /**
  39752. * Creates a new instance PostProcess
  39753. * @param scene The scene that the post process is associated with.
  39754. */
  39755. constructor(scene: Scene);
  39756. private _prepareBuffers;
  39757. private _buildIndexBuffer;
  39758. /**
  39759. * Rebuilds the vertex buffers of the manager.
  39760. * @hidden
  39761. */
  39762. _rebuild(): void;
  39763. /**
  39764. * Prepares a frame to be run through a post process.
  39765. * @param sourceTexture The input texture to the post procesess. (default: null)
  39766. * @param postProcesses An array of post processes to be run. (default: null)
  39767. * @returns True if the post processes were able to be run.
  39768. * @hidden
  39769. */
  39770. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  39771. /**
  39772. * Manually render a set of post processes to a texture.
  39773. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  39774. * @param postProcesses An array of post processes to be run.
  39775. * @param targetTexture The target texture to render to.
  39776. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  39777. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  39778. * @param lodLevel defines which lod of the texture to render to
  39779. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  39780. */
  39781. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  39782. /**
  39783. * Finalize the result of the output of the postprocesses.
  39784. * @param doNotPresent If true the result will not be displayed to the screen.
  39785. * @param targetTexture The target texture to render to.
  39786. * @param faceIndex The index of the face to bind the target texture to.
  39787. * @param postProcesses The array of post processes to render.
  39788. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  39789. * @hidden
  39790. */
  39791. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  39792. /**
  39793. * Disposes of the post process manager.
  39794. */
  39795. dispose(): void;
  39796. }
  39797. }
  39798. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  39799. import { Observable } from "babylonjs/Misc/observable";
  39800. import { SmartArray } from "babylonjs/Misc/smartArray";
  39801. import { Nullable, Immutable } from "babylonjs/types";
  39802. import { Camera } from "babylonjs/Cameras/camera";
  39803. import { Scene } from "babylonjs/scene";
  39804. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  39805. import { Color4 } from "babylonjs/Maths/math.color";
  39806. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  39807. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39808. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39809. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39810. import { Texture } from "babylonjs/Materials/Textures/texture";
  39811. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39812. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  39813. import "babylonjs/Engines/Extensions/engine.renderTarget";
  39814. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  39815. import { Engine } from "babylonjs/Engines/engine";
  39816. /**
  39817. * This Helps creating a texture that will be created from a camera in your scene.
  39818. * It is basically a dynamic texture that could be used to create special effects for instance.
  39819. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  39820. */
  39821. export class RenderTargetTexture extends Texture {
  39822. /**
  39823. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  39824. */
  39825. static readonly REFRESHRATE_RENDER_ONCE: number;
  39826. /**
  39827. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  39828. */
  39829. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  39830. /**
  39831. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  39832. * the central point of your effect and can save a lot of performances.
  39833. */
  39834. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  39835. /**
  39836. * Use this predicate to dynamically define the list of mesh you want to render.
  39837. * If set, the renderList property will be overwritten.
  39838. */
  39839. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  39840. private _renderList;
  39841. /**
  39842. * Use this list to define the list of mesh you want to render.
  39843. */
  39844. get renderList(): Nullable<Array<AbstractMesh>>;
  39845. set renderList(value: Nullable<Array<AbstractMesh>>);
  39846. /**
  39847. * Use this function to overload the renderList array at rendering time.
  39848. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  39849. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  39850. * the cube (if the RTT is a cube, else layerOrFace=0).
  39851. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  39852. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  39853. * hold dummy elements!
  39854. */
  39855. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  39856. private _hookArray;
  39857. /**
  39858. * Define if particles should be rendered in your texture.
  39859. */
  39860. renderParticles: boolean;
  39861. /**
  39862. * Define if sprites should be rendered in your texture.
  39863. */
  39864. renderSprites: boolean;
  39865. /**
  39866. * Define the camera used to render the texture.
  39867. */
  39868. activeCamera: Nullable<Camera>;
  39869. /**
  39870. * Override the mesh isReady function with your own one.
  39871. */
  39872. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  39873. /**
  39874. * Override the render function of the texture with your own one.
  39875. */
  39876. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  39877. /**
  39878. * Define if camera post processes should be use while rendering the texture.
  39879. */
  39880. useCameraPostProcesses: boolean;
  39881. /**
  39882. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  39883. */
  39884. ignoreCameraViewport: boolean;
  39885. private _postProcessManager;
  39886. private _postProcesses;
  39887. private _resizeObserver;
  39888. /**
  39889. * An event triggered when the texture is unbind.
  39890. */
  39891. onBeforeBindObservable: Observable<RenderTargetTexture>;
  39892. /**
  39893. * An event triggered when the texture is unbind.
  39894. */
  39895. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  39896. private _onAfterUnbindObserver;
  39897. /**
  39898. * Set a after unbind callback in the texture.
  39899. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  39900. */
  39901. set onAfterUnbind(callback: () => void);
  39902. /**
  39903. * An event triggered before rendering the texture
  39904. */
  39905. onBeforeRenderObservable: Observable<number>;
  39906. private _onBeforeRenderObserver;
  39907. /**
  39908. * Set a before render callback in the texture.
  39909. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  39910. */
  39911. set onBeforeRender(callback: (faceIndex: number) => void);
  39912. /**
  39913. * An event triggered after rendering the texture
  39914. */
  39915. onAfterRenderObservable: Observable<number>;
  39916. private _onAfterRenderObserver;
  39917. /**
  39918. * Set a after render callback in the texture.
  39919. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  39920. */
  39921. set onAfterRender(callback: (faceIndex: number) => void);
  39922. /**
  39923. * An event triggered after the texture clear
  39924. */
  39925. onClearObservable: Observable<Engine>;
  39926. private _onClearObserver;
  39927. /**
  39928. * Set a clear callback in the texture.
  39929. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  39930. */
  39931. set onClear(callback: (Engine: Engine) => void);
  39932. /**
  39933. * An event triggered when the texture is resized.
  39934. */
  39935. onResizeObservable: Observable<RenderTargetTexture>;
  39936. /**
  39937. * Define the clear color of the Render Target if it should be different from the scene.
  39938. */
  39939. clearColor: Color4;
  39940. protected _size: number | {
  39941. width: number;
  39942. height: number;
  39943. layers?: number;
  39944. };
  39945. protected _initialSizeParameter: number | {
  39946. width: number;
  39947. height: number;
  39948. } | {
  39949. ratio: number;
  39950. };
  39951. protected _sizeRatio: Nullable<number>;
  39952. /** @hidden */
  39953. _generateMipMaps: boolean;
  39954. protected _renderingManager: RenderingManager;
  39955. /** @hidden */
  39956. _waitingRenderList?: string[];
  39957. protected _doNotChangeAspectRatio: boolean;
  39958. protected _currentRefreshId: number;
  39959. protected _refreshRate: number;
  39960. protected _textureMatrix: Matrix;
  39961. protected _samples: number;
  39962. protected _renderTargetOptions: RenderTargetCreationOptions;
  39963. /**
  39964. * Gets render target creation options that were used.
  39965. */
  39966. get renderTargetOptions(): RenderTargetCreationOptions;
  39967. protected _onRatioRescale(): void;
  39968. /**
  39969. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  39970. * It must define where the camera used to render the texture is set
  39971. */
  39972. boundingBoxPosition: Vector3;
  39973. private _boundingBoxSize;
  39974. /**
  39975. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  39976. * When defined, the cubemap will switch to local mode
  39977. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  39978. * @example https://www.babylonjs-playground.com/#RNASML
  39979. */
  39980. set boundingBoxSize(value: Vector3);
  39981. get boundingBoxSize(): Vector3;
  39982. /**
  39983. * In case the RTT has been created with a depth texture, get the associated
  39984. * depth texture.
  39985. * Otherwise, return null.
  39986. */
  39987. get depthStencilTexture(): Nullable<InternalTexture>;
  39988. /**
  39989. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  39990. * or used a shadow, depth texture...
  39991. * @param name The friendly name of the texture
  39992. * @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)
  39993. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  39994. * @param generateMipMaps True if mip maps need to be generated after render.
  39995. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  39996. * @param type The type of the buffer in the RTT (int, half float, float...)
  39997. * @param isCube True if a cube texture needs to be created
  39998. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  39999. * @param generateDepthBuffer True to generate a depth buffer
  40000. * @param generateStencilBuffer True to generate a stencil buffer
  40001. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  40002. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  40003. * @param delayAllocation if the texture allocation should be delayed (default: false)
  40004. * @param samples sample count to use when creating the RTT
  40005. */
  40006. constructor(name: string, size: number | {
  40007. width: number;
  40008. height: number;
  40009. layers?: number;
  40010. } | {
  40011. ratio: number;
  40012. }, 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);
  40013. /**
  40014. * Creates a depth stencil texture.
  40015. * This is only available in WebGL 2 or with the depth texture extension available.
  40016. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  40017. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  40018. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  40019. * @param samples sample count of the depth/stencil texture
  40020. */
  40021. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean, samples?: number): void;
  40022. private _processSizeParameter;
  40023. /**
  40024. * Define the number of samples to use in case of MSAA.
  40025. * It defaults to one meaning no MSAA has been enabled.
  40026. */
  40027. get samples(): number;
  40028. set samples(value: number);
  40029. /**
  40030. * Resets the refresh counter of the texture and start bak from scratch.
  40031. * Could be useful to regenerate the texture if it is setup to render only once.
  40032. */
  40033. resetRefreshCounter(): void;
  40034. /**
  40035. * Define the refresh rate of the texture or the rendering frequency.
  40036. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  40037. */
  40038. get refreshRate(): number;
  40039. set refreshRate(value: number);
  40040. /**
  40041. * Adds a post process to the render target rendering passes.
  40042. * @param postProcess define the post process to add
  40043. */
  40044. addPostProcess(postProcess: PostProcess): void;
  40045. /**
  40046. * Clear all the post processes attached to the render target
  40047. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  40048. */
  40049. clearPostProcesses(dispose?: boolean): void;
  40050. /**
  40051. * Remove one of the post process from the list of attached post processes to the texture
  40052. * @param postProcess define the post process to remove from the list
  40053. */
  40054. removePostProcess(postProcess: PostProcess): void;
  40055. /** @hidden */
  40056. _shouldRender(): boolean;
  40057. /**
  40058. * Gets the actual render size of the texture.
  40059. * @returns the width of the render size
  40060. */
  40061. getRenderSize(): number;
  40062. /**
  40063. * Gets the actual render width of the texture.
  40064. * @returns the width of the render size
  40065. */
  40066. getRenderWidth(): number;
  40067. /**
  40068. * Gets the actual render height of the texture.
  40069. * @returns the height of the render size
  40070. */
  40071. getRenderHeight(): number;
  40072. /**
  40073. * Gets the actual number of layers of the texture.
  40074. * @returns the number of layers
  40075. */
  40076. getRenderLayers(): number;
  40077. /**
  40078. * Get if the texture can be rescaled or not.
  40079. */
  40080. get canRescale(): boolean;
  40081. /**
  40082. * Resize the texture using a ratio.
  40083. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  40084. */
  40085. scale(ratio: number): void;
  40086. /**
  40087. * Get the texture reflection matrix used to rotate/transform the reflection.
  40088. * @returns the reflection matrix
  40089. */
  40090. getReflectionTextureMatrix(): Matrix;
  40091. /**
  40092. * Resize the texture to a new desired size.
  40093. * Be carrefull as it will recreate all the data in the new texture.
  40094. * @param size Define the new size. It can be:
  40095. * - a number for squared texture,
  40096. * - an object containing { width: number, height: number }
  40097. * - or an object containing a ratio { ratio: number }
  40098. */
  40099. resize(size: number | {
  40100. width: number;
  40101. height: number;
  40102. } | {
  40103. ratio: number;
  40104. }): void;
  40105. private _defaultRenderListPrepared;
  40106. /**
  40107. * Renders all the objects from the render list into the texture.
  40108. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  40109. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  40110. */
  40111. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  40112. private _bestReflectionRenderTargetDimension;
  40113. private _prepareRenderingManager;
  40114. /**
  40115. * @hidden
  40116. * @param faceIndex face index to bind to if this is a cubetexture
  40117. * @param layer defines the index of the texture to bind in the array
  40118. */
  40119. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  40120. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  40121. private renderToTarget;
  40122. /**
  40123. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  40124. * This allowed control for front to back rendering or reversly depending of the special needs.
  40125. *
  40126. * @param renderingGroupId The rendering group id corresponding to its index
  40127. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  40128. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  40129. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  40130. */
  40131. 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;
  40132. /**
  40133. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  40134. *
  40135. * @param renderingGroupId The rendering group id corresponding to its index
  40136. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  40137. */
  40138. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  40139. /**
  40140. * Clones the texture.
  40141. * @returns the cloned texture
  40142. */
  40143. clone(): RenderTargetTexture;
  40144. /**
  40145. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  40146. * @returns The JSON representation of the texture
  40147. */
  40148. serialize(): any;
  40149. /**
  40150. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  40151. */
  40152. disposeFramebufferObjects(): void;
  40153. /**
  40154. * Dispose the texture and release its associated resources.
  40155. */
  40156. dispose(): void;
  40157. /** @hidden */
  40158. _rebuild(): void;
  40159. /**
  40160. * Clear the info related to rendering groups preventing retention point in material dispose.
  40161. */
  40162. freeRenderingGroups(): void;
  40163. /**
  40164. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  40165. * @returns the view count
  40166. */
  40167. getViewCount(): number;
  40168. }
  40169. }
  40170. declare module "babylonjs/Materials/effect" {
  40171. import { Observable } from "babylonjs/Misc/observable";
  40172. import { FloatArray, Nullable } from "babylonjs/types";
  40173. import { IDisposable } from "babylonjs/scene";
  40174. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  40175. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  40176. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  40177. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  40178. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  40179. import { Engine } from "babylonjs/Engines/engine";
  40180. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  40181. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  40182. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40183. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40184. /**
  40185. * Options to be used when creating an effect.
  40186. */
  40187. export interface IEffectCreationOptions {
  40188. /**
  40189. * Atrributes that will be used in the shader.
  40190. */
  40191. attributes: string[];
  40192. /**
  40193. * Uniform varible names that will be set in the shader.
  40194. */
  40195. uniformsNames: string[];
  40196. /**
  40197. * Uniform buffer variable names that will be set in the shader.
  40198. */
  40199. uniformBuffersNames: string[];
  40200. /**
  40201. * Sampler texture variable names that will be set in the shader.
  40202. */
  40203. samplers: string[];
  40204. /**
  40205. * Define statements that will be set in the shader.
  40206. */
  40207. defines: any;
  40208. /**
  40209. * Possible fallbacks for this effect to improve performance when needed.
  40210. */
  40211. fallbacks: Nullable<IEffectFallbacks>;
  40212. /**
  40213. * Callback that will be called when the shader is compiled.
  40214. */
  40215. onCompiled: Nullable<(effect: Effect) => void>;
  40216. /**
  40217. * Callback that will be called if an error occurs during shader compilation.
  40218. */
  40219. onError: Nullable<(effect: Effect, errors: string) => void>;
  40220. /**
  40221. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  40222. */
  40223. indexParameters?: any;
  40224. /**
  40225. * Max number of lights that can be used in the shader.
  40226. */
  40227. maxSimultaneousLights?: number;
  40228. /**
  40229. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  40230. */
  40231. transformFeedbackVaryings?: Nullable<string[]>;
  40232. /**
  40233. * 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
  40234. */
  40235. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  40236. /**
  40237. * Is this effect rendering to several color attachments ?
  40238. */
  40239. multiTarget?: boolean;
  40240. }
  40241. /**
  40242. * Effect containing vertex and fragment shader that can be executed on an object.
  40243. */
  40244. export class Effect implements IDisposable {
  40245. /**
  40246. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  40247. */
  40248. static ShadersRepository: string;
  40249. /**
  40250. * Enable logging of the shader code when a compilation error occurs
  40251. */
  40252. static LogShaderCodeOnCompilationError: boolean;
  40253. /**
  40254. * Name of the effect.
  40255. */
  40256. name: any;
  40257. /**
  40258. * String container all the define statements that should be set on the shader.
  40259. */
  40260. defines: string;
  40261. /**
  40262. * Callback that will be called when the shader is compiled.
  40263. */
  40264. onCompiled: Nullable<(effect: Effect) => void>;
  40265. /**
  40266. * Callback that will be called if an error occurs during shader compilation.
  40267. */
  40268. onError: Nullable<(effect: Effect, errors: string) => void>;
  40269. /**
  40270. * Callback that will be called when effect is bound.
  40271. */
  40272. onBind: Nullable<(effect: Effect) => void>;
  40273. /**
  40274. * Unique ID of the effect.
  40275. */
  40276. uniqueId: number;
  40277. /**
  40278. * Observable that will be called when the shader is compiled.
  40279. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  40280. */
  40281. onCompileObservable: Observable<Effect>;
  40282. /**
  40283. * Observable that will be called if an error occurs during shader compilation.
  40284. */
  40285. onErrorObservable: Observable<Effect>;
  40286. /** @hidden */
  40287. _onBindObservable: Nullable<Observable<Effect>>;
  40288. /**
  40289. * @hidden
  40290. * Specifies if the effect was previously ready
  40291. */
  40292. _wasPreviouslyReady: boolean;
  40293. /**
  40294. * Observable that will be called when effect is bound.
  40295. */
  40296. get onBindObservable(): Observable<Effect>;
  40297. /** @hidden */
  40298. _bonesComputationForcedToCPU: boolean;
  40299. /** @hidden */
  40300. _uniformBuffersNames: {
  40301. [key: string]: number;
  40302. };
  40303. /** @hidden */
  40304. _samplerList: string[];
  40305. /** @hidden */
  40306. _multiTarget: boolean;
  40307. private static _uniqueIdSeed;
  40308. private _engine;
  40309. private _uniformBuffersNamesList;
  40310. private _uniformsNames;
  40311. private _samplers;
  40312. private _isReady;
  40313. private _compilationError;
  40314. private _allFallbacksProcessed;
  40315. private _attributesNames;
  40316. private _attributes;
  40317. private _attributeLocationByName;
  40318. private _uniforms;
  40319. /**
  40320. * Key for the effect.
  40321. * @hidden
  40322. */
  40323. _key: string;
  40324. private _indexParameters;
  40325. private _fallbacks;
  40326. private _vertexSourceCodeOverride;
  40327. private _fragmentSourceCodeOverride;
  40328. private _transformFeedbackVaryings;
  40329. /**
  40330. * Compiled shader to webGL program.
  40331. * @hidden
  40332. */
  40333. _pipelineContext: Nullable<IPipelineContext>;
  40334. /** @hidden */
  40335. _vertexSourceCode: string;
  40336. /** @hidden */
  40337. _fragmentSourceCode: string;
  40338. /** @hidden */
  40339. private _rawVertexSourceCode;
  40340. /** @hidden */
  40341. private _rawFragmentSourceCode;
  40342. private static _baseCache;
  40343. private _processingContext;
  40344. /**
  40345. * Instantiates an effect.
  40346. * An effect can be used to create/manage/execute vertex and fragment shaders.
  40347. * @param baseName Name of the effect.
  40348. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  40349. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  40350. * @param samplers List of sampler variables that will be passed to the shader.
  40351. * @param engine Engine to be used to render the effect
  40352. * @param defines Define statements to be added to the shader.
  40353. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  40354. * @param onCompiled Callback that will be called when the shader is compiled.
  40355. * @param onError Callback that will be called if an error occurs during shader compilation.
  40356. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  40357. * @param key Effect Key identifying uniquely compiled shader variants
  40358. */
  40359. 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);
  40360. private _useFinalCode;
  40361. /**
  40362. * Unique key for this effect
  40363. */
  40364. get key(): string;
  40365. /**
  40366. * If the effect has been compiled and prepared.
  40367. * @returns if the effect is compiled and prepared.
  40368. */
  40369. isReady(): boolean;
  40370. private _isReadyInternal;
  40371. /**
  40372. * The engine the effect was initialized with.
  40373. * @returns the engine.
  40374. */
  40375. getEngine(): Engine;
  40376. /**
  40377. * The pipeline context for this effect
  40378. * @returns the associated pipeline context
  40379. */
  40380. getPipelineContext(): Nullable<IPipelineContext>;
  40381. /**
  40382. * The set of names of attribute variables for the shader.
  40383. * @returns An array of attribute names.
  40384. */
  40385. getAttributesNames(): string[];
  40386. /**
  40387. * Returns the attribute at the given index.
  40388. * @param index The index of the attribute.
  40389. * @returns The location of the attribute.
  40390. */
  40391. getAttributeLocation(index: number): number;
  40392. /**
  40393. * Returns the attribute based on the name of the variable.
  40394. * @param name of the attribute to look up.
  40395. * @returns the attribute location.
  40396. */
  40397. getAttributeLocationByName(name: string): number;
  40398. /**
  40399. * The number of attributes.
  40400. * @returns the numnber of attributes.
  40401. */
  40402. getAttributesCount(): number;
  40403. /**
  40404. * Gets the index of a uniform variable.
  40405. * @param uniformName of the uniform to look up.
  40406. * @returns the index.
  40407. */
  40408. getUniformIndex(uniformName: string): number;
  40409. /**
  40410. * Returns the attribute based on the name of the variable.
  40411. * @param uniformName of the uniform to look up.
  40412. * @returns the location of the uniform.
  40413. */
  40414. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  40415. /**
  40416. * Returns an array of sampler variable names
  40417. * @returns The array of sampler variable names.
  40418. */
  40419. getSamplers(): string[];
  40420. /**
  40421. * Returns an array of uniform variable names
  40422. * @returns The array of uniform variable names.
  40423. */
  40424. getUniformNames(): string[];
  40425. /**
  40426. * Returns an array of uniform buffer variable names
  40427. * @returns The array of uniform buffer variable names.
  40428. */
  40429. getUniformBuffersNames(): string[];
  40430. /**
  40431. * Returns the index parameters used to create the effect
  40432. * @returns The index parameters object
  40433. */
  40434. getIndexParameters(): any;
  40435. /**
  40436. * The error from the last compilation.
  40437. * @returns the error string.
  40438. */
  40439. getCompilationError(): string;
  40440. /**
  40441. * Gets a boolean indicating that all fallbacks were used during compilation
  40442. * @returns true if all fallbacks were used
  40443. */
  40444. allFallbacksProcessed(): boolean;
  40445. /**
  40446. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  40447. * @param func The callback to be used.
  40448. */
  40449. executeWhenCompiled(func: (effect: Effect) => void): void;
  40450. private _checkIsReady;
  40451. private _loadShader;
  40452. /**
  40453. * Gets the vertex shader source code of this effect
  40454. */
  40455. get vertexSourceCode(): string;
  40456. /**
  40457. * Gets the fragment shader source code of this effect
  40458. */
  40459. get fragmentSourceCode(): string;
  40460. /**
  40461. * Gets the vertex shader source code before it has been processed by the preprocessor
  40462. */
  40463. get rawVertexSourceCode(): string;
  40464. /**
  40465. * Gets the fragment shader source code before it has been processed by the preprocessor
  40466. */
  40467. get rawFragmentSourceCode(): string;
  40468. /**
  40469. * Recompiles the webGL program
  40470. * @param vertexSourceCode The source code for the vertex shader.
  40471. * @param fragmentSourceCode The source code for the fragment shader.
  40472. * @param onCompiled Callback called when completed.
  40473. * @param onError Callback called on error.
  40474. * @hidden
  40475. */
  40476. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  40477. /**
  40478. * Prepares the effect
  40479. * @hidden
  40480. */
  40481. _prepareEffect(): void;
  40482. private _getShaderCodeAndErrorLine;
  40483. private _processCompilationErrors;
  40484. /**
  40485. * Checks if the effect is supported. (Must be called after compilation)
  40486. */
  40487. get isSupported(): boolean;
  40488. /**
  40489. * Binds a texture to the engine to be used as output of the shader.
  40490. * @param channel Name of the output variable.
  40491. * @param texture Texture to bind.
  40492. * @hidden
  40493. */
  40494. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  40495. /**
  40496. * Sets a texture on the engine to be used in the shader.
  40497. * @param channel Name of the sampler variable.
  40498. * @param texture Texture to set.
  40499. */
  40500. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  40501. /**
  40502. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  40503. * @param channel Name of the sampler variable.
  40504. * @param texture Texture to set.
  40505. */
  40506. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  40507. /**
  40508. * Sets an array of textures on the engine to be used in the shader.
  40509. * @param channel Name of the variable.
  40510. * @param textures Textures to set.
  40511. */
  40512. setTextureArray(channel: string, textures: ThinTexture[]): void;
  40513. /**
  40514. * 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)
  40515. * @param channel Name of the sampler variable.
  40516. * @param postProcess Post process to get the input texture from.
  40517. */
  40518. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  40519. /**
  40520. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  40521. * 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)
  40522. * @param channel Name of the sampler variable.
  40523. * @param postProcess Post process to get the output texture from.
  40524. */
  40525. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  40526. /**
  40527. * Binds a buffer to a uniform.
  40528. * @param buffer Buffer to bind.
  40529. * @param name Name of the uniform variable to bind to.
  40530. */
  40531. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  40532. /**
  40533. * Binds block to a uniform.
  40534. * @param blockName Name of the block to bind.
  40535. * @param index Index to bind.
  40536. */
  40537. bindUniformBlock(blockName: string, index: number): void;
  40538. /**
  40539. * Sets an interger value on a uniform variable.
  40540. * @param uniformName Name of the variable.
  40541. * @param value Value to be set.
  40542. * @returns this effect.
  40543. */
  40544. setInt(uniformName: string, value: number): Effect;
  40545. /**
  40546. * Sets an int2 value on a uniform variable.
  40547. * @param uniformName Name of the variable.
  40548. * @param x First int in int2.
  40549. * @param y Second int in int2.
  40550. * @returns this effect.
  40551. */
  40552. setInt2(uniformName: string, x: number, y: number): Effect;
  40553. /**
  40554. * Sets an int3 value on a uniform variable.
  40555. * @param uniformName Name of the variable.
  40556. * @param x First int in int3.
  40557. * @param y Second int in int3.
  40558. * @param z Third int in int3.
  40559. * @returns this effect.
  40560. */
  40561. setInt3(uniformName: string, x: number, y: number, z: number): Effect;
  40562. /**
  40563. * Sets an int4 value on a uniform variable.
  40564. * @param uniformName Name of the variable.
  40565. * @param x First int in int4.
  40566. * @param y Second int in int4.
  40567. * @param z Third int in int4.
  40568. * @param w Fourth int in int4.
  40569. * @returns this effect.
  40570. */
  40571. setInt4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  40572. /**
  40573. * Sets an int array on a uniform variable.
  40574. * @param uniformName Name of the variable.
  40575. * @param array array to be set.
  40576. * @returns this effect.
  40577. */
  40578. setIntArray(uniformName: string, array: Int32Array): Effect;
  40579. /**
  40580. * 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)
  40581. * @param uniformName Name of the variable.
  40582. * @param array array to be set.
  40583. * @returns this effect.
  40584. */
  40585. setIntArray2(uniformName: string, array: Int32Array): Effect;
  40586. /**
  40587. * 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)
  40588. * @param uniformName Name of the variable.
  40589. * @param array array to be set.
  40590. * @returns this effect.
  40591. */
  40592. setIntArray3(uniformName: string, array: Int32Array): Effect;
  40593. /**
  40594. * 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)
  40595. * @param uniformName Name of the variable.
  40596. * @param array array to be set.
  40597. * @returns this effect.
  40598. */
  40599. setIntArray4(uniformName: string, array: Int32Array): Effect;
  40600. /**
  40601. * Sets an float array on a uniform variable.
  40602. * @param uniformName Name of the variable.
  40603. * @param array array to be set.
  40604. * @returns this effect.
  40605. */
  40606. setFloatArray(uniformName: string, array: FloatArray): Effect;
  40607. /**
  40608. * 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)
  40609. * @param uniformName Name of the variable.
  40610. * @param array array to be set.
  40611. * @returns this effect.
  40612. */
  40613. setFloatArray2(uniformName: string, array: FloatArray): Effect;
  40614. /**
  40615. * 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)
  40616. * @param uniformName Name of the variable.
  40617. * @param array array to be set.
  40618. * @returns this effect.
  40619. */
  40620. setFloatArray3(uniformName: string, array: FloatArray): Effect;
  40621. /**
  40622. * 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)
  40623. * @param uniformName Name of the variable.
  40624. * @param array array to be set.
  40625. * @returns this effect.
  40626. */
  40627. setFloatArray4(uniformName: string, array: FloatArray): Effect;
  40628. /**
  40629. * Sets an array on a uniform variable.
  40630. * @param uniformName Name of the variable.
  40631. * @param array array to be set.
  40632. * @returns this effect.
  40633. */
  40634. setArray(uniformName: string, array: number[]): Effect;
  40635. /**
  40636. * 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)
  40637. * @param uniformName Name of the variable.
  40638. * @param array array to be set.
  40639. * @returns this effect.
  40640. */
  40641. setArray2(uniformName: string, array: number[]): Effect;
  40642. /**
  40643. * 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)
  40644. * @param uniformName Name of the variable.
  40645. * @param array array to be set.
  40646. * @returns this effect.
  40647. */
  40648. setArray3(uniformName: string, array: number[]): Effect;
  40649. /**
  40650. * 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)
  40651. * @param uniformName Name of the variable.
  40652. * @param array array to be set.
  40653. * @returns this effect.
  40654. */
  40655. setArray4(uniformName: string, array: number[]): Effect;
  40656. /**
  40657. * Sets matrices on a uniform variable.
  40658. * @param uniformName Name of the variable.
  40659. * @param matrices matrices to be set.
  40660. * @returns this effect.
  40661. */
  40662. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  40663. /**
  40664. * Sets matrix on a uniform variable.
  40665. * @param uniformName Name of the variable.
  40666. * @param matrix matrix to be set.
  40667. * @returns this effect.
  40668. */
  40669. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  40670. /**
  40671. * 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)
  40672. * @param uniformName Name of the variable.
  40673. * @param matrix matrix to be set.
  40674. * @returns this effect.
  40675. */
  40676. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  40677. /**
  40678. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  40679. * @param uniformName Name of the variable.
  40680. * @param matrix matrix to be set.
  40681. * @returns this effect.
  40682. */
  40683. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  40684. /**
  40685. * Sets a float on a uniform variable.
  40686. * @param uniformName Name of the variable.
  40687. * @param value value to be set.
  40688. * @returns this effect.
  40689. */
  40690. setFloat(uniformName: string, value: number): Effect;
  40691. /**
  40692. * Sets a boolean on a uniform variable.
  40693. * @param uniformName Name of the variable.
  40694. * @param bool value to be set.
  40695. * @returns this effect.
  40696. */
  40697. setBool(uniformName: string, bool: boolean): Effect;
  40698. /**
  40699. * Sets a Vector2 on a uniform variable.
  40700. * @param uniformName Name of the variable.
  40701. * @param vector2 vector2 to be set.
  40702. * @returns this effect.
  40703. */
  40704. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  40705. /**
  40706. * Sets a float2 on a uniform variable.
  40707. * @param uniformName Name of the variable.
  40708. * @param x First float in float2.
  40709. * @param y Second float in float2.
  40710. * @returns this effect.
  40711. */
  40712. setFloat2(uniformName: string, x: number, y: number): Effect;
  40713. /**
  40714. * Sets a Vector3 on a uniform variable.
  40715. * @param uniformName Name of the variable.
  40716. * @param vector3 Value to be set.
  40717. * @returns this effect.
  40718. */
  40719. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  40720. /**
  40721. * Sets a float3 on a uniform variable.
  40722. * @param uniformName Name of the variable.
  40723. * @param x First float in float3.
  40724. * @param y Second float in float3.
  40725. * @param z Third float in float3.
  40726. * @returns this effect.
  40727. */
  40728. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  40729. /**
  40730. * Sets a Vector4 on a uniform variable.
  40731. * @param uniformName Name of the variable.
  40732. * @param vector4 Value to be set.
  40733. * @returns this effect.
  40734. */
  40735. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  40736. /**
  40737. * Sets a float4 on a uniform variable.
  40738. * @param uniformName Name of the variable.
  40739. * @param x First float in float4.
  40740. * @param y Second float in float4.
  40741. * @param z Third float in float4.
  40742. * @param w Fourth float in float4.
  40743. * @returns this effect.
  40744. */
  40745. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  40746. /**
  40747. * Sets a Color3 on a uniform variable.
  40748. * @param uniformName Name of the variable.
  40749. * @param color3 Value to be set.
  40750. * @returns this effect.
  40751. */
  40752. setColor3(uniformName: string, color3: IColor3Like): Effect;
  40753. /**
  40754. * Sets a Color4 on a uniform variable.
  40755. * @param uniformName Name of the variable.
  40756. * @param color3 Value to be set.
  40757. * @param alpha Alpha value to be set.
  40758. * @returns this effect.
  40759. */
  40760. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  40761. /**
  40762. * Sets a Color4 on a uniform variable
  40763. * @param uniformName defines the name of the variable
  40764. * @param color4 defines the value to be set
  40765. * @returns this effect.
  40766. */
  40767. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  40768. /**
  40769. * Release all associated resources.
  40770. **/
  40771. dispose(): void;
  40772. /**
  40773. * This function will add a new shader to the shader store
  40774. * @param name the name of the shader
  40775. * @param pixelShader optional pixel shader content
  40776. * @param vertexShader optional vertex shader content
  40777. */
  40778. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  40779. /**
  40780. * Store of each shader (The can be looked up using effect.key)
  40781. */
  40782. static ShadersStore: {
  40783. [key: string]: string;
  40784. };
  40785. /**
  40786. * Store of each included file for a shader (The can be looked up using effect.key)
  40787. */
  40788. static IncludesShadersStore: {
  40789. [key: string]: string;
  40790. };
  40791. /**
  40792. * Resets the cache of effects.
  40793. */
  40794. static ResetCache(): void;
  40795. }
  40796. }
  40797. declare module "babylonjs/Engines/engineCapabilities" {
  40798. /**
  40799. * Interface used to describe the capabilities of the engine relatively to the current browser
  40800. */
  40801. export interface EngineCapabilities {
  40802. /** Maximum textures units per fragment shader */
  40803. maxTexturesImageUnits: number;
  40804. /** Maximum texture units per vertex shader */
  40805. maxVertexTextureImageUnits: number;
  40806. /** Maximum textures units in the entire pipeline */
  40807. maxCombinedTexturesImageUnits: number;
  40808. /** Maximum texture size */
  40809. maxTextureSize: number;
  40810. /** Maximum texture samples */
  40811. maxSamples?: number;
  40812. /** Maximum cube texture size */
  40813. maxCubemapTextureSize: number;
  40814. /** Maximum render texture size */
  40815. maxRenderTextureSize: number;
  40816. /** Maximum number of vertex attributes */
  40817. maxVertexAttribs: number;
  40818. /** Maximum number of varyings */
  40819. maxVaryingVectors: number;
  40820. /** Maximum number of uniforms per vertex shader */
  40821. maxVertexUniformVectors: number;
  40822. /** Maximum number of uniforms per fragment shader */
  40823. maxFragmentUniformVectors: number;
  40824. /** Defines if standard derivates (dx/dy) are supported */
  40825. standardDerivatives: boolean;
  40826. /** Defines if s3tc texture compression is supported */
  40827. s3tc?: WEBGL_compressed_texture_s3tc;
  40828. /** Defines if pvrtc texture compression is supported */
  40829. pvrtc: any;
  40830. /** Defines if etc1 texture compression is supported */
  40831. etc1: any;
  40832. /** Defines if etc2 texture compression is supported */
  40833. etc2: any;
  40834. /** Defines if astc texture compression is supported */
  40835. astc: any;
  40836. /** Defines if bptc texture compression is supported */
  40837. bptc: any;
  40838. /** Defines if float textures are supported */
  40839. textureFloat: boolean;
  40840. /** Defines if vertex array objects are supported */
  40841. vertexArrayObject: boolean;
  40842. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  40843. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  40844. /** Gets the maximum level of anisotropy supported */
  40845. maxAnisotropy: number;
  40846. /** Defines if instancing is supported */
  40847. instancedArrays: boolean;
  40848. /** Defines if 32 bits indices are supported */
  40849. uintIndices: boolean;
  40850. /** Defines if high precision shaders are supported */
  40851. highPrecisionShaderSupported: boolean;
  40852. /** Defines if depth reading in the fragment shader is supported */
  40853. fragmentDepthSupported: boolean;
  40854. /** Defines if float texture linear filtering is supported*/
  40855. textureFloatLinearFiltering: boolean;
  40856. /** Defines if rendering to float textures is supported */
  40857. textureFloatRender: boolean;
  40858. /** Defines if half float textures are supported*/
  40859. textureHalfFloat: boolean;
  40860. /** Defines if half float texture linear filtering is supported*/
  40861. textureHalfFloatLinearFiltering: boolean;
  40862. /** Defines if rendering to half float textures is supported */
  40863. textureHalfFloatRender: boolean;
  40864. /** Defines if textureLOD shader command is supported */
  40865. textureLOD: boolean;
  40866. /** Defines if draw buffers extension is supported */
  40867. drawBuffersExtension: boolean;
  40868. /** Defines if depth textures are supported */
  40869. depthTextureExtension: boolean;
  40870. /** Defines if float color buffer are supported */
  40871. colorBufferFloat: boolean;
  40872. /** Gets disjoint timer query extension (null if not supported) */
  40873. timerQuery?: EXT_disjoint_timer_query;
  40874. /** Defines if timestamp can be used with timer query */
  40875. canUseTimestampForTimerQuery: boolean;
  40876. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  40877. multiview?: any;
  40878. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  40879. oculusMultiview?: any;
  40880. /** Function used to let the system compiles shaders in background */
  40881. parallelShaderCompile?: {
  40882. COMPLETION_STATUS_KHR: number;
  40883. };
  40884. /** Max number of texture samples for MSAA */
  40885. maxMSAASamples: number;
  40886. /** Defines if the blend min max extension is supported */
  40887. blendMinMax: boolean;
  40888. /** 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 */
  40889. canUseGLInstanceID: boolean;
  40890. }
  40891. }
  40892. declare module "babylonjs/States/depthCullingState" {
  40893. import { Nullable } from "babylonjs/types";
  40894. /**
  40895. * @hidden
  40896. **/
  40897. export class DepthCullingState {
  40898. private _isDepthTestDirty;
  40899. private _isDepthMaskDirty;
  40900. private _isDepthFuncDirty;
  40901. private _isCullFaceDirty;
  40902. private _isCullDirty;
  40903. private _isZOffsetDirty;
  40904. private _isFrontFaceDirty;
  40905. private _depthTest;
  40906. private _depthMask;
  40907. private _depthFunc;
  40908. private _cull;
  40909. private _cullFace;
  40910. private _zOffset;
  40911. private _frontFace;
  40912. /**
  40913. * Initializes the state.
  40914. */
  40915. constructor();
  40916. get isDirty(): boolean;
  40917. get zOffset(): number;
  40918. set zOffset(value: number);
  40919. get cullFace(): Nullable<number>;
  40920. set cullFace(value: Nullable<number>);
  40921. get cull(): Nullable<boolean>;
  40922. set cull(value: Nullable<boolean>);
  40923. get depthFunc(): Nullable<number>;
  40924. set depthFunc(value: Nullable<number>);
  40925. get depthMask(): boolean;
  40926. set depthMask(value: boolean);
  40927. get depthTest(): boolean;
  40928. set depthTest(value: boolean);
  40929. get frontFace(): Nullable<number>;
  40930. set frontFace(value: Nullable<number>);
  40931. reset(): void;
  40932. apply(gl: WebGLRenderingContext): void;
  40933. }
  40934. }
  40935. declare module "babylonjs/States/stencilState" {
  40936. /**
  40937. * @hidden
  40938. **/
  40939. export class StencilState {
  40940. /** 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 */
  40941. static readonly ALWAYS: number;
  40942. /** Passed to stencilOperation to specify that stencil value must be kept */
  40943. static readonly KEEP: number;
  40944. /** Passed to stencilOperation to specify that stencil value must be replaced */
  40945. static readonly REPLACE: number;
  40946. private _isStencilTestDirty;
  40947. private _isStencilMaskDirty;
  40948. private _isStencilFuncDirty;
  40949. private _isStencilOpDirty;
  40950. private _stencilTest;
  40951. private _stencilMask;
  40952. private _stencilFunc;
  40953. private _stencilFuncRef;
  40954. private _stencilFuncMask;
  40955. private _stencilOpStencilFail;
  40956. private _stencilOpDepthFail;
  40957. private _stencilOpStencilDepthPass;
  40958. get isDirty(): boolean;
  40959. get stencilFunc(): number;
  40960. set stencilFunc(value: number);
  40961. get stencilFuncRef(): number;
  40962. set stencilFuncRef(value: number);
  40963. get stencilFuncMask(): number;
  40964. set stencilFuncMask(value: number);
  40965. get stencilOpStencilFail(): number;
  40966. set stencilOpStencilFail(value: number);
  40967. get stencilOpDepthFail(): number;
  40968. set stencilOpDepthFail(value: number);
  40969. get stencilOpStencilDepthPass(): number;
  40970. set stencilOpStencilDepthPass(value: number);
  40971. get stencilMask(): number;
  40972. set stencilMask(value: number);
  40973. get stencilTest(): boolean;
  40974. set stencilTest(value: boolean);
  40975. constructor();
  40976. reset(): void;
  40977. apply(gl: WebGLRenderingContext): void;
  40978. }
  40979. }
  40980. declare module "babylonjs/States/alphaCullingState" {
  40981. import { Nullable } from "babylonjs/types";
  40982. /**
  40983. * @hidden
  40984. **/
  40985. export class AlphaState {
  40986. _blendFunctionParameters: Nullable<number>[];
  40987. _blendEquationParameters: Nullable<number>[];
  40988. _blendConstants: Nullable<number>[];
  40989. _isBlendConstantsDirty: boolean;
  40990. private _alphaBlend;
  40991. private _isAlphaBlendDirty;
  40992. private _isBlendFunctionParametersDirty;
  40993. private _isBlendEquationParametersDirty;
  40994. /**
  40995. * Initializes the state.
  40996. */
  40997. constructor();
  40998. get isDirty(): boolean;
  40999. get alphaBlend(): boolean;
  41000. set alphaBlend(value: boolean);
  41001. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  41002. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  41003. setAlphaEquationParameters(rgb: number, alpha: number): void;
  41004. reset(): void;
  41005. apply(gl: WebGLRenderingContext): void;
  41006. }
  41007. }
  41008. declare module "babylonjs/Engines/WebGL/webGLShaderProcessors" {
  41009. import { Nullable } from "babylonjs/types";
  41010. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  41011. import { ShaderProcessingContext } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  41012. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  41013. /** @hidden */
  41014. export class WebGLShaderProcessor implements IShaderProcessor {
  41015. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  41016. }
  41017. }
  41018. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  41019. import { Nullable } from "babylonjs/types";
  41020. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  41021. import { ShaderProcessingContext } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  41022. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  41023. /** @hidden */
  41024. export class WebGL2ShaderProcessor implements IShaderProcessor {
  41025. attributeProcessor(attribute: string): string;
  41026. varyingProcessor(varying: string, isFragment: boolean): string;
  41027. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  41028. }
  41029. }
  41030. declare module "babylonjs/Engines/instancingAttributeInfo" {
  41031. /**
  41032. * Interface for attribute information associated with buffer instanciation
  41033. */
  41034. export interface InstancingAttributeInfo {
  41035. /**
  41036. * Name of the GLSL attribute
  41037. * if attribute index is not specified, this is used to retrieve the index from the effect
  41038. */
  41039. attributeName: string;
  41040. /**
  41041. * Index/offset of the attribute in the vertex shader
  41042. * if not specified, this will be computes from the name.
  41043. */
  41044. index?: number;
  41045. /**
  41046. * size of the attribute, 1, 2, 3 or 4
  41047. */
  41048. attributeSize: number;
  41049. /**
  41050. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  41051. */
  41052. offset: number;
  41053. /**
  41054. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  41055. * default to 1
  41056. */
  41057. divisor?: number;
  41058. /**
  41059. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  41060. * default is FLOAT
  41061. */
  41062. attributeType?: number;
  41063. /**
  41064. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  41065. */
  41066. normalized?: boolean;
  41067. }
  41068. }
  41069. declare module "babylonjs/Engines/engineFeatures" {
  41070. /** @hidden */
  41071. export interface EngineFeatures {
  41072. /** Force using Bitmap when Bitmap or HTMLImageElement can be used */
  41073. forceBitmapOverHTMLImageElement: boolean;
  41074. /** Indicates that the engine support rendering to as well as copying to lod float textures */
  41075. supportRenderAndCopyToLodForFloatTextures: boolean;
  41076. /** Indicates that the engine support handling depth/stencil textures */
  41077. supportDepthStencilTexture: boolean;
  41078. /** Indicates that the engine support shadow samplers */
  41079. supportShadowSamplers: boolean;
  41080. /** 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 */
  41081. uniformBufferHardCheckMatrix: boolean;
  41082. /** Indicates that prefiltered mipmaps can be generated in some processes (for eg when loading an HDR cube texture) */
  41083. allowTexturePrefiltering: boolean;
  41084. /** Indicates to track the usage of ubos and to create new ones as necessary during a frame duration */
  41085. trackUbosInFrame: boolean;
  41086. /** Indicates that the Cascaded Shadow Map technic is supported */
  41087. supportCSM: boolean;
  41088. /** Indicates that the textures transcoded by the basis transcoder must have power of 2 width and height */
  41089. basisNeedsPOT: boolean;
  41090. /** Indicates that the engine supports 3D textures */
  41091. support3DTextures: boolean;
  41092. /** Indicates that constants need a type suffix in shaders (used by realtime filtering...) */
  41093. needTypeSuffixInShaderConstants: boolean;
  41094. /** Indicates that MSAA is supported */
  41095. supportMSAA: boolean;
  41096. /** Indicates that SSAO2 is supported */
  41097. supportSSAO2: boolean;
  41098. /** Indicates that some additional texture formats are supported (like TEXTUREFORMAT_R for eg) */
  41099. supportExtendedTextureFormats: boolean;
  41100. /** Indicates that the switch/case construct is supported in shaders */
  41101. supportSwitchCaseInShader: boolean;
  41102. /** @hidden */
  41103. _collectUbosUpdatedInFrame: boolean;
  41104. }
  41105. }
  41106. declare module "babylonjs/Engines/WebGL/webGLHardwareTexture" {
  41107. import { HardwareTextureWrapper } from "babylonjs/Materials/Textures/hardwareTextureWrapper";
  41108. import { Nullable } from "babylonjs/types";
  41109. /** @hidden */
  41110. export class WebGLHardwareTexture implements HardwareTextureWrapper {
  41111. private _webGLTexture;
  41112. private _context;
  41113. get underlyingResource(): Nullable<WebGLTexture>;
  41114. constructor(existingTexture: WebGLTexture | null | undefined, context: WebGLRenderingContext);
  41115. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  41116. set(hardwareTexture: WebGLTexture): void;
  41117. reset(): void;
  41118. release(): void;
  41119. }
  41120. }
  41121. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  41122. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41123. import { Nullable } from "babylonjs/types";
  41124. module "babylonjs/Engines/thinEngine" {
  41125. interface ThinEngine {
  41126. /**
  41127. * Update a video texture
  41128. * @param texture defines the texture to update
  41129. * @param video defines the video element to use
  41130. * @param invertY defines if data must be stored with Y axis inverted
  41131. */
  41132. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  41133. }
  41134. }
  41135. }
  41136. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  41137. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41138. import { Nullable } from "babylonjs/types";
  41139. module "babylonjs/Engines/thinEngine" {
  41140. interface ThinEngine {
  41141. /**
  41142. * Creates a dynamic texture
  41143. * @param width defines the width of the texture
  41144. * @param height defines the height of the texture
  41145. * @param generateMipMaps defines if the engine should generate the mip levels
  41146. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  41147. * @returns the dynamic texture inside an InternalTexture
  41148. */
  41149. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  41150. /**
  41151. * Update the content of a dynamic texture
  41152. * @param texture defines the texture to update
  41153. * @param source defines the source containing the data
  41154. * @param invertY defines if data must be stored with Y axis inverted
  41155. * @param premulAlpha defines if alpha is stored as premultiplied
  41156. * @param format defines the format of the data
  41157. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  41158. */
  41159. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  41160. }
  41161. }
  41162. }
  41163. declare module "babylonjs/Materials/Textures/videoTexture" {
  41164. import { Observable } from "babylonjs/Misc/observable";
  41165. import { Nullable } from "babylonjs/types";
  41166. import { Scene } from "babylonjs/scene";
  41167. import { Texture } from "babylonjs/Materials/Textures/texture";
  41168. import "babylonjs/Engines/Extensions/engine.videoTexture";
  41169. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  41170. /**
  41171. * Settings for finer control over video usage
  41172. */
  41173. export interface VideoTextureSettings {
  41174. /**
  41175. * Applies `autoplay` to video, if specified
  41176. */
  41177. autoPlay?: boolean;
  41178. /**
  41179. * Applies `muted` to video, if specified
  41180. */
  41181. muted?: boolean;
  41182. /**
  41183. * Applies `loop` to video, if specified
  41184. */
  41185. loop?: boolean;
  41186. /**
  41187. * Automatically updates internal texture from video at every frame in the render loop
  41188. */
  41189. autoUpdateTexture: boolean;
  41190. /**
  41191. * Image src displayed during the video loading or until the user interacts with the video.
  41192. */
  41193. poster?: string;
  41194. }
  41195. /**
  41196. * If you want to display a video in your scene, this is the special texture for that.
  41197. * This special texture works similar to other textures, with the exception of a few parameters.
  41198. * @see https://doc.babylonjs.com/how_to/video_texture
  41199. */
  41200. export class VideoTexture extends Texture {
  41201. /**
  41202. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  41203. */
  41204. readonly autoUpdateTexture: boolean;
  41205. /**
  41206. * The video instance used by the texture internally
  41207. */
  41208. readonly video: HTMLVideoElement;
  41209. private _onUserActionRequestedObservable;
  41210. /**
  41211. * Event triggerd when a dom action is required by the user to play the video.
  41212. * This happens due to recent changes in browser policies preventing video to auto start.
  41213. */
  41214. get onUserActionRequestedObservable(): Observable<Texture>;
  41215. private _generateMipMaps;
  41216. private _stillImageCaptured;
  41217. private _displayingPosterTexture;
  41218. private _settings;
  41219. private _createInternalTextureOnEvent;
  41220. private _frameId;
  41221. private _currentSrc;
  41222. /**
  41223. * Creates a video texture.
  41224. * If you want to display a video in your scene, this is the special texture for that.
  41225. * This special texture works similar to other textures, with the exception of a few parameters.
  41226. * @see https://doc.babylonjs.com/how_to/video_texture
  41227. * @param name optional name, will detect from video source, if not defined
  41228. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  41229. * @param scene is obviously the current scene.
  41230. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  41231. * @param invertY is false by default but can be used to invert video on Y axis
  41232. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  41233. * @param settings allows finer control over video usage
  41234. */
  41235. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  41236. private _getName;
  41237. private _getVideo;
  41238. private _createInternalTexture;
  41239. private reset;
  41240. /**
  41241. * @hidden Internal method to initiate `update`.
  41242. */
  41243. _rebuild(): void;
  41244. /**
  41245. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  41246. */
  41247. update(): void;
  41248. /**
  41249. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  41250. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  41251. */
  41252. updateTexture(isVisible: boolean): void;
  41253. protected _updateInternalTexture: () => void;
  41254. /**
  41255. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  41256. * @param url New url.
  41257. */
  41258. updateURL(url: string): void;
  41259. /**
  41260. * Clones the texture.
  41261. * @returns the cloned texture
  41262. */
  41263. clone(): VideoTexture;
  41264. /**
  41265. * Dispose the texture and release its associated resources.
  41266. */
  41267. dispose(): void;
  41268. /**
  41269. * Creates a video texture straight from a stream.
  41270. * @param scene Define the scene the texture should be created in
  41271. * @param stream Define the stream the texture should be created from
  41272. * @returns The created video texture as a promise
  41273. */
  41274. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  41275. /**
  41276. * Creates a video texture straight from your WebCam video feed.
  41277. * @param scene Define the scene the texture should be created in
  41278. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  41279. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  41280. * @returns The created video texture as a promise
  41281. */
  41282. static CreateFromWebCamAsync(scene: Scene, constraints: {
  41283. minWidth: number;
  41284. maxWidth: number;
  41285. minHeight: number;
  41286. maxHeight: number;
  41287. deviceId: string;
  41288. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  41289. /**
  41290. * Creates a video texture straight from your WebCam video feed.
  41291. * @param scene Define the scene the texture should be created in
  41292. * @param onReady Define a callback to triggered once the texture will be ready
  41293. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  41294. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  41295. */
  41296. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  41297. minWidth: number;
  41298. maxWidth: number;
  41299. minHeight: number;
  41300. maxHeight: number;
  41301. deviceId: string;
  41302. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  41303. }
  41304. }
  41305. declare module "babylonjs/Engines/thinEngine" {
  41306. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  41307. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  41308. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  41309. import { ShaderProcessingContext } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  41310. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  41311. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  41312. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  41313. import { Observable } from "babylonjs/Misc/observable";
  41314. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  41315. import { StencilState } from "babylonjs/States/stencilState";
  41316. import { AlphaState } from "babylonjs/States/alphaCullingState";
  41317. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41318. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  41319. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  41320. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  41321. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  41322. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  41323. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  41324. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  41325. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  41326. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  41327. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  41328. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  41329. import { EngineFeatures } from "babylonjs/Engines/engineFeatures";
  41330. import { HardwareTextureWrapper } from "babylonjs/Materials/Textures/hardwareTextureWrapper";
  41331. import { WebRequest } from "babylonjs/Misc/webRequest";
  41332. import { LoadFileError } from "babylonjs/Misc/fileTools";
  41333. /**
  41334. * Defines the interface used by objects working like Scene
  41335. * @hidden
  41336. */
  41337. export interface ISceneLike {
  41338. _addPendingData(data: any): void;
  41339. _removePendingData(data: any): void;
  41340. offlineProvider: IOfflineProvider;
  41341. }
  41342. /**
  41343. * Information about the current host
  41344. */
  41345. export interface HostInformation {
  41346. /**
  41347. * Defines if the current host is a mobile
  41348. */
  41349. isMobile: boolean;
  41350. }
  41351. /** Interface defining initialization parameters for Engine class */
  41352. export interface EngineOptions extends WebGLContextAttributes {
  41353. /**
  41354. * Defines if the engine should no exceed a specified device ratio
  41355. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  41356. */
  41357. limitDeviceRatio?: number;
  41358. /**
  41359. * Defines if webvr should be enabled automatically
  41360. * @see https://doc.babylonjs.com/how_to/webvr_camera
  41361. */
  41362. autoEnableWebVR?: boolean;
  41363. /**
  41364. * Defines if webgl2 should be turned off even if supported
  41365. * @see https://doc.babylonjs.com/features/webgl2
  41366. */
  41367. disableWebGL2Support?: boolean;
  41368. /**
  41369. * Defines if webaudio should be initialized as well
  41370. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41371. */
  41372. audioEngine?: boolean;
  41373. /**
  41374. * Defines if animations should run using a deterministic lock step
  41375. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41376. */
  41377. deterministicLockstep?: boolean;
  41378. /** Defines the maximum steps to use with deterministic lock step mode */
  41379. lockstepMaxSteps?: number;
  41380. /** Defines the seconds between each deterministic lock step */
  41381. timeStep?: number;
  41382. /**
  41383. * Defines that engine should ignore context lost events
  41384. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  41385. */
  41386. doNotHandleContextLost?: boolean;
  41387. /**
  41388. * Defines that engine should ignore modifying touch action attribute and style
  41389. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  41390. */
  41391. doNotHandleTouchAction?: boolean;
  41392. /**
  41393. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  41394. */
  41395. useHighPrecisionFloats?: boolean;
  41396. /**
  41397. * Make the canvas XR Compatible for XR sessions
  41398. */
  41399. xrCompatible?: boolean;
  41400. /**
  41401. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  41402. */
  41403. useHighPrecisionMatrix?: boolean;
  41404. /**
  41405. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  41406. */
  41407. failIfMajorPerformanceCaveat?: boolean;
  41408. }
  41409. /**
  41410. * The base engine class (root of all engines)
  41411. */
  41412. export class ThinEngine {
  41413. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  41414. static ExceptionList: ({
  41415. key: string;
  41416. capture: string;
  41417. captureConstraint: number;
  41418. targets: string[];
  41419. } | {
  41420. key: string;
  41421. capture: null;
  41422. captureConstraint: null;
  41423. targets: string[];
  41424. })[];
  41425. /** @hidden */
  41426. static _TextureLoaders: IInternalTextureLoader[];
  41427. /**
  41428. * Returns the current npm package of the sdk
  41429. */
  41430. static get NpmPackage(): string;
  41431. /**
  41432. * Returns the current version of the framework
  41433. */
  41434. static get Version(): string;
  41435. /**
  41436. * Returns a string describing the current engine
  41437. */
  41438. get description(): string;
  41439. /**
  41440. * Returns the name of the engine
  41441. */
  41442. get name(): string;
  41443. /**
  41444. * Returns the version of the engine
  41445. */
  41446. get version(): number;
  41447. /**
  41448. * Gets or sets the epsilon value used by collision engine
  41449. */
  41450. static CollisionsEpsilon: number;
  41451. /**
  41452. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  41453. */
  41454. static get ShadersRepository(): string;
  41455. static set ShadersRepository(value: string);
  41456. /** @hidden */
  41457. _shaderProcessor: Nullable<IShaderProcessor>;
  41458. /**
  41459. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  41460. */
  41461. forcePOTTextures: boolean;
  41462. /**
  41463. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  41464. */
  41465. isFullscreen: boolean;
  41466. /**
  41467. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  41468. */
  41469. cullBackFaces: boolean;
  41470. /**
  41471. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  41472. */
  41473. renderEvenInBackground: boolean;
  41474. /**
  41475. * Gets or sets a boolean indicating that cache can be kept between frames
  41476. */
  41477. preventCacheWipeBetweenFrames: boolean;
  41478. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  41479. validateShaderPrograms: boolean;
  41480. /**
  41481. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  41482. * This can provide greater z depth for distant objects.
  41483. */
  41484. useReverseDepthBuffer: boolean;
  41485. /**
  41486. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  41487. */
  41488. disableUniformBuffers: boolean;
  41489. private _frameId;
  41490. /**
  41491. * Gets the current frame id
  41492. */
  41493. get frameId(): number;
  41494. /** @hidden */
  41495. _uniformBuffers: UniformBuffer[];
  41496. /**
  41497. * Gets a boolean indicating that the engine supports uniform buffers
  41498. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  41499. */
  41500. get supportsUniformBuffers(): boolean;
  41501. /** @hidden */
  41502. _gl: WebGLRenderingContext;
  41503. /** @hidden */
  41504. _webGLVersion: number;
  41505. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  41506. protected _windowIsBackground: boolean;
  41507. protected _creationOptions: EngineOptions;
  41508. protected _highPrecisionShadersAllowed: boolean;
  41509. /** @hidden */
  41510. get _shouldUseHighPrecisionShader(): boolean;
  41511. /**
  41512. * Gets a boolean indicating that only power of 2 textures are supported
  41513. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  41514. */
  41515. get needPOTTextures(): boolean;
  41516. /** @hidden */
  41517. _badOS: boolean;
  41518. /** @hidden */
  41519. _badDesktopOS: boolean;
  41520. protected _hardwareScalingLevel: number;
  41521. /** @hidden */
  41522. _caps: EngineCapabilities;
  41523. /** @hidden */
  41524. _features: EngineFeatures;
  41525. protected _isStencilEnable: boolean;
  41526. private _glVersion;
  41527. private _glRenderer;
  41528. private _glVendor;
  41529. /** @hidden */
  41530. _videoTextureSupported: boolean;
  41531. protected _renderingQueueLaunched: boolean;
  41532. protected _activeRenderLoops: (() => void)[];
  41533. /**
  41534. * Observable signaled when a context lost event is raised
  41535. */
  41536. onContextLostObservable: Observable<ThinEngine>;
  41537. /**
  41538. * Observable signaled when a context restored event is raised
  41539. */
  41540. onContextRestoredObservable: Observable<ThinEngine>;
  41541. private _onContextLost;
  41542. private _onContextRestored;
  41543. protected _contextWasLost: boolean;
  41544. /** @hidden */
  41545. _doNotHandleContextLost: boolean;
  41546. /**
  41547. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  41548. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  41549. */
  41550. get doNotHandleContextLost(): boolean;
  41551. set doNotHandleContextLost(value: boolean);
  41552. /**
  41553. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  41554. */
  41555. disableVertexArrayObjects: boolean;
  41556. /** @hidden */
  41557. protected _colorWrite: boolean;
  41558. /** @hidden */
  41559. protected _colorWriteChanged: boolean;
  41560. /** @hidden */
  41561. protected _depthCullingState: DepthCullingState;
  41562. /** @hidden */
  41563. protected _stencilState: StencilState;
  41564. /** @hidden */
  41565. _alphaState: AlphaState;
  41566. /** @hidden */
  41567. _alphaMode: number;
  41568. /** @hidden */
  41569. _alphaEquation: number;
  41570. /** @hidden */
  41571. _internalTexturesCache: InternalTexture[];
  41572. /** @hidden */
  41573. protected _activeChannel: number;
  41574. private _currentTextureChannel;
  41575. /** @hidden */
  41576. protected _boundTexturesCache: {
  41577. [key: string]: Nullable<InternalTexture>;
  41578. };
  41579. /** @hidden */
  41580. protected _currentEffect: Nullable<Effect>;
  41581. /** @hidden */
  41582. protected _currentProgram: Nullable<WebGLProgram>;
  41583. protected _compiledEffects: {
  41584. [key: string]: Effect;
  41585. };
  41586. private _vertexAttribArraysEnabled;
  41587. /** @hidden */
  41588. protected _cachedViewport: Nullable<IViewportLike>;
  41589. private _cachedVertexArrayObject;
  41590. /** @hidden */
  41591. protected _cachedVertexBuffers: any;
  41592. /** @hidden */
  41593. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  41594. /** @hidden */
  41595. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  41596. /** @hidden */
  41597. _currentRenderTarget: Nullable<InternalTexture>;
  41598. private _uintIndicesCurrentlySet;
  41599. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  41600. /** @hidden */
  41601. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  41602. /** @hidden */
  41603. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  41604. private _currentBufferPointers;
  41605. private _currentInstanceLocations;
  41606. private _currentInstanceBuffers;
  41607. private _textureUnits;
  41608. /** @hidden */
  41609. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  41610. /** @hidden */
  41611. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  41612. /** @hidden */
  41613. _boundRenderFunction: any;
  41614. private _vaoRecordInProgress;
  41615. private _mustWipeVertexAttributes;
  41616. private _emptyTexture;
  41617. private _emptyCubeTexture;
  41618. private _emptyTexture3D;
  41619. private _emptyTexture2DArray;
  41620. /** @hidden */
  41621. _frameHandler: number;
  41622. private _nextFreeTextureSlots;
  41623. private _maxSimultaneousTextures;
  41624. private _activeRequests;
  41625. /** @hidden */
  41626. _transformTextureUrl: Nullable<(url: string) => string>;
  41627. /**
  41628. * Gets information about the current host
  41629. */
  41630. hostInformation: HostInformation;
  41631. protected get _supportsHardwareTextureRescaling(): boolean;
  41632. private _framebufferDimensionsObject;
  41633. /**
  41634. * sets the object from which width and height will be taken from when getting render width and height
  41635. * Will fallback to the gl object
  41636. * @param dimensions the framebuffer width and height that will be used.
  41637. */
  41638. set framebufferDimensionsObject(dimensions: Nullable<{
  41639. framebufferWidth: number;
  41640. framebufferHeight: number;
  41641. }>);
  41642. /**
  41643. * Gets the current viewport
  41644. */
  41645. get currentViewport(): Nullable<IViewportLike>;
  41646. /**
  41647. * Gets the default empty texture
  41648. */
  41649. get emptyTexture(): InternalTexture;
  41650. /**
  41651. * Gets the default empty 3D texture
  41652. */
  41653. get emptyTexture3D(): InternalTexture;
  41654. /**
  41655. * Gets the default empty 2D array texture
  41656. */
  41657. get emptyTexture2DArray(): InternalTexture;
  41658. /**
  41659. * Gets the default empty cube texture
  41660. */
  41661. get emptyCubeTexture(): InternalTexture;
  41662. /**
  41663. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  41664. */
  41665. premultipliedAlpha: boolean;
  41666. /**
  41667. * Observable event triggered before each texture is initialized
  41668. */
  41669. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  41670. /** @hidden */
  41671. protected _isWebGPU: boolean;
  41672. /**
  41673. * Gets a boolean indicating if the engine runs in WebGPU or not.
  41674. */
  41675. get isWebGPU(): boolean;
  41676. /** @hidden */
  41677. protected _shaderPlatformName: string;
  41678. /**
  41679. * Gets the shader platfrom name used by the effects.
  41680. */
  41681. get shaderPlatformName(): string;
  41682. /**
  41683. * Creates a new engine
  41684. * @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
  41685. * @param antialias defines enable antialiasing (default: false)
  41686. * @param options defines further options to be sent to the getContext() function
  41687. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  41688. */
  41689. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  41690. /**
  41691. * @hidden
  41692. */
  41693. _debugPushGroup(groupName: string, targetObject?: number): void;
  41694. /**
  41695. * @hidden
  41696. */
  41697. _debugPopGroup(targetObject?: number): void;
  41698. /**
  41699. * @hidden
  41700. */
  41701. _debugInsertMarker(text: string, targetObject?: number): void;
  41702. /**
  41703. * Shared initialization across engines types.
  41704. * @param canvas The canvas associated with this instance of the engine.
  41705. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  41706. * @param audioEngine Defines if an audio engine should be created by default
  41707. */
  41708. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  41709. /**
  41710. * Gets a shader processor implementation fitting with the current engine type.
  41711. * @returns The shader processor implementation.
  41712. */
  41713. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  41714. /** @hidden */
  41715. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  41716. private _rebuildInternalTextures;
  41717. private _rebuildEffects;
  41718. /**
  41719. * Gets a boolean indicating if all created effects are ready
  41720. * @returns true if all effects are ready
  41721. */
  41722. areAllEffectsReady(): boolean;
  41723. protected _rebuildBuffers(): void;
  41724. protected _initGLContext(): void;
  41725. protected _initFeatures(): void;
  41726. /**
  41727. * Gets version of the current webGL context
  41728. * Keep it for back compat - use version instead
  41729. */
  41730. get webGLVersion(): number;
  41731. /**
  41732. * Gets a string identifying the name of the class
  41733. * @returns "Engine" string
  41734. */
  41735. getClassName(): string;
  41736. /**
  41737. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  41738. */
  41739. get isStencilEnable(): boolean;
  41740. /** @hidden */
  41741. _prepareWorkingCanvas(): void;
  41742. /**
  41743. * Reset the texture cache to empty state
  41744. */
  41745. resetTextureCache(): void;
  41746. /**
  41747. * Gets an object containing information about the current webGL context
  41748. * @returns an object containing the vender, the renderer and the version of the current webGL context
  41749. */
  41750. getGlInfo(): {
  41751. vendor: string;
  41752. renderer: string;
  41753. version: string;
  41754. };
  41755. /**
  41756. * Defines the hardware scaling level.
  41757. * By default the hardware scaling level is computed from the window device ratio.
  41758. * 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.
  41759. * @param level defines the level to use
  41760. */
  41761. setHardwareScalingLevel(level: number): void;
  41762. /**
  41763. * Gets the current hardware scaling level.
  41764. * By default the hardware scaling level is computed from the window device ratio.
  41765. * 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.
  41766. * @returns a number indicating the current hardware scaling level
  41767. */
  41768. getHardwareScalingLevel(): number;
  41769. /**
  41770. * Gets the list of loaded textures
  41771. * @returns an array containing all loaded textures
  41772. */
  41773. getLoadedTexturesCache(): InternalTexture[];
  41774. /**
  41775. * Gets the object containing all engine capabilities
  41776. * @returns the EngineCapabilities object
  41777. */
  41778. getCaps(): EngineCapabilities;
  41779. /**
  41780. * stop executing a render loop function and remove it from the execution array
  41781. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  41782. */
  41783. stopRenderLoop(renderFunction?: () => void): void;
  41784. /** @hidden */
  41785. _renderLoop(): void;
  41786. /**
  41787. * Gets the HTML canvas attached with the current webGL context
  41788. * @returns a HTML canvas
  41789. */
  41790. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  41791. /**
  41792. * Gets host window
  41793. * @returns the host window object
  41794. */
  41795. getHostWindow(): Nullable<Window>;
  41796. /**
  41797. * Gets the current render width
  41798. * @param useScreen defines if screen size must be used (or the current render target if any)
  41799. * @returns a number defining the current render width
  41800. */
  41801. getRenderWidth(useScreen?: boolean): number;
  41802. /**
  41803. * Gets the current render height
  41804. * @param useScreen defines if screen size must be used (or the current render target if any)
  41805. * @returns a number defining the current render height
  41806. */
  41807. getRenderHeight(useScreen?: boolean): number;
  41808. /**
  41809. * Can be used to override the current requestAnimationFrame requester.
  41810. * @hidden
  41811. */
  41812. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  41813. /**
  41814. * Register and execute a render loop. The engine can have more than one render function
  41815. * @param renderFunction defines the function to continuously execute
  41816. */
  41817. runRenderLoop(renderFunction: () => void): void;
  41818. /**
  41819. * Clear the current render buffer or the current render target (if any is set up)
  41820. * @param color defines the color to use
  41821. * @param backBuffer defines if the back buffer must be cleared
  41822. * @param depth defines if the depth buffer must be cleared
  41823. * @param stencil defines if the stencil buffer must be cleared
  41824. */
  41825. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41826. protected _viewportCached: {
  41827. x: number;
  41828. y: number;
  41829. z: number;
  41830. w: number;
  41831. };
  41832. /** @hidden */
  41833. _viewport(x: number, y: number, width: number, height: number): void;
  41834. /**
  41835. * Set the WebGL's viewport
  41836. * @param viewport defines the viewport element to be used
  41837. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  41838. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  41839. */
  41840. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  41841. /**
  41842. * Begin a new frame
  41843. */
  41844. beginFrame(): void;
  41845. /**
  41846. * Enf the current frame
  41847. */
  41848. endFrame(): void;
  41849. /**
  41850. * Resize the view according to the canvas' size
  41851. * @param forceSetSize true to force setting the sizes of the underlying canvas
  41852. */
  41853. resize(forceSetSize?: boolean): void;
  41854. /**
  41855. * Force a specific size of the canvas
  41856. * @param width defines the new canvas' width
  41857. * @param height defines the new canvas' height
  41858. * @param forceSetSize true to force setting the sizes of the underlying canvas
  41859. * @returns true if the size was changed
  41860. */
  41861. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  41862. /**
  41863. * Binds the frame buffer to the specified texture.
  41864. * @param texture The texture to render to or null for the default canvas
  41865. * @param faceIndex The face of the texture to render to in case of cube texture
  41866. * @param requiredWidth The width of the target to render to
  41867. * @param requiredHeight The height of the target to render to
  41868. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  41869. * @param lodLevel defines the lod level to bind to the frame buffer
  41870. * @param layer defines the 2d array index to bind to frame buffer to
  41871. */
  41872. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  41873. /** @hidden */
  41874. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  41875. /**
  41876. * Unbind the current render target texture from the webGL context
  41877. * @param texture defines the render target texture to unbind
  41878. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  41879. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  41880. */
  41881. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41882. /**
  41883. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  41884. */
  41885. flushFramebuffer(): void;
  41886. /**
  41887. * Unbind the current render target and bind the default framebuffer
  41888. */
  41889. restoreDefaultFramebuffer(): void;
  41890. /** @hidden */
  41891. protected _resetVertexBufferBinding(): void;
  41892. /**
  41893. * Creates a vertex buffer
  41894. * @param data the data for the vertex buffer
  41895. * @returns the new WebGL static buffer
  41896. */
  41897. createVertexBuffer(data: DataArray): DataBuffer;
  41898. private _createVertexBuffer;
  41899. /**
  41900. * Creates a dynamic vertex buffer
  41901. * @param data the data for the dynamic vertex buffer
  41902. * @returns the new WebGL dynamic buffer
  41903. */
  41904. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  41905. protected _resetIndexBufferBinding(): void;
  41906. /**
  41907. * Creates a new index buffer
  41908. * @param indices defines the content of the index buffer
  41909. * @param updatable defines if the index buffer must be updatable
  41910. * @returns a new webGL buffer
  41911. */
  41912. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  41913. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  41914. /**
  41915. * Bind a webGL buffer to the webGL context
  41916. * @param buffer defines the buffer to bind
  41917. */
  41918. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  41919. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  41920. private bindBuffer;
  41921. /**
  41922. * update the bound buffer with the given data
  41923. * @param data defines the data to update
  41924. */
  41925. updateArrayBuffer(data: Float32Array): void;
  41926. private _vertexAttribPointer;
  41927. /** @hidden */
  41928. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  41929. private _bindVertexBuffersAttributes;
  41930. /**
  41931. * Records a vertex array object
  41932. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  41933. * @param vertexBuffers defines the list of vertex buffers to store
  41934. * @param indexBuffer defines the index buffer to store
  41935. * @param effect defines the effect to store
  41936. * @returns the new vertex array object
  41937. */
  41938. recordVertexArrayObject(vertexBuffers: {
  41939. [key: string]: VertexBuffer;
  41940. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  41941. /**
  41942. * Bind a specific vertex array object
  41943. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  41944. * @param vertexArrayObject defines the vertex array object to bind
  41945. * @param indexBuffer defines the index buffer to bind
  41946. */
  41947. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  41948. /**
  41949. * Bind webGl buffers directly to the webGL context
  41950. * @param vertexBuffer defines the vertex buffer to bind
  41951. * @param indexBuffer defines the index buffer to bind
  41952. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  41953. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  41954. * @param effect defines the effect associated with the vertex buffer
  41955. */
  41956. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  41957. private _unbindVertexArrayObject;
  41958. /**
  41959. * Bind a list of vertex buffers to the webGL context
  41960. * @param vertexBuffers defines the list of vertex buffers to bind
  41961. * @param indexBuffer defines the index buffer to bind
  41962. * @param effect defines the effect associated with the vertex buffers
  41963. */
  41964. bindBuffers(vertexBuffers: {
  41965. [key: string]: Nullable<VertexBuffer>;
  41966. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  41967. /**
  41968. * Unbind all instance attributes
  41969. */
  41970. unbindInstanceAttributes(): void;
  41971. /**
  41972. * Release and free the memory of a vertex array object
  41973. * @param vao defines the vertex array object to delete
  41974. */
  41975. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  41976. /** @hidden */
  41977. _releaseBuffer(buffer: DataBuffer): boolean;
  41978. protected _deleteBuffer(buffer: DataBuffer): void;
  41979. /**
  41980. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  41981. * @param instancesBuffer defines the webGL buffer to update and bind
  41982. * @param data defines the data to store in the buffer
  41983. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  41984. */
  41985. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  41986. /**
  41987. * Bind the content of a webGL buffer used with instantiation
  41988. * @param instancesBuffer defines the webGL buffer to bind
  41989. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  41990. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  41991. */
  41992. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  41993. /**
  41994. * Disable the instance attribute corresponding to the name in parameter
  41995. * @param name defines the name of the attribute to disable
  41996. */
  41997. disableInstanceAttributeByName(name: string): void;
  41998. /**
  41999. * Disable the instance attribute corresponding to the location in parameter
  42000. * @param attributeLocation defines the attribute location of the attribute to disable
  42001. */
  42002. disableInstanceAttribute(attributeLocation: number): void;
  42003. /**
  42004. * Disable the attribute corresponding to the location in parameter
  42005. * @param attributeLocation defines the attribute location of the attribute to disable
  42006. */
  42007. disableAttributeByIndex(attributeLocation: number): void;
  42008. /**
  42009. * Send a draw order
  42010. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  42011. * @param indexStart defines the starting index
  42012. * @param indexCount defines the number of index to draw
  42013. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  42014. */
  42015. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42016. /**
  42017. * Draw a list of points
  42018. * @param verticesStart defines the index of first vertex to draw
  42019. * @param verticesCount defines the count of vertices to draw
  42020. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  42021. */
  42022. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42023. /**
  42024. * Draw a list of unindexed primitives
  42025. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  42026. * @param verticesStart defines the index of first vertex to draw
  42027. * @param verticesCount defines the count of vertices to draw
  42028. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  42029. */
  42030. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42031. /**
  42032. * Draw a list of indexed primitives
  42033. * @param fillMode defines the primitive to use
  42034. * @param indexStart defines the starting index
  42035. * @param indexCount defines the number of index to draw
  42036. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  42037. */
  42038. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42039. /**
  42040. * Draw a list of unindexed primitives
  42041. * @param fillMode defines the primitive to use
  42042. * @param verticesStart defines the index of first vertex to draw
  42043. * @param verticesCount defines the count of vertices to draw
  42044. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  42045. */
  42046. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42047. private _drawMode;
  42048. /** @hidden */
  42049. protected _reportDrawCall(): void;
  42050. /** @hidden */
  42051. _releaseEffect(effect: Effect): void;
  42052. /** @hidden */
  42053. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  42054. /**
  42055. * Create a new effect (used to store vertex/fragment shaders)
  42056. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  42057. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  42058. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  42059. * @param samplers defines an array of string used to represent textures
  42060. * @param defines defines the string containing the defines to use to compile the shaders
  42061. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  42062. * @param onCompiled defines a function to call when the effect creation is successful
  42063. * @param onError defines a function to call when the effect creation has failed
  42064. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  42065. * @returns the new Effect
  42066. */
  42067. 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;
  42068. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  42069. private _compileShader;
  42070. private _compileRawShader;
  42071. /** @hidden */
  42072. _getShaderSource(shader: WebGLShader): Nullable<string>;
  42073. /**
  42074. * Directly creates a webGL program
  42075. * @param pipelineContext defines the pipeline context to attach to
  42076. * @param vertexCode defines the vertex shader code to use
  42077. * @param fragmentCode defines the fragment shader code to use
  42078. * @param context defines the webGL context to use (if not set, the current one will be used)
  42079. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  42080. * @returns the new webGL program
  42081. */
  42082. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42083. /**
  42084. * Creates a webGL program
  42085. * @param pipelineContext defines the pipeline context to attach to
  42086. * @param vertexCode defines the vertex shader code to use
  42087. * @param fragmentCode defines the fragment shader code to use
  42088. * @param defines defines the string containing the defines to use to compile the shaders
  42089. * @param context defines the webGL context to use (if not set, the current one will be used)
  42090. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  42091. * @returns the new webGL program
  42092. */
  42093. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42094. /**
  42095. * Creates a new pipeline context
  42096. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  42097. * @returns the new pipeline
  42098. */
  42099. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  42100. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42101. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  42102. /** @hidden */
  42103. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  42104. /** @hidden */
  42105. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  42106. /** @hidden */
  42107. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  42108. /**
  42109. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  42110. * @param pipelineContext defines the pipeline context to use
  42111. * @param uniformsNames defines the list of uniform names
  42112. * @returns an array of webGL uniform locations
  42113. */
  42114. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  42115. /**
  42116. * Gets the list of active attributes for a given webGL program
  42117. * @param pipelineContext defines the pipeline context to use
  42118. * @param attributesNames defines the list of attribute names to get
  42119. * @returns an array of indices indicating the offset of each attribute
  42120. */
  42121. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  42122. /**
  42123. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  42124. * @param effect defines the effect to activate
  42125. */
  42126. enableEffect(effect: Nullable<Effect>): void;
  42127. /**
  42128. * Set the value of an uniform to a number (int)
  42129. * @param uniform defines the webGL uniform location where to store the value
  42130. * @param value defines the int number to store
  42131. * @returns true if the value was set
  42132. */
  42133. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  42134. /**
  42135. * Set the value of an uniform to a int2
  42136. * @param uniform defines the webGL uniform location where to store the value
  42137. * @param x defines the 1st component of the value
  42138. * @param y defines the 2nd component of the value
  42139. * @returns true if the value was set
  42140. */
  42141. setInt2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  42142. /**
  42143. * Set the value of an uniform to a int3
  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. * @returns true if the value was set
  42149. */
  42150. setInt3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  42151. /**
  42152. * Set the value of an uniform to a int4
  42153. * @param uniform defines the webGL uniform location where to store the value
  42154. * @param x defines the 1st component of the value
  42155. * @param y defines the 2nd component of the value
  42156. * @param z defines the 3rd component of the value
  42157. * @param w defines the 4th component of the value
  42158. * @returns true if the value was set
  42159. */
  42160. setInt4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  42161. /**
  42162. * Set the value of an uniform to an array of int32
  42163. * @param uniform defines the webGL uniform location where to store the value
  42164. * @param array defines the array of int32 to store
  42165. * @returns true if the value was set
  42166. */
  42167. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  42168. /**
  42169. * Set the value of an uniform to an array of int32 (stored as vec2)
  42170. * @param uniform defines the webGL uniform location where to store the value
  42171. * @param array defines the array of int32 to store
  42172. * @returns true if the value was set
  42173. */
  42174. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  42175. /**
  42176. * Set the value of an uniform to an array of int32 (stored as vec3)
  42177. * @param uniform defines the webGL uniform location where to store the value
  42178. * @param array defines the array of int32 to store
  42179. * @returns true if the value was set
  42180. */
  42181. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  42182. /**
  42183. * Set the value of an uniform to an array of int32 (stored as vec4)
  42184. * @param uniform defines the webGL uniform location where to store the value
  42185. * @param array defines the array of int32 to store
  42186. * @returns true if the value was set
  42187. */
  42188. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  42189. /**
  42190. * Set the value of an uniform to an array of number
  42191. * @param uniform defines the webGL uniform location where to store the value
  42192. * @param array defines the array of number to store
  42193. * @returns true if the value was set
  42194. */
  42195. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  42196. /**
  42197. * Set the value of an uniform to an array of number (stored as vec2)
  42198. * @param uniform defines the webGL uniform location where to store the value
  42199. * @param array defines the array of number to store
  42200. * @returns true if the value was set
  42201. */
  42202. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  42203. /**
  42204. * Set the value of an uniform to an array of number (stored as vec3)
  42205. * @param uniform defines the webGL uniform location where to store the value
  42206. * @param array defines the array of number to store
  42207. * @returns true if the value was set
  42208. */
  42209. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  42210. /**
  42211. * Set the value of an uniform to an array of number (stored as vec4)
  42212. * @param uniform defines the webGL uniform location where to store the value
  42213. * @param array defines the array of number to store
  42214. * @returns true if the value was set
  42215. */
  42216. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  42217. /**
  42218. * Set the value of an uniform to an array of float32 (stored as matrices)
  42219. * @param uniform defines the webGL uniform location where to store the value
  42220. * @param matrices defines the array of float32 to store
  42221. * @returns true if the value was set
  42222. */
  42223. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  42224. /**
  42225. * Set the value of an uniform to a matrix (3x3)
  42226. * @param uniform defines the webGL uniform location where to store the value
  42227. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  42228. * @returns true if the value was set
  42229. */
  42230. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  42231. /**
  42232. * Set the value of an uniform to a matrix (2x2)
  42233. * @param uniform defines the webGL uniform location where to store the value
  42234. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  42235. * @returns true if the value was set
  42236. */
  42237. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  42238. /**
  42239. * Set the value of an uniform to a number (float)
  42240. * @param uniform defines the webGL uniform location where to store the value
  42241. * @param value defines the float number to store
  42242. * @returns true if the value was transfered
  42243. */
  42244. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  42245. /**
  42246. * Set the value of an uniform to a vec2
  42247. * @param uniform defines the webGL uniform location where to store the value
  42248. * @param x defines the 1st component of the value
  42249. * @param y defines the 2nd component of the value
  42250. * @returns true if the value was set
  42251. */
  42252. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  42253. /**
  42254. * Set the value of an uniform to a vec3
  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. * @returns true if the value was set
  42260. */
  42261. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  42262. /**
  42263. * Set the value of an uniform to a vec4
  42264. * @param uniform defines the webGL uniform location where to store the value
  42265. * @param x defines the 1st component of the value
  42266. * @param y defines the 2nd component of the value
  42267. * @param z defines the 3rd component of the value
  42268. * @param w defines the 4th component of the value
  42269. * @returns true if the value was set
  42270. */
  42271. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  42272. /**
  42273. * Apply all cached states (depth, culling, stencil and alpha)
  42274. */
  42275. applyStates(): void;
  42276. /**
  42277. * Enable or disable color writing
  42278. * @param enable defines the state to set
  42279. */
  42280. setColorWrite(enable: boolean): void;
  42281. /**
  42282. * Gets a boolean indicating if color writing is enabled
  42283. * @returns the current color writing state
  42284. */
  42285. getColorWrite(): boolean;
  42286. /**
  42287. * Gets the depth culling state manager
  42288. */
  42289. get depthCullingState(): DepthCullingState;
  42290. /**
  42291. * Gets the alpha state manager
  42292. */
  42293. get alphaState(): AlphaState;
  42294. /**
  42295. * Gets the stencil state manager
  42296. */
  42297. get stencilState(): StencilState;
  42298. /**
  42299. * Clears the list of texture accessible through engine.
  42300. * This can help preventing texture load conflict due to name collision.
  42301. */
  42302. clearInternalTexturesCache(): void;
  42303. /**
  42304. * Force the entire cache to be cleared
  42305. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  42306. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  42307. */
  42308. wipeCaches(bruteForce?: boolean): void;
  42309. /** @hidden */
  42310. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  42311. min: number;
  42312. mag: number;
  42313. };
  42314. /** @hidden */
  42315. protected _createTexture(): WebGLTexture;
  42316. /** @hidden */
  42317. _createHardwareTexture(): HardwareTextureWrapper;
  42318. 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 | {
  42319. width: number;
  42320. height: number;
  42321. }, invertY: boolean, noMipmap: boolean, isCompressed: boolean, processFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  42322. width: number;
  42323. height: number;
  42324. }, extension: string, texture: InternalTexture, continuationCallback: () => void) => boolean, samplingMode: number) => void, prepareTextureProcessFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  42325. width: number;
  42326. height: number;
  42327. }, 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;
  42328. /**
  42329. * Usually called from Texture.ts.
  42330. * Passed information to create a WebGLTexture
  42331. * @param url defines a value which contains one of the following:
  42332. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  42333. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  42334. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  42335. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  42336. * @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)
  42337. * @param scene needed for loading to the correct scene
  42338. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  42339. * @param onLoad optional callback to be called upon successful completion
  42340. * @param onError optional callback to be called upon failure
  42341. * @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
  42342. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  42343. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  42344. * @param forcedExtension defines the extension to use to pick the right loader
  42345. * @param mimeType defines an optional mime type
  42346. * @param loaderOptions options to be passed to the loader
  42347. * @returns a InternalTexture for assignment back into BABYLON.Texture
  42348. */
  42349. 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;
  42350. /**
  42351. * Loads an image as an HTMLImageElement.
  42352. * @param input url string, ArrayBuffer, or Blob to load
  42353. * @param onLoad callback called when the image successfully loads
  42354. * @param onError callback called when the image fails to load
  42355. * @param offlineProvider offline provider for caching
  42356. * @param mimeType optional mime type
  42357. * @returns the HTMLImageElement of the loaded image
  42358. * @hidden
  42359. */
  42360. 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>;
  42361. /**
  42362. * @hidden
  42363. */
  42364. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  42365. private _unpackFlipYCached;
  42366. /**
  42367. * In case you are sharing the context with other applications, it might
  42368. * be interested to not cache the unpack flip y state to ensure a consistent
  42369. * value would be set.
  42370. */
  42371. enableUnpackFlipYCached: boolean;
  42372. /** @hidden */
  42373. _unpackFlipY(value: boolean): void;
  42374. /** @hidden */
  42375. _getUnpackAlignement(): number;
  42376. private _getTextureTarget;
  42377. /**
  42378. * Update the sampling mode of a given texture
  42379. * @param samplingMode defines the required sampling mode
  42380. * @param texture defines the texture to update
  42381. * @param generateMipMaps defines whether to generate mipmaps for the texture
  42382. */
  42383. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  42384. /**
  42385. * Update the dimensions of a texture
  42386. * @param texture texture to update
  42387. * @param width new width of the texture
  42388. * @param height new height of the texture
  42389. * @param depth new depth of the texture
  42390. */
  42391. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  42392. /**
  42393. * Update the sampling mode of a given texture
  42394. * @param texture defines the texture to update
  42395. * @param wrapU defines the texture wrap mode of the u coordinates
  42396. * @param wrapV defines the texture wrap mode of the v coordinates
  42397. * @param wrapR defines the texture wrap mode of the r coordinates
  42398. */
  42399. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  42400. /** @hidden */
  42401. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  42402. width: number;
  42403. height: number;
  42404. layers?: number;
  42405. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  42406. /** @hidden */
  42407. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42408. /** @hidden */
  42409. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  42410. /**
  42411. * Update a portion of an internal texture
  42412. * @param texture defines the texture to update
  42413. * @param imageData defines the data to store into the texture
  42414. * @param xOffset defines the x coordinates of the update rectangle
  42415. * @param yOffset defines the y coordinates of the update rectangle
  42416. * @param width defines the width of the update rectangle
  42417. * @param height defines the height of the update rectangle
  42418. * @param faceIndex defines the face index if texture is a cube (0 by default)
  42419. * @param lod defines the lod level to update (0 by default)
  42420. */
  42421. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  42422. /** @hidden */
  42423. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42424. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  42425. private _prepareWebGLTexture;
  42426. /** @hidden */
  42427. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  42428. private _getDepthStencilBuffer;
  42429. /** @hidden */
  42430. _releaseFramebufferObjects(texture: InternalTexture): void;
  42431. /** @hidden */
  42432. _releaseTexture(texture: InternalTexture): void;
  42433. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  42434. protected _setProgram(program: WebGLProgram): void;
  42435. protected _boundUniforms: {
  42436. [key: number]: WebGLUniformLocation;
  42437. };
  42438. /**
  42439. * Binds an effect to the webGL context
  42440. * @param effect defines the effect to bind
  42441. */
  42442. bindSamplers(effect: Effect): void;
  42443. private _activateCurrentTexture;
  42444. /** @hidden */
  42445. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  42446. /** @hidden */
  42447. _bindTexture(channel: number, texture: Nullable<InternalTexture>, name: string): void;
  42448. /**
  42449. * Unbind all textures from the webGL context
  42450. */
  42451. unbindAllTextures(): void;
  42452. /**
  42453. * Sets a texture to the according uniform.
  42454. * @param channel The texture channel
  42455. * @param uniform The uniform to set
  42456. * @param texture The texture to apply
  42457. * @param name The name of the uniform in the effect
  42458. */
  42459. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>, name: string): void;
  42460. private _bindSamplerUniformToChannel;
  42461. private _getTextureWrapMode;
  42462. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string): boolean;
  42463. /**
  42464. * Sets an array of texture to the webGL context
  42465. * @param channel defines the channel where the texture array must be set
  42466. * @param uniform defines the associated uniform location
  42467. * @param textures defines the array of textures to bind
  42468. * @param name name of the channel
  42469. */
  42470. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[], name: string): void;
  42471. /** @hidden */
  42472. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  42473. private _setTextureParameterFloat;
  42474. private _setTextureParameterInteger;
  42475. /**
  42476. * Unbind all vertex attributes from the webGL context
  42477. */
  42478. unbindAllAttributes(): void;
  42479. /**
  42480. * 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
  42481. */
  42482. releaseEffects(): void;
  42483. /**
  42484. * Dispose and release all associated resources
  42485. */
  42486. dispose(): void;
  42487. /**
  42488. * Attach a new callback raised when context lost event is fired
  42489. * @param callback defines the callback to call
  42490. */
  42491. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  42492. /**
  42493. * Attach a new callback raised when context restored event is fired
  42494. * @param callback defines the callback to call
  42495. */
  42496. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  42497. /**
  42498. * Get the current error code of the webGL context
  42499. * @returns the error code
  42500. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42501. */
  42502. getError(): number;
  42503. private _canRenderToFloatFramebuffer;
  42504. private _canRenderToHalfFloatFramebuffer;
  42505. private _canRenderToFramebuffer;
  42506. /** @hidden */
  42507. _getWebGLTextureType(type: number): number;
  42508. /** @hidden */
  42509. _getInternalFormat(format: number): number;
  42510. /** @hidden */
  42511. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  42512. /** @hidden */
  42513. _getRGBAMultiSampleBufferFormat(type: number): number;
  42514. /** @hidden */
  42515. _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;
  42516. /**
  42517. * Loads a file from a url
  42518. * @param url url to load
  42519. * @param onSuccess callback called when the file successfully loads
  42520. * @param onProgress callback called while file is loading (if the server supports this mode)
  42521. * @param offlineProvider defines the offline provider for caching
  42522. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42523. * @param onError callback called when the file fails to load
  42524. * @returns a file request object
  42525. * @hidden
  42526. */
  42527. 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;
  42528. /**
  42529. * Reads pixels from the current frame buffer. Please note that this function can be slow
  42530. * @param x defines the x coordinate of the rectangle where pixels must be read
  42531. * @param y defines the y coordinate of the rectangle where pixels must be read
  42532. * @param width defines the width of the rectangle where pixels must be read
  42533. * @param height defines the height of the rectangle where pixels must be read
  42534. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  42535. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  42536. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  42537. */
  42538. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  42539. private static _IsSupported;
  42540. private static _HasMajorPerformanceCaveat;
  42541. /**
  42542. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  42543. */
  42544. static get IsSupported(): boolean;
  42545. /**
  42546. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  42547. * @returns true if the engine can be created
  42548. * @ignorenaming
  42549. */
  42550. static isSupported(): boolean;
  42551. /**
  42552. * 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)
  42553. */
  42554. static get HasMajorPerformanceCaveat(): boolean;
  42555. /**
  42556. * Find the next highest power of two.
  42557. * @param x Number to start search from.
  42558. * @return Next highest power of two.
  42559. */
  42560. static CeilingPOT(x: number): number;
  42561. /**
  42562. * Find the next lowest power of two.
  42563. * @param x Number to start search from.
  42564. * @return Next lowest power of two.
  42565. */
  42566. static FloorPOT(x: number): number;
  42567. /**
  42568. * Find the nearest power of two.
  42569. * @param x Number to start search from.
  42570. * @return Next nearest power of two.
  42571. */
  42572. static NearestPOT(x: number): number;
  42573. /**
  42574. * Get the closest exponent of two
  42575. * @param value defines the value to approximate
  42576. * @param max defines the maximum value to return
  42577. * @param mode defines how to define the closest value
  42578. * @returns closest exponent of two of the given value
  42579. */
  42580. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  42581. /**
  42582. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  42583. * @param func - the function to be called
  42584. * @param requester - the object that will request the next frame. Falls back to window.
  42585. * @returns frame number
  42586. */
  42587. static QueueNewFrame(func: () => void, requester?: any): number;
  42588. /**
  42589. * Gets host document
  42590. * @returns the host document object
  42591. */
  42592. getHostDocument(): Nullable<Document>;
  42593. }
  42594. }
  42595. declare module "babylonjs/Materials/Textures/internalTexture" {
  42596. import { Observable } from "babylonjs/Misc/observable";
  42597. import { Nullable, int } from "babylonjs/types";
  42598. import { HardwareTextureWrapper } from "babylonjs/Materials/Textures/hardwareTextureWrapper";
  42599. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  42600. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42601. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  42602. /**
  42603. * Defines the source of the internal texture
  42604. */
  42605. export enum InternalTextureSource {
  42606. /**
  42607. * The source of the texture data is unknown
  42608. */
  42609. Unknown = 0,
  42610. /**
  42611. * Texture data comes from an URL
  42612. */
  42613. Url = 1,
  42614. /**
  42615. * Texture data is only used for temporary storage
  42616. */
  42617. Temp = 2,
  42618. /**
  42619. * Texture data comes from raw data (ArrayBuffer)
  42620. */
  42621. Raw = 3,
  42622. /**
  42623. * Texture content is dynamic (video or dynamic texture)
  42624. */
  42625. Dynamic = 4,
  42626. /**
  42627. * Texture content is generated by rendering to it
  42628. */
  42629. RenderTarget = 5,
  42630. /**
  42631. * Texture content is part of a multi render target process
  42632. */
  42633. MultiRenderTarget = 6,
  42634. /**
  42635. * Texture data comes from a cube data file
  42636. */
  42637. Cube = 7,
  42638. /**
  42639. * Texture data comes from a raw cube data
  42640. */
  42641. CubeRaw = 8,
  42642. /**
  42643. * Texture data come from a prefiltered cube data file
  42644. */
  42645. CubePrefiltered = 9,
  42646. /**
  42647. * Texture content is raw 3D data
  42648. */
  42649. Raw3D = 10,
  42650. /**
  42651. * Texture content is raw 2D array data
  42652. */
  42653. Raw2DArray = 11,
  42654. /**
  42655. * Texture content is a depth texture
  42656. */
  42657. Depth = 12,
  42658. /**
  42659. * Texture data comes from a raw cube data encoded with RGBD
  42660. */
  42661. CubeRawRGBD = 13
  42662. }
  42663. /**
  42664. * Class used to store data associated with WebGL texture data for the engine
  42665. * This class should not be used directly
  42666. */
  42667. export class InternalTexture {
  42668. /** @hidden */
  42669. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  42670. /**
  42671. * Defines if the texture is ready
  42672. */
  42673. isReady: boolean;
  42674. /**
  42675. * Defines if the texture is a cube texture
  42676. */
  42677. isCube: boolean;
  42678. /**
  42679. * Defines if the texture contains 3D data
  42680. */
  42681. is3D: boolean;
  42682. /**
  42683. * Defines if the texture contains 2D array data
  42684. */
  42685. is2DArray: boolean;
  42686. /**
  42687. * Defines if the texture contains multiview data
  42688. */
  42689. isMultiview: boolean;
  42690. /**
  42691. * Gets the URL used to load this texture
  42692. */
  42693. url: string;
  42694. /** @hidden */
  42695. _originalUrl: string;
  42696. /**
  42697. * Gets the sampling mode of the texture
  42698. */
  42699. samplingMode: number;
  42700. /**
  42701. * Gets a boolean indicating if the texture needs mipmaps generation
  42702. */
  42703. generateMipMaps: boolean;
  42704. /**
  42705. * Gets the number of samples used by the texture (WebGL2+ only)
  42706. */
  42707. samples: number;
  42708. /**
  42709. * Gets the type of the texture (int, float...)
  42710. */
  42711. type: number;
  42712. /**
  42713. * Gets the format of the texture (RGB, RGBA...)
  42714. */
  42715. format: number;
  42716. /**
  42717. * Observable called when the texture is loaded
  42718. */
  42719. onLoadedObservable: Observable<InternalTexture>;
  42720. /**
  42721. * Gets the width of the texture
  42722. */
  42723. width: number;
  42724. /**
  42725. * Gets the height of the texture
  42726. */
  42727. height: number;
  42728. /**
  42729. * Gets the depth of the texture
  42730. */
  42731. depth: number;
  42732. /**
  42733. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  42734. */
  42735. baseWidth: number;
  42736. /**
  42737. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  42738. */
  42739. baseHeight: number;
  42740. /**
  42741. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  42742. */
  42743. baseDepth: number;
  42744. /**
  42745. * Gets a boolean indicating if the texture is inverted on Y axis
  42746. */
  42747. invertY: boolean;
  42748. /** @hidden */
  42749. _invertVScale: boolean;
  42750. /** @hidden */
  42751. _associatedChannel: number;
  42752. /** @hidden */
  42753. _source: InternalTextureSource;
  42754. /** @hidden */
  42755. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  42756. /** @hidden */
  42757. _bufferView: Nullable<ArrayBufferView>;
  42758. /** @hidden */
  42759. _bufferViewArray: Nullable<ArrayBufferView[]>;
  42760. /** @hidden */
  42761. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  42762. /** @hidden */
  42763. _size: number;
  42764. /** @hidden */
  42765. _extension: string;
  42766. /** @hidden */
  42767. _files: Nullable<string[]>;
  42768. /** @hidden */
  42769. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  42770. /** @hidden */
  42771. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  42772. /** @hidden */
  42773. _framebuffer: Nullable<WebGLFramebuffer>;
  42774. /** @hidden */
  42775. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  42776. /** @hidden */
  42777. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  42778. /** @hidden */
  42779. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  42780. /** @hidden */
  42781. _attachments: Nullable<number[]>;
  42782. /** @hidden */
  42783. _textureArray: Nullable<InternalTexture[]>;
  42784. /** @hidden */
  42785. _cachedCoordinatesMode: Nullable<number>;
  42786. /** @hidden */
  42787. _cachedWrapU: Nullable<number>;
  42788. /** @hidden */
  42789. _cachedWrapV: Nullable<number>;
  42790. /** @hidden */
  42791. _cachedWrapR: Nullable<number>;
  42792. /** @hidden */
  42793. _cachedAnisotropicFilteringLevel: Nullable<number>;
  42794. /** @hidden */
  42795. _isDisabled: boolean;
  42796. /** @hidden */
  42797. _compression: Nullable<string>;
  42798. /** @hidden */
  42799. _generateStencilBuffer: boolean;
  42800. /** @hidden */
  42801. _generateDepthBuffer: boolean;
  42802. /** @hidden */
  42803. _comparisonFunction: number;
  42804. /** @hidden */
  42805. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  42806. /** @hidden */
  42807. _sphericalPolynomialPromise: Nullable<Promise<SphericalPolynomial>>;
  42808. /** @hidden */
  42809. _sphericalPolynomialComputed: boolean;
  42810. /** @hidden */
  42811. _lodGenerationScale: number;
  42812. /** @hidden */
  42813. _lodGenerationOffset: number;
  42814. /** @hidden */
  42815. _depthStencilTexture: Nullable<InternalTexture>;
  42816. /** @hidden */
  42817. _colorTextureArray: Nullable<WebGLTexture>;
  42818. /** @hidden */
  42819. _depthStencilTextureArray: Nullable<WebGLTexture>;
  42820. /** @hidden */
  42821. _lodTextureHigh: Nullable<BaseTexture>;
  42822. /** @hidden */
  42823. _lodTextureMid: Nullable<BaseTexture>;
  42824. /** @hidden */
  42825. _lodTextureLow: Nullable<BaseTexture>;
  42826. /** @hidden */
  42827. _isRGBD: boolean;
  42828. /** @hidden */
  42829. _linearSpecularLOD: boolean;
  42830. /** @hidden */
  42831. _irradianceTexture: Nullable<BaseTexture>;
  42832. /** @hidden */
  42833. _hardwareTexture: Nullable<HardwareTextureWrapper>;
  42834. /** @hidden */
  42835. _references: number;
  42836. /** @hidden */
  42837. _gammaSpace: Nullable<boolean>;
  42838. private _engine;
  42839. private _uniqueId;
  42840. private static _Counter;
  42841. /** Gets the unique id of the internal texture */
  42842. get uniqueId(): number;
  42843. /**
  42844. * Gets the Engine the texture belongs to.
  42845. * @returns The babylon engine
  42846. */
  42847. getEngine(): ThinEngine;
  42848. /**
  42849. * Gets the data source type of the texture
  42850. */
  42851. get source(): InternalTextureSource;
  42852. /**
  42853. * Creates a new InternalTexture
  42854. * @param engine defines the engine to use
  42855. * @param source defines the type of data that will be used
  42856. * @param delayAllocation if the texture allocation should be delayed (default: false)
  42857. */
  42858. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  42859. /**
  42860. * Increments the number of references (ie. the number of Texture that point to it)
  42861. */
  42862. incrementReferences(): void;
  42863. /**
  42864. * Change the size of the texture (not the size of the content)
  42865. * @param width defines the new width
  42866. * @param height defines the new height
  42867. * @param depth defines the new depth (1 by default)
  42868. */
  42869. updateSize(width: int, height: int, depth?: int): void;
  42870. /** @hidden */
  42871. _rebuild(): void;
  42872. /** @hidden */
  42873. _swapAndDie(target: InternalTexture): void;
  42874. /**
  42875. * Dispose the current allocated resources
  42876. */
  42877. dispose(): void;
  42878. }
  42879. }
  42880. declare module "babylonjs/Loading/loadingScreen" {
  42881. /**
  42882. * Interface used to present a loading screen while loading a scene
  42883. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42884. */
  42885. export interface ILoadingScreen {
  42886. /**
  42887. * Function called to display the loading screen
  42888. */
  42889. displayLoadingUI: () => void;
  42890. /**
  42891. * Function called to hide the loading screen
  42892. */
  42893. hideLoadingUI: () => void;
  42894. /**
  42895. * Gets or sets the color to use for the background
  42896. */
  42897. loadingUIBackgroundColor: string;
  42898. /**
  42899. * Gets or sets the text to display while loading
  42900. */
  42901. loadingUIText: string;
  42902. }
  42903. /**
  42904. * Class used for the default loading screen
  42905. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42906. */
  42907. export class DefaultLoadingScreen implements ILoadingScreen {
  42908. private _renderingCanvas;
  42909. private _loadingText;
  42910. private _loadingDivBackgroundColor;
  42911. private _loadingDiv;
  42912. private _loadingTextDiv;
  42913. /** Gets or sets the logo url to use for the default loading screen */
  42914. static DefaultLogoUrl: string;
  42915. /** Gets or sets the spinner url to use for the default loading screen */
  42916. static DefaultSpinnerUrl: string;
  42917. /**
  42918. * Creates a new default loading screen
  42919. * @param _renderingCanvas defines the canvas used to render the scene
  42920. * @param _loadingText defines the default text to display
  42921. * @param _loadingDivBackgroundColor defines the default background color
  42922. */
  42923. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  42924. /**
  42925. * Function called to display the loading screen
  42926. */
  42927. displayLoadingUI(): void;
  42928. /**
  42929. * Function called to hide the loading screen
  42930. */
  42931. hideLoadingUI(): void;
  42932. /**
  42933. * Gets or sets the text to display while loading
  42934. */
  42935. set loadingUIText(text: string);
  42936. get loadingUIText(): string;
  42937. /**
  42938. * Gets or sets the color to use for the background
  42939. */
  42940. get loadingUIBackgroundColor(): string;
  42941. set loadingUIBackgroundColor(color: string);
  42942. private _resizeLoadingUI;
  42943. }
  42944. }
  42945. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  42946. /**
  42947. * Interface for any object that can request an animation frame
  42948. */
  42949. export interface ICustomAnimationFrameRequester {
  42950. /**
  42951. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  42952. */
  42953. renderFunction?: Function;
  42954. /**
  42955. * Called to request the next frame to render to
  42956. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  42957. */
  42958. requestAnimationFrame: Function;
  42959. /**
  42960. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  42961. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  42962. */
  42963. requestID?: number;
  42964. }
  42965. }
  42966. declare module "babylonjs/Misc/performanceMonitor" {
  42967. /**
  42968. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  42969. */
  42970. export class PerformanceMonitor {
  42971. private _enabled;
  42972. private _rollingFrameTime;
  42973. private _lastFrameTimeMs;
  42974. /**
  42975. * constructor
  42976. * @param frameSampleSize The number of samples required to saturate the sliding window
  42977. */
  42978. constructor(frameSampleSize?: number);
  42979. /**
  42980. * Samples current frame
  42981. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  42982. */
  42983. sampleFrame(timeMs?: number): void;
  42984. /**
  42985. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  42986. */
  42987. get averageFrameTime(): number;
  42988. /**
  42989. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  42990. */
  42991. get averageFrameTimeVariance(): number;
  42992. /**
  42993. * Returns the frame time of the most recent frame
  42994. */
  42995. get instantaneousFrameTime(): number;
  42996. /**
  42997. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  42998. */
  42999. get averageFPS(): number;
  43000. /**
  43001. * Returns the average framerate in frames per second using the most recent frame time
  43002. */
  43003. get instantaneousFPS(): number;
  43004. /**
  43005. * Returns true if enough samples have been taken to completely fill the sliding window
  43006. */
  43007. get isSaturated(): boolean;
  43008. /**
  43009. * Enables contributions to the sliding window sample set
  43010. */
  43011. enable(): void;
  43012. /**
  43013. * Disables contributions to the sliding window sample set
  43014. * Samples will not be interpolated over the disabled period
  43015. */
  43016. disable(): void;
  43017. /**
  43018. * Returns true if sampling is enabled
  43019. */
  43020. get isEnabled(): boolean;
  43021. /**
  43022. * Resets performance monitor
  43023. */
  43024. reset(): void;
  43025. }
  43026. /**
  43027. * RollingAverage
  43028. *
  43029. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  43030. */
  43031. export class RollingAverage {
  43032. /**
  43033. * Current average
  43034. */
  43035. average: number;
  43036. /**
  43037. * Current variance
  43038. */
  43039. variance: number;
  43040. protected _samples: Array<number>;
  43041. protected _sampleCount: number;
  43042. protected _pos: number;
  43043. protected _m2: number;
  43044. /**
  43045. * constructor
  43046. * @param length The number of samples required to saturate the sliding window
  43047. */
  43048. constructor(length: number);
  43049. /**
  43050. * Adds a sample to the sample set
  43051. * @param v The sample value
  43052. */
  43053. add(v: number): void;
  43054. /**
  43055. * Returns previously added values or null if outside of history or outside the sliding window domain
  43056. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  43057. * @return Value previously recorded with add() or null if outside of range
  43058. */
  43059. history(i: number): number;
  43060. /**
  43061. * Returns true if enough samples have been taken to completely fill the sliding window
  43062. * @return true if sample-set saturated
  43063. */
  43064. isSaturated(): boolean;
  43065. /**
  43066. * Resets the rolling average (equivalent to 0 samples taken so far)
  43067. */
  43068. reset(): void;
  43069. /**
  43070. * Wraps a value around the sample range boundaries
  43071. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  43072. * @return Wrapped position in sample range
  43073. */
  43074. protected _wrapPosition(i: number): number;
  43075. }
  43076. }
  43077. declare module "babylonjs/Misc/perfCounter" {
  43078. /**
  43079. * This class is used to track a performance counter which is number based.
  43080. * The user has access to many properties which give statistics of different nature.
  43081. *
  43082. * The implementer can track two kinds of Performance Counter: time and count.
  43083. * 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.
  43084. * 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.
  43085. */
  43086. export class PerfCounter {
  43087. /**
  43088. * Gets or sets a global boolean to turn on and off all the counters
  43089. */
  43090. static Enabled: boolean;
  43091. /**
  43092. * Returns the smallest value ever
  43093. */
  43094. get min(): number;
  43095. /**
  43096. * Returns the biggest value ever
  43097. */
  43098. get max(): number;
  43099. /**
  43100. * Returns the average value since the performance counter is running
  43101. */
  43102. get average(): number;
  43103. /**
  43104. * Returns the average value of the last second the counter was monitored
  43105. */
  43106. get lastSecAverage(): number;
  43107. /**
  43108. * Returns the current value
  43109. */
  43110. get current(): number;
  43111. /**
  43112. * Gets the accumulated total
  43113. */
  43114. get total(): number;
  43115. /**
  43116. * Gets the total value count
  43117. */
  43118. get count(): number;
  43119. /**
  43120. * Creates a new counter
  43121. */
  43122. constructor();
  43123. /**
  43124. * Call this method to start monitoring a new frame.
  43125. * 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.
  43126. */
  43127. fetchNewFrame(): void;
  43128. /**
  43129. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  43130. * @param newCount the count value to add to the monitored count
  43131. * @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.
  43132. */
  43133. addCount(newCount: number, fetchResult: boolean): void;
  43134. /**
  43135. * Start monitoring this performance counter
  43136. */
  43137. beginMonitoring(): void;
  43138. /**
  43139. * Compute the time lapsed since the previous beginMonitoring() call.
  43140. * @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
  43141. */
  43142. endMonitoring(newFrame?: boolean): void;
  43143. private _fetchResult;
  43144. private _startMonitoringTime;
  43145. private _min;
  43146. private _max;
  43147. private _average;
  43148. private _current;
  43149. private _totalValueCount;
  43150. private _totalAccumulated;
  43151. private _lastSecAverage;
  43152. private _lastSecAccumulated;
  43153. private _lastSecTime;
  43154. private _lastSecValueCount;
  43155. }
  43156. }
  43157. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  43158. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43159. import { Nullable } from "babylonjs/types";
  43160. module "babylonjs/Engines/thinEngine" {
  43161. interface ThinEngine {
  43162. /** @hidden */
  43163. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  43164. }
  43165. }
  43166. }
  43167. declare module "babylonjs/Audio/analyser" {
  43168. import { Scene } from "babylonjs/scene";
  43169. /**
  43170. * Class used to work with sound analyzer using fast fourier transform (FFT)
  43171. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43172. */
  43173. export class Analyser {
  43174. /**
  43175. * Gets or sets the smoothing
  43176. * @ignorenaming
  43177. */
  43178. SMOOTHING: number;
  43179. /**
  43180. * Gets or sets the FFT table size
  43181. * @ignorenaming
  43182. */
  43183. FFT_SIZE: number;
  43184. /**
  43185. * Gets or sets the bar graph amplitude
  43186. * @ignorenaming
  43187. */
  43188. BARGRAPHAMPLITUDE: number;
  43189. /**
  43190. * Gets or sets the position of the debug canvas
  43191. * @ignorenaming
  43192. */
  43193. DEBUGCANVASPOS: {
  43194. x: number;
  43195. y: number;
  43196. };
  43197. /**
  43198. * Gets or sets the debug canvas size
  43199. * @ignorenaming
  43200. */
  43201. DEBUGCANVASSIZE: {
  43202. width: number;
  43203. height: number;
  43204. };
  43205. private _byteFreqs;
  43206. private _byteTime;
  43207. private _floatFreqs;
  43208. private _webAudioAnalyser;
  43209. private _debugCanvas;
  43210. private _debugCanvasContext;
  43211. private _scene;
  43212. private _registerFunc;
  43213. private _audioEngine;
  43214. /**
  43215. * Creates a new analyser
  43216. * @param scene defines hosting scene
  43217. */
  43218. constructor(scene: Scene);
  43219. /**
  43220. * Get the number of data values you will have to play with for the visualization
  43221. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  43222. * @returns a number
  43223. */
  43224. getFrequencyBinCount(): number;
  43225. /**
  43226. * Gets the current frequency data as a byte array
  43227. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  43228. * @returns a Uint8Array
  43229. */
  43230. getByteFrequencyData(): Uint8Array;
  43231. /**
  43232. * Gets the current waveform as a byte array
  43233. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  43234. * @returns a Uint8Array
  43235. */
  43236. getByteTimeDomainData(): Uint8Array;
  43237. /**
  43238. * Gets the current frequency data as a float array
  43239. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  43240. * @returns a Float32Array
  43241. */
  43242. getFloatFrequencyData(): Float32Array;
  43243. /**
  43244. * Renders the debug canvas
  43245. */
  43246. drawDebugCanvas(): void;
  43247. /**
  43248. * Stops rendering the debug canvas and removes it
  43249. */
  43250. stopDebugCanvas(): void;
  43251. /**
  43252. * Connects two audio nodes
  43253. * @param inputAudioNode defines first node to connect
  43254. * @param outputAudioNode defines second node to connect
  43255. */
  43256. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  43257. /**
  43258. * Releases all associated resources
  43259. */
  43260. dispose(): void;
  43261. }
  43262. }
  43263. declare module "babylonjs/Audio/Interfaces/IAudioEngine" {
  43264. import { Observable } from "babylonjs/Misc/observable";
  43265. import { IDisposable } from "babylonjs/scene";
  43266. import { Nullable } from "babylonjs/types";
  43267. import { Analyser } from "babylonjs/Audio/analyser";
  43268. /**
  43269. * This represents an audio engine and it is responsible
  43270. * to play, synchronize and analyse sounds throughout the application.
  43271. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43272. */
  43273. export interface IAudioEngine extends IDisposable {
  43274. /**
  43275. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  43276. */
  43277. readonly canUseWebAudio: boolean;
  43278. /**
  43279. * Gets the current AudioContext if available.
  43280. */
  43281. readonly audioContext: Nullable<AudioContext>;
  43282. /**
  43283. * The master gain node defines the global audio volume of your audio engine.
  43284. */
  43285. readonly masterGain: GainNode;
  43286. /**
  43287. * Gets whether or not mp3 are supported by your browser.
  43288. */
  43289. readonly isMP3supported: boolean;
  43290. /**
  43291. * Gets whether or not ogg are supported by your browser.
  43292. */
  43293. readonly isOGGsupported: boolean;
  43294. /**
  43295. * Defines if Babylon should emit a warning if WebAudio is not supported.
  43296. * @ignoreNaming
  43297. */
  43298. WarnedWebAudioUnsupported: boolean;
  43299. /**
  43300. * Defines if the audio engine relies on a custom unlocked button.
  43301. * In this case, the embedded button will not be displayed.
  43302. */
  43303. useCustomUnlockedButton: boolean;
  43304. /**
  43305. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  43306. */
  43307. readonly unlocked: boolean;
  43308. /**
  43309. * Event raised when audio has been unlocked on the browser.
  43310. */
  43311. onAudioUnlockedObservable: Observable<IAudioEngine>;
  43312. /**
  43313. * Event raised when audio has been locked on the browser.
  43314. */
  43315. onAudioLockedObservable: Observable<IAudioEngine>;
  43316. /**
  43317. * Flags the audio engine in Locked state.
  43318. * This happens due to new browser policies preventing audio to autoplay.
  43319. */
  43320. lock(): void;
  43321. /**
  43322. * Unlocks the audio engine once a user action has been done on the dom.
  43323. * This is helpful to resume play once browser policies have been satisfied.
  43324. */
  43325. unlock(): void;
  43326. /**
  43327. * Gets the global volume sets on the master gain.
  43328. * @returns the global volume if set or -1 otherwise
  43329. */
  43330. getGlobalVolume(): number;
  43331. /**
  43332. * Sets the global volume of your experience (sets on the master gain).
  43333. * @param newVolume Defines the new global volume of the application
  43334. */
  43335. setGlobalVolume(newVolume: number): void;
  43336. /**
  43337. * Connect the audio engine to an audio analyser allowing some amazing
  43338. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  43339. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  43340. * @param analyser The analyser to connect to the engine
  43341. */
  43342. connectToAnalyser(analyser: Analyser): void;
  43343. }
  43344. }
  43345. declare module "babylonjs/Engines/engine" {
  43346. import { Observable } from "babylonjs/Misc/observable";
  43347. import { Nullable } from "babylonjs/types";
  43348. import { Scene } from "babylonjs/scene";
  43349. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43350. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  43351. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  43352. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  43353. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  43354. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  43355. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  43356. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  43357. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43358. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  43359. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43360. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  43361. import "babylonjs/Engines/Extensions/engine.alpha";
  43362. import "babylonjs/Engines/Extensions/engine.readTexture";
  43363. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  43364. import { IAudioEngine } from "babylonjs/Audio/Interfaces/IAudioEngine";
  43365. import { Material } from "babylonjs/Materials/material";
  43366. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43367. /**
  43368. * Defines the interface used by display changed events
  43369. */
  43370. export interface IDisplayChangedEventArgs {
  43371. /** Gets the vrDisplay object (if any) */
  43372. vrDisplay: Nullable<any>;
  43373. /** Gets a boolean indicating if webVR is supported */
  43374. vrSupported: boolean;
  43375. }
  43376. /**
  43377. * Defines the interface used by objects containing a viewport (like a camera)
  43378. */
  43379. interface IViewportOwnerLike {
  43380. /**
  43381. * Gets or sets the viewport
  43382. */
  43383. viewport: IViewportLike;
  43384. }
  43385. /**
  43386. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  43387. */
  43388. export class Engine extends ThinEngine {
  43389. /** Defines that alpha blending is disabled */
  43390. static readonly ALPHA_DISABLE: number;
  43391. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  43392. static readonly ALPHA_ADD: number;
  43393. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  43394. static readonly ALPHA_COMBINE: number;
  43395. /** Defines that alpha blending to DEST - SRC * DEST */
  43396. static readonly ALPHA_SUBTRACT: number;
  43397. /** Defines that alpha blending to SRC * DEST */
  43398. static readonly ALPHA_MULTIPLY: number;
  43399. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  43400. static readonly ALPHA_MAXIMIZED: number;
  43401. /** Defines that alpha blending to SRC + DEST */
  43402. static readonly ALPHA_ONEONE: number;
  43403. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  43404. static readonly ALPHA_PREMULTIPLIED: number;
  43405. /**
  43406. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  43407. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  43408. */
  43409. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  43410. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  43411. static readonly ALPHA_INTERPOLATE: number;
  43412. /**
  43413. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  43414. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  43415. */
  43416. static readonly ALPHA_SCREENMODE: number;
  43417. /** Defines that the ressource is not delayed*/
  43418. static readonly DELAYLOADSTATE_NONE: number;
  43419. /** Defines that the ressource was successfully delay loaded */
  43420. static readonly DELAYLOADSTATE_LOADED: number;
  43421. /** Defines that the ressource is currently delay loading */
  43422. static readonly DELAYLOADSTATE_LOADING: number;
  43423. /** Defines that the ressource is delayed and has not started loading */
  43424. static readonly DELAYLOADSTATE_NOTLOADED: number;
  43425. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  43426. static readonly NEVER: number;
  43427. /** 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 */
  43428. static readonly ALWAYS: number;
  43429. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  43430. static readonly LESS: number;
  43431. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  43432. static readonly EQUAL: number;
  43433. /** 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 */
  43434. static readonly LEQUAL: number;
  43435. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  43436. static readonly GREATER: number;
  43437. /** 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 */
  43438. static readonly GEQUAL: number;
  43439. /** 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 */
  43440. static readonly NOTEQUAL: number;
  43441. /** Passed to stencilOperation to specify that stencil value must be kept */
  43442. static readonly KEEP: number;
  43443. /** Passed to stencilOperation to specify that stencil value must be replaced */
  43444. static readonly REPLACE: number;
  43445. /** Passed to stencilOperation to specify that stencil value must be incremented */
  43446. static readonly INCR: number;
  43447. /** Passed to stencilOperation to specify that stencil value must be decremented */
  43448. static readonly DECR: number;
  43449. /** Passed to stencilOperation to specify that stencil value must be inverted */
  43450. static readonly INVERT: number;
  43451. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  43452. static readonly INCR_WRAP: number;
  43453. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  43454. static readonly DECR_WRAP: number;
  43455. /** Texture is not repeating outside of 0..1 UVs */
  43456. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  43457. /** Texture is repeating outside of 0..1 UVs */
  43458. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  43459. /** Texture is repeating and mirrored */
  43460. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  43461. /** ALPHA */
  43462. static readonly TEXTUREFORMAT_ALPHA: number;
  43463. /** LUMINANCE */
  43464. static readonly TEXTUREFORMAT_LUMINANCE: number;
  43465. /** LUMINANCE_ALPHA */
  43466. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  43467. /** RGB */
  43468. static readonly TEXTUREFORMAT_RGB: number;
  43469. /** RGBA */
  43470. static readonly TEXTUREFORMAT_RGBA: number;
  43471. /** RED */
  43472. static readonly TEXTUREFORMAT_RED: number;
  43473. /** RED (2nd reference) */
  43474. static readonly TEXTUREFORMAT_R: number;
  43475. /** RG */
  43476. static readonly TEXTUREFORMAT_RG: number;
  43477. /** RED_INTEGER */
  43478. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  43479. /** RED_INTEGER (2nd reference) */
  43480. static readonly TEXTUREFORMAT_R_INTEGER: number;
  43481. /** RG_INTEGER */
  43482. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  43483. /** RGB_INTEGER */
  43484. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  43485. /** RGBA_INTEGER */
  43486. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  43487. /** UNSIGNED_BYTE */
  43488. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  43489. /** UNSIGNED_BYTE (2nd reference) */
  43490. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  43491. /** FLOAT */
  43492. static readonly TEXTURETYPE_FLOAT: number;
  43493. /** HALF_FLOAT */
  43494. static readonly TEXTURETYPE_HALF_FLOAT: number;
  43495. /** BYTE */
  43496. static readonly TEXTURETYPE_BYTE: number;
  43497. /** SHORT */
  43498. static readonly TEXTURETYPE_SHORT: number;
  43499. /** UNSIGNED_SHORT */
  43500. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  43501. /** INT */
  43502. static readonly TEXTURETYPE_INT: number;
  43503. /** UNSIGNED_INT */
  43504. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  43505. /** UNSIGNED_SHORT_4_4_4_4 */
  43506. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  43507. /** UNSIGNED_SHORT_5_5_5_1 */
  43508. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  43509. /** UNSIGNED_SHORT_5_6_5 */
  43510. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  43511. /** UNSIGNED_INT_2_10_10_10_REV */
  43512. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  43513. /** UNSIGNED_INT_24_8 */
  43514. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  43515. /** UNSIGNED_INT_10F_11F_11F_REV */
  43516. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  43517. /** UNSIGNED_INT_5_9_9_9_REV */
  43518. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  43519. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  43520. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  43521. /** nearest is mag = nearest and min = nearest and mip = none */
  43522. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  43523. /** Bilinear is mag = linear and min = linear and mip = nearest */
  43524. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  43525. /** Trilinear is mag = linear and min = linear and mip = linear */
  43526. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  43527. /** nearest is mag = nearest and min = nearest and mip = linear */
  43528. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  43529. /** Bilinear is mag = linear and min = linear and mip = nearest */
  43530. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  43531. /** Trilinear is mag = linear and min = linear and mip = linear */
  43532. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  43533. /** mag = nearest and min = nearest and mip = nearest */
  43534. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  43535. /** mag = nearest and min = linear and mip = nearest */
  43536. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  43537. /** mag = nearest and min = linear and mip = linear */
  43538. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  43539. /** mag = nearest and min = linear and mip = none */
  43540. static readonly TEXTURE_NEAREST_LINEAR: number;
  43541. /** mag = nearest and min = nearest and mip = none */
  43542. static readonly TEXTURE_NEAREST_NEAREST: number;
  43543. /** mag = linear and min = nearest and mip = nearest */
  43544. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  43545. /** mag = linear and min = nearest and mip = linear */
  43546. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  43547. /** mag = linear and min = linear and mip = none */
  43548. static readonly TEXTURE_LINEAR_LINEAR: number;
  43549. /** mag = linear and min = nearest and mip = none */
  43550. static readonly TEXTURE_LINEAR_NEAREST: number;
  43551. /** Explicit coordinates mode */
  43552. static readonly TEXTURE_EXPLICIT_MODE: number;
  43553. /** Spherical coordinates mode */
  43554. static readonly TEXTURE_SPHERICAL_MODE: number;
  43555. /** Planar coordinates mode */
  43556. static readonly TEXTURE_PLANAR_MODE: number;
  43557. /** Cubic coordinates mode */
  43558. static readonly TEXTURE_CUBIC_MODE: number;
  43559. /** Projection coordinates mode */
  43560. static readonly TEXTURE_PROJECTION_MODE: number;
  43561. /** Skybox coordinates mode */
  43562. static readonly TEXTURE_SKYBOX_MODE: number;
  43563. /** Inverse Cubic coordinates mode */
  43564. static readonly TEXTURE_INVCUBIC_MODE: number;
  43565. /** Equirectangular coordinates mode */
  43566. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  43567. /** Equirectangular Fixed coordinates mode */
  43568. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  43569. /** Equirectangular Fixed Mirrored coordinates mode */
  43570. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  43571. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  43572. static readonly SCALEMODE_FLOOR: number;
  43573. /** Defines that texture rescaling will look for the nearest power of 2 size */
  43574. static readonly SCALEMODE_NEAREST: number;
  43575. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  43576. static readonly SCALEMODE_CEILING: number;
  43577. /**
  43578. * Returns the current npm package of the sdk
  43579. */
  43580. static get NpmPackage(): string;
  43581. /**
  43582. * Returns the current version of the framework
  43583. */
  43584. static get Version(): string;
  43585. /** Gets the list of created engines */
  43586. static get Instances(): Engine[];
  43587. /**
  43588. * Gets the latest created engine
  43589. */
  43590. static get LastCreatedEngine(): Nullable<Engine>;
  43591. /**
  43592. * Gets the latest created scene
  43593. */
  43594. static get LastCreatedScene(): Nullable<Scene>;
  43595. /**
  43596. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  43597. * @param flag defines which part of the materials must be marked as dirty
  43598. * @param predicate defines a predicate used to filter which materials should be affected
  43599. */
  43600. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  43601. /**
  43602. * Method called to create the default loading screen.
  43603. * This can be overriden in your own app.
  43604. * @param canvas The rendering canvas element
  43605. * @returns The loading screen
  43606. */
  43607. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  43608. /**
  43609. * Method called to create the default rescale post process on each engine.
  43610. */
  43611. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  43612. /**
  43613. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  43614. **/
  43615. enableOfflineSupport: boolean;
  43616. /**
  43617. * 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)
  43618. **/
  43619. disableManifestCheck: boolean;
  43620. /**
  43621. * Gets the list of created scenes
  43622. */
  43623. scenes: Scene[];
  43624. /**
  43625. * Event raised when a new scene is created
  43626. */
  43627. onNewSceneAddedObservable: Observable<Scene>;
  43628. /**
  43629. * Gets the list of created postprocesses
  43630. */
  43631. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  43632. /**
  43633. * Gets a boolean indicating if the pointer is currently locked
  43634. */
  43635. isPointerLock: boolean;
  43636. /**
  43637. * Observable event triggered each time the rendering canvas is resized
  43638. */
  43639. onResizeObservable: Observable<Engine>;
  43640. /**
  43641. * Observable event triggered each time the canvas loses focus
  43642. */
  43643. onCanvasBlurObservable: Observable<Engine>;
  43644. /**
  43645. * Observable event triggered each time the canvas gains focus
  43646. */
  43647. onCanvasFocusObservable: Observable<Engine>;
  43648. /**
  43649. * Observable event triggered each time the canvas receives pointerout event
  43650. */
  43651. onCanvasPointerOutObservable: Observable<PointerEvent>;
  43652. /**
  43653. * Observable raised when the engine begins a new frame
  43654. */
  43655. onBeginFrameObservable: Observable<Engine>;
  43656. /**
  43657. * If set, will be used to request the next animation frame for the render loop
  43658. */
  43659. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  43660. /**
  43661. * Observable raised when the engine ends the current frame
  43662. */
  43663. onEndFrameObservable: Observable<Engine>;
  43664. /**
  43665. * Observable raised when the engine is about to compile a shader
  43666. */
  43667. onBeforeShaderCompilationObservable: Observable<Engine>;
  43668. /**
  43669. * Observable raised when the engine has jsut compiled a shader
  43670. */
  43671. onAfterShaderCompilationObservable: Observable<Engine>;
  43672. /**
  43673. * Gets the audio engine
  43674. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43675. * @ignorenaming
  43676. */
  43677. static audioEngine: IAudioEngine;
  43678. /**
  43679. * Default AudioEngine factory responsible of creating the Audio Engine.
  43680. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  43681. */
  43682. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  43683. /**
  43684. * Default offline support factory responsible of creating a tool used to store data locally.
  43685. * By default, this will create a Database object if the workload has been embedded.
  43686. */
  43687. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  43688. private _loadingScreen;
  43689. private _pointerLockRequested;
  43690. private _rescalePostProcess;
  43691. protected _deterministicLockstep: boolean;
  43692. protected _lockstepMaxSteps: number;
  43693. protected _timeStep: number;
  43694. protected get _supportsHardwareTextureRescaling(): boolean;
  43695. private _fps;
  43696. private _deltaTime;
  43697. /** @hidden */
  43698. _drawCalls: PerfCounter;
  43699. /** 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 */
  43700. canvasTabIndex: number;
  43701. /**
  43702. * Turn this value on if you want to pause FPS computation when in background
  43703. */
  43704. disablePerformanceMonitorInBackground: boolean;
  43705. private _performanceMonitor;
  43706. /**
  43707. * Gets the performance monitor attached to this engine
  43708. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  43709. */
  43710. get performanceMonitor(): PerformanceMonitor;
  43711. private _onFocus;
  43712. private _onBlur;
  43713. private _onCanvasPointerOut;
  43714. private _onCanvasBlur;
  43715. private _onCanvasFocus;
  43716. private _onFullscreenChange;
  43717. private _onPointerLockChange;
  43718. /**
  43719. * Gets the HTML element used to attach event listeners
  43720. * @returns a HTML element
  43721. */
  43722. getInputElement(): Nullable<HTMLElement>;
  43723. /**
  43724. * Creates a new engine
  43725. * @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
  43726. * @param antialias defines enable antialiasing (default: false)
  43727. * @param options defines further options to be sent to the getContext() function
  43728. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  43729. */
  43730. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  43731. /**
  43732. * Shared initialization across engines types.
  43733. * @param canvas The canvas associated with this instance of the engine.
  43734. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  43735. * @param audioEngine Defines if an audio engine should be created by default
  43736. */
  43737. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  43738. /**
  43739. * Gets current aspect ratio
  43740. * @param viewportOwner defines the camera to use to get the aspect ratio
  43741. * @param useScreen defines if screen size must be used (or the current render target if any)
  43742. * @returns a number defining the aspect ratio
  43743. */
  43744. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  43745. /**
  43746. * Gets current screen aspect ratio
  43747. * @returns a number defining the aspect ratio
  43748. */
  43749. getScreenAspectRatio(): number;
  43750. /**
  43751. * Gets the client rect of the HTML canvas attached with the current webGL context
  43752. * @returns a client rectanglee
  43753. */
  43754. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  43755. /**
  43756. * Gets the client rect of the HTML element used for events
  43757. * @returns a client rectanglee
  43758. */
  43759. getInputElementClientRect(): Nullable<ClientRect>;
  43760. /**
  43761. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  43762. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43763. * @returns true if engine is in deterministic lock step mode
  43764. */
  43765. isDeterministicLockStep(): boolean;
  43766. /**
  43767. * Gets the max steps when engine is running in deterministic lock step
  43768. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43769. * @returns the max steps
  43770. */
  43771. getLockstepMaxSteps(): number;
  43772. /**
  43773. * Returns the time in ms between steps when using deterministic lock step.
  43774. * @returns time step in (ms)
  43775. */
  43776. getTimeStep(): number;
  43777. /**
  43778. * Force the mipmap generation for the given render target texture
  43779. * @param texture defines the render target texture to use
  43780. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  43781. */
  43782. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  43783. /** States */
  43784. /**
  43785. * Set various states to the webGL context
  43786. * @param culling defines backface culling state
  43787. * @param zOffset defines the value to apply to zOffset (0 by default)
  43788. * @param force defines if states must be applied even if cache is up to date
  43789. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  43790. */
  43791. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43792. /**
  43793. * Set the z offset to apply to current rendering
  43794. * @param value defines the offset to apply
  43795. */
  43796. setZOffset(value: number): void;
  43797. /**
  43798. * Gets the current value of the zOffset
  43799. * @returns the current zOffset state
  43800. */
  43801. getZOffset(): number;
  43802. /**
  43803. * Gets a boolean indicating if depth testing is enabled
  43804. * @returns the current state
  43805. */
  43806. getDepthBuffer(): boolean;
  43807. /**
  43808. * Enable or disable depth buffering
  43809. * @param enable defines the state to set
  43810. */
  43811. setDepthBuffer(enable: boolean): void;
  43812. /**
  43813. * Gets a boolean indicating if depth writing is enabled
  43814. * @returns the current depth writing state
  43815. */
  43816. getDepthWrite(): boolean;
  43817. /**
  43818. * Enable or disable depth writing
  43819. * @param enable defines the state to set
  43820. */
  43821. setDepthWrite(enable: boolean): void;
  43822. /**
  43823. * Gets a boolean indicating if stencil buffer is enabled
  43824. * @returns the current stencil buffer state
  43825. */
  43826. getStencilBuffer(): boolean;
  43827. /**
  43828. * Enable or disable the stencil buffer
  43829. * @param enable defines if the stencil buffer must be enabled or disabled
  43830. */
  43831. setStencilBuffer(enable: boolean): void;
  43832. /**
  43833. * Gets the current stencil mask
  43834. * @returns a number defining the new stencil mask to use
  43835. */
  43836. getStencilMask(): number;
  43837. /**
  43838. * Sets the current stencil mask
  43839. * @param mask defines the new stencil mask to use
  43840. */
  43841. setStencilMask(mask: number): void;
  43842. /**
  43843. * Gets the current stencil function
  43844. * @returns a number defining the stencil function to use
  43845. */
  43846. getStencilFunction(): number;
  43847. /**
  43848. * Gets the current stencil reference value
  43849. * @returns a number defining the stencil reference value to use
  43850. */
  43851. getStencilFunctionReference(): number;
  43852. /**
  43853. * Gets the current stencil mask
  43854. * @returns a number defining the stencil mask to use
  43855. */
  43856. getStencilFunctionMask(): number;
  43857. /**
  43858. * Sets the current stencil function
  43859. * @param stencilFunc defines the new stencil function to use
  43860. */
  43861. setStencilFunction(stencilFunc: number): void;
  43862. /**
  43863. * Sets the current stencil reference
  43864. * @param reference defines the new stencil reference to use
  43865. */
  43866. setStencilFunctionReference(reference: number): void;
  43867. /**
  43868. * Sets the current stencil mask
  43869. * @param mask defines the new stencil mask to use
  43870. */
  43871. setStencilFunctionMask(mask: number): void;
  43872. /**
  43873. * Gets the current stencil operation when stencil fails
  43874. * @returns a number defining stencil operation to use when stencil fails
  43875. */
  43876. getStencilOperationFail(): number;
  43877. /**
  43878. * Gets the current stencil operation when depth fails
  43879. * @returns a number defining stencil operation to use when depth fails
  43880. */
  43881. getStencilOperationDepthFail(): number;
  43882. /**
  43883. * Gets the current stencil operation when stencil passes
  43884. * @returns a number defining stencil operation to use when stencil passes
  43885. */
  43886. getStencilOperationPass(): number;
  43887. /**
  43888. * Sets the stencil operation to use when stencil fails
  43889. * @param operation defines the stencil operation to use when stencil fails
  43890. */
  43891. setStencilOperationFail(operation: number): void;
  43892. /**
  43893. * Sets the stencil operation to use when depth fails
  43894. * @param operation defines the stencil operation to use when depth fails
  43895. */
  43896. setStencilOperationDepthFail(operation: number): void;
  43897. /**
  43898. * Sets the stencil operation to use when stencil passes
  43899. * @param operation defines the stencil operation to use when stencil passes
  43900. */
  43901. setStencilOperationPass(operation: number): void;
  43902. /**
  43903. * Sets a boolean indicating if the dithering state is enabled or disabled
  43904. * @param value defines the dithering state
  43905. */
  43906. setDitheringState(value: boolean): void;
  43907. /**
  43908. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  43909. * @param value defines the rasterizer state
  43910. */
  43911. setRasterizerState(value: boolean): void;
  43912. /**
  43913. * Gets the current depth function
  43914. * @returns a number defining the depth function
  43915. */
  43916. getDepthFunction(): Nullable<number>;
  43917. /**
  43918. * Sets the current depth function
  43919. * @param depthFunc defines the function to use
  43920. */
  43921. setDepthFunction(depthFunc: number): void;
  43922. /**
  43923. * Sets the current depth function to GREATER
  43924. */
  43925. setDepthFunctionToGreater(): void;
  43926. /**
  43927. * Sets the current depth function to GEQUAL
  43928. */
  43929. setDepthFunctionToGreaterOrEqual(): void;
  43930. /**
  43931. * Sets the current depth function to LESS
  43932. */
  43933. setDepthFunctionToLess(): void;
  43934. /**
  43935. * Sets the current depth function to LEQUAL
  43936. */
  43937. setDepthFunctionToLessOrEqual(): void;
  43938. private _cachedStencilBuffer;
  43939. private _cachedStencilFunction;
  43940. private _cachedStencilMask;
  43941. private _cachedStencilOperationPass;
  43942. private _cachedStencilOperationFail;
  43943. private _cachedStencilOperationDepthFail;
  43944. private _cachedStencilReference;
  43945. /**
  43946. * Caches the the state of the stencil buffer
  43947. */
  43948. cacheStencilState(): void;
  43949. /**
  43950. * Restores the state of the stencil buffer
  43951. */
  43952. restoreStencilState(): void;
  43953. /**
  43954. * Directly set the WebGL Viewport
  43955. * @param x defines the x coordinate of the viewport (in screen space)
  43956. * @param y defines the y coordinate of the viewport (in screen space)
  43957. * @param width defines the width of the viewport (in screen space)
  43958. * @param height defines the height of the viewport (in screen space)
  43959. * @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
  43960. */
  43961. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  43962. /**
  43963. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  43964. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  43965. * @param y defines the y-coordinate of the corner of the clear rectangle
  43966. * @param width defines the width of the clear rectangle
  43967. * @param height defines the height of the clear rectangle
  43968. * @param clearColor defines the clear color
  43969. */
  43970. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  43971. /**
  43972. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  43973. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  43974. * @param y defines the y-coordinate of the corner of the clear rectangle
  43975. * @param width defines the width of the clear rectangle
  43976. * @param height defines the height of the clear rectangle
  43977. */
  43978. enableScissor(x: number, y: number, width: number, height: number): void;
  43979. /**
  43980. * Disable previously set scissor test rectangle
  43981. */
  43982. disableScissor(): void;
  43983. protected _reportDrawCall(): void;
  43984. /**
  43985. * Initializes a webVR display and starts listening to display change events
  43986. * The onVRDisplayChangedObservable will be notified upon these changes
  43987. * @returns The onVRDisplayChangedObservable
  43988. */
  43989. initWebVR(): Observable<IDisplayChangedEventArgs>;
  43990. /** @hidden */
  43991. _prepareVRComponent(): void;
  43992. /** @hidden */
  43993. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  43994. /** @hidden */
  43995. _submitVRFrame(): void;
  43996. /**
  43997. * Call this function to leave webVR mode
  43998. * Will do nothing if webVR is not supported or if there is no webVR device
  43999. * @see https://doc.babylonjs.com/how_to/webvr_camera
  44000. */
  44001. disableVR(): void;
  44002. /**
  44003. * Gets a boolean indicating that the system is in VR mode and is presenting
  44004. * @returns true if VR mode is engaged
  44005. */
  44006. isVRPresenting(): boolean;
  44007. /** @hidden */
  44008. _requestVRFrame(): void;
  44009. /** @hidden */
  44010. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44011. /**
  44012. * Gets the source code of the vertex shader associated with a specific webGL program
  44013. * @param program defines the program to use
  44014. * @returns a string containing the source code of the vertex shader associated with the program
  44015. */
  44016. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  44017. /**
  44018. * Gets the source code of the fragment shader associated with a specific webGL program
  44019. * @param program defines the program to use
  44020. * @returns a string containing the source code of the fragment shader associated with the program
  44021. */
  44022. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  44023. /**
  44024. * Sets a depth stencil texture from a render target to the according uniform.
  44025. * @param channel The texture channel
  44026. * @param uniform The uniform to set
  44027. * @param texture The render target texture containing the depth stencil texture to apply
  44028. * @param name The texture name
  44029. */
  44030. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>, name?: string): void;
  44031. /**
  44032. * Sets a texture to the webGL context from a postprocess
  44033. * @param channel defines the channel to use
  44034. * @param postProcess defines the source postprocess
  44035. * @param name name of the channel
  44036. */
  44037. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  44038. /**
  44039. * Binds the output of the passed in post process to the texture channel specified
  44040. * @param channel The channel the texture should be bound to
  44041. * @param postProcess The post process which's output should be bound
  44042. * @param name name of the channel
  44043. */
  44044. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  44045. protected _rebuildBuffers(): void;
  44046. /** @hidden */
  44047. _renderFrame(): void;
  44048. _renderLoop(): void;
  44049. /** @hidden */
  44050. _renderViews(): boolean;
  44051. /**
  44052. * Toggle full screen mode
  44053. * @param requestPointerLock defines if a pointer lock should be requested from the user
  44054. */
  44055. switchFullscreen(requestPointerLock: boolean): void;
  44056. /**
  44057. * Enters full screen mode
  44058. * @param requestPointerLock defines if a pointer lock should be requested from the user
  44059. */
  44060. enterFullscreen(requestPointerLock: boolean): void;
  44061. /**
  44062. * Exits full screen mode
  44063. */
  44064. exitFullscreen(): void;
  44065. /**
  44066. * Enters Pointerlock mode
  44067. */
  44068. enterPointerlock(): void;
  44069. /**
  44070. * Exits Pointerlock mode
  44071. */
  44072. exitPointerlock(): void;
  44073. /**
  44074. * Begin a new frame
  44075. */
  44076. beginFrame(): void;
  44077. /**
  44078. * End the current frame
  44079. */
  44080. endFrame(): void;
  44081. /**
  44082. * Resize the view according to the canvas' size
  44083. * @param forceSetSize true to force setting the sizes of the underlying canvas
  44084. */
  44085. resize(forceSetSize?: boolean): void;
  44086. /**
  44087. * Force a specific size of the canvas
  44088. * @param width defines the new canvas' width
  44089. * @param height defines the new canvas' height
  44090. * @param forceSetSize true to force setting the sizes of the underlying canvas
  44091. * @returns true if the size was changed
  44092. */
  44093. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  44094. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  44095. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  44096. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  44097. _releaseTexture(texture: InternalTexture): void;
  44098. /**
  44099. * @hidden
  44100. * Rescales a texture
  44101. * @param source input texutre
  44102. * @param destination destination texture
  44103. * @param scene scene to use to render the resize
  44104. * @param internalFormat format to use when resizing
  44105. * @param onComplete callback to be called when resize has completed
  44106. */
  44107. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  44108. /**
  44109. * Gets the current framerate
  44110. * @returns a number representing the framerate
  44111. */
  44112. getFps(): number;
  44113. /**
  44114. * Gets the time spent between current and previous frame
  44115. * @returns a number representing the delta time in ms
  44116. */
  44117. getDeltaTime(): number;
  44118. private _measureFps;
  44119. /** @hidden */
  44120. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  44121. /**
  44122. * Updates the sample count of a render target texture
  44123. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  44124. * @param texture defines the texture to update
  44125. * @param samples defines the sample count to set
  44126. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  44127. */
  44128. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  44129. /**
  44130. * Updates a depth texture Comparison Mode and Function.
  44131. * If the comparison Function is equal to 0, the mode will be set to none.
  44132. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  44133. * @param texture The texture to set the comparison function for
  44134. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  44135. */
  44136. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  44137. /**
  44138. * Creates a webGL buffer to use with instanciation
  44139. * @param capacity defines the size of the buffer
  44140. * @returns the webGL buffer
  44141. */
  44142. createInstancesBuffer(capacity: number): DataBuffer;
  44143. /**
  44144. * Delete a webGL buffer used with instanciation
  44145. * @param buffer defines the webGL buffer to delete
  44146. */
  44147. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  44148. private _clientWaitAsync;
  44149. /** @hidden */
  44150. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Nullable<Promise<ArrayBufferView>>;
  44151. dispose(): void;
  44152. private _disableTouchAction;
  44153. /**
  44154. * Display the loading screen
  44155. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  44156. */
  44157. displayLoadingUI(): void;
  44158. /**
  44159. * Hide the loading screen
  44160. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  44161. */
  44162. hideLoadingUI(): void;
  44163. /**
  44164. * Gets the current loading screen object
  44165. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  44166. */
  44167. get loadingScreen(): ILoadingScreen;
  44168. /**
  44169. * Sets the current loading screen object
  44170. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  44171. */
  44172. set loadingScreen(loadingScreen: ILoadingScreen);
  44173. /**
  44174. * Sets the current loading screen text
  44175. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  44176. */
  44177. set loadingUIText(text: string);
  44178. /**
  44179. * Sets the current loading screen background color
  44180. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  44181. */
  44182. set loadingUIBackgroundColor(color: string);
  44183. /** Pointerlock and fullscreen */
  44184. /**
  44185. * Ask the browser to promote the current element to pointerlock mode
  44186. * @param element defines the DOM element to promote
  44187. */
  44188. static _RequestPointerlock(element: HTMLElement): void;
  44189. /**
  44190. * Asks the browser to exit pointerlock mode
  44191. */
  44192. static _ExitPointerlock(): void;
  44193. /**
  44194. * Ask the browser to promote the current element to fullscreen rendering mode
  44195. * @param element defines the DOM element to promote
  44196. */
  44197. static _RequestFullscreen(element: HTMLElement): void;
  44198. /**
  44199. * Asks the browser to exit fullscreen mode
  44200. */
  44201. static _ExitFullscreen(): void;
  44202. }
  44203. }
  44204. declare module "babylonjs/Engines/engineStore" {
  44205. import { Nullable } from "babylonjs/types";
  44206. import { Engine } from "babylonjs/Engines/engine";
  44207. import { Scene } from "babylonjs/scene";
  44208. /**
  44209. * The engine store class is responsible to hold all the instances of Engine and Scene created
  44210. * during the life time of the application.
  44211. */
  44212. export class EngineStore {
  44213. /** Gets the list of created engines */
  44214. static Instances: import("babylonjs/Engines/engine").Engine[];
  44215. /** @hidden */
  44216. static _LastCreatedScene: Nullable<Scene>;
  44217. /**
  44218. * Gets the latest created engine
  44219. */
  44220. static get LastCreatedEngine(): Nullable<Engine>;
  44221. /**
  44222. * Gets the latest created scene
  44223. */
  44224. static get LastCreatedScene(): Nullable<Scene>;
  44225. /**
  44226. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  44227. * @ignorenaming
  44228. */
  44229. static UseFallbackTexture: boolean;
  44230. /**
  44231. * Texture content used if a texture cannot loaded
  44232. * @ignorenaming
  44233. */
  44234. static FallbackTexture: string;
  44235. }
  44236. }
  44237. declare module "babylonjs/Misc/promise" {
  44238. /**
  44239. * Helper class that provides a small promise polyfill
  44240. */
  44241. export class PromisePolyfill {
  44242. /**
  44243. * Static function used to check if the polyfill is required
  44244. * If this is the case then the function will inject the polyfill to window.Promise
  44245. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  44246. */
  44247. static Apply(force?: boolean): void;
  44248. }
  44249. }
  44250. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  44251. /**
  44252. * Interface for screenshot methods with describe argument called `size` as object with options
  44253. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  44254. */
  44255. export interface IScreenshotSize {
  44256. /**
  44257. * number in pixels for canvas height
  44258. */
  44259. height?: number;
  44260. /**
  44261. * multiplier allowing render at a higher or lower resolution
  44262. * If value is defined then height and width will be ignored and taken from camera
  44263. */
  44264. precision?: number;
  44265. /**
  44266. * number in pixels for canvas width
  44267. */
  44268. width?: number;
  44269. }
  44270. }
  44271. declare module "babylonjs/Misc/tools" {
  44272. import { Nullable, float } from "babylonjs/types";
  44273. import { DomManagement } from "babylonjs/Misc/domManagement";
  44274. import { WebRequest } from "babylonjs/Misc/webRequest";
  44275. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44276. import { ReadFileError } from "babylonjs/Misc/fileTools";
  44277. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  44278. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  44279. import { Camera } from "babylonjs/Cameras/camera";
  44280. import { Engine } from "babylonjs/Engines/engine";
  44281. interface IColor4Like {
  44282. r: float;
  44283. g: float;
  44284. b: float;
  44285. a: float;
  44286. }
  44287. /**
  44288. * Class containing a set of static utilities functions
  44289. */
  44290. export class Tools {
  44291. /**
  44292. * Gets or sets the base URL to use to load assets
  44293. */
  44294. static get BaseUrl(): string;
  44295. static set BaseUrl(value: string);
  44296. /**
  44297. * Enable/Disable Custom HTTP Request Headers globally.
  44298. * default = false
  44299. * @see CustomRequestHeaders
  44300. */
  44301. static UseCustomRequestHeaders: boolean;
  44302. /**
  44303. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  44304. * i.e. when loading files, where the server/service expects an Authorization header
  44305. */
  44306. static CustomRequestHeaders: {
  44307. [key: string]: string;
  44308. };
  44309. /**
  44310. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  44311. */
  44312. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  44313. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  44314. /**
  44315. * Default behaviour for cors in the application.
  44316. * It can be a string if the expected behavior is identical in the entire app.
  44317. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  44318. */
  44319. static get CorsBehavior(): string | ((url: string | string[]) => string);
  44320. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  44321. /**
  44322. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  44323. * @ignorenaming
  44324. */
  44325. static get UseFallbackTexture(): boolean;
  44326. static set UseFallbackTexture(value: boolean);
  44327. /**
  44328. * Use this object to register external classes like custom textures or material
  44329. * to allow the laoders to instantiate them
  44330. */
  44331. static get RegisteredExternalClasses(): {
  44332. [key: string]: Object;
  44333. };
  44334. static set RegisteredExternalClasses(classes: {
  44335. [key: string]: Object;
  44336. });
  44337. /**
  44338. * Texture content used if a texture cannot loaded
  44339. * @ignorenaming
  44340. */
  44341. static get fallbackTexture(): string;
  44342. static set fallbackTexture(value: string);
  44343. /**
  44344. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  44345. * @param u defines the coordinate on X axis
  44346. * @param v defines the coordinate on Y axis
  44347. * @param width defines the width of the source data
  44348. * @param height defines the height of the source data
  44349. * @param pixels defines the source byte array
  44350. * @param color defines the output color
  44351. */
  44352. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  44353. /**
  44354. * Interpolates between a and b via alpha
  44355. * @param a The lower value (returned when alpha = 0)
  44356. * @param b The upper value (returned when alpha = 1)
  44357. * @param alpha The interpolation-factor
  44358. * @return The mixed value
  44359. */
  44360. static Mix(a: number, b: number, alpha: number): number;
  44361. /**
  44362. * Tries to instantiate a new object from a given class name
  44363. * @param className defines the class name to instantiate
  44364. * @returns the new object or null if the system was not able to do the instantiation
  44365. */
  44366. static Instantiate(className: string): any;
  44367. /**
  44368. * Provides a slice function that will work even on IE
  44369. * @param data defines the array to slice
  44370. * @param start defines the start of the data (optional)
  44371. * @param end defines the end of the data (optional)
  44372. * @returns the new sliced array
  44373. */
  44374. static Slice<T>(data: T, start?: number, end?: number): T;
  44375. /**
  44376. * Provides a slice function that will work even on IE
  44377. * The difference between this and Slice is that this will force-convert to array
  44378. * @param data defines the array to slice
  44379. * @param start defines the start of the data (optional)
  44380. * @param end defines the end of the data (optional)
  44381. * @returns the new sliced array
  44382. */
  44383. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  44384. /**
  44385. * Polyfill for setImmediate
  44386. * @param action defines the action to execute after the current execution block
  44387. */
  44388. static SetImmediate(action: () => void): void;
  44389. /**
  44390. * Function indicating if a number is an exponent of 2
  44391. * @param value defines the value to test
  44392. * @returns true if the value is an exponent of 2
  44393. */
  44394. static IsExponentOfTwo(value: number): boolean;
  44395. private static _tmpFloatArray;
  44396. /**
  44397. * Returns the nearest 32-bit single precision float representation of a Number
  44398. * @param value A Number. If the parameter is of a different type, it will get converted
  44399. * to a number or to NaN if it cannot be converted
  44400. * @returns number
  44401. */
  44402. static FloatRound(value: number): number;
  44403. /**
  44404. * Extracts the filename from a path
  44405. * @param path defines the path to use
  44406. * @returns the filename
  44407. */
  44408. static GetFilename(path: string): string;
  44409. /**
  44410. * Extracts the "folder" part of a path (everything before the filename).
  44411. * @param uri The URI to extract the info from
  44412. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  44413. * @returns The "folder" part of the path
  44414. */
  44415. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  44416. /**
  44417. * Extracts text content from a DOM element hierarchy
  44418. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  44419. */
  44420. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  44421. /**
  44422. * Convert an angle in radians to degrees
  44423. * @param angle defines the angle to convert
  44424. * @returns the angle in degrees
  44425. */
  44426. static ToDegrees(angle: number): number;
  44427. /**
  44428. * Convert an angle in degrees to radians
  44429. * @param angle defines the angle to convert
  44430. * @returns the angle in radians
  44431. */
  44432. static ToRadians(angle: number): number;
  44433. /**
  44434. * Returns an array if obj is not an array
  44435. * @param obj defines the object to evaluate as an array
  44436. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  44437. * @returns either obj directly if obj is an array or a new array containing obj
  44438. */
  44439. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  44440. /**
  44441. * Gets the pointer prefix to use
  44442. * @param engine defines the engine we are finding the prefix for
  44443. * @returns "pointer" if touch is enabled. Else returns "mouse"
  44444. */
  44445. static GetPointerPrefix(engine: Engine): string;
  44446. /**
  44447. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  44448. * @param url define the url we are trying
  44449. * @param element define the dom element where to configure the cors policy
  44450. */
  44451. static SetCorsBehavior(url: string | string[], element: {
  44452. crossOrigin: string | null;
  44453. }): void;
  44454. /**
  44455. * Removes unwanted characters from an url
  44456. * @param url defines the url to clean
  44457. * @returns the cleaned url
  44458. */
  44459. static CleanUrl(url: string): string;
  44460. /**
  44461. * Gets or sets a function used to pre-process url before using them to load assets
  44462. */
  44463. static get PreprocessUrl(): (url: string) => string;
  44464. static set PreprocessUrl(processor: (url: string) => string);
  44465. /**
  44466. * Loads an image as an HTMLImageElement.
  44467. * @param input url string, ArrayBuffer, or Blob to load
  44468. * @param onLoad callback called when the image successfully loads
  44469. * @param onError callback called when the image fails to load
  44470. * @param offlineProvider offline provider for caching
  44471. * @param mimeType optional mime type
  44472. * @returns the HTMLImageElement of the loaded image
  44473. */
  44474. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  44475. /**
  44476. * Loads a file from a url
  44477. * @param url url string, ArrayBuffer, or Blob to load
  44478. * @param onSuccess callback called when the file successfully loads
  44479. * @param onProgress callback called while file is loading (if the server supports this mode)
  44480. * @param offlineProvider defines the offline provider for caching
  44481. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44482. * @param onError callback called when the file fails to load
  44483. * @returns a file request object
  44484. */
  44485. 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;
  44486. /**
  44487. * Loads a file from a url
  44488. * @param url the file url to load
  44489. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44490. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  44491. */
  44492. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  44493. /**
  44494. * Load a script (identified by an url). When the url returns, the
  44495. * content of this file is added into a new script element, attached to the DOM (body element)
  44496. * @param scriptUrl defines the url of the script to laod
  44497. * @param onSuccess defines the callback called when the script is loaded
  44498. * @param onError defines the callback to call if an error occurs
  44499. * @param scriptId defines the id of the script element
  44500. */
  44501. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  44502. /**
  44503. * Load an asynchronous script (identified by an url). When the url returns, the
  44504. * content of this file is added into a new script element, attached to the DOM (body element)
  44505. * @param scriptUrl defines the url of the script to laod
  44506. * @param scriptId defines the id of the script element
  44507. * @returns a promise request object
  44508. */
  44509. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  44510. /**
  44511. * Loads a file from a blob
  44512. * @param fileToLoad defines the blob to use
  44513. * @param callback defines the callback to call when data is loaded
  44514. * @param progressCallback defines the callback to call during loading process
  44515. * @returns a file request object
  44516. */
  44517. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  44518. /**
  44519. * Reads a file from a File object
  44520. * @param file defines the file to load
  44521. * @param onSuccess defines the callback to call when data is loaded
  44522. * @param onProgress defines the callback to call during loading process
  44523. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44524. * @param onError defines the callback to call when an error occurs
  44525. * @returns a file request object
  44526. */
  44527. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  44528. /**
  44529. * Creates a data url from a given string content
  44530. * @param content defines the content to convert
  44531. * @returns the new data url link
  44532. */
  44533. static FileAsURL(content: string): string;
  44534. /**
  44535. * Format the given number to a specific decimal format
  44536. * @param value defines the number to format
  44537. * @param decimals defines the number of decimals to use
  44538. * @returns the formatted string
  44539. */
  44540. static Format(value: number, decimals?: number): string;
  44541. /**
  44542. * Tries to copy an object by duplicating every property
  44543. * @param source defines the source object
  44544. * @param destination defines the target object
  44545. * @param doNotCopyList defines a list of properties to avoid
  44546. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  44547. */
  44548. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  44549. /**
  44550. * Gets a boolean indicating if the given object has no own property
  44551. * @param obj defines the object to test
  44552. * @returns true if object has no own property
  44553. */
  44554. static IsEmpty(obj: any): boolean;
  44555. /**
  44556. * Function used to register events at window level
  44557. * @param windowElement defines the Window object to use
  44558. * @param events defines the events to register
  44559. */
  44560. static RegisterTopRootEvents(windowElement: Window, events: {
  44561. name: string;
  44562. handler: Nullable<(e: FocusEvent) => any>;
  44563. }[]): void;
  44564. /**
  44565. * Function used to unregister events from window level
  44566. * @param windowElement defines the Window object to use
  44567. * @param events defines the events to unregister
  44568. */
  44569. static UnregisterTopRootEvents(windowElement: Window, events: {
  44570. name: string;
  44571. handler: Nullable<(e: FocusEvent) => any>;
  44572. }[]): void;
  44573. /**
  44574. * @ignore
  44575. */
  44576. static _ScreenshotCanvas: HTMLCanvasElement;
  44577. /**
  44578. * Dumps the current bound framebuffer
  44579. * @param width defines the rendering width
  44580. * @param height defines the rendering height
  44581. * @param engine defines the hosting engine
  44582. * @param successCallback defines the callback triggered once the data are available
  44583. * @param mimeType defines the mime type of the result
  44584. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  44585. * @return a void promise
  44586. */
  44587. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): Promise<void>;
  44588. /**
  44589. * Dumps an array buffer
  44590. * @param width defines the rendering width
  44591. * @param height defines the rendering height
  44592. * @param data the data array
  44593. * @param successCallback defines the callback triggered once the data are available
  44594. * @param mimeType defines the mime type of the result
  44595. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  44596. * @param invertY true to invert the picture in the Y dimension
  44597. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  44598. */
  44599. static DumpData(width: number, height: number, data: ArrayBufferView, successCallback?: (data: string | ArrayBuffer) => void, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): void;
  44600. /**
  44601. * Dumps an array buffer
  44602. * @param width defines the rendering width
  44603. * @param height defines the rendering height
  44604. * @param data the data array
  44605. * @param successCallback defines the callback triggered once the data are available
  44606. * @param mimeType defines the mime type of the result
  44607. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  44608. * @param invertY true to invert the picture in the Y dimension
  44609. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  44610. * @return a promise that resolve to the final data
  44611. */
  44612. static DumpDataAsync(width: number, height: number, data: ArrayBufferView, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44613. /**
  44614. * Converts the canvas data to blob.
  44615. * This acts as a polyfill for browsers not supporting the to blob function.
  44616. * @param canvas Defines the canvas to extract the data from
  44617. * @param successCallback Defines the callback triggered once the data are available
  44618. * @param mimeType Defines the mime type of the result
  44619. */
  44620. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  44621. /**
  44622. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  44623. * @param successCallback defines the callback triggered once the data are available
  44624. * @param mimeType defines the mime type of the result
  44625. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  44626. * @param canvas canvas to get the data from. If not provided, use the default screenshot canvas
  44627. */
  44628. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string, canvas?: HTMLCanvasElement): void;
  44629. /**
  44630. * Downloads a blob in the browser
  44631. * @param blob defines the blob to download
  44632. * @param fileName defines the name of the downloaded file
  44633. */
  44634. static Download(blob: Blob, fileName: string): void;
  44635. /**
  44636. * Will return the right value of the noPreventDefault variable
  44637. * Needed to keep backwards compatibility to the old API.
  44638. *
  44639. * @param args arguments passed to the attachControl function
  44640. * @returns the correct value for noPreventDefault
  44641. */
  44642. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  44643. /**
  44644. * Captures a screenshot of the current rendering
  44645. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  44646. * @param engine defines the rendering engine
  44647. * @param camera defines the source camera
  44648. * @param size This parameter can be set to a single number or to an object with the
  44649. * following (optional) properties: precision, width, height. If a single number is passed,
  44650. * it will be used for both width and height. If an object is passed, the screenshot size
  44651. * will be derived from the parameters. The precision property is a multiplier allowing
  44652. * rendering at a higher or lower resolution
  44653. * @param successCallback defines the callback receives a single parameter which contains the
  44654. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  44655. * src parameter of an <img> to display it
  44656. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  44657. * Check your browser for supported MIME types
  44658. */
  44659. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  44660. /**
  44661. * Captures a screenshot of the current rendering
  44662. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  44663. * @param engine defines the rendering engine
  44664. * @param camera defines the source camera
  44665. * @param size This parameter can be set to a single number or to an object with the
  44666. * following (optional) properties: precision, width, height. If a single number is passed,
  44667. * it will be used for both width and height. If an object is passed, the screenshot size
  44668. * will be derived from the parameters. The precision property is a multiplier allowing
  44669. * rendering at a higher or lower resolution
  44670. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  44671. * Check your browser for supported MIME types
  44672. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  44673. * to the src parameter of an <img> to display it
  44674. */
  44675. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  44676. /**
  44677. * Generates an image screenshot from the specified camera.
  44678. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  44679. * @param engine The engine to use for rendering
  44680. * @param camera The camera to use for rendering
  44681. * @param size This parameter can be set to a single number or to an object with the
  44682. * following (optional) properties: precision, width, height. If a single number is passed,
  44683. * it will be used for both width and height. If an object is passed, the screenshot size
  44684. * will be derived from the parameters. The precision property is a multiplier allowing
  44685. * rendering at a higher or lower resolution
  44686. * @param successCallback The callback receives a single parameter which contains the
  44687. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  44688. * src parameter of an <img> to display it
  44689. * @param mimeType The MIME type of the screenshot image (default: image/png).
  44690. * Check your browser for supported MIME types
  44691. * @param samples Texture samples (default: 1)
  44692. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  44693. * @param fileName A name for for the downloaded file.
  44694. */
  44695. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  44696. /**
  44697. * Generates an image screenshot from the specified camera.
  44698. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  44699. * @param engine The engine to use for rendering
  44700. * @param camera The camera to use for rendering
  44701. * @param size This parameter can be set to a single number or to an object with the
  44702. * following (optional) properties: precision, width, height. If a single number is passed,
  44703. * it will be used for both width and height. If an object is passed, the screenshot size
  44704. * will be derived from the parameters. The precision property is a multiplier allowing
  44705. * rendering at a higher or lower resolution
  44706. * @param mimeType The MIME type of the screenshot image (default: image/png).
  44707. * Check your browser for supported MIME types
  44708. * @param samples Texture samples (default: 1)
  44709. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  44710. * @param fileName A name for for the downloaded file.
  44711. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  44712. * to the src parameter of an <img> to display it
  44713. */
  44714. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  44715. /**
  44716. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  44717. * Be aware Math.random() could cause collisions, but:
  44718. * "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"
  44719. * @returns a pseudo random id
  44720. */
  44721. static RandomId(): string;
  44722. /**
  44723. * Test if the given uri is a base64 string
  44724. * @param uri The uri to test
  44725. * @return True if the uri is a base64 string or false otherwise
  44726. */
  44727. static IsBase64(uri: string): boolean;
  44728. /**
  44729. * Decode the given base64 uri.
  44730. * @param uri The uri to decode
  44731. * @return The decoded base64 data.
  44732. */
  44733. static DecodeBase64(uri: string): ArrayBuffer;
  44734. /**
  44735. * Gets the absolute url.
  44736. * @param url the input url
  44737. * @return the absolute url
  44738. */
  44739. static GetAbsoluteUrl(url: string): string;
  44740. /**
  44741. * No log
  44742. */
  44743. static readonly NoneLogLevel: number;
  44744. /**
  44745. * Only message logs
  44746. */
  44747. static readonly MessageLogLevel: number;
  44748. /**
  44749. * Only warning logs
  44750. */
  44751. static readonly WarningLogLevel: number;
  44752. /**
  44753. * Only error logs
  44754. */
  44755. static readonly ErrorLogLevel: number;
  44756. /**
  44757. * All logs
  44758. */
  44759. static readonly AllLogLevel: number;
  44760. /**
  44761. * Gets a value indicating the number of loading errors
  44762. * @ignorenaming
  44763. */
  44764. static get errorsCount(): number;
  44765. /**
  44766. * Callback called when a new log is added
  44767. */
  44768. static OnNewCacheEntry: (entry: string) => void;
  44769. /**
  44770. * Log a message to the console
  44771. * @param message defines the message to log
  44772. */
  44773. static Log(message: string): void;
  44774. /**
  44775. * Write a warning message to the console
  44776. * @param message defines the message to log
  44777. */
  44778. static Warn(message: string): void;
  44779. /**
  44780. * Write an error message to the console
  44781. * @param message defines the message to log
  44782. */
  44783. static Error(message: string): void;
  44784. /**
  44785. * Gets current log cache (list of logs)
  44786. */
  44787. static get LogCache(): string;
  44788. /**
  44789. * Clears the log cache
  44790. */
  44791. static ClearLogCache(): void;
  44792. /**
  44793. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  44794. */
  44795. static set LogLevels(level: number);
  44796. /**
  44797. * Checks if the window object exists
  44798. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  44799. */
  44800. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  44801. /**
  44802. * No performance log
  44803. */
  44804. static readonly PerformanceNoneLogLevel: number;
  44805. /**
  44806. * Use user marks to log performance
  44807. */
  44808. static readonly PerformanceUserMarkLogLevel: number;
  44809. /**
  44810. * Log performance to the console
  44811. */
  44812. static readonly PerformanceConsoleLogLevel: number;
  44813. private static _performance;
  44814. /**
  44815. * Sets the current performance log level
  44816. */
  44817. static set PerformanceLogLevel(level: number);
  44818. private static _StartPerformanceCounterDisabled;
  44819. private static _EndPerformanceCounterDisabled;
  44820. private static _StartUserMark;
  44821. private static _EndUserMark;
  44822. private static _StartPerformanceConsole;
  44823. private static _EndPerformanceConsole;
  44824. /**
  44825. * Starts a performance counter
  44826. */
  44827. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  44828. /**
  44829. * Ends a specific performance coutner
  44830. */
  44831. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  44832. /**
  44833. * Gets either window.performance.now() if supported or Date.now() else
  44834. */
  44835. static get Now(): number;
  44836. /**
  44837. * This method will return the name of the class used to create the instance of the given object.
  44838. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  44839. * @param object the object to get the class name from
  44840. * @param isType defines if the object is actually a type
  44841. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  44842. */
  44843. static GetClassName(object: any, isType?: boolean): string;
  44844. /**
  44845. * Gets the first element of an array satisfying a given predicate
  44846. * @param array defines the array to browse
  44847. * @param predicate defines the predicate to use
  44848. * @returns null if not found or the element
  44849. */
  44850. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  44851. /**
  44852. * This method will return the name of the full name of the class, including its owning module (if any).
  44853. * 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).
  44854. * @param object the object to get the class name from
  44855. * @param isType defines if the object is actually a type
  44856. * @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.
  44857. * @ignorenaming
  44858. */
  44859. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  44860. /**
  44861. * Returns a promise that resolves after the given amount of time.
  44862. * @param delay Number of milliseconds to delay
  44863. * @returns Promise that resolves after the given amount of time
  44864. */
  44865. static DelayAsync(delay: number): Promise<void>;
  44866. /**
  44867. * Utility function to detect if the current user agent is Safari
  44868. * @returns whether or not the current user agent is safari
  44869. */
  44870. static IsSafari(): boolean;
  44871. }
  44872. /**
  44873. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  44874. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  44875. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  44876. * @param name The name of the class, case should be preserved
  44877. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  44878. */
  44879. export function className(name: string, module?: string): (target: Object) => void;
  44880. /**
  44881. * An implementation of a loop for asynchronous functions.
  44882. */
  44883. export class AsyncLoop {
  44884. /**
  44885. * Defines the number of iterations for the loop
  44886. */
  44887. iterations: number;
  44888. /**
  44889. * Defines the current index of the loop.
  44890. */
  44891. index: number;
  44892. private _done;
  44893. private _fn;
  44894. private _successCallback;
  44895. /**
  44896. * Constructor.
  44897. * @param iterations the number of iterations.
  44898. * @param func the function to run each iteration
  44899. * @param successCallback the callback that will be called upon succesful execution
  44900. * @param offset starting offset.
  44901. */
  44902. constructor(
  44903. /**
  44904. * Defines the number of iterations for the loop
  44905. */
  44906. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  44907. /**
  44908. * Execute the next iteration. Must be called after the last iteration was finished.
  44909. */
  44910. executeNext(): void;
  44911. /**
  44912. * Break the loop and run the success callback.
  44913. */
  44914. breakLoop(): void;
  44915. /**
  44916. * Create and run an async loop.
  44917. * @param iterations the number of iterations.
  44918. * @param fn the function to run each iteration
  44919. * @param successCallback the callback that will be called upon succesful execution
  44920. * @param offset starting offset.
  44921. * @returns the created async loop object
  44922. */
  44923. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  44924. /**
  44925. * A for-loop that will run a given number of iterations synchronous and the rest async.
  44926. * @param iterations total number of iterations
  44927. * @param syncedIterations number of synchronous iterations in each async iteration.
  44928. * @param fn the function to call each iteration.
  44929. * @param callback a success call back that will be called when iterating stops.
  44930. * @param breakFunction a break condition (optional)
  44931. * @param timeout timeout settings for the setTimeout function. default - 0.
  44932. * @returns the created async loop object
  44933. */
  44934. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  44935. }
  44936. }
  44937. declare module "babylonjs/Misc/stringDictionary" {
  44938. import { Nullable } from "babylonjs/types";
  44939. /**
  44940. * This class implement a typical dictionary using a string as key and the generic type T as value.
  44941. * The underlying implementation relies on an associative array to ensure the best performances.
  44942. * The value can be anything including 'null' but except 'undefined'
  44943. */
  44944. export class StringDictionary<T> {
  44945. /**
  44946. * This will clear this dictionary and copy the content from the 'source' one.
  44947. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  44948. * @param source the dictionary to take the content from and copy to this dictionary
  44949. */
  44950. copyFrom(source: StringDictionary<T>): void;
  44951. /**
  44952. * Get a value based from its key
  44953. * @param key the given key to get the matching value from
  44954. * @return the value if found, otherwise undefined is returned
  44955. */
  44956. get(key: string): T | undefined;
  44957. /**
  44958. * Get a value from its key or add it if it doesn't exist.
  44959. * This method will ensure you that a given key/data will be present in the dictionary.
  44960. * @param key the given key to get the matching value from
  44961. * @param factory the factory that will create the value if the key is not present in the dictionary.
  44962. * The factory will only be invoked if there's no data for the given key.
  44963. * @return the value corresponding to the key.
  44964. */
  44965. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  44966. /**
  44967. * Get a value from its key if present in the dictionary otherwise add it
  44968. * @param key the key to get the value from
  44969. * @param val if there's no such key/value pair in the dictionary add it with this value
  44970. * @return the value corresponding to the key
  44971. */
  44972. getOrAdd(key: string, val: T): T;
  44973. /**
  44974. * Check if there's a given key in the dictionary
  44975. * @param key the key to check for
  44976. * @return true if the key is present, false otherwise
  44977. */
  44978. contains(key: string): boolean;
  44979. /**
  44980. * Add a new key and its corresponding value
  44981. * @param key the key to add
  44982. * @param value the value corresponding to the key
  44983. * @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
  44984. */
  44985. add(key: string, value: T): boolean;
  44986. /**
  44987. * Update a specific value associated to a key
  44988. * @param key defines the key to use
  44989. * @param value defines the value to store
  44990. * @returns true if the value was updated (or false if the key was not found)
  44991. */
  44992. set(key: string, value: T): boolean;
  44993. /**
  44994. * Get the element of the given key and remove it from the dictionary
  44995. * @param key defines the key to search
  44996. * @returns the value associated with the key or null if not found
  44997. */
  44998. getAndRemove(key: string): Nullable<T>;
  44999. /**
  45000. * Remove a key/value from the dictionary.
  45001. * @param key the key to remove
  45002. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  45003. */
  45004. remove(key: string): boolean;
  45005. /**
  45006. * Clear the whole content of the dictionary
  45007. */
  45008. clear(): void;
  45009. /**
  45010. * Gets the current count
  45011. */
  45012. get count(): number;
  45013. /**
  45014. * Execute a callback on each key/val of the dictionary.
  45015. * Note that you can remove any element in this dictionary in the callback implementation
  45016. * @param callback the callback to execute on a given key/value pair
  45017. */
  45018. forEach(callback: (key: string, val: T) => void): void;
  45019. /**
  45020. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  45021. * If the callback returns null or undefined the method will iterate to the next key/value pair
  45022. * Note that you can remove any element in this dictionary in the callback implementation
  45023. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  45024. * @returns the first item
  45025. */
  45026. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  45027. private _count;
  45028. private _data;
  45029. }
  45030. }
  45031. declare module "babylonjs/Collisions/collisionCoordinator" {
  45032. import { Nullable } from "babylonjs/types";
  45033. import { Scene } from "babylonjs/scene";
  45034. import { Vector3 } from "babylonjs/Maths/math.vector";
  45035. import { Collider } from "babylonjs/Collisions/collider";
  45036. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45037. /** @hidden */
  45038. export interface ICollisionCoordinator {
  45039. createCollider(): Collider;
  45040. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  45041. init(scene: Scene): void;
  45042. }
  45043. /** @hidden */
  45044. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  45045. private _scene;
  45046. private _scaledPosition;
  45047. private _scaledVelocity;
  45048. private _finalPosition;
  45049. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  45050. createCollider(): Collider;
  45051. init(scene: Scene): void;
  45052. private _collideWithWorld;
  45053. }
  45054. }
  45055. declare module "babylonjs/Inputs/scene.inputManager" {
  45056. import { Nullable } from "babylonjs/types";
  45057. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  45058. import { Vector2 } from "babylonjs/Maths/math.vector";
  45059. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45060. import { Scene } from "babylonjs/scene";
  45061. /**
  45062. * Class used to manage all inputs for the scene.
  45063. */
  45064. export class InputManager {
  45065. /** The distance in pixel that you have to move to prevent some events */
  45066. static DragMovementThreshold: number;
  45067. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  45068. static LongPressDelay: number;
  45069. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  45070. static DoubleClickDelay: number;
  45071. /** If you need to check double click without raising a single click at first click, enable this flag */
  45072. static ExclusiveDoubleClickMode: boolean;
  45073. /** 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. */
  45074. private _alreadyAttached;
  45075. private _alreadyAttachedTo;
  45076. private _wheelEventName;
  45077. private _onPointerMove;
  45078. private _onPointerDown;
  45079. private _onPointerUp;
  45080. private _initClickEvent;
  45081. private _initActionManager;
  45082. private _delayedSimpleClick;
  45083. private _delayedSimpleClickTimeout;
  45084. private _previousDelayedSimpleClickTimeout;
  45085. private _meshPickProceed;
  45086. private _previousButtonPressed;
  45087. private _currentPickResult;
  45088. private _previousPickResult;
  45089. private _totalPointersPressed;
  45090. private _doubleClickOccured;
  45091. private _pointerOverMesh;
  45092. private _pickedDownMesh;
  45093. private _pickedUpMesh;
  45094. private _pointerX;
  45095. private _pointerY;
  45096. private _unTranslatedPointerX;
  45097. private _unTranslatedPointerY;
  45098. private _startingPointerPosition;
  45099. private _previousStartingPointerPosition;
  45100. private _startingPointerTime;
  45101. private _previousStartingPointerTime;
  45102. private _pointerCaptures;
  45103. private _meshUnderPointerId;
  45104. private _onKeyDown;
  45105. private _onKeyUp;
  45106. private _keyboardIsAttached;
  45107. private _onCanvasFocusObserver;
  45108. private _onCanvasBlurObserver;
  45109. private _scene;
  45110. /**
  45111. * Creates a new InputManager
  45112. * @param scene defines the hosting scene
  45113. */
  45114. constructor(scene: Scene);
  45115. /**
  45116. * Gets the mesh that is currently under the pointer
  45117. */
  45118. get meshUnderPointer(): Nullable<AbstractMesh>;
  45119. /**
  45120. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  45121. * @param pointerId the pointer id to use
  45122. * @returns The mesh under this pointer id or null if not found
  45123. */
  45124. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  45125. /**
  45126. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  45127. */
  45128. get unTranslatedPointer(): Vector2;
  45129. /**
  45130. * Gets or sets the current on-screen X position of the pointer
  45131. */
  45132. get pointerX(): number;
  45133. set pointerX(value: number);
  45134. /**
  45135. * Gets or sets the current on-screen Y position of the pointer
  45136. */
  45137. get pointerY(): number;
  45138. set pointerY(value: number);
  45139. private _updatePointerPosition;
  45140. private _processPointerMove;
  45141. private _setRayOnPointerInfo;
  45142. private _checkPrePointerObservable;
  45143. /**
  45144. * Use this method to simulate a pointer move 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. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  45150. /**
  45151. * Use this method to simulate a pointer down on a mesh
  45152. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45153. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45154. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45155. */
  45156. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  45157. private _processPointerDown;
  45158. /** @hidden */
  45159. _isPointerSwiping(): boolean;
  45160. /**
  45161. * Use this method to simulate a pointer up on a mesh
  45162. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45163. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45164. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45165. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  45166. */
  45167. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  45168. private _processPointerUp;
  45169. /**
  45170. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  45171. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  45172. * @returns true if the pointer was captured
  45173. */
  45174. isPointerCaptured(pointerId?: number): boolean;
  45175. /**
  45176. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  45177. * @param attachUp defines if you want to attach events to pointerup
  45178. * @param attachDown defines if you want to attach events to pointerdown
  45179. * @param attachMove defines if you want to attach events to pointermove
  45180. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  45181. */
  45182. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  45183. /**
  45184. * Detaches all event handlers
  45185. */
  45186. detachControl(): void;
  45187. /**
  45188. * Force the value of meshUnderPointer
  45189. * @param mesh defines the mesh to use
  45190. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  45191. */
  45192. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  45193. /**
  45194. * Gets the mesh under the pointer
  45195. * @returns a Mesh or null if no mesh is under the pointer
  45196. */
  45197. getPointerOverMesh(): Nullable<AbstractMesh>;
  45198. }
  45199. }
  45200. declare module "babylonjs/Animations/animationGroup" {
  45201. import { Animatable } from "babylonjs/Animations/animatable";
  45202. import { Animation } from "babylonjs/Animations/animation";
  45203. import { Scene, IDisposable } from "babylonjs/scene";
  45204. import { Observable } from "babylonjs/Misc/observable";
  45205. import { Nullable } from "babylonjs/types";
  45206. import "babylonjs/Animations/animatable";
  45207. /**
  45208. * This class defines the direct association between an animation and a target
  45209. */
  45210. export class TargetedAnimation {
  45211. /**
  45212. * Animation to perform
  45213. */
  45214. animation: Animation;
  45215. /**
  45216. * Target to animate
  45217. */
  45218. target: any;
  45219. /**
  45220. * Returns the string "TargetedAnimation"
  45221. * @returns "TargetedAnimation"
  45222. */
  45223. getClassName(): string;
  45224. /**
  45225. * Serialize the object
  45226. * @returns the JSON object representing the current entity
  45227. */
  45228. serialize(): any;
  45229. }
  45230. /**
  45231. * Use this class to create coordinated animations on multiple targets
  45232. */
  45233. export class AnimationGroup implements IDisposable {
  45234. /** The name of the animation group */
  45235. name: string;
  45236. private _scene;
  45237. private _targetedAnimations;
  45238. private _animatables;
  45239. private _from;
  45240. private _to;
  45241. private _isStarted;
  45242. private _isPaused;
  45243. private _speedRatio;
  45244. private _loopAnimation;
  45245. private _isAdditive;
  45246. /**
  45247. * Gets or sets the unique id of the node
  45248. */
  45249. uniqueId: number;
  45250. /**
  45251. * This observable will notify when one animation have ended
  45252. */
  45253. onAnimationEndObservable: Observable<TargetedAnimation>;
  45254. /**
  45255. * Observer raised when one animation loops
  45256. */
  45257. onAnimationLoopObservable: Observable<TargetedAnimation>;
  45258. /**
  45259. * Observer raised when all animations have looped
  45260. */
  45261. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  45262. /**
  45263. * This observable will notify when all animations have ended.
  45264. */
  45265. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  45266. /**
  45267. * This observable will notify when all animations have paused.
  45268. */
  45269. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  45270. /**
  45271. * This observable will notify when all animations are playing.
  45272. */
  45273. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  45274. /**
  45275. * Gets the first frame
  45276. */
  45277. get from(): number;
  45278. /**
  45279. * Gets the last frame
  45280. */
  45281. get to(): number;
  45282. /**
  45283. * Define if the animations are started
  45284. */
  45285. get isStarted(): boolean;
  45286. /**
  45287. * Gets a value indicating that the current group is playing
  45288. */
  45289. get isPlaying(): boolean;
  45290. /**
  45291. * Gets or sets the speed ratio to use for all animations
  45292. */
  45293. get speedRatio(): number;
  45294. /**
  45295. * Gets or sets the speed ratio to use for all animations
  45296. */
  45297. set speedRatio(value: number);
  45298. /**
  45299. * Gets or sets if all animations should loop or not
  45300. */
  45301. get loopAnimation(): boolean;
  45302. set loopAnimation(value: boolean);
  45303. /**
  45304. * Gets or sets if all animations should be evaluated additively
  45305. */
  45306. get isAdditive(): boolean;
  45307. set isAdditive(value: boolean);
  45308. /**
  45309. * Gets the targeted animations for this animation group
  45310. */
  45311. get targetedAnimations(): Array<TargetedAnimation>;
  45312. /**
  45313. * returning the list of animatables controlled by this animation group.
  45314. */
  45315. get animatables(): Array<Animatable>;
  45316. /**
  45317. * Gets the list of target animations
  45318. */
  45319. get children(): TargetedAnimation[];
  45320. /**
  45321. * Instantiates a new Animation Group.
  45322. * This helps managing several animations at once.
  45323. * @see https://doc.babylonjs.com/how_to/group
  45324. * @param name Defines the name of the group
  45325. * @param scene Defines the scene the group belongs to
  45326. */
  45327. constructor(
  45328. /** The name of the animation group */
  45329. name: string, scene?: Nullable<Scene>);
  45330. /**
  45331. * Add an animation (with its target) in the group
  45332. * @param animation defines the animation we want to add
  45333. * @param target defines the target of the animation
  45334. * @returns the TargetedAnimation object
  45335. */
  45336. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  45337. /**
  45338. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  45339. * It can add constant keys at begin or end
  45340. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  45341. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  45342. * @returns the animation group
  45343. */
  45344. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  45345. private _animationLoopCount;
  45346. private _animationLoopFlags;
  45347. private _processLoop;
  45348. /**
  45349. * Start all animations on given targets
  45350. * @param loop defines if animations must loop
  45351. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  45352. * @param from defines the from key (optional)
  45353. * @param to defines the to key (optional)
  45354. * @param isAdditive defines the additive state for the resulting animatables (optional)
  45355. * @returns the current animation group
  45356. */
  45357. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  45358. /**
  45359. * Pause all animations
  45360. * @returns the animation group
  45361. */
  45362. pause(): AnimationGroup;
  45363. /**
  45364. * Play all animations to initial state
  45365. * This function will start() the animations if they were not started or will restart() them if they were paused
  45366. * @param loop defines if animations must loop
  45367. * @returns the animation group
  45368. */
  45369. play(loop?: boolean): AnimationGroup;
  45370. /**
  45371. * Reset all animations to initial state
  45372. * @returns the animation group
  45373. */
  45374. reset(): AnimationGroup;
  45375. /**
  45376. * Restart animations from key 0
  45377. * @returns the animation group
  45378. */
  45379. restart(): AnimationGroup;
  45380. /**
  45381. * Stop all animations
  45382. * @returns the animation group
  45383. */
  45384. stop(): AnimationGroup;
  45385. /**
  45386. * Set animation weight for all animatables
  45387. * @param weight defines the weight to use
  45388. * @return the animationGroup
  45389. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  45390. */
  45391. setWeightForAllAnimatables(weight: number): AnimationGroup;
  45392. /**
  45393. * Synchronize and normalize all animatables with a source animatable
  45394. * @param root defines the root animatable to synchronize with
  45395. * @return the animationGroup
  45396. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  45397. */
  45398. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  45399. /**
  45400. * Goes to a specific frame in this animation group
  45401. * @param frame the frame number to go to
  45402. * @return the animationGroup
  45403. */
  45404. goToFrame(frame: number): AnimationGroup;
  45405. /**
  45406. * Dispose all associated resources
  45407. */
  45408. dispose(): void;
  45409. private _checkAnimationGroupEnded;
  45410. /**
  45411. * Clone the current animation group and returns a copy
  45412. * @param newName defines the name of the new group
  45413. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  45414. * @returns the new aniamtion group
  45415. */
  45416. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  45417. /**
  45418. * Serializes the animationGroup to an object
  45419. * @returns Serialized object
  45420. */
  45421. serialize(): any;
  45422. /**
  45423. * Returns a new AnimationGroup object parsed from the source provided.
  45424. * @param parsedAnimationGroup defines the source
  45425. * @param scene defines the scene that will receive the animationGroup
  45426. * @returns a new AnimationGroup
  45427. */
  45428. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  45429. /**
  45430. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  45431. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  45432. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  45433. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  45434. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  45435. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  45436. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  45437. */
  45438. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  45439. /**
  45440. * Returns the string "AnimationGroup"
  45441. * @returns "AnimationGroup"
  45442. */
  45443. getClassName(): string;
  45444. /**
  45445. * Creates a detailled string about the object
  45446. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  45447. * @returns a string representing the object
  45448. */
  45449. toString(fullDetails?: boolean): string;
  45450. }
  45451. }
  45452. declare module "babylonjs/Instrumentation/timeToken" {
  45453. import { Nullable } from "babylonjs/types";
  45454. /**
  45455. * @hidden
  45456. **/
  45457. export class _TimeToken {
  45458. _startTimeQuery: Nullable<WebGLQuery>;
  45459. _endTimeQuery: Nullable<WebGLQuery>;
  45460. _timeElapsedQuery: Nullable<WebGLQuery>;
  45461. _timeElapsedQueryEnded: boolean;
  45462. }
  45463. }
  45464. declare module "babylonjs/Engines/WebGPU/webgpuConstants" {
  45465. /** @hidden */
  45466. export enum ExtensionName {
  45467. DepthClamping = "depth-clamping",
  45468. Depth24UnormStencil8 = "depth24unorm-stencil8",
  45469. Depth32FloatStencil8 = "depth32float-stencil8",
  45470. PipelineStatisticsQuery = "pipeline-statistics-query",
  45471. TextureCompressionBC = "texture-compression-bc",
  45472. TimestampQuery = "timestamp-query"
  45473. }
  45474. /** @hidden */
  45475. export enum AddressMode {
  45476. ClampToEdge = "clamp-to-edge",
  45477. Repeat = "repeat",
  45478. MirrorRepeat = "mirror-repeat"
  45479. }
  45480. /** @hidden */
  45481. export enum BindingType {
  45482. UniformBuffer = "uniform-buffer",
  45483. StorageBuffer = "storage-buffer",
  45484. ReadonlyStorageBuffer = "readonly-storage-buffer",
  45485. Sampler = "sampler",
  45486. ComparisonSampler = "comparison-sampler",
  45487. SampledTexture = "sampled-texture",
  45488. ReadonlyStorageTexture = "readonly-storage-texture",
  45489. WriteonlyStorageTexture = "writeonly-storage-texture"
  45490. }
  45491. /** @hidden */
  45492. export enum BlendFactor {
  45493. Zero = "zero",
  45494. One = "one",
  45495. SrcColor = "src-color",
  45496. OneMinusSrcColor = "one-minus-src-color",
  45497. SrcAlpha = "src-alpha",
  45498. OneMinusSrcAlpha = "one-minus-src-alpha",
  45499. DstColor = "dst-color",
  45500. OneMinusDstColor = "one-minus-dst-color",
  45501. DstAlpha = "dst-alpha",
  45502. OneMinusDstAlpha = "one-minus-dst-alpha",
  45503. SrcAlphaSaturated = "src-alpha-saturated",
  45504. BlendColor = "blend-color",
  45505. OneMinusBlendColor = "one-minus-blend-color"
  45506. }
  45507. /** @hidden */
  45508. export enum BlendOperation {
  45509. Add = "add",
  45510. Subtract = "subtract",
  45511. ReverseSubtract = "reverse-subtract",
  45512. Min = "min",
  45513. Max = "max"
  45514. }
  45515. /** @hidden */
  45516. export enum CompareFunction {
  45517. Never = "never",
  45518. Less = "less",
  45519. Equal = "equal",
  45520. LessEqual = "less-equal",
  45521. Greater = "greater",
  45522. NotEqual = "not-equal",
  45523. GreaterEqual = "greater-equal",
  45524. Always = "always"
  45525. }
  45526. /** @hidden */
  45527. export enum CullMode {
  45528. None = "none",
  45529. Front = "front",
  45530. Back = "back"
  45531. }
  45532. /** @hidden */
  45533. export enum FilterMode {
  45534. Nearest = "nearest",
  45535. Linear = "linear"
  45536. }
  45537. /** @hidden */
  45538. export enum FrontFace {
  45539. CCW = "ccw",
  45540. CW = "cw"
  45541. }
  45542. /** @hidden */
  45543. export enum IndexFormat {
  45544. Uint16 = "uint16",
  45545. Uint32 = "uint32"
  45546. }
  45547. /** @hidden */
  45548. export enum InputStepMode {
  45549. Vertex = "vertex",
  45550. Instance = "instance"
  45551. }
  45552. /** @hidden */
  45553. export enum LoadOp {
  45554. Load = "load"
  45555. }
  45556. /** @hidden */
  45557. export enum PrimitiveTopology {
  45558. PointList = "point-list",
  45559. LineList = "line-list",
  45560. LineStrip = "line-strip",
  45561. TriangleList = "triangle-list",
  45562. TriangleStrip = "triangle-strip"
  45563. }
  45564. /** @hidden */
  45565. export enum StencilOperation {
  45566. Keep = "keep",
  45567. Zero = "zero",
  45568. Replace = "replace",
  45569. Invert = "invert",
  45570. IncrementClamp = "increment-clamp",
  45571. DecrementClamp = "decrement-clamp",
  45572. IncrementWrap = "increment-wrap",
  45573. DecrementWrap = "decrement-wrap"
  45574. }
  45575. /** @hidden */
  45576. export enum StoreOp {
  45577. Store = "store",
  45578. Clear = "clear"
  45579. }
  45580. /** @hidden */
  45581. export enum TextureDimension {
  45582. E1d = "1d",
  45583. E2d = "2d",
  45584. E3d = "3d"
  45585. }
  45586. /** @hidden */
  45587. export enum TextureFormat {
  45588. R8Unorm = "r8unorm",
  45589. R8Snorm = "r8snorm",
  45590. R8Uint = "r8uint",
  45591. R8Sint = "r8sint",
  45592. R16Uint = "r16uint",
  45593. R16Sint = "r16sint",
  45594. R16Float = "r16float",
  45595. RG8Unorm = "rg8unorm",
  45596. RG8Snorm = "rg8snorm",
  45597. RG8Uint = "rg8uint",
  45598. RG8Sint = "rg8sint",
  45599. R32Uint = "r32uint",
  45600. R32Sint = "r32sint",
  45601. R32Float = "r32float",
  45602. RG16Uint = "rg16uint",
  45603. RG16Sint = "rg16sint",
  45604. RG16Float = "rg16float",
  45605. RGBA8Unorm = "rgba8unorm",
  45606. RGBA8UnormSRGB = "rgba8unorm-srgb",
  45607. RGBA8Snorm = "rgba8snorm",
  45608. RGBA8Uint = "rgba8uint",
  45609. RGBA8Sint = "rgba8sint",
  45610. BGRA8Unorm = "bgra8unorm",
  45611. BGRA8UnormSRGB = "bgra8unorm-srgb",
  45612. RGB9E5UFloat = "rgb9e5ufloat",
  45613. RGB10A2Unorm = "rgb10a2unorm",
  45614. RG11B10UFloat = "rg11b10ufloat",
  45615. RG32Uint = "rg32uint",
  45616. RG32Sint = "rg32sint",
  45617. RG32Float = "rg32float",
  45618. RGBA16Uint = "rgba16uint",
  45619. RGBA16Sint = "rgba16sint",
  45620. RGBA16Float = "rgba16float",
  45621. RGBA32Uint = "rgba32uint",
  45622. RGBA32Sint = "rgba32sint",
  45623. RGBA32Float = "rgba32float",
  45624. Stencil8 = "stencil8",
  45625. Depth16Unorm = "depth16unorm",
  45626. Depth24Plus = "depth24plus",
  45627. Depth24PlusStencil8 = "depth24plus-stencil8",
  45628. Depth32Float = "depth32float",
  45629. BC1RGBAUNorm = "bc1-rgba-unorm",
  45630. BC1RGBAUnormSRGB = "bc1-rgba-unorm-srgb",
  45631. BC2RGBAUnorm = "bc2-rgba-unorm",
  45632. BC2RGBAUnormSRGB = "bc2-rgba-unorm-srgb",
  45633. BC3RGBAUnorm = "bc3-rgba-unorm",
  45634. BC3RGBAUnormSRGB = "bc3-rgba-unorm-srgb",
  45635. BC4RUnorm = "bc4-r-unorm",
  45636. BC4RSnorm = "bc4-r-snorm",
  45637. BC5RGUnorm = "bc5-rg-unorm",
  45638. BC5RGSnorm = "bc5-rg-snorm",
  45639. BC6HRGBUFloat = "bc6h-rgb-ufloat",
  45640. BC6HRGBFloat = "bc6h-rgb-float",
  45641. BC7RGBAUnorm = "bc7-rgba-unorm",
  45642. BC7RGBAUnormSRGB = "bc7-rgba-unorm-srgb",
  45643. Depth24UnormStencil8 = "depth24unorm-stencil8",
  45644. Depth32FloatStencil8 = "depth32float-stencil8"
  45645. }
  45646. /** @hidden */
  45647. export enum TextureComponentType {
  45648. Float = "float",
  45649. Sint = "sint",
  45650. Uint = "uint",
  45651. DepthComparison = "depth-comparison"
  45652. }
  45653. /** @hidden */
  45654. export enum TextureViewDimension {
  45655. E1d = "1d",
  45656. E2d = "2d",
  45657. E2dArray = "2d-array",
  45658. Cube = "cube",
  45659. CubeArray = "cube-array",
  45660. E3d = "3d"
  45661. }
  45662. /** @hidden */
  45663. export enum VertexFormat {
  45664. Uchar2 = "uchar2",
  45665. Uchar4 = "uchar4",
  45666. Char2 = "char2",
  45667. Char4 = "char4",
  45668. Uchar2Norm = "uchar2norm",
  45669. Uchar4Norm = "uchar4norm",
  45670. Char2Norm = "char2norm",
  45671. Char4Norm = "char4norm",
  45672. Ushort2 = "ushort2",
  45673. Ushort4 = "ushort4",
  45674. Short2 = "short2",
  45675. Short4 = "short4",
  45676. Ushort2Norm = "ushort2norm",
  45677. Ushort4Norm = "ushort4norm",
  45678. Short2Norm = "short2norm",
  45679. Short4Norm = "short4norm",
  45680. Half2 = "half2",
  45681. Half4 = "half4",
  45682. Float = "float",
  45683. Float2 = "float2",
  45684. Float3 = "float3",
  45685. Float4 = "float4",
  45686. Uint = "uint",
  45687. Uint2 = "uint2",
  45688. Uint3 = "uint3",
  45689. Uint4 = "uint4",
  45690. Int = "int",
  45691. Int2 = "int2",
  45692. Int3 = "int3",
  45693. Int4 = "int4"
  45694. }
  45695. /** @hidden */
  45696. export enum TextureAspect {
  45697. All = "all",
  45698. StencilOnly = "stencil-only",
  45699. DepthOnly = "depth-only"
  45700. }
  45701. /** @hidden */
  45702. export enum CompilationMessageType {
  45703. Error = "error",
  45704. Warning = "warning",
  45705. Info = "info"
  45706. }
  45707. /** @hidden */
  45708. export enum QueryType {
  45709. Occlusion = "occlusion"
  45710. }
  45711. /** @hidden */
  45712. export enum BufferUsage {
  45713. MapRead = 1,
  45714. MapWrite = 2,
  45715. CopySrc = 4,
  45716. CopyDst = 8,
  45717. Index = 16,
  45718. Vertex = 32,
  45719. Uniform = 64,
  45720. Storage = 128,
  45721. Indirect = 256,
  45722. QueryResolve = 512
  45723. }
  45724. /** @hidden */
  45725. export enum ColorWrite {
  45726. Red = 1,
  45727. Green = 2,
  45728. Blue = 4,
  45729. Alpha = 8,
  45730. All = 15
  45731. }
  45732. /** @hidden */
  45733. export enum ShaderStage {
  45734. Vertex = 1,
  45735. Fragment = 2,
  45736. Compute = 4
  45737. }
  45738. /** @hidden */
  45739. export enum TextureUsage {
  45740. CopySrc = 1,
  45741. CopyDst = 2,
  45742. Sampled = 4,
  45743. Storage = 8,
  45744. OutputAttachment = 16
  45745. }
  45746. /** @hidden */
  45747. export enum MapMode {
  45748. Read = 1,
  45749. Write = 2
  45750. }
  45751. }
  45752. declare module "babylonjs/Engines/WebGPU/webgpuShaderProcessingContext" {
  45753. import { ShaderProcessingContext } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  45754. /** @hidden */
  45755. export interface WebGPUBindingInfo {
  45756. setIndex: number;
  45757. bindingIndex: number;
  45758. }
  45759. /** @hidden */
  45760. export interface WebGPUTextureSamplerBindingDescription {
  45761. sampler: WebGPUBindingInfo;
  45762. isTextureArray: boolean;
  45763. textures: Array<WebGPUBindingInfo>;
  45764. }
  45765. /** @hidden
  45766. * If the binding is a UBO, isSampler=isTexture=false
  45767. */
  45768. export interface WebGPUBindingDescription {
  45769. name: string;
  45770. usedInVertex: boolean;
  45771. usedInFragment: boolean;
  45772. isSampler: boolean;
  45773. isComparisonSampler?: boolean;
  45774. isTexture: boolean;
  45775. componentType?: GPUTextureComponentType;
  45776. textureDimension?: GPUTextureViewDimension;
  45777. }
  45778. /**
  45779. * @hidden
  45780. */
  45781. export class WebGPUShaderProcessingContext implements ShaderProcessingContext {
  45782. uboNextBindingIndex: number;
  45783. freeSetIndex: number;
  45784. freeBindingIndex: number;
  45785. availableVaryings: {
  45786. [key: string]: number;
  45787. };
  45788. availableAttributes: {
  45789. [key: string]: number;
  45790. };
  45791. availableUBOs: {
  45792. [key: string]: {
  45793. setIndex: number;
  45794. bindingIndex: number;
  45795. };
  45796. };
  45797. availableSamplers: {
  45798. [key: string]: WebGPUTextureSamplerBindingDescription;
  45799. };
  45800. leftOverUniforms: {
  45801. name: string;
  45802. type: string;
  45803. length: number;
  45804. }[];
  45805. orderedAttributes: string[];
  45806. orderedUBOsAndSamplers: WebGPUBindingDescription[][];
  45807. private _attributeNextLocation;
  45808. private _varyingNextLocation;
  45809. constructor();
  45810. getAttributeNextLocation(dataType: string, arrayLength?: number): number;
  45811. getVaryingNextLocation(dataType: string, arrayLength?: number): number;
  45812. getNextFreeUBOBinding(): {
  45813. setIndex: number;
  45814. bindingIndex: number;
  45815. };
  45816. private _getNextFreeBinding;
  45817. }
  45818. }
  45819. declare module "babylonjs/Engines/WebGPU/webgpuPipelineContext" {
  45820. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45821. import { Nullable } from "babylonjs/types";
  45822. import { WebGPUEngine } from "babylonjs/Engines/webgpuEngine";
  45823. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45824. import { Effect } from "babylonjs/Materials/effect";
  45825. import { WebGPUShaderProcessingContext } from "babylonjs/Engines/WebGPU/webgpuShaderProcessingContext";
  45826. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45827. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  45828. /** @hidden */
  45829. export interface IWebGPUPipelineContextSamplerCache {
  45830. samplerBinding: number;
  45831. firstTextureName: string;
  45832. }
  45833. /** @hidden */
  45834. export interface IWebGPUPipelineContextTextureCache {
  45835. textureBinding: number;
  45836. texture: InternalTexture;
  45837. }
  45838. /** @hidden */
  45839. export interface IWebGPUPipelineContextVertexInputsCache {
  45840. indexBuffer: Nullable<GPUBuffer>;
  45841. indexOffset: number;
  45842. vertexStartSlot: number;
  45843. vertexBuffers: GPUBuffer[];
  45844. vertexOffsets: number[];
  45845. }
  45846. /** @hidden */
  45847. export interface IWebGPURenderPipelineStageDescriptor {
  45848. vertexStage: GPUProgrammableStageDescriptor;
  45849. fragmentStage?: GPUProgrammableStageDescriptor;
  45850. }
  45851. /** @hidden */
  45852. export class WebGPUPipelineContext implements IPipelineContext {
  45853. engine: WebGPUEngine;
  45854. shaderProcessingContext: WebGPUShaderProcessingContext;
  45855. leftOverUniformsByName: {
  45856. [name: string]: string;
  45857. };
  45858. sources: {
  45859. vertex: string;
  45860. fragment: string;
  45861. rawVertex: string;
  45862. rawFragment: string;
  45863. };
  45864. stages: Nullable<IWebGPURenderPipelineStageDescriptor>;
  45865. samplers: {
  45866. [name: string]: Nullable<IWebGPUPipelineContextSamplerCache>;
  45867. };
  45868. textures: {
  45869. [name: string]: Nullable<IWebGPUPipelineContextTextureCache>;
  45870. };
  45871. bindGroupLayouts: GPUBindGroupLayout[];
  45872. /**
  45873. * Stores the uniform buffer
  45874. */
  45875. uniformBuffer: Nullable<UniformBuffer>;
  45876. onCompiled?: () => void;
  45877. get isAsync(): boolean;
  45878. get isReady(): boolean;
  45879. /** @hidden */
  45880. _name: string;
  45881. constructor(shaderProcessingContext: WebGPUShaderProcessingContext, engine: WebGPUEngine);
  45882. _handlesSpectorRebuildCallback(onCompiled: (program: any) => void): void;
  45883. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  45884. [key: string]: number;
  45885. }, uniformsNames: string[], uniforms: {
  45886. [key: string]: Nullable<WebGLUniformLocation>;
  45887. }, samplerList: string[], samplers: {
  45888. [key: string]: number;
  45889. }, attributesNames: string[], attributes: number[]): void;
  45890. /** @hidden */
  45891. /**
  45892. * Build the uniform buffer used in the material.
  45893. */
  45894. buildUniformLayout(): void;
  45895. /**
  45896. * Release all associated resources.
  45897. **/
  45898. dispose(): void;
  45899. /**
  45900. * Sets an integer value on a uniform variable.
  45901. * @param uniformName Name of the variable.
  45902. * @param value Value to be set.
  45903. */
  45904. setInt(uniformName: string, value: number): void;
  45905. /**
  45906. * Sets an int2 value on a uniform variable.
  45907. * @param uniformName Name of the variable.
  45908. * @param x First int in int2.
  45909. * @param y Second int in int2.
  45910. */
  45911. setInt2(uniformName: string, x: number, y: number): void;
  45912. /**
  45913. * Sets an int3 value on a uniform variable.
  45914. * @param uniformName Name of the variable.
  45915. * @param x First int in int3.
  45916. * @param y Second int in int3.
  45917. * @param z Third int in int3.
  45918. */
  45919. setInt3(uniformName: string, x: number, y: number, z: number): void;
  45920. /**
  45921. * Sets an int4 value on a uniform variable.
  45922. * @param uniformName Name of the variable.
  45923. * @param x First int in int4.
  45924. * @param y Second int in int4.
  45925. * @param z Third int in int4.
  45926. * @param w Fourth int in int4.
  45927. */
  45928. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  45929. /**
  45930. * Sets an int array on a uniform variable.
  45931. * @param uniformName Name of the variable.
  45932. * @param array array to be set.
  45933. */
  45934. setIntArray(uniformName: string, array: Int32Array): void;
  45935. /**
  45936. * 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)
  45937. * @param uniformName Name of the variable.
  45938. * @param array array to be set.
  45939. */
  45940. setIntArray2(uniformName: string, array: Int32Array): void;
  45941. /**
  45942. * 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)
  45943. * @param uniformName Name of the variable.
  45944. * @param array array to be set.
  45945. */
  45946. setIntArray3(uniformName: string, array: Int32Array): void;
  45947. /**
  45948. * 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)
  45949. * @param uniformName Name of the variable.
  45950. * @param array array to be set.
  45951. */
  45952. setIntArray4(uniformName: string, array: Int32Array): void;
  45953. /**
  45954. * Sets an array on a uniform variable.
  45955. * @param uniformName Name of the variable.
  45956. * @param array array to be set.
  45957. */
  45958. setArray(uniformName: string, array: number[]): void;
  45959. /**
  45960. * 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)
  45961. * @param uniformName Name of the variable.
  45962. * @param array array to be set.
  45963. */
  45964. setArray2(uniformName: string, array: number[]): void;
  45965. /**
  45966. * 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)
  45967. * @param uniformName Name of the variable.
  45968. * @param array array to be set.
  45969. * @returns this effect.
  45970. */
  45971. setArray3(uniformName: string, array: number[]): void;
  45972. /**
  45973. * 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)
  45974. * @param uniformName Name of the variable.
  45975. * @param array array to be set.
  45976. */
  45977. setArray4(uniformName: string, array: number[]): void;
  45978. /**
  45979. * Sets matrices on a uniform variable.
  45980. * @param uniformName Name of the variable.
  45981. * @param matrices matrices to be set.
  45982. */
  45983. setMatrices(uniformName: string, matrices: Float32Array): void;
  45984. /**
  45985. * Sets matrix on a uniform variable.
  45986. * @param uniformName Name of the variable.
  45987. * @param matrix matrix to be set.
  45988. */
  45989. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  45990. /**
  45991. * 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)
  45992. * @param uniformName Name of the variable.
  45993. * @param matrix matrix to be set.
  45994. */
  45995. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  45996. /**
  45997. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  45998. * @param uniformName Name of the variable.
  45999. * @param matrix matrix to be set.
  46000. */
  46001. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  46002. /**
  46003. * Sets a float on a uniform variable.
  46004. * @param uniformName Name of the variable.
  46005. * @param value value to be set.
  46006. * @returns this effect.
  46007. */
  46008. setFloat(uniformName: string, value: number): void;
  46009. /**
  46010. * Sets a Vector2 on a uniform variable.
  46011. * @param uniformName Name of the variable.
  46012. * @param vector2 vector2 to be set.
  46013. */
  46014. setVector2(uniformName: string, vector2: IVector2Like): void;
  46015. /**
  46016. * Sets a float2 on a uniform variable.
  46017. * @param uniformName Name of the variable.
  46018. * @param x First float in float2.
  46019. * @param y Second float in float2.
  46020. */
  46021. setFloat2(uniformName: string, x: number, y: number): void;
  46022. /**
  46023. * Sets a Vector3 on a uniform variable.
  46024. * @param uniformName Name of the variable.
  46025. * @param vector3 Value to be set.
  46026. */
  46027. setVector3(uniformName: string, vector3: IVector3Like): void;
  46028. /**
  46029. * Sets a float3 on a uniform variable.
  46030. * @param uniformName Name of the variable.
  46031. * @param x First float in float3.
  46032. * @param y Second float in float3.
  46033. * @param z Third float in float3.
  46034. */
  46035. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  46036. /**
  46037. * Sets a Vector4 on a uniform variable.
  46038. * @param uniformName Name of the variable.
  46039. * @param vector4 Value to be set.
  46040. */
  46041. setVector4(uniformName: string, vector4: IVector4Like): void;
  46042. /**
  46043. * Sets a float4 on a uniform variable.
  46044. * @param uniformName Name of the variable.
  46045. * @param x First float in float4.
  46046. * @param y Second float in float4.
  46047. * @param z Third float in float4.
  46048. * @param w Fourth float in float4.
  46049. * @returns this effect.
  46050. */
  46051. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  46052. /**
  46053. * Sets a Color3 on a uniform variable.
  46054. * @param uniformName Name of the variable.
  46055. * @param color3 Value to be set.
  46056. */
  46057. setColor3(uniformName: string, color3: IColor3Like): void;
  46058. /**
  46059. * Sets a Color4 on a uniform variable.
  46060. * @param uniformName Name of the variable.
  46061. * @param color3 Value to be set.
  46062. * @param alpha Alpha value to be set.
  46063. */
  46064. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  46065. /**
  46066. * Sets a Color4 on a uniform variable
  46067. * @param uniformName defines the name of the variable
  46068. * @param color4 defines the value to be set
  46069. */
  46070. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  46071. _getVertexShaderCode(): string | null;
  46072. _getFragmentShaderCode(): string | null;
  46073. }
  46074. }
  46075. declare module "babylonjs/Meshes/WebGPU/webgpuDataBuffer" {
  46076. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46077. /** @hidden */
  46078. export class WebGPUDataBuffer extends DataBuffer {
  46079. private _buffer;
  46080. constructor(resource: GPUBuffer);
  46081. get underlyingResource(): any;
  46082. }
  46083. }
  46084. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  46085. /**
  46086. * Class used to inline functions in shader code
  46087. */
  46088. export class ShaderCodeInliner {
  46089. private static readonly _RegexpFindFunctionNameAndType;
  46090. private _sourceCode;
  46091. private _functionDescr;
  46092. private _numMaxIterations;
  46093. /** Gets or sets the token used to mark the functions to inline */
  46094. inlineToken: string;
  46095. /** Gets or sets the debug mode */
  46096. debug: boolean;
  46097. /** Gets the code after the inlining process */
  46098. get code(): string;
  46099. /**
  46100. * Initializes the inliner
  46101. * @param sourceCode shader code source to inline
  46102. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  46103. */
  46104. constructor(sourceCode: string, numMaxIterations?: number);
  46105. /**
  46106. * Start the processing of the shader code
  46107. */
  46108. processCode(): void;
  46109. private _collectFunctions;
  46110. private _processInlining;
  46111. private _extractBetweenMarkers;
  46112. private _skipWhitespaces;
  46113. private _isIdentifierChar;
  46114. private _removeComments;
  46115. private _replaceFunctionCallsByCode;
  46116. private _findBackward;
  46117. private _escapeRegExp;
  46118. private _replaceNames;
  46119. }
  46120. }
  46121. declare module "babylonjs/Engines/WebGPU/webgpuShaderProcessors" {
  46122. import { Nullable } from "babylonjs/types";
  46123. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  46124. import { ShaderProcessingContext } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  46125. /** @hidden */
  46126. export class WebGPUShaderProcessor implements IShaderProcessor {
  46127. protected _missingVaryings: Array<string>;
  46128. protected _textureArrayProcessing: Array<string>;
  46129. protected _preProcessors: {
  46130. [key: string]: string;
  46131. };
  46132. private _getArraySize;
  46133. initializeShaders(processingContext: Nullable<ShaderProcessingContext>): void;
  46134. varyingProcessor(varying: string, isFragment: boolean, preProcessors: {
  46135. [key: string]: string;
  46136. }, processingContext: Nullable<ShaderProcessingContext>): string;
  46137. attributeProcessor(attribute: string, preProcessors: {
  46138. [key: string]: string;
  46139. }, processingContext: Nullable<ShaderProcessingContext>): string;
  46140. uniformProcessor(uniform: string, isFragment: boolean, preProcessors: {
  46141. [key: string]: string;
  46142. }, processingContext: Nullable<ShaderProcessingContext>): string;
  46143. uniformBufferProcessor(uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  46144. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  46145. private _applyTextureArrayProcessing;
  46146. finalizeShaders(vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>): {
  46147. vertexCode: string;
  46148. fragmentCode: string;
  46149. };
  46150. }
  46151. }
  46152. declare module "babylonjs/Engines/WebGPU/webgpuBufferManager" {
  46153. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46154. import { WebGPUDataBuffer } from "babylonjs/Meshes/WebGPU/webgpuDataBuffer";
  46155. import { Nullable } from "babylonjs/types";
  46156. /** @hidden */
  46157. export class WebGPUBufferManager {
  46158. private _device;
  46159. private _deferredReleaseBuffers;
  46160. private static _IsGPUBuffer;
  46161. constructor(device: GPUDevice);
  46162. createRawBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags, mappedAtCreation?: boolean): GPUBuffer;
  46163. createBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags): DataBuffer;
  46164. setSubData(dataBuffer: WebGPUDataBuffer, dstByteOffset: number, src: ArrayBufferView, srcByteOffset?: number, byteLength?: number): void;
  46165. private _FromHalfFloat;
  46166. private _GetHalfFloatAsFloatRGBAArrayBuffer;
  46167. readDataFromBuffer(gpuBuffer: GPUBuffer, size: number, width: number, height: number, bytesPerRow: number, bytesPerRowAligned: number, floatFormat?: number, offset?: number, buffer?: Nullable<ArrayBufferView>, destroyBuffer?: boolean): Promise<ArrayBufferView>;
  46168. releaseBuffer(buffer: DataBuffer | GPUBuffer): boolean;
  46169. destroyDeferredBuffers(): void;
  46170. }
  46171. }
  46172. declare module "babylonjs/Engines/WebGPU/webgpuHardwareTexture" {
  46173. import { HardwareTextureWrapper } from "babylonjs/Materials/Textures/hardwareTextureWrapper";
  46174. import { Nullable } from "babylonjs/types";
  46175. /** @hidden */
  46176. export class WebGPUHardwareTexture implements HardwareTextureWrapper {
  46177. private _webgpuTexture;
  46178. private _webgpuMSAATexture;
  46179. get underlyingResource(): Nullable<GPUTexture>;
  46180. get msaaTexture(): Nullable<GPUTexture>;
  46181. set msaaTexture(texture: Nullable<GPUTexture>);
  46182. view: Nullable<GPUTextureView>;
  46183. format: GPUTextureFormat;
  46184. textureUsages: number;
  46185. constructor(existingTexture?: Nullable<GPUTexture>);
  46186. set(hardwareTexture: GPUTexture): void;
  46187. setMSAATexture(hardwareTexture: GPUTexture): void;
  46188. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  46189. createView(descriptor?: GPUTextureViewDescriptor): void;
  46190. reset(): void;
  46191. release(): void;
  46192. }
  46193. }
  46194. declare module "babylonjs/Engines/WebGPU/webgpuTextureHelper" {
  46195. import { WebGPUBufferManager } from "babylonjs/Engines/WebGPU/webgpuBufferManager";
  46196. import { Nullable } from "babylonjs/types";
  46197. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46198. import { WebGPUHardwareTexture } from "babylonjs/Engines/WebGPU/webgpuHardwareTexture";
  46199. import { IColor4Like } from "babylonjs/Maths/math.like";
  46200. /** @hidden */
  46201. export class WebGPUTextureHelper {
  46202. private _device;
  46203. private _glslang;
  46204. private _bufferManager;
  46205. private _mipmapSampler;
  46206. private _invertYPreMultiplyAlphaSampler;
  46207. private _pipelines;
  46208. private _compiledShaders;
  46209. private _deferredReleaseTextures;
  46210. private _commandEncoderForCreation;
  46211. static ComputeNumMipmapLevels(width: number, height: number): number;
  46212. constructor(device: GPUDevice, glslang: any, bufferManager: WebGPUBufferManager);
  46213. private _getPipeline;
  46214. private static _GetTextureTypeFromFormat;
  46215. private static _GetBlockInformationFromFormat;
  46216. private static _IsHardwareTexture;
  46217. private static _IsInternalTexture;
  46218. static GetCompareFunction(compareFunction: Nullable<number>): GPUCompareFunction;
  46219. static IsImageBitmap(imageBitmap: ImageBitmap | {
  46220. width: number;
  46221. height: number;
  46222. }): imageBitmap is ImageBitmap;
  46223. static IsImageBitmapArray(imageBitmap: ImageBitmap[] | {
  46224. width: number;
  46225. height: number;
  46226. }): imageBitmap is ImageBitmap[];
  46227. setCommandEncoder(encoder: GPUCommandEncoder): void;
  46228. static IsCompressedFormat(format: GPUTextureFormat): boolean;
  46229. static GetWebGPUTextureFormat(type: number, format: number): GPUTextureFormat;
  46230. invertYPreMultiplyAlpha(gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  46231. clear(format: GPUTextureFormat, color: IColor4Like, passEncoder: GPURenderPassEncoder): void;
  46232. createTexture(imageBitmap: ImageBitmap | {
  46233. width: number;
  46234. height: number;
  46235. layers: number;
  46236. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, is3D?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  46237. createCubeTexture(imageBitmaps: ImageBitmap[] | {
  46238. width: number;
  46239. height: number;
  46240. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  46241. generateCubeMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, commandEncoder?: GPUCommandEncoder): void;
  46242. generateMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  46243. createGPUTextureForInternalTexture(texture: InternalTexture, width?: number, height?: number, depth?: number): WebGPUHardwareTexture;
  46244. createMSAATexture(texture: InternalTexture, samples: number): void;
  46245. updateCubeTextures(imageBitmaps: ImageBitmap[] | Uint8Array[], gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, offsetX?: number, offsetY?: number, commandEncoder?: GPUCommandEncoder): void;
  46246. 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;
  46247. readPixels(texture: GPUTexture, x: number, y: number, width: number, height: number, format: GPUTextureFormat, faceIndex?: number, mipLevel?: number, buffer?: Nullable<ArrayBufferView>): Promise<ArrayBufferView>;
  46248. releaseTexture(texture: InternalTexture | GPUTexture): void;
  46249. destroyDeferredTextures(): void;
  46250. }
  46251. }
  46252. declare module "babylonjs/Engines/WebGPU/webgpuRenderPassWrapper" {
  46253. import { Nullable } from "babylonjs/types";
  46254. import { WebGPUHardwareTexture } from "babylonjs/Engines/WebGPU/webgpuHardwareTexture";
  46255. /** @hidden */
  46256. export class WebGPURenderPassWrapper {
  46257. renderPassDescriptor: Nullable<GPURenderPassDescriptor>;
  46258. renderPass: Nullable<GPURenderPassEncoder>;
  46259. colorAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  46260. depthAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  46261. colorAttachmentGPUTextures: WebGPUHardwareTexture[];
  46262. depthTextureFormat: GPUTextureFormat | undefined;
  46263. constructor();
  46264. reset(fullReset?: boolean): void;
  46265. }
  46266. }
  46267. declare module "babylonjs/Engines/WebGPU/webgpuCacheSampler" {
  46268. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46269. /** @hidden */
  46270. export class WebGPUCacheSampler {
  46271. private _samplers;
  46272. private _device;
  46273. constructor(device: GPUDevice);
  46274. private static _GetSamplerHashCode;
  46275. private static _GetSamplerFilterDescriptor;
  46276. private static _GetWrappingMode;
  46277. private static _GetSamplerWrappingDescriptor;
  46278. private static _GetSamplerDescriptor;
  46279. getSampler(internalTexture: InternalTexture, bypassCache?: boolean): GPUSampler;
  46280. }
  46281. }
  46282. declare module "babylonjs/Engines/WebGPU/webgpuShaderManager" {
  46283. import { IWebGPURenderPipelineStageDescriptor } from "babylonjs/Engines/WebGPU/webgpuPipelineContext";
  46284. /** @hidden */
  46285. export class WebGPUShaderManager {
  46286. private _shaders;
  46287. private _device;
  46288. constructor(device: GPUDevice);
  46289. getCompiledShaders(name: string): IWebGPURenderPipelineStageDescriptor;
  46290. }
  46291. }
  46292. declare module "babylonjs/Shaders/clearQuad.vertex" {
  46293. /** @hidden */
  46294. export var clearQuadVertexShader: {
  46295. name: string;
  46296. shader: string;
  46297. };
  46298. }
  46299. declare module "babylonjs/Shaders/clearQuad.fragment" {
  46300. /** @hidden */
  46301. export var clearQuadPixelShader: {
  46302. name: string;
  46303. shader: string;
  46304. };
  46305. }
  46306. declare module "babylonjs/Engines/webgpuEngine" {
  46307. import { Nullable, DataArray, IndicesArray, FloatArray, Immutable } from "babylonjs/types";
  46308. import { Engine } from "babylonjs/Engines/engine";
  46309. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  46310. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46311. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46312. import { IEffectCreationOptions, Effect } from "babylonjs/Materials/effect";
  46313. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  46314. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46315. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46316. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46317. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46318. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  46319. import { ShaderProcessingContext } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  46320. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  46321. import { Scene } from "babylonjs/scene";
  46322. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  46323. import { HardwareTextureWrapper } from "babylonjs/Materials/Textures/hardwareTextureWrapper";
  46324. import { IColor4Like } from "babylonjs/Maths/math.like";
  46325. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  46326. import "babylonjs/Shaders/clearQuad.vertex";
  46327. import "babylonjs/Shaders/clearQuad.fragment";
  46328. /**
  46329. * Options to load the associated Glslang library
  46330. */
  46331. export interface GlslangOptions {
  46332. /**
  46333. * Defines an existing instance of Glslang (usefull in modules who do not access the global instance).
  46334. */
  46335. glslang?: any;
  46336. /**
  46337. * Defines the URL of the glslang JS File.
  46338. */
  46339. jsPath?: string;
  46340. /**
  46341. * Defines the URL of the glslang WASM File.
  46342. */
  46343. wasmPath?: string;
  46344. }
  46345. /**
  46346. * Options to create the WebGPU engine
  46347. */
  46348. export interface WebGPUEngineOptions extends GPURequestAdapterOptions {
  46349. /**
  46350. * If delta time between frames should be constant
  46351. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46352. */
  46353. deterministicLockstep?: boolean;
  46354. /**
  46355. * Maximum about of steps between frames (Default: 4)
  46356. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46357. */
  46358. lockstepMaxSteps?: number;
  46359. /**
  46360. * Defines the seconds between each deterministic lock step
  46361. */
  46362. timeStep?: number;
  46363. /**
  46364. * Defines that engine should ignore modifying touch action attribute and style
  46365. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  46366. */
  46367. doNotHandleTouchAction?: boolean;
  46368. /**
  46369. * Defines if webaudio should be initialized as well
  46370. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  46371. */
  46372. audioEngine?: boolean;
  46373. /**
  46374. * Defines the category of adapter to use.
  46375. * Is it the discrete or integrated device.
  46376. */
  46377. powerPreference?: GPUPowerPreference;
  46378. /**
  46379. * Defines the device descriptor used to create a device.
  46380. */
  46381. deviceDescriptor?: GPUDeviceDescriptor;
  46382. /**
  46383. * Defines the requested Swap Chain Format.
  46384. */
  46385. swapChainFormat?: GPUTextureFormat;
  46386. /**
  46387. * Defines wether MSAA is enabled on the canvas.
  46388. */
  46389. antialiasing?: boolean;
  46390. /**
  46391. * Defines wether the stencil buffer should be enabled.
  46392. */
  46393. stencil?: boolean;
  46394. /**
  46395. * Defines wether we should generate debug markers in the gpu command lists (can be seen with PIX for eg)
  46396. */
  46397. enableGPUDebugMarkers?: boolean;
  46398. }
  46399. /**
  46400. * The web GPU engine class provides support for WebGPU version of babylon.js.
  46401. */
  46402. export class WebGPUEngine extends Engine {
  46403. private static readonly _glslangDefaultOptions;
  46404. private readonly _uploadEncoderDescriptor;
  46405. private readonly _renderEncoderDescriptor;
  46406. private readonly _renderTargetEncoderDescriptor;
  46407. private readonly _clearDepthValue;
  46408. private readonly _clearReverseDepthValue;
  46409. private readonly _clearStencilValue;
  46410. private readonly _defaultSampleCount;
  46411. private _canvas;
  46412. private _options;
  46413. private _glslang;
  46414. private _adapter;
  46415. private _adapterSupportedExtensions;
  46416. private _device;
  46417. private _deviceEnabledExtensions;
  46418. private _context;
  46419. private _swapChain;
  46420. private _swapChainTexture;
  46421. private _mainPassSampleCount;
  46422. private _textureHelper;
  46423. private _bufferManager;
  46424. private _shaderManager;
  46425. private _cacheSampler;
  46426. private _emptyVertexBuffer;
  46427. private _lastCachedWrapU;
  46428. private _lastCachedWrapV;
  46429. private _lastCachedWrapR;
  46430. private _mrtAttachments;
  46431. private _counters;
  46432. private _mainTexture;
  46433. private _depthTexture;
  46434. private _mainTextureExtends;
  46435. private _depthTextureFormat;
  46436. private _colorFormat;
  46437. private _uploadEncoder;
  46438. private _renderEncoder;
  46439. private _renderTargetEncoder;
  46440. private _commandBuffers;
  46441. private _currentRenderPass;
  46442. private _mainRenderPassWrapper;
  46443. private _rttRenderPassWrapper;
  46444. private _pendingDebugCommands;
  46445. private _currentVertexBuffers;
  46446. private _currentIndexBuffer;
  46447. private __colorWrite;
  46448. private _uniformsBuffers;
  46449. private _forceEnableEffect;
  46450. /** @hidden */
  46451. dbgShowShaderCode: boolean;
  46452. /** @hidden */
  46453. dbgSanityChecks: boolean;
  46454. /** @hidden */
  46455. dbgGenerateLogs: boolean;
  46456. /** @hidden */
  46457. dbgVerboseLogsForFirstFrames: boolean;
  46458. /** @hidden */
  46459. dbgVerboseLogsNumFrames: number;
  46460. /** @hidden */
  46461. dbgShowWarningsNotImplemented: boolean;
  46462. /**
  46463. * Gets a boolean indicating that the engine supports uniform buffers
  46464. */
  46465. get supportsUniformBuffers(): boolean;
  46466. /** Gets the supported extensions by the WebGPU adapter */
  46467. get supportedExtensions(): Immutable<GPUExtensionName[]>;
  46468. /** Gets the currently enabled extensions on the WebGPU device */
  46469. get enabledExtensions(): Immutable<GPUExtensionName[]>;
  46470. /**
  46471. * Returns the name of the engine
  46472. */
  46473. get name(): string;
  46474. /**
  46475. * Returns a string describing the current engine
  46476. */
  46477. get description(): string;
  46478. /**
  46479. * Returns the version of the engine
  46480. */
  46481. get version(): number;
  46482. /**
  46483. * Create a new instance of the gpu engine.
  46484. * @param canvas Defines the canvas to use to display the result
  46485. * @param options Defines the options passed to the engine to create the GPU context dependencies
  46486. */
  46487. constructor(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions);
  46488. /**
  46489. * Initializes the WebGPU context and dependencies.
  46490. * @param glslangOptions Defines the GLSLang compiler options if necessary
  46491. * @returns a promise notifying the readiness of the engine.
  46492. */
  46493. initAsync(glslangOptions?: GlslangOptions): Promise<void>;
  46494. private _initGlslang;
  46495. private _initializeLimits;
  46496. private _initializeContextAndSwapChain;
  46497. private _initializeMainAttachments;
  46498. /**
  46499. * Force a specific size of the canvas
  46500. * @param width defines the new canvas' width
  46501. * @param height defines the new canvas' height
  46502. * @param forceSetSize true to force setting the sizes of the underlying canvas
  46503. * @returns true if the size was changed
  46504. */
  46505. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  46506. /**
  46507. * Gets a shader processor implementation fitting with the current engine type.
  46508. * @returns The shader processor implementation.
  46509. */
  46510. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  46511. /** @hidden */
  46512. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  46513. /**
  46514. * Force the entire cache to be cleared
  46515. * You should not have to use this function unless your engine needs to share the WebGPU context with another engine
  46516. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46517. */
  46518. wipeCaches(bruteForce?: boolean): void;
  46519. /**
  46520. * Enable or disable color writing
  46521. * @param enable defines the state to set
  46522. */
  46523. setColorWrite(enable: boolean): void;
  46524. /**
  46525. * Gets a boolean indicating if color writing is enabled
  46526. * @returns the current color writing state
  46527. */
  46528. getColorWrite(): boolean;
  46529. private _viewportsCurrent;
  46530. private _resetCurrentViewport;
  46531. private _applyViewport;
  46532. /** @hidden */
  46533. _viewport(x: number, y: number, width: number, height: number): void;
  46534. private _scissorsCurrent;
  46535. protected _scissorCached: {
  46536. x: number;
  46537. y: number;
  46538. z: number;
  46539. w: number;
  46540. };
  46541. private _resetCurrentScissor;
  46542. private _applyScissor;
  46543. private _scissorIsActive;
  46544. enableScissor(x: number, y: number, width: number, height: number): void;
  46545. disableScissor(): void;
  46546. /**
  46547. * Clear the current render buffer or the current render target (if any is set up)
  46548. * @param color defines the color to use
  46549. * @param backBuffer defines if the back buffer must be cleared
  46550. * @param depth defines if the depth buffer must be cleared
  46551. * @param stencil defines if the stencil buffer must be cleared
  46552. */
  46553. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46554. /**
  46555. * Clears a list of attachments
  46556. * @param attachments list of the attachments
  46557. * @param colorMain clear color for the main attachment (the first one)
  46558. * @param colorOthers clear color for the other attachments
  46559. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  46560. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  46561. */
  46562. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  46563. /**
  46564. * Creates a vertex buffer
  46565. * @param data the data for the vertex buffer
  46566. * @returns the new buffer
  46567. */
  46568. createVertexBuffer(data: DataArray): DataBuffer;
  46569. /**
  46570. * Creates a vertex buffer
  46571. * @param data the data for the dynamic vertex buffer
  46572. * @returns the new buffer
  46573. */
  46574. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  46575. /**
  46576. * Updates a vertex buffer.
  46577. * @param vertexBuffer the vertex buffer to update
  46578. * @param data the data used to update the vertex buffer
  46579. * @param byteOffset the byte offset of the data
  46580. * @param byteLength the byte length of the data
  46581. */
  46582. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46583. /**
  46584. * Creates a new index buffer
  46585. * @param indices defines the content of the index buffer
  46586. * @param updatable defines if the index buffer must be updatable - not used in WebGPU
  46587. * @returns a new buffer
  46588. */
  46589. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  46590. /**
  46591. * Update an index buffer
  46592. * @param indexBuffer defines the target index buffer
  46593. * @param indices defines the data to update
  46594. * @param offset defines the offset in the target index buffer where update should start
  46595. */
  46596. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  46597. /** @hidden */
  46598. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  46599. /** @hidden */
  46600. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  46601. /**
  46602. * Bind a list of vertex buffers with the engine
  46603. * @param vertexBuffers defines the list of vertex buffers to bind
  46604. * @param indexBuffer defines the index buffer to bind
  46605. * @param effect defines the effect associated with the vertex buffers
  46606. */
  46607. bindBuffers(vertexBuffers: {
  46608. [key: string]: Nullable<VertexBuffer>;
  46609. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  46610. /** @hidden */
  46611. _releaseBuffer(buffer: DataBuffer): boolean;
  46612. createUniformBuffer(elements: FloatArray): DataBuffer;
  46613. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  46614. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  46615. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  46616. /**
  46617. * Create a new effect (used to store vertex/fragment shaders)
  46618. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  46619. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  46620. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  46621. * @param samplers defines an array of string used to represent textures
  46622. * @param defines defines the string containing the defines to use to compile the shaders
  46623. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  46624. * @param onCompiled defines a function to call when the effect creation is successful
  46625. * @param onError defines a function to call when the effect creation has failed
  46626. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  46627. * @returns the new Effect
  46628. */
  46629. 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;
  46630. private _compileRawShaderToSpirV;
  46631. private _compileShaderToSpirV;
  46632. private _createPipelineStageDescriptor;
  46633. private _compileRawPipelineStageDescriptor;
  46634. private _compilePipelineStageDescriptor;
  46635. /** @hidden */
  46636. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  46637. /** @hidden */
  46638. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  46639. /**
  46640. * Creates a new pipeline context
  46641. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  46642. * @returns the new pipeline
  46643. */
  46644. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  46645. /** @hidden */
  46646. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  46647. /**
  46648. * Gets the list of active attributes for a given WebGPU program
  46649. * @param pipelineContext defines the pipeline context to use
  46650. * @param attributesNames defines the list of attribute names to get
  46651. * @returns an array of indices indicating the offset of each attribute
  46652. */
  46653. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46654. /**
  46655. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46656. * @param effect defines the effect to activate
  46657. */
  46658. enableEffect(effect: Nullable<Effect>): void;
  46659. /** @hidden */
  46660. _releaseEffect(effect: Effect): void;
  46661. /**
  46662. * 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
  46663. */
  46664. releaseEffects(): void;
  46665. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46666. /**
  46667. * Gets a boolean indicating that only power of 2 textures are supported
  46668. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  46669. */
  46670. get needPOTTextures(): boolean;
  46671. /** @hidden */
  46672. _createHardwareTexture(): HardwareTextureWrapper;
  46673. /** @hidden */
  46674. _releaseTexture(texture: InternalTexture): void;
  46675. /** @hidden */
  46676. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  46677. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  46678. /**
  46679. * Usually called from Texture.ts.
  46680. * Passed information to create a hardware texture
  46681. * @param url defines a value which contains one of the following:
  46682. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46683. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46684. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46685. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46686. * @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)
  46687. * @param scene needed for loading to the correct scene
  46688. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46689. * @param onLoad optional callback to be called upon successful completion
  46690. * @param onError optional callback to be called upon failure
  46691. * @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
  46692. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46693. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46694. * @param forcedExtension defines the extension to use to pick the right loader
  46695. * @param mimeType defines an optional mime type
  46696. * @param loaderOptions options to be passed to the loader
  46697. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46698. */
  46699. 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;
  46700. /** @hidden */
  46701. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  46702. /**
  46703. * Creates a cube texture
  46704. * @param rootUrl defines the url where the files to load is located
  46705. * @param scene defines the current scene
  46706. * @param files defines the list of files to load (1 per face)
  46707. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  46708. * @param onLoad defines an optional callback raised when the texture is loaded
  46709. * @param onError defines an optional callback raised if there is an issue to load the texture
  46710. * @param format defines the format of the data
  46711. * @param forcedExtension defines the extension to use to pick the right loader
  46712. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  46713. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46714. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46715. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  46716. * @param loaderOptions options to be passed to the loader
  46717. * @returns the cube texture as an InternalTexture
  46718. */
  46719. 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;
  46720. /**
  46721. * Creates a raw texture
  46722. * @param data defines the data to store in the texture
  46723. * @param width defines the width of the texture
  46724. * @param height defines the height of the texture
  46725. * @param format defines the format of the data
  46726. * @param generateMipMaps defines if the engine should generate the mip levels
  46727. * @param invertY defines if data must be stored with Y axis inverted
  46728. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  46729. * @param compression defines the compression used (null by default)
  46730. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  46731. * @returns the raw texture inside an InternalTexture
  46732. */
  46733. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  46734. /**
  46735. * Creates a new raw cube texture
  46736. * @param data defines the array of data to use to create each face
  46737. * @param size defines the size of the textures
  46738. * @param format defines the format of the data
  46739. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  46740. * @param generateMipMaps defines if the engine should generate the mip levels
  46741. * @param invertY defines if data must be stored with Y axis inverted
  46742. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  46743. * @param compression defines the compression used (null by default)
  46744. * @returns the cube texture as an InternalTexture
  46745. */
  46746. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  46747. /**
  46748. * Creates a new raw cube texture from a specified url
  46749. * @param url defines the url where the data is located
  46750. * @param scene defines the current scene
  46751. * @param size defines the size of the textures
  46752. * @param format defines the format of the data
  46753. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  46754. * @param noMipmap defines if the engine should avoid generating the mip levels
  46755. * @param callback defines a callback used to extract texture data from loaded data
  46756. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  46757. * @param onLoad defines a callback called when texture is loaded
  46758. * @param onError defines a callback called if there is an error
  46759. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  46760. * @param invertY defines if data must be stored with Y axis inverted
  46761. * @returns the cube texture as an InternalTexture
  46762. */
  46763. 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;
  46764. /**
  46765. * Creates a new raw 2D array texture
  46766. * @param data defines the data used to create the texture
  46767. * @param width defines the width of the texture
  46768. * @param height defines the height of the texture
  46769. * @param depth defines the number of layers of the texture
  46770. * @param format defines the format of the texture
  46771. * @param generateMipMaps defines if the engine must generate mip levels
  46772. * @param invertY defines if data must be stored with Y axis inverted
  46773. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  46774. * @param compression defines the compressed used (can be null)
  46775. * @param textureType defines the compressed used (can be null)
  46776. * @returns a new raw 2D array texture (stored in an InternalTexture)
  46777. */
  46778. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  46779. /**
  46780. * Creates a new raw 3D texture
  46781. * @param data defines the data used to create the texture
  46782. * @param width defines the width of the texture
  46783. * @param height defines the height of the texture
  46784. * @param depth defines the depth of the texture
  46785. * @param format defines the format of the texture
  46786. * @param generateMipMaps defines if the engine must generate mip levels
  46787. * @param invertY defines if data must be stored with Y axis inverted
  46788. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  46789. * @param compression defines the compressed used (can be null)
  46790. * @param textureType defines the compressed used (can be null)
  46791. * @returns a new raw 3D texture (stored in an InternalTexture)
  46792. */
  46793. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  46794. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  46795. /**
  46796. * Update the sampling mode of a given texture
  46797. * @param samplingMode defines the required sampling mode
  46798. * @param texture defines the texture to update
  46799. * @param generateMipMaps defines whether to generate mipmaps for the texture
  46800. */
  46801. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  46802. /**
  46803. * Update the sampling mode of a given texture
  46804. * @param texture defines the texture to update
  46805. * @param wrapU defines the texture wrap mode of the u coordinates
  46806. * @param wrapV defines the texture wrap mode of the v coordinates
  46807. * @param wrapR defines the texture wrap mode of the r coordinates
  46808. */
  46809. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  46810. /**
  46811. * Update the dimensions of a texture
  46812. * @param texture texture to update
  46813. * @param width new width of the texture
  46814. * @param height new height of the texture
  46815. * @param depth new depth of the texture
  46816. */
  46817. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  46818. private _setInternalTexture;
  46819. /**
  46820. * Sets a texture to the according uniform.
  46821. * @param channel The texture channel
  46822. * @param unused unused parameter
  46823. * @param texture The texture to apply
  46824. * @param name The name of the uniform in the effect
  46825. */
  46826. setTexture(channel: number, unused: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>, name: string): void;
  46827. /**
  46828. * Sets an array of texture to the WebGPU context
  46829. * @param channel defines the channel where the texture array must be set
  46830. * @param unused unused parameter
  46831. * @param textures defines the array of textures to bind
  46832. * @param name name of the channel
  46833. */
  46834. setTextureArray(channel: number, unused: Nullable<WebGLUniformLocation>, textures: BaseTexture[], name: string): void;
  46835. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string, baseName?: string, textureIndex?: number): boolean;
  46836. /** @hidden */
  46837. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  46838. /** @hidden */
  46839. _bindTexture(channel: number, texture: InternalTexture, name: string): void;
  46840. private _generateMipmaps;
  46841. /**
  46842. * Update the content of a texture
  46843. * @param texture defines the texture to update
  46844. * @param canvas defines the source containing the data
  46845. * @param invertY defines if data must be stored with Y axis inverted
  46846. * @param premulAlpha defines if alpha is stored as premultiplied
  46847. * @param format defines the format of the data
  46848. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46849. */
  46850. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  46851. /**
  46852. * Update a portion of an internal texture
  46853. * @param texture defines the texture to update
  46854. * @param imageData defines the data to store into the texture
  46855. * @param xOffset defines the x coordinates of the update rectangle
  46856. * @param yOffset defines the y coordinates of the update rectangle
  46857. * @param width defines the width of the update rectangle
  46858. * @param height defines the height of the update rectangle
  46859. * @param faceIndex defines the face index if texture is a cube (0 by default)
  46860. * @param lod defines the lod level to update (0 by default)
  46861. */
  46862. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  46863. /**
  46864. * Update a video texture
  46865. * @param texture defines the texture to update
  46866. * @param video defines the video element to use
  46867. * @param invertY defines if data must be stored with Y axis inverted
  46868. */
  46869. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  46870. /** @hidden */
  46871. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46872. /** @hidden */
  46873. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  46874. /** @hidden */
  46875. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46876. /** @hidden */
  46877. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  46878. /**
  46879. * Update a raw texture
  46880. * @param texture defines the texture to update
  46881. * @param bufferView defines the data to store in the texture
  46882. * @param format defines the format of the data
  46883. * @param invertY defines if data must be stored with Y axis inverted
  46884. * @param compression defines the compression used (null by default)
  46885. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  46886. */
  46887. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  46888. /**
  46889. * Update a raw cube texture
  46890. * @param texture defines the texture to udpdate
  46891. * @param bufferView defines the data to store
  46892. * @param format defines the data format
  46893. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  46894. * @param invertY defines if data must be stored with Y axis inverted
  46895. * @param compression defines the compression used (null by default)
  46896. * @param level defines which level of the texture to update
  46897. */
  46898. updateRawCubeTexture(texture: InternalTexture, bufferView: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  46899. /**
  46900. * Update a raw 2D array texture
  46901. * @param texture defines the texture to update
  46902. * @param bufferView defines the data to store
  46903. * @param format defines the data format
  46904. * @param invertY defines if data must be stored with Y axis inverted
  46905. * @param compression defines the used compression (can be null)
  46906. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  46907. */
  46908. updateRawTexture2DArray(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  46909. /**
  46910. * Update a raw 3D texture
  46911. * @param texture defines the texture to update
  46912. * @param bufferView defines the data to store
  46913. * @param format defines the data format
  46914. * @param invertY defines if data must be stored with Y axis inverted
  46915. * @param compression defines the used compression (can be null)
  46916. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  46917. */
  46918. updateRawTexture3D(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  46919. /**
  46920. * Reads pixels from the current frame buffer. Please note that this function can be slow
  46921. * @param x defines the x coordinate of the rectangle where pixels must be read
  46922. * @param y defines the y coordinate of the rectangle where pixels must be read
  46923. * @param width defines the width of the rectangle where pixels must be read
  46924. * @param height defines the height of the rectangle where pixels must be read
  46925. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  46926. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  46927. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  46928. */
  46929. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  46930. /** @hidden */
  46931. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  46932. /**
  46933. * Creates a new render target texture
  46934. * @param size defines the size of the texture
  46935. * @param options defines the options used to create the texture
  46936. * @returns a new render target texture stored in an InternalTexture
  46937. */
  46938. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46939. /**
  46940. * Create a multi render target texture
  46941. * @param size defines the size of the texture
  46942. * @param options defines the creation options
  46943. * @returns the cube texture as an InternalTexture
  46944. */
  46945. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46946. /**
  46947. * Creates a new render target cube texture
  46948. * @param size defines the size of the texture
  46949. * @param options defines the options used to create the texture
  46950. * @returns a new render target cube texture stored in an InternalTexture
  46951. */
  46952. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  46953. /** @hidden */
  46954. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  46955. width: number;
  46956. height: number;
  46957. layers?: number;
  46958. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  46959. /** @hidden */
  46960. _createDepthStencilTexture(size: number | {
  46961. width: number;
  46962. height: number;
  46963. layers?: number;
  46964. }, options: DepthTextureCreationOptions): InternalTexture;
  46965. /** @hidden */
  46966. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  46967. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  46968. /**
  46969. * Update the sample count for a given multiple render target texture
  46970. * @param textures defines the textures to update
  46971. * @param samples defines the sample count to set
  46972. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46973. */
  46974. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46975. /**
  46976. * Begin a new frame
  46977. */
  46978. beginFrame(): void;
  46979. /**
  46980. * End the current frame
  46981. */
  46982. endFrame(): void;
  46983. /**
  46984. * Force a WebGPU flush (ie. a flush of all waiting commands)
  46985. */
  46986. flushFramebuffer(): void;
  46987. private _startRenderTargetRenderPass;
  46988. private _endRenderTargetRenderPass;
  46989. private _getCurrentRenderPass;
  46990. private _currentRenderPassIsMRT;
  46991. private _startMainRenderPass;
  46992. private _endMainRenderPass;
  46993. /**
  46994. * Restores the WebGPU state to only draw on the main color attachment
  46995. */
  46996. restoreSingleAttachment(): void;
  46997. /**
  46998. * Creates a layout object to draw/clear on specific textures in a MRT
  46999. * @param textureStatus textureStatus[i] indicates if the i-th is active
  47000. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  47001. */
  47002. buildTextureLayout(textureStatus: boolean[]): number[];
  47003. /**
  47004. * Select a subsets of attachments to draw to.
  47005. * @param attachments index of attachments
  47006. */
  47007. bindAttachments(attachments: number[]): void;
  47008. /**
  47009. * Binds the frame buffer to the specified texture.
  47010. * @param texture The texture to render to or null for the default canvas
  47011. * @param faceIndex The face of the texture to render to in case of cube texture
  47012. * @param requiredWidth The width of the target to render to
  47013. * @param requiredHeight The height of the target to render to
  47014. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  47015. * @param lodLevel defines the lod level to bind to the frame buffer
  47016. * @param layer defines the 2d array index to bind to frame buffer to
  47017. */
  47018. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  47019. /**
  47020. * Unbind the current render target texture from the WebGPU context
  47021. * @param texture defines the render target texture to unbind
  47022. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47023. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47024. */
  47025. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47026. /**
  47027. * Unbind a list of render target textures from the WebGPU context
  47028. * @param textures defines the render target textures to unbind
  47029. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47030. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47031. */
  47032. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47033. /**
  47034. * Unbind the current render target and bind the default framebuffer
  47035. */
  47036. restoreDefaultFramebuffer(): void;
  47037. setZOffset(value: number): void;
  47038. private _setColorFormat;
  47039. private _setDepthTextureFormat;
  47040. setDepthBuffer(enable: boolean): void;
  47041. setDepthWrite(enable: boolean): void;
  47042. setStencilBuffer(enable: boolean): void;
  47043. setStencilMask(mask: number): void;
  47044. setStencilFunction(stencilFunc: number): void;
  47045. setStencilFunctionReference(reference: number): void;
  47046. setStencilFunctionMask(mask: number): void;
  47047. setStencilOperationFail(operation: number): void;
  47048. setStencilOperationDepthFail(operation: number): void;
  47049. setStencilOperationPass(operation: number): void;
  47050. setDitheringState(value: boolean): void;
  47051. setRasterizerState(value: boolean): void;
  47052. setDepthFunction(depthFunc: number): void;
  47053. setDepthFunctionToGreater(): void;
  47054. setDepthFunctionToGreaterOrEqual(): void;
  47055. setDepthFunctionToLess(): void;
  47056. setDepthFunctionToLessOrEqual(): void;
  47057. private _indexFormatInRenderPass;
  47058. private _getTopology;
  47059. private _getOpFunction;
  47060. private _getDepthStencilStateDescriptor;
  47061. /**
  47062. * Set various states to the context
  47063. * @param culling defines backface culling state
  47064. * @param zOffset defines the value to apply to zOffset (0 by default)
  47065. * @param force defines if states must be applied even if cache is up to date
  47066. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  47067. */
  47068. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47069. private _getFrontFace;
  47070. private _getCullMode;
  47071. private _getRasterizationStateDescriptor;
  47072. private _getWriteMask;
  47073. /**
  47074. * Sets the current alpha mode
  47075. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  47076. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47077. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47078. */
  47079. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47080. private _getAphaBlendOperation;
  47081. private _getAphaBlendFactor;
  47082. private _getAphaBlendState;
  47083. private _getColorBlendState;
  47084. private _getColorStateDescriptors;
  47085. private _getStages;
  47086. private _getVertexInputDescriptorFormat;
  47087. private _getVertexInputDescriptor;
  47088. private _getPipelineLayout;
  47089. private _getRenderPipeline;
  47090. private _getVertexInputsToRender;
  47091. private _getBindGroupsToRender;
  47092. private _bindVertexInputs;
  47093. private _setRenderBindGroups;
  47094. private _setRenderPipeline;
  47095. /**
  47096. * Draw a list of indexed primitives
  47097. * @param fillMode defines the primitive to use
  47098. * @param indexStart defines the starting index
  47099. * @param indexCount defines the number of index to draw
  47100. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47101. */
  47102. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47103. /**
  47104. * Draw a list of unindexed primitives
  47105. * @param fillMode defines the primitive to use
  47106. * @param verticesStart defines the index of first vertex to draw
  47107. * @param verticesCount defines the count of vertices to draw
  47108. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47109. */
  47110. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47111. private _bundleEncoder;
  47112. /**
  47113. * Start recording all the gpu calls into a bundle.
  47114. */
  47115. startRecordBundle(): void;
  47116. /**
  47117. * Stops recording the bundle.
  47118. * @returns the recorded bundle
  47119. */
  47120. stopRecordBundle(): GPURenderBundle;
  47121. /**
  47122. * Execute the previously recorded bundle.
  47123. * @param bundles defines the bundle to replay
  47124. */
  47125. executeBundles(bundles: GPURenderBundle[]): void;
  47126. /**
  47127. * Dispose and release all associated resources
  47128. */
  47129. dispose(): void;
  47130. /**
  47131. * Gets the current render width
  47132. * @param useScreen defines if screen size must be used (or the current render target if any)
  47133. * @returns a number defining the current render width
  47134. */
  47135. getRenderWidth(useScreen?: boolean): number;
  47136. /**
  47137. * Gets the current render height
  47138. * @param useScreen defines if screen size must be used (or the current render target if any)
  47139. * @returns a number defining the current render height
  47140. */
  47141. getRenderHeight(useScreen?: boolean): number;
  47142. /**
  47143. * Gets the HTML canvas attached with the current WebGPU context
  47144. * @returns a HTML canvas
  47145. */
  47146. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  47147. /** @hidden */
  47148. _debugPushGroup(groupName: string, targetObject?: number): void;
  47149. /** @hidden */
  47150. _debugPopGroup(targetObject?: number): void;
  47151. /** @hidden */
  47152. _debugInsertMarker(text: string, targetObject?: number): void;
  47153. private _debugFlushPendingCommands;
  47154. /**
  47155. * Get the current error code of the WebGPU context
  47156. * @returns the error code
  47157. */
  47158. getError(): number;
  47159. /** @hidden */
  47160. bindSamplers(effect: Effect): void;
  47161. /** @hidden */
  47162. _bindTextureDirectly(target: number, texture: InternalTexture, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  47163. /** @hidden */
  47164. _releaseFramebufferObjects(texture: InternalTexture): void;
  47165. /** @hidden */
  47166. applyStates(): void;
  47167. /**
  47168. * Gets a boolean indicating if all created effects are ready
  47169. * @returns always true - No parallel shader compilation
  47170. */
  47171. areAllEffectsReady(): boolean;
  47172. /** @hidden */
  47173. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47174. /** @hidden */
  47175. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47176. /** @hidden */
  47177. _getUnpackAlignement(): number;
  47178. /** @hidden */
  47179. _unpackFlipY(value: boolean): void;
  47180. /** @hidden */
  47181. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  47182. min: number;
  47183. mag: number;
  47184. };
  47185. /** @hidden */
  47186. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47187. /** @hidden */
  47188. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  47189. /** @hidden */
  47190. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  47191. /** @hidden */
  47192. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  47193. /** @hidden */
  47194. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  47195. /** @hidden */
  47196. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  47197. /** @hidden */
  47198. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  47199. /** @hidden */
  47200. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  47201. /** @hidden */
  47202. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  47203. /** @hidden */
  47204. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  47205. /** @hidden */
  47206. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  47207. /** @hidden */
  47208. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  47209. /** @hidden */
  47210. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  47211. /** @hidden */
  47212. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  47213. /** @hidden */
  47214. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  47215. /** @hidden */
  47216. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  47217. /** @hidden */
  47218. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  47219. }
  47220. }
  47221. declare module "babylonjs/scene" {
  47222. import { Nullable } from "babylonjs/types";
  47223. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47224. import { Observable } from "babylonjs/Misc/observable";
  47225. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47226. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  47227. import { Geometry } from "babylonjs/Meshes/geometry";
  47228. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47229. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47230. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47231. import { Mesh } from "babylonjs/Meshes/mesh";
  47232. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  47233. import { Bone } from "babylonjs/Bones/bone";
  47234. import { Skeleton } from "babylonjs/Bones/skeleton";
  47235. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  47236. import { Camera } from "babylonjs/Cameras/camera";
  47237. import { AbstractScene } from "babylonjs/abstractScene";
  47238. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47239. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47240. import { Material } from "babylonjs/Materials/material";
  47241. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47242. import { Effect } from "babylonjs/Materials/effect";
  47243. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47244. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  47245. import { Light } from "babylonjs/Lights/light";
  47246. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  47247. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  47248. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  47249. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  47250. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  47251. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  47252. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  47253. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, PreActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  47254. import { Engine } from "babylonjs/Engines/engine";
  47255. import { Node } from "babylonjs/node";
  47256. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  47257. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  47258. import { WebRequest } from "babylonjs/Misc/webRequest";
  47259. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  47260. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  47261. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  47262. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  47263. import { Plane } from "babylonjs/Maths/math.plane";
  47264. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  47265. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  47266. import { Ray } from "babylonjs/Culling/ray";
  47267. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  47268. import { Animation } from "babylonjs/Animations/animation";
  47269. import { Animatable } from "babylonjs/Animations/animatable";
  47270. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  47271. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  47272. import { Collider } from "babylonjs/Collisions/collider";
  47273. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  47274. /**
  47275. * Define an interface for all classes that will hold resources
  47276. */
  47277. export interface IDisposable {
  47278. /**
  47279. * Releases all held resources
  47280. */
  47281. dispose(): void;
  47282. }
  47283. /** Interface defining initialization parameters for Scene class */
  47284. export interface SceneOptions {
  47285. /**
  47286. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  47287. * It will improve performance when the number of geometries becomes important.
  47288. */
  47289. useGeometryUniqueIdsMap?: boolean;
  47290. /**
  47291. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  47292. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  47293. */
  47294. useMaterialMeshMap?: boolean;
  47295. /**
  47296. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  47297. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  47298. */
  47299. useClonedMeshMap?: boolean;
  47300. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  47301. virtual?: boolean;
  47302. }
  47303. /**
  47304. * Represents a scene to be rendered by the engine.
  47305. * @see https://doc.babylonjs.com/features/scene
  47306. */
  47307. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  47308. /** The fog is deactivated */
  47309. static readonly FOGMODE_NONE: number;
  47310. /** The fog density is following an exponential function */
  47311. static readonly FOGMODE_EXP: number;
  47312. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  47313. static readonly FOGMODE_EXP2: number;
  47314. /** The fog density is following a linear function. */
  47315. static readonly FOGMODE_LINEAR: number;
  47316. /**
  47317. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  47318. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47319. */
  47320. static MinDeltaTime: number;
  47321. /**
  47322. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  47323. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47324. */
  47325. static MaxDeltaTime: number;
  47326. /**
  47327. * Factory used to create the default material.
  47328. * @param name The name of the material to create
  47329. * @param scene The scene to create the material for
  47330. * @returns The default material
  47331. */
  47332. static DefaultMaterialFactory(scene: Scene): Material;
  47333. /**
  47334. * Factory used to create the a collision coordinator.
  47335. * @returns The collision coordinator
  47336. */
  47337. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  47338. /** @hidden */
  47339. _inputManager: InputManager;
  47340. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  47341. cameraToUseForPointers: Nullable<Camera>;
  47342. /** @hidden */
  47343. readonly _isScene: boolean;
  47344. /** @hidden */
  47345. _blockEntityCollection: boolean;
  47346. /**
  47347. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  47348. */
  47349. autoClear: boolean;
  47350. /**
  47351. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  47352. */
  47353. autoClearDepthAndStencil: boolean;
  47354. /**
  47355. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  47356. */
  47357. clearColor: Color4;
  47358. /**
  47359. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  47360. */
  47361. ambientColor: Color3;
  47362. /**
  47363. * This is use to store the default BRDF lookup for PBR materials in your scene.
  47364. * It should only be one of the following (if not the default embedded one):
  47365. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47366. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  47367. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47368. * The material properties need to be setup according to the type of texture in use.
  47369. */
  47370. environmentBRDFTexture: BaseTexture;
  47371. /**
  47372. * Texture used in all pbr material as the reflection texture.
  47373. * As in the majority of the scene they are the same (exception for multi room and so on),
  47374. * this is easier to reference from here than from all the materials.
  47375. */
  47376. get environmentTexture(): Nullable<BaseTexture>;
  47377. /**
  47378. * Texture used in all pbr material as the reflection texture.
  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 environmentTexture(value: Nullable<BaseTexture>);
  47383. /** @hidden */
  47384. protected _environmentIntensity: number;
  47385. /**
  47386. * Intensity of the environment in all pbr material.
  47387. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  47388. * As in the majority of the scene they are the same (exception for multi room and so on),
  47389. * this is easier to reference from here than from all the materials.
  47390. */
  47391. get environmentIntensity(): number;
  47392. /**
  47393. * Intensity of the environment in all pbr material.
  47394. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  47395. * As in the majority of the scene they are the same (exception for multi room and so on),
  47396. * this is easier to set here than in all the materials.
  47397. */
  47398. set environmentIntensity(value: number);
  47399. /** @hidden */
  47400. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47401. /**
  47402. * Default image processing configuration used either in the rendering
  47403. * Forward main pass or through the imageProcessingPostProcess if present.
  47404. * As in the majority of the scene they are the same (exception for multi camera),
  47405. * this is easier to reference from here than from all the materials and post process.
  47406. *
  47407. * No setter as we it is a shared configuration, you can set the values instead.
  47408. */
  47409. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  47410. private _forceWireframe;
  47411. /**
  47412. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  47413. */
  47414. set forceWireframe(value: boolean);
  47415. get forceWireframe(): boolean;
  47416. private _skipFrustumClipping;
  47417. /**
  47418. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  47419. */
  47420. set skipFrustumClipping(value: boolean);
  47421. get skipFrustumClipping(): boolean;
  47422. private _forcePointsCloud;
  47423. /**
  47424. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  47425. */
  47426. set forcePointsCloud(value: boolean);
  47427. get forcePointsCloud(): boolean;
  47428. /**
  47429. * Gets or sets the active clipplane 1
  47430. */
  47431. clipPlane: Nullable<Plane>;
  47432. /**
  47433. * Gets or sets the active clipplane 2
  47434. */
  47435. clipPlane2: Nullable<Plane>;
  47436. /**
  47437. * Gets or sets the active clipplane 3
  47438. */
  47439. clipPlane3: Nullable<Plane>;
  47440. /**
  47441. * Gets or sets the active clipplane 4
  47442. */
  47443. clipPlane4: Nullable<Plane>;
  47444. /**
  47445. * Gets or sets the active clipplane 5
  47446. */
  47447. clipPlane5: Nullable<Plane>;
  47448. /**
  47449. * Gets or sets the active clipplane 6
  47450. */
  47451. clipPlane6: Nullable<Plane>;
  47452. /**
  47453. * Gets or sets a boolean indicating if animations are enabled
  47454. */
  47455. animationsEnabled: boolean;
  47456. private _animationPropertiesOverride;
  47457. /**
  47458. * Gets or sets the animation properties override
  47459. */
  47460. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  47461. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  47462. /**
  47463. * Gets or sets a boolean indicating if a constant deltatime has to be used
  47464. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  47465. */
  47466. useConstantAnimationDeltaTime: boolean;
  47467. /**
  47468. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  47469. * Please note that it requires to run a ray cast through the scene on every frame
  47470. */
  47471. constantlyUpdateMeshUnderPointer: boolean;
  47472. /**
  47473. * Defines the HTML cursor to use when hovering over interactive elements
  47474. */
  47475. hoverCursor: string;
  47476. /**
  47477. * Defines the HTML default cursor to use (empty by default)
  47478. */
  47479. defaultCursor: string;
  47480. /**
  47481. * Defines whether cursors are handled by the scene.
  47482. */
  47483. doNotHandleCursors: boolean;
  47484. /**
  47485. * This is used to call preventDefault() on pointer down
  47486. * in order to block unwanted artifacts like system double clicks
  47487. */
  47488. preventDefaultOnPointerDown: boolean;
  47489. /**
  47490. * This is used to call preventDefault() on pointer up
  47491. * in order to block unwanted artifacts like system double clicks
  47492. */
  47493. preventDefaultOnPointerUp: boolean;
  47494. /**
  47495. * Gets or sets user defined metadata
  47496. */
  47497. metadata: any;
  47498. /**
  47499. * For internal use only. Please do not use.
  47500. */
  47501. reservedDataStore: any;
  47502. /**
  47503. * Gets the name of the plugin used to load this scene (null by default)
  47504. */
  47505. loadingPluginName: string;
  47506. /**
  47507. * Use this array to add regular expressions used to disable offline support for specific urls
  47508. */
  47509. disableOfflineSupportExceptionRules: RegExp[];
  47510. /**
  47511. * An event triggered when the scene is disposed.
  47512. */
  47513. onDisposeObservable: Observable<Scene>;
  47514. private _onDisposeObserver;
  47515. /** Sets a function to be executed when this scene is disposed. */
  47516. set onDispose(callback: () => void);
  47517. /**
  47518. * An event triggered before rendering the scene (right after animations and physics)
  47519. */
  47520. onBeforeRenderObservable: Observable<Scene>;
  47521. private _onBeforeRenderObserver;
  47522. /** Sets a function to be executed before rendering this scene */
  47523. set beforeRender(callback: Nullable<() => void>);
  47524. /**
  47525. * An event triggered after rendering the scene
  47526. */
  47527. onAfterRenderObservable: Observable<Scene>;
  47528. /**
  47529. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  47530. */
  47531. onAfterRenderCameraObservable: Observable<Camera>;
  47532. private _onAfterRenderObserver;
  47533. /** Sets a function to be executed after rendering this scene */
  47534. set afterRender(callback: Nullable<() => void>);
  47535. /**
  47536. * An event triggered before animating the scene
  47537. */
  47538. onBeforeAnimationsObservable: Observable<Scene>;
  47539. /**
  47540. * An event triggered after animations processing
  47541. */
  47542. onAfterAnimationsObservable: Observable<Scene>;
  47543. /**
  47544. * An event triggered before draw calls are ready to be sent
  47545. */
  47546. onBeforeDrawPhaseObservable: Observable<Scene>;
  47547. /**
  47548. * An event triggered after draw calls have been sent
  47549. */
  47550. onAfterDrawPhaseObservable: Observable<Scene>;
  47551. /**
  47552. * An event triggered when the scene is ready
  47553. */
  47554. onReadyObservable: Observable<Scene>;
  47555. /**
  47556. * An event triggered before rendering a camera
  47557. */
  47558. onBeforeCameraRenderObservable: Observable<Camera>;
  47559. private _onBeforeCameraRenderObserver;
  47560. /** Sets a function to be executed before rendering a camera*/
  47561. set beforeCameraRender(callback: () => void);
  47562. /**
  47563. * An event triggered after rendering a camera
  47564. */
  47565. onAfterCameraRenderObservable: Observable<Camera>;
  47566. private _onAfterCameraRenderObserver;
  47567. /** Sets a function to be executed after rendering a camera*/
  47568. set afterCameraRender(callback: () => void);
  47569. /**
  47570. * An event triggered when active meshes evaluation is about to start
  47571. */
  47572. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  47573. /**
  47574. * An event triggered when active meshes evaluation is done
  47575. */
  47576. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  47577. /**
  47578. * An event triggered when particles rendering is about to start
  47579. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  47580. */
  47581. onBeforeParticlesRenderingObservable: Observable<Scene>;
  47582. /**
  47583. * An event triggered when particles rendering is done
  47584. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  47585. */
  47586. onAfterParticlesRenderingObservable: Observable<Scene>;
  47587. /**
  47588. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  47589. */
  47590. onDataLoadedObservable: Observable<Scene>;
  47591. /**
  47592. * An event triggered when a camera is created
  47593. */
  47594. onNewCameraAddedObservable: Observable<Camera>;
  47595. /**
  47596. * An event triggered when a camera is removed
  47597. */
  47598. onCameraRemovedObservable: Observable<Camera>;
  47599. /**
  47600. * An event triggered when a light is created
  47601. */
  47602. onNewLightAddedObservable: Observable<Light>;
  47603. /**
  47604. * An event triggered when a light is removed
  47605. */
  47606. onLightRemovedObservable: Observable<Light>;
  47607. /**
  47608. * An event triggered when a geometry is created
  47609. */
  47610. onNewGeometryAddedObservable: Observable<Geometry>;
  47611. /**
  47612. * An event triggered when a geometry is removed
  47613. */
  47614. onGeometryRemovedObservable: Observable<Geometry>;
  47615. /**
  47616. * An event triggered when a transform node is created
  47617. */
  47618. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  47619. /**
  47620. * An event triggered when a transform node is removed
  47621. */
  47622. onTransformNodeRemovedObservable: Observable<TransformNode>;
  47623. /**
  47624. * An event triggered when a mesh is created
  47625. */
  47626. onNewMeshAddedObservable: Observable<AbstractMesh>;
  47627. /**
  47628. * An event triggered when a mesh is removed
  47629. */
  47630. onMeshRemovedObservable: Observable<AbstractMesh>;
  47631. /**
  47632. * An event triggered when a skeleton is created
  47633. */
  47634. onNewSkeletonAddedObservable: Observable<Skeleton>;
  47635. /**
  47636. * An event triggered when a skeleton is removed
  47637. */
  47638. onSkeletonRemovedObservable: Observable<Skeleton>;
  47639. /**
  47640. * An event triggered when a material is created
  47641. */
  47642. onNewMaterialAddedObservable: Observable<Material>;
  47643. /**
  47644. * An event triggered when a multi material is created
  47645. */
  47646. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  47647. /**
  47648. * An event triggered when a material is removed
  47649. */
  47650. onMaterialRemovedObservable: Observable<Material>;
  47651. /**
  47652. * An event triggered when a multi material is removed
  47653. */
  47654. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  47655. /**
  47656. * An event triggered when a texture is created
  47657. */
  47658. onNewTextureAddedObservable: Observable<BaseTexture>;
  47659. /**
  47660. * An event triggered when a texture is removed
  47661. */
  47662. onTextureRemovedObservable: Observable<BaseTexture>;
  47663. /**
  47664. * An event triggered when render targets are about to be rendered
  47665. * Can happen multiple times per frame.
  47666. */
  47667. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  47668. /**
  47669. * An event triggered when render targets were rendered.
  47670. * Can happen multiple times per frame.
  47671. */
  47672. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  47673. /**
  47674. * An event triggered before calculating deterministic simulation step
  47675. */
  47676. onBeforeStepObservable: Observable<Scene>;
  47677. /**
  47678. * An event triggered after calculating deterministic simulation step
  47679. */
  47680. onAfterStepObservable: Observable<Scene>;
  47681. /**
  47682. * An event triggered when the activeCamera property is updated
  47683. */
  47684. onActiveCameraChanged: Observable<Scene>;
  47685. /**
  47686. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  47687. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  47688. * 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)
  47689. */
  47690. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  47691. /**
  47692. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  47693. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  47694. * 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)
  47695. */
  47696. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  47697. /**
  47698. * This Observable will when a mesh has been imported into the scene.
  47699. */
  47700. onMeshImportedObservable: Observable<AbstractMesh>;
  47701. /**
  47702. * This Observable will when an animation file has been imported into the scene.
  47703. */
  47704. onAnimationFileImportedObservable: Observable<Scene>;
  47705. /**
  47706. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  47707. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  47708. */
  47709. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  47710. /** @hidden */
  47711. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  47712. /**
  47713. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  47714. */
  47715. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  47716. /**
  47717. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  47718. */
  47719. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  47720. /**
  47721. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  47722. */
  47723. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  47724. /** Callback called when a pointer move is detected */
  47725. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  47726. /** Callback called when a pointer down is detected */
  47727. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  47728. /** Callback called when a pointer up is detected */
  47729. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  47730. /** Callback called when a pointer pick is detected */
  47731. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  47732. /**
  47733. * 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).
  47734. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  47735. */
  47736. onPrePointerObservable: Observable<PointerInfoPre>;
  47737. /**
  47738. * Observable event triggered each time an input event is received from the rendering canvas
  47739. */
  47740. onPointerObservable: Observable<PointerInfo>;
  47741. /**
  47742. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  47743. */
  47744. get unTranslatedPointer(): Vector2;
  47745. /**
  47746. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  47747. */
  47748. static get DragMovementThreshold(): number;
  47749. static set DragMovementThreshold(value: number);
  47750. /**
  47751. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  47752. */
  47753. static get LongPressDelay(): number;
  47754. static set LongPressDelay(value: number);
  47755. /**
  47756. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  47757. */
  47758. static get DoubleClickDelay(): number;
  47759. static set DoubleClickDelay(value: number);
  47760. /** If you need to check double click without raising a single click at first click, enable this flag */
  47761. static get ExclusiveDoubleClickMode(): boolean;
  47762. static set ExclusiveDoubleClickMode(value: boolean);
  47763. /** @hidden */
  47764. _mirroredCameraPosition: Nullable<Vector3>;
  47765. /**
  47766. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  47767. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  47768. */
  47769. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  47770. /**
  47771. * Observable event triggered each time an keyboard event is received from the hosting window
  47772. */
  47773. onKeyboardObservable: Observable<KeyboardInfo>;
  47774. private _useRightHandedSystem;
  47775. /**
  47776. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  47777. */
  47778. set useRightHandedSystem(value: boolean);
  47779. get useRightHandedSystem(): boolean;
  47780. private _timeAccumulator;
  47781. private _currentStepId;
  47782. private _currentInternalStep;
  47783. /**
  47784. * Sets the step Id used by deterministic lock step
  47785. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47786. * @param newStepId defines the step Id
  47787. */
  47788. setStepId(newStepId: number): void;
  47789. /**
  47790. * Gets the step Id used by deterministic lock step
  47791. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47792. * @returns the step Id
  47793. */
  47794. getStepId(): number;
  47795. /**
  47796. * Gets the internal step used by deterministic lock step
  47797. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47798. * @returns the internal step
  47799. */
  47800. getInternalStep(): number;
  47801. private _fogEnabled;
  47802. /**
  47803. * Gets or sets a boolean indicating if fog is enabled on this scene
  47804. * @see https://doc.babylonjs.com/babylon101/environment#fog
  47805. * (Default is true)
  47806. */
  47807. set fogEnabled(value: boolean);
  47808. get fogEnabled(): boolean;
  47809. private _fogMode;
  47810. /**
  47811. * Gets or sets the fog mode to use
  47812. * @see https://doc.babylonjs.com/babylon101/environment#fog
  47813. * | mode | value |
  47814. * | --- | --- |
  47815. * | FOGMODE_NONE | 0 |
  47816. * | FOGMODE_EXP | 1 |
  47817. * | FOGMODE_EXP2 | 2 |
  47818. * | FOGMODE_LINEAR | 3 |
  47819. */
  47820. set fogMode(value: number);
  47821. get fogMode(): number;
  47822. /**
  47823. * Gets or sets the fog color to use
  47824. * @see https://doc.babylonjs.com/babylon101/environment#fog
  47825. * (Default is Color3(0.2, 0.2, 0.3))
  47826. */
  47827. fogColor: Color3;
  47828. /**
  47829. * Gets or sets the fog density to use
  47830. * @see https://doc.babylonjs.com/babylon101/environment#fog
  47831. * (Default is 0.1)
  47832. */
  47833. fogDensity: number;
  47834. /**
  47835. * Gets or sets the fog start distance to use
  47836. * @see https://doc.babylonjs.com/babylon101/environment#fog
  47837. * (Default is 0)
  47838. */
  47839. fogStart: number;
  47840. /**
  47841. * Gets or sets the fog end distance to use
  47842. * @see https://doc.babylonjs.com/babylon101/environment#fog
  47843. * (Default is 1000)
  47844. */
  47845. fogEnd: number;
  47846. /**
  47847. * Flag indicating that the frame buffer binding is handled by another component
  47848. */
  47849. prePass: boolean;
  47850. private _shadowsEnabled;
  47851. /**
  47852. * Gets or sets a boolean indicating if shadows are enabled on this scene
  47853. */
  47854. set shadowsEnabled(value: boolean);
  47855. get shadowsEnabled(): boolean;
  47856. private _lightsEnabled;
  47857. /**
  47858. * Gets or sets a boolean indicating if lights are enabled on this scene
  47859. */
  47860. set lightsEnabled(value: boolean);
  47861. get lightsEnabled(): boolean;
  47862. /** All of the active cameras added to this scene. */
  47863. activeCameras: Nullable<Camera[]>;
  47864. /** @hidden */
  47865. _activeCamera: Nullable<Camera>;
  47866. /** Gets or sets the current active camera */
  47867. get activeCamera(): Nullable<Camera>;
  47868. set activeCamera(value: Nullable<Camera>);
  47869. private _defaultMaterial;
  47870. /** The default material used on meshes when no material is affected */
  47871. get defaultMaterial(): Material;
  47872. /** The default material used on meshes when no material is affected */
  47873. set defaultMaterial(value: Material);
  47874. private _texturesEnabled;
  47875. /**
  47876. * Gets or sets a boolean indicating if textures are enabled on this scene
  47877. */
  47878. set texturesEnabled(value: boolean);
  47879. get texturesEnabled(): boolean;
  47880. /**
  47881. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  47882. */
  47883. physicsEnabled: boolean;
  47884. /**
  47885. * Gets or sets a boolean indicating if particles are enabled on this scene
  47886. */
  47887. particlesEnabled: boolean;
  47888. /**
  47889. * Gets or sets a boolean indicating if sprites are enabled on this scene
  47890. */
  47891. spritesEnabled: boolean;
  47892. private _skeletonsEnabled;
  47893. /**
  47894. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  47895. */
  47896. set skeletonsEnabled(value: boolean);
  47897. get skeletonsEnabled(): boolean;
  47898. /**
  47899. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  47900. */
  47901. lensFlaresEnabled: boolean;
  47902. /**
  47903. * Gets or sets a boolean indicating if collisions are enabled on this scene
  47904. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  47905. */
  47906. collisionsEnabled: boolean;
  47907. private _collisionCoordinator;
  47908. /** @hidden */
  47909. get collisionCoordinator(): ICollisionCoordinator;
  47910. /**
  47911. * Defines the gravity applied to this scene (used only for collisions)
  47912. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  47913. */
  47914. gravity: Vector3;
  47915. /**
  47916. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  47917. */
  47918. postProcessesEnabled: boolean;
  47919. /**
  47920. * Gets the current postprocess manager
  47921. */
  47922. postProcessManager: PostProcessManager;
  47923. /**
  47924. * Gets or sets a boolean indicating if render targets are enabled on this scene
  47925. */
  47926. renderTargetsEnabled: boolean;
  47927. /**
  47928. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  47929. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  47930. */
  47931. dumpNextRenderTargets: boolean;
  47932. /**
  47933. * The list of user defined render targets added to the scene
  47934. */
  47935. customRenderTargets: RenderTargetTexture[];
  47936. /**
  47937. * Defines if texture loading must be delayed
  47938. * If true, textures will only be loaded when they need to be rendered
  47939. */
  47940. useDelayedTextureLoading: boolean;
  47941. /**
  47942. * Gets the list of meshes imported to the scene through SceneLoader
  47943. */
  47944. importedMeshesFiles: String[];
  47945. /**
  47946. * Gets or sets a boolean indicating if probes are enabled on this scene
  47947. */
  47948. probesEnabled: boolean;
  47949. /**
  47950. * Gets or sets the current offline provider to use to store scene data
  47951. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  47952. */
  47953. offlineProvider: IOfflineProvider;
  47954. /**
  47955. * Gets or sets the action manager associated with the scene
  47956. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  47957. */
  47958. actionManager: AbstractActionManager;
  47959. private _meshesForIntersections;
  47960. /**
  47961. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  47962. */
  47963. proceduralTexturesEnabled: boolean;
  47964. private _engine;
  47965. private _totalVertices;
  47966. /** @hidden */
  47967. _activeIndices: PerfCounter;
  47968. /** @hidden */
  47969. _activeParticles: PerfCounter;
  47970. /** @hidden */
  47971. _activeBones: PerfCounter;
  47972. private _animationRatio;
  47973. /** @hidden */
  47974. _animationTimeLast: number;
  47975. /** @hidden */
  47976. _animationTime: number;
  47977. /**
  47978. * Gets or sets a general scale for animation speed
  47979. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  47980. */
  47981. animationTimeScale: number;
  47982. /** @hidden */
  47983. _cachedMaterial: Nullable<Material>;
  47984. /** @hidden */
  47985. _cachedEffect: Nullable<Effect>;
  47986. /** @hidden */
  47987. _cachedVisibility: Nullable<number>;
  47988. private _renderId;
  47989. private _frameId;
  47990. private _executeWhenReadyTimeoutId;
  47991. private _intermediateRendering;
  47992. private _viewUpdateFlag;
  47993. private _projectionUpdateFlag;
  47994. /** @hidden */
  47995. _toBeDisposed: Nullable<IDisposable>[];
  47996. private _activeRequests;
  47997. /** @hidden */
  47998. _pendingData: any[];
  47999. private _isDisposed;
  48000. /**
  48001. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  48002. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  48003. */
  48004. dispatchAllSubMeshesOfActiveMeshes: boolean;
  48005. private _activeMeshes;
  48006. private _processedMaterials;
  48007. private _renderTargets;
  48008. /** @hidden */
  48009. _activeParticleSystems: SmartArray<IParticleSystem>;
  48010. private _activeSkeletons;
  48011. private _softwareSkinnedMeshes;
  48012. private _renderingManager;
  48013. /** @hidden */
  48014. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  48015. private _transformMatrix;
  48016. private _sceneUbo;
  48017. /** @hidden */
  48018. _viewMatrix: Matrix;
  48019. /** @hidden */
  48020. _projectionMatrix: Matrix;
  48021. /** @hidden */
  48022. _forcedViewPosition: Nullable<Vector3>;
  48023. /** @hidden */
  48024. _frustumPlanes: Plane[];
  48025. /**
  48026. * Gets the list of frustum planes (built from the active camera)
  48027. */
  48028. get frustumPlanes(): Plane[];
  48029. /**
  48030. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  48031. * This is useful if there are more lights that the maximum simulteanous authorized
  48032. */
  48033. requireLightSorting: boolean;
  48034. /** @hidden */
  48035. readonly useMaterialMeshMap: boolean;
  48036. /** @hidden */
  48037. readonly useClonedMeshMap: boolean;
  48038. private _externalData;
  48039. private _uid;
  48040. /**
  48041. * @hidden
  48042. * Backing store of defined scene components.
  48043. */
  48044. _components: ISceneComponent[];
  48045. /**
  48046. * @hidden
  48047. * Backing store of defined scene components.
  48048. */
  48049. _serializableComponents: ISceneSerializableComponent[];
  48050. /**
  48051. * List of components to register on the next registration step.
  48052. */
  48053. private _transientComponents;
  48054. /**
  48055. * Registers the transient components if needed.
  48056. */
  48057. private _registerTransientComponents;
  48058. /**
  48059. * @hidden
  48060. * Add a component to the scene.
  48061. * Note that the ccomponent could be registered on th next frame if this is called after
  48062. * the register component stage.
  48063. * @param component Defines the component to add to the scene
  48064. */
  48065. _addComponent(component: ISceneComponent): void;
  48066. /**
  48067. * @hidden
  48068. * Gets a component from the scene.
  48069. * @param name defines the name of the component to retrieve
  48070. * @returns the component or null if not present
  48071. */
  48072. _getComponent(name: string): Nullable<ISceneComponent>;
  48073. /**
  48074. * @hidden
  48075. * Defines the actions happening before camera updates.
  48076. */
  48077. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  48078. /**
  48079. * @hidden
  48080. * Defines the actions happening before clear the canvas.
  48081. */
  48082. _beforeClearStage: Stage<SimpleStageAction>;
  48083. /**
  48084. * @hidden
  48085. * Defines the actions when collecting render targets for the frame.
  48086. */
  48087. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  48088. /**
  48089. * @hidden
  48090. * Defines the actions happening for one camera in the frame.
  48091. */
  48092. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  48093. /**
  48094. * @hidden
  48095. * Defines the actions happening during the per mesh ready checks.
  48096. */
  48097. _isReadyForMeshStage: Stage<MeshStageAction>;
  48098. /**
  48099. * @hidden
  48100. * Defines the actions happening before evaluate active mesh checks.
  48101. */
  48102. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  48103. /**
  48104. * @hidden
  48105. * Defines the actions happening during the evaluate sub mesh checks.
  48106. */
  48107. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  48108. /**
  48109. * @hidden
  48110. * Defines the actions happening during the active mesh stage.
  48111. */
  48112. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  48113. /**
  48114. * @hidden
  48115. * Defines the actions happening during the per camera render target step.
  48116. */
  48117. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  48118. /**
  48119. * @hidden
  48120. * Defines the actions happening just before the active camera is drawing.
  48121. */
  48122. _beforeCameraDrawStage: Stage<CameraStageAction>;
  48123. /**
  48124. * @hidden
  48125. * Defines the actions happening just before a render target is drawing.
  48126. */
  48127. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  48128. /**
  48129. * @hidden
  48130. * Defines the actions happening just before a rendering group is drawing.
  48131. */
  48132. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  48133. /**
  48134. * @hidden
  48135. * Defines the actions happening just before a mesh is drawing.
  48136. */
  48137. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  48138. /**
  48139. * @hidden
  48140. * Defines the actions happening just after a mesh has been drawn.
  48141. */
  48142. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  48143. /**
  48144. * @hidden
  48145. * Defines the actions happening just after a rendering group has been drawn.
  48146. */
  48147. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  48148. /**
  48149. * @hidden
  48150. * Defines the actions happening just after the active camera has been drawn.
  48151. */
  48152. _afterCameraDrawStage: Stage<CameraStageAction>;
  48153. /**
  48154. * @hidden
  48155. * Defines the actions happening just after a render target has been drawn.
  48156. */
  48157. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  48158. /**
  48159. * @hidden
  48160. * Defines the actions happening just after rendering all cameras and computing intersections.
  48161. */
  48162. _afterRenderStage: Stage<SimpleStageAction>;
  48163. /**
  48164. * @hidden
  48165. * Defines the actions happening when a pointer move event happens.
  48166. */
  48167. _pointerMoveStage: Stage<PointerMoveStageAction>;
  48168. /**
  48169. * @hidden
  48170. * Defines the actions happening when a pointer down event happens.
  48171. */
  48172. _pointerDownStage: Stage<PointerUpDownStageAction>;
  48173. /**
  48174. * @hidden
  48175. * Defines the actions happening when a pointer up event happens.
  48176. */
  48177. _pointerUpStage: Stage<PointerUpDownStageAction>;
  48178. /**
  48179. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  48180. */
  48181. private geometriesByUniqueId;
  48182. private _renderBundles;
  48183. /**
  48184. * Creates a new Scene
  48185. * @param engine defines the engine to use to render this scene
  48186. * @param options defines the scene options
  48187. */
  48188. constructor(engine: Engine, options?: SceneOptions);
  48189. /**
  48190. * Gets a string identifying the name of the class
  48191. * @returns "Scene" string
  48192. */
  48193. getClassName(): string;
  48194. private _defaultMeshCandidates;
  48195. /**
  48196. * @hidden
  48197. */
  48198. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  48199. private _defaultSubMeshCandidates;
  48200. /**
  48201. * @hidden
  48202. */
  48203. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  48204. /**
  48205. * Sets the default candidate providers for the scene.
  48206. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  48207. * and getCollidingSubMeshCandidates to their default function
  48208. */
  48209. setDefaultCandidateProviders(): void;
  48210. /**
  48211. * Gets the mesh that is currently under the pointer
  48212. */
  48213. get meshUnderPointer(): Nullable<AbstractMesh>;
  48214. /**
  48215. * Gets or sets the current on-screen X position of the pointer
  48216. */
  48217. get pointerX(): number;
  48218. set pointerX(value: number);
  48219. /**
  48220. * Gets or sets the current on-screen Y position of the pointer
  48221. */
  48222. get pointerY(): number;
  48223. set pointerY(value: number);
  48224. /**
  48225. * Gets the cached material (ie. the latest rendered one)
  48226. * @returns the cached material
  48227. */
  48228. getCachedMaterial(): Nullable<Material>;
  48229. /**
  48230. * Gets the cached effect (ie. the latest rendered one)
  48231. * @returns the cached effect
  48232. */
  48233. getCachedEffect(): Nullable<Effect>;
  48234. /**
  48235. * Gets the cached visibility state (ie. the latest rendered one)
  48236. * @returns the cached visibility state
  48237. */
  48238. getCachedVisibility(): Nullable<number>;
  48239. /**
  48240. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  48241. * @param material defines the current material
  48242. * @param effect defines the current effect
  48243. * @param visibility defines the current visibility state
  48244. * @returns true if one parameter is not cached
  48245. */
  48246. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  48247. /**
  48248. * Gets the engine associated with the scene
  48249. * @returns an Engine
  48250. */
  48251. getEngine(): Engine;
  48252. /**
  48253. * Gets the total number of vertices rendered per frame
  48254. * @returns the total number of vertices rendered per frame
  48255. */
  48256. getTotalVertices(): number;
  48257. /**
  48258. * Gets the performance counter for total vertices
  48259. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  48260. */
  48261. get totalVerticesPerfCounter(): PerfCounter;
  48262. /**
  48263. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  48264. * @returns the total number of active indices rendered per frame
  48265. */
  48266. getActiveIndices(): number;
  48267. /**
  48268. * Gets the performance counter for active indices
  48269. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  48270. */
  48271. get totalActiveIndicesPerfCounter(): PerfCounter;
  48272. /**
  48273. * Gets the total number of active particles rendered per frame
  48274. * @returns the total number of active particles rendered per frame
  48275. */
  48276. getActiveParticles(): number;
  48277. /**
  48278. * Gets the performance counter for active particles
  48279. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  48280. */
  48281. get activeParticlesPerfCounter(): PerfCounter;
  48282. /**
  48283. * Gets the total number of active bones rendered per frame
  48284. * @returns the total number of active bones rendered per frame
  48285. */
  48286. getActiveBones(): number;
  48287. /**
  48288. * Gets the performance counter for active bones
  48289. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  48290. */
  48291. get activeBonesPerfCounter(): PerfCounter;
  48292. /**
  48293. * Gets the array of active meshes
  48294. * @returns an array of AbstractMesh
  48295. */
  48296. getActiveMeshes(): SmartArray<AbstractMesh>;
  48297. /**
  48298. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  48299. * @returns a number
  48300. */
  48301. getAnimationRatio(): number;
  48302. /**
  48303. * Gets an unique Id for the current render phase
  48304. * @returns a number
  48305. */
  48306. getRenderId(): number;
  48307. /**
  48308. * Gets an unique Id for the current frame
  48309. * @returns a number
  48310. */
  48311. getFrameId(): number;
  48312. /** Call this function if you want to manually increment the render Id*/
  48313. incrementRenderId(): void;
  48314. private _createUbo;
  48315. /**
  48316. * Use this method to simulate a pointer move 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. * @returns the current scene
  48321. */
  48322. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  48323. /**
  48324. * Use this method to simulate a pointer down on a mesh
  48325. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  48326. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  48327. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  48328. * @returns the current scene
  48329. */
  48330. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  48331. /**
  48332. * Use this method to simulate a pointer up on a mesh
  48333. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  48334. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  48335. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  48336. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  48337. * @returns the current scene
  48338. */
  48339. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  48340. /**
  48341. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  48342. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  48343. * @returns true if the pointer was captured
  48344. */
  48345. isPointerCaptured(pointerId?: number): boolean;
  48346. /**
  48347. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  48348. * @param attachUp defines if you want to attach events to pointerup
  48349. * @param attachDown defines if you want to attach events to pointerdown
  48350. * @param attachMove defines if you want to attach events to pointermove
  48351. */
  48352. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  48353. /** Detaches all event handlers*/
  48354. detachControl(): void;
  48355. /**
  48356. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  48357. * Delay loaded resources are not taking in account
  48358. * @return true if all required resources are ready
  48359. */
  48360. isReady(): boolean;
  48361. /** Resets all cached information relative to material (including effect and visibility) */
  48362. resetCachedMaterial(): void;
  48363. /**
  48364. * Registers a function to be called before every frame render
  48365. * @param func defines the function to register
  48366. */
  48367. registerBeforeRender(func: () => void): void;
  48368. /**
  48369. * Unregisters a function called before every frame render
  48370. * @param func defines the function to unregister
  48371. */
  48372. unregisterBeforeRender(func: () => void): void;
  48373. /**
  48374. * Registers a function to be called after every frame render
  48375. * @param func defines the function to register
  48376. */
  48377. registerAfterRender(func: () => void): void;
  48378. /**
  48379. * Unregisters a function called after every frame render
  48380. * @param func defines the function to unregister
  48381. */
  48382. unregisterAfterRender(func: () => void): void;
  48383. private _executeOnceBeforeRender;
  48384. /**
  48385. * The provided function will run before render once and will be disposed afterwards.
  48386. * A timeout delay can be provided so that the function will be executed in N ms.
  48387. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  48388. * @param func The function to be executed.
  48389. * @param timeout optional delay in ms
  48390. */
  48391. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  48392. /** @hidden */
  48393. _addPendingData(data: any): void;
  48394. /** @hidden */
  48395. _removePendingData(data: any): void;
  48396. /**
  48397. * Returns the number of items waiting to be loaded
  48398. * @returns the number of items waiting to be loaded
  48399. */
  48400. getWaitingItemsCount(): number;
  48401. /**
  48402. * Returns a boolean indicating if the scene is still loading data
  48403. */
  48404. get isLoading(): boolean;
  48405. /**
  48406. * Registers a function to be executed when the scene is ready
  48407. * @param {Function} func - the function to be executed
  48408. */
  48409. executeWhenReady(func: () => void): void;
  48410. /**
  48411. * Returns a promise that resolves when the scene is ready
  48412. * @returns A promise that resolves when the scene is ready
  48413. */
  48414. whenReadyAsync(): Promise<void>;
  48415. /** @hidden */
  48416. _checkIsReady(): void;
  48417. /**
  48418. * Gets all animatable attached to the scene
  48419. */
  48420. get animatables(): Animatable[];
  48421. /**
  48422. * Resets the last animation time frame.
  48423. * Useful to override when animations start running when loading a scene for the first time.
  48424. */
  48425. resetLastAnimationTimeFrame(): void;
  48426. /**
  48427. * Gets the current view matrix
  48428. * @returns a Matrix
  48429. */
  48430. getViewMatrix(): Matrix;
  48431. /**
  48432. * Gets the current projection matrix
  48433. * @returns a Matrix
  48434. */
  48435. getProjectionMatrix(): Matrix;
  48436. /**
  48437. * Gets the current transform matrix
  48438. * @returns a Matrix made of View * Projection
  48439. */
  48440. getTransformMatrix(): Matrix;
  48441. /**
  48442. * Sets the current transform matrix
  48443. * @param viewL defines the View matrix to use
  48444. * @param projectionL defines the Projection matrix to use
  48445. * @param viewR defines the right View matrix to use (if provided)
  48446. * @param projectionR defines the right Projection matrix to use (if provided)
  48447. */
  48448. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  48449. /**
  48450. * Gets the uniform buffer used to store scene data
  48451. * @returns a UniformBuffer
  48452. */
  48453. getSceneUniformBuffer(): UniformBuffer;
  48454. /**
  48455. * Gets an unique (relatively to the current scene) Id
  48456. * @returns an unique number for the scene
  48457. */
  48458. getUniqueId(): number;
  48459. /**
  48460. * Add a mesh to the list of scene's meshes
  48461. * @param newMesh defines the mesh to add
  48462. * @param recursive if all child meshes should also be added to the scene
  48463. */
  48464. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  48465. /**
  48466. * Remove a mesh for the list of scene's meshes
  48467. * @param toRemove defines the mesh to remove
  48468. * @param recursive if all child meshes should also be removed from the scene
  48469. * @returns the index where the mesh was in the mesh list
  48470. */
  48471. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  48472. /**
  48473. * Add a transform node to the list of scene's transform nodes
  48474. * @param newTransformNode defines the transform node to add
  48475. */
  48476. addTransformNode(newTransformNode: TransformNode): void;
  48477. /**
  48478. * Remove a transform node for the list of scene's transform nodes
  48479. * @param toRemove defines the transform node to remove
  48480. * @returns the index where the transform node was in the transform node list
  48481. */
  48482. removeTransformNode(toRemove: TransformNode): number;
  48483. /**
  48484. * Remove a skeleton for the list of scene's skeletons
  48485. * @param toRemove defines the skeleton to remove
  48486. * @returns the index where the skeleton was in the skeleton list
  48487. */
  48488. removeSkeleton(toRemove: Skeleton): number;
  48489. /**
  48490. * Remove a morph target for the list of scene's morph targets
  48491. * @param toRemove defines the morph target to remove
  48492. * @returns the index where the morph target was in the morph target list
  48493. */
  48494. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  48495. /**
  48496. * Remove a light for the list of scene's lights
  48497. * @param toRemove defines the light to remove
  48498. * @returns the index where the light was in the light list
  48499. */
  48500. removeLight(toRemove: Light): number;
  48501. /**
  48502. * Remove a camera for the list of scene's cameras
  48503. * @param toRemove defines the camera to remove
  48504. * @returns the index where the camera was in the camera list
  48505. */
  48506. removeCamera(toRemove: Camera): number;
  48507. /**
  48508. * Remove a particle system for the list of scene's particle systems
  48509. * @param toRemove defines the particle system to remove
  48510. * @returns the index where the particle system was in the particle system list
  48511. */
  48512. removeParticleSystem(toRemove: IParticleSystem): number;
  48513. /**
  48514. * Remove a animation for the list of scene's animations
  48515. * @param toRemove defines the animation to remove
  48516. * @returns the index where the animation was in the animation list
  48517. */
  48518. removeAnimation(toRemove: Animation): number;
  48519. /**
  48520. * Will stop the animation of the given target
  48521. * @param target - the target
  48522. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  48523. * @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)
  48524. */
  48525. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  48526. /**
  48527. * Removes the given animation group from this scene.
  48528. * @param toRemove The animation group to remove
  48529. * @returns The index of the removed animation group
  48530. */
  48531. removeAnimationGroup(toRemove: AnimationGroup): number;
  48532. /**
  48533. * Removes the given multi-material from this scene.
  48534. * @param toRemove The multi-material to remove
  48535. * @returns The index of the removed multi-material
  48536. */
  48537. removeMultiMaterial(toRemove: MultiMaterial): number;
  48538. /**
  48539. * Removes the given material from this scene.
  48540. * @param toRemove The material to remove
  48541. * @returns The index of the removed material
  48542. */
  48543. removeMaterial(toRemove: Material): number;
  48544. /**
  48545. * Removes the given action manager from this scene.
  48546. * @param toRemove The action manager to remove
  48547. * @returns The index of the removed action manager
  48548. */
  48549. removeActionManager(toRemove: AbstractActionManager): number;
  48550. /**
  48551. * Removes the given texture from this scene.
  48552. * @param toRemove The texture to remove
  48553. * @returns The index of the removed texture
  48554. */
  48555. removeTexture(toRemove: BaseTexture): number;
  48556. /**
  48557. * Adds the given light to this scene
  48558. * @param newLight The light to add
  48559. */
  48560. addLight(newLight: Light): void;
  48561. /**
  48562. * Sorts the list list based on light priorities
  48563. */
  48564. sortLightsByPriority(): void;
  48565. /**
  48566. * Adds the given camera to this scene
  48567. * @param newCamera The camera to add
  48568. */
  48569. addCamera(newCamera: Camera): void;
  48570. /**
  48571. * Adds the given skeleton to this scene
  48572. * @param newSkeleton The skeleton to add
  48573. */
  48574. addSkeleton(newSkeleton: Skeleton): void;
  48575. /**
  48576. * Adds the given particle system to this scene
  48577. * @param newParticleSystem The particle system to add
  48578. */
  48579. addParticleSystem(newParticleSystem: IParticleSystem): void;
  48580. /**
  48581. * Adds the given animation to this scene
  48582. * @param newAnimation The animation to add
  48583. */
  48584. addAnimation(newAnimation: Animation): void;
  48585. /**
  48586. * Adds the given animation group to this scene.
  48587. * @param newAnimationGroup The animation group to add
  48588. */
  48589. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  48590. /**
  48591. * Adds the given multi-material to this scene
  48592. * @param newMultiMaterial The multi-material to add
  48593. */
  48594. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  48595. /**
  48596. * Adds the given material to this scene
  48597. * @param newMaterial The material to add
  48598. */
  48599. addMaterial(newMaterial: Material): void;
  48600. /**
  48601. * Adds the given morph target to this scene
  48602. * @param newMorphTargetManager The morph target to add
  48603. */
  48604. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  48605. /**
  48606. * Adds the given geometry to this scene
  48607. * @param newGeometry The geometry to add
  48608. */
  48609. addGeometry(newGeometry: Geometry): void;
  48610. /**
  48611. * Adds the given action manager to this scene
  48612. * @param newActionManager The action manager to add
  48613. */
  48614. addActionManager(newActionManager: AbstractActionManager): void;
  48615. /**
  48616. * Adds the given texture to this scene.
  48617. * @param newTexture The texture to add
  48618. */
  48619. addTexture(newTexture: BaseTexture): void;
  48620. /**
  48621. * Switch active camera
  48622. * @param newCamera defines the new active camera
  48623. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  48624. */
  48625. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  48626. /**
  48627. * sets the active camera of the scene using its ID
  48628. * @param id defines the camera's ID
  48629. * @return the new active camera or null if none found.
  48630. */
  48631. setActiveCameraByID(id: string): Nullable<Camera>;
  48632. /**
  48633. * sets the active camera of the scene using its name
  48634. * @param name defines the camera's name
  48635. * @returns the new active camera or null if none found.
  48636. */
  48637. setActiveCameraByName(name: string): Nullable<Camera>;
  48638. /**
  48639. * get an animation group using its name
  48640. * @param name defines the material's name
  48641. * @return the animation group or null if none found.
  48642. */
  48643. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  48644. /**
  48645. * Get a material using its unique id
  48646. * @param uniqueId defines the material's unique id
  48647. * @return the material or null if none found.
  48648. */
  48649. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  48650. /**
  48651. * get a material using its id
  48652. * @param id defines the material's ID
  48653. * @return the material or null if none found.
  48654. */
  48655. getMaterialByID(id: string): Nullable<Material>;
  48656. /**
  48657. * Gets a the last added material using a given id
  48658. * @param id defines the material's ID
  48659. * @return the last material with the given id or null if none found.
  48660. */
  48661. getLastMaterialByID(id: string): Nullable<Material>;
  48662. /**
  48663. * Gets a material using its name
  48664. * @param name defines the material's name
  48665. * @return the material or null if none found.
  48666. */
  48667. getMaterialByName(name: string): Nullable<Material>;
  48668. /**
  48669. * Get a texture using its unique id
  48670. * @param uniqueId defines the texture's unique id
  48671. * @return the texture or null if none found.
  48672. */
  48673. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  48674. /**
  48675. * Gets a camera using its id
  48676. * @param id defines the id to look for
  48677. * @returns the camera or null if not found
  48678. */
  48679. getCameraByID(id: string): Nullable<Camera>;
  48680. /**
  48681. * Gets a camera using its unique id
  48682. * @param uniqueId defines the unique id to look for
  48683. * @returns the camera or null if not found
  48684. */
  48685. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  48686. /**
  48687. * Gets a camera using its name
  48688. * @param name defines the camera's name
  48689. * @return the camera or null if none found.
  48690. */
  48691. getCameraByName(name: string): Nullable<Camera>;
  48692. /**
  48693. * Gets a bone using its id
  48694. * @param id defines the bone's id
  48695. * @return the bone or null if not found
  48696. */
  48697. getBoneByID(id: string): Nullable<Bone>;
  48698. /**
  48699. * Gets a bone using its id
  48700. * @param name defines the bone's name
  48701. * @return the bone or null if not found
  48702. */
  48703. getBoneByName(name: string): Nullable<Bone>;
  48704. /**
  48705. * Gets a light node using its name
  48706. * @param name defines the the light's name
  48707. * @return the light or null if none found.
  48708. */
  48709. getLightByName(name: string): Nullable<Light>;
  48710. /**
  48711. * Gets a light node using its id
  48712. * @param id defines the light's id
  48713. * @return the light or null if none found.
  48714. */
  48715. getLightByID(id: string): Nullable<Light>;
  48716. /**
  48717. * Gets a light node using its scene-generated unique ID
  48718. * @param uniqueId defines the light's unique id
  48719. * @return the light or null if none found.
  48720. */
  48721. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  48722. /**
  48723. * Gets a particle system by id
  48724. * @param id defines the particle system id
  48725. * @return the corresponding system or null if none found
  48726. */
  48727. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  48728. /**
  48729. * Gets a geometry using its ID
  48730. * @param id defines the geometry's id
  48731. * @return the geometry or null if none found.
  48732. */
  48733. getGeometryByID(id: string): Nullable<Geometry>;
  48734. private _getGeometryByUniqueID;
  48735. /**
  48736. * Add a new geometry to this scene
  48737. * @param geometry defines the geometry to be added to the scene.
  48738. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  48739. * @return a boolean defining if the geometry was added or not
  48740. */
  48741. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  48742. /**
  48743. * Removes an existing geometry
  48744. * @param geometry defines the geometry to be removed from the scene
  48745. * @return a boolean defining if the geometry was removed or not
  48746. */
  48747. removeGeometry(geometry: Geometry): boolean;
  48748. /**
  48749. * Gets the list of geometries attached to the scene
  48750. * @returns an array of Geometry
  48751. */
  48752. getGeometries(): Geometry[];
  48753. /**
  48754. * Gets the first added mesh found of a given ID
  48755. * @param id defines the id to search for
  48756. * @return the mesh found or null if not found at all
  48757. */
  48758. getMeshByID(id: string): Nullable<AbstractMesh>;
  48759. /**
  48760. * Gets a list of meshes using their id
  48761. * @param id defines the id to search for
  48762. * @returns a list of meshes
  48763. */
  48764. getMeshesByID(id: string): Array<AbstractMesh>;
  48765. /**
  48766. * Gets the first added transform node found of a given ID
  48767. * @param id defines the id to search for
  48768. * @return the found transform node or null if not found at all.
  48769. */
  48770. getTransformNodeByID(id: string): Nullable<TransformNode>;
  48771. /**
  48772. * Gets a transform node with its auto-generated unique id
  48773. * @param uniqueId efines the unique id to search for
  48774. * @return the found transform node or null if not found at all.
  48775. */
  48776. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  48777. /**
  48778. * Gets a list of transform nodes using their id
  48779. * @param id defines the id to search for
  48780. * @returns a list of transform nodes
  48781. */
  48782. getTransformNodesByID(id: string): Array<TransformNode>;
  48783. /**
  48784. * Gets a mesh with its auto-generated unique id
  48785. * @param uniqueId defines the unique id to search for
  48786. * @return the found mesh or null if not found at all.
  48787. */
  48788. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  48789. /**
  48790. * Gets a the last added mesh using a given id
  48791. * @param id defines the id to search for
  48792. * @return the found mesh or null if not found at all.
  48793. */
  48794. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  48795. /**
  48796. * Gets a the last added node (Mesh, Camera, Light) using a given id
  48797. * @param id defines the id to search for
  48798. * @return the found node or null if not found at all
  48799. */
  48800. getLastEntryByID(id: string): Nullable<Node>;
  48801. /**
  48802. * Gets a node (Mesh, Camera, Light) using a given id
  48803. * @param id defines the id to search for
  48804. * @return the found node or null if not found at all
  48805. */
  48806. getNodeByID(id: string): Nullable<Node>;
  48807. /**
  48808. * Gets a node (Mesh, Camera, Light) using a given name
  48809. * @param name defines the name to search for
  48810. * @return the found node or null if not found at all.
  48811. */
  48812. getNodeByName(name: string): Nullable<Node>;
  48813. /**
  48814. * Gets a mesh using a given name
  48815. * @param name defines the name to search for
  48816. * @return the found mesh or null if not found at all.
  48817. */
  48818. getMeshByName(name: string): Nullable<AbstractMesh>;
  48819. /**
  48820. * Gets a transform node using a given name
  48821. * @param name defines the name to search for
  48822. * @return the found transform node or null if not found at all.
  48823. */
  48824. getTransformNodeByName(name: string): Nullable<TransformNode>;
  48825. /**
  48826. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  48827. * @param id defines the id to search for
  48828. * @return the found skeleton or null if not found at all.
  48829. */
  48830. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  48831. /**
  48832. * Gets a skeleton using a given auto generated unique id
  48833. * @param uniqueId defines the unique id to search for
  48834. * @return the found skeleton or null if not found at all.
  48835. */
  48836. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  48837. /**
  48838. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  48839. * @param id defines the id to search for
  48840. * @return the found skeleton or null if not found at all.
  48841. */
  48842. getSkeletonById(id: string): Nullable<Skeleton>;
  48843. /**
  48844. * Gets a skeleton using a given name
  48845. * @param name defines the name to search for
  48846. * @return the found skeleton or null if not found at all.
  48847. */
  48848. getSkeletonByName(name: string): Nullable<Skeleton>;
  48849. /**
  48850. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  48851. * @param id defines the id to search for
  48852. * @return the found morph target manager or null if not found at all.
  48853. */
  48854. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  48855. /**
  48856. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  48857. * @param id defines the id to search for
  48858. * @return the found morph target or null if not found at all.
  48859. */
  48860. getMorphTargetById(id: string): Nullable<MorphTarget>;
  48861. /**
  48862. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  48863. * @param name defines the name to search for
  48864. * @return the found morph target or null if not found at all.
  48865. */
  48866. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  48867. /**
  48868. * Gets a post process using a given name (if many are found, this function will pick the first one)
  48869. * @param name defines the name to search for
  48870. * @return the found post process or null if not found at all.
  48871. */
  48872. getPostProcessByName(name: string): Nullable<PostProcess>;
  48873. /**
  48874. * Gets a boolean indicating if the given mesh is active
  48875. * @param mesh defines the mesh to look for
  48876. * @returns true if the mesh is in the active list
  48877. */
  48878. isActiveMesh(mesh: AbstractMesh): boolean;
  48879. /**
  48880. * Return a unique id as a string which can serve as an identifier for the scene
  48881. */
  48882. get uid(): string;
  48883. /**
  48884. * Add an externaly attached data from its key.
  48885. * This method call will fail and return false, if such key already exists.
  48886. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  48887. * @param key the unique key that identifies the data
  48888. * @param data the data object to associate to the key for this Engine instance
  48889. * @return true if no such key were already present and the data was added successfully, false otherwise
  48890. */
  48891. addExternalData<T>(key: string, data: T): boolean;
  48892. /**
  48893. * Get an externaly attached data from its key
  48894. * @param key the unique key that identifies the data
  48895. * @return the associated data, if present (can be null), or undefined if not present
  48896. */
  48897. getExternalData<T>(key: string): Nullable<T>;
  48898. /**
  48899. * Get an externaly attached data from its key, create it using a factory if it's not already present
  48900. * @param key the unique key that identifies the data
  48901. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  48902. * @return the associated data, can be null if the factory returned null.
  48903. */
  48904. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  48905. /**
  48906. * Remove an externaly attached data from the Engine instance
  48907. * @param key the unique key that identifies the data
  48908. * @return true if the data was successfully removed, false if it doesn't exist
  48909. */
  48910. removeExternalData(key: string): boolean;
  48911. private _evaluateSubMesh;
  48912. /**
  48913. * Clear the processed materials smart array preventing retention point in material dispose.
  48914. */
  48915. freeProcessedMaterials(): void;
  48916. private _preventFreeActiveMeshesAndRenderingGroups;
  48917. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  48918. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  48919. * when disposing several meshes in a row or a hierarchy of meshes.
  48920. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  48921. */
  48922. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  48923. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  48924. /**
  48925. * Clear the active meshes smart array preventing retention point in mesh dispose.
  48926. */
  48927. freeActiveMeshes(): void;
  48928. /**
  48929. * Clear the info related to rendering groups preventing retention points during dispose.
  48930. */
  48931. freeRenderingGroups(): void;
  48932. /** @hidden */
  48933. _isInIntermediateRendering(): boolean;
  48934. /**
  48935. * Lambda returning the list of potentially active meshes.
  48936. */
  48937. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  48938. /**
  48939. * Lambda returning the list of potentially active sub meshes.
  48940. */
  48941. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  48942. /**
  48943. * Lambda returning the list of potentially intersecting sub meshes.
  48944. */
  48945. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  48946. /**
  48947. * Lambda returning the list of potentially colliding sub meshes.
  48948. */
  48949. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  48950. /** @hidden */
  48951. _activeMeshesFrozen: boolean;
  48952. private _skipEvaluateActiveMeshesCompletely;
  48953. /**
  48954. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  48955. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  48956. * @param onSuccess optional success callback
  48957. * @param onError optional error callback
  48958. * @returns the current scene
  48959. */
  48960. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  48961. /**
  48962. * Use this function to restart evaluating active meshes on every frame
  48963. * @returns the current scene
  48964. */
  48965. unfreezeActiveMeshes(): Scene;
  48966. private _evaluateActiveMeshes;
  48967. private _activeMesh;
  48968. /**
  48969. * Update the transform matrix to update from the current active camera
  48970. * @param force defines a boolean used to force the update even if cache is up to date
  48971. */
  48972. updateTransformMatrix(force?: boolean): void;
  48973. private _bindFrameBuffer;
  48974. /** @hidden */
  48975. _allowPostProcessClearColor: boolean;
  48976. /** @hidden */
  48977. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  48978. private _processSubCameras;
  48979. private _checkIntersections;
  48980. /** @hidden */
  48981. _advancePhysicsEngineStep(step: number): void;
  48982. /**
  48983. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  48984. */
  48985. getDeterministicFrameTime: () => number;
  48986. /** @hidden */
  48987. _animate(): void;
  48988. /** Execute all animations (for a frame) */
  48989. animate(): void;
  48990. /**
  48991. * Render the scene
  48992. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  48993. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  48994. */
  48995. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  48996. /**
  48997. * Freeze all materials
  48998. * A frozen material will not be updatable but should be faster to render
  48999. */
  49000. freezeMaterials(): void;
  49001. /**
  49002. * Unfreeze all materials
  49003. * A frozen material will not be updatable but should be faster to render
  49004. */
  49005. unfreezeMaterials(): void;
  49006. /**
  49007. * Releases all held ressources
  49008. */
  49009. dispose(): void;
  49010. /**
  49011. * Gets if the scene is already disposed
  49012. */
  49013. get isDisposed(): boolean;
  49014. /**
  49015. * Call this function to reduce memory footprint of the scene.
  49016. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  49017. */
  49018. clearCachedVertexData(): void;
  49019. /**
  49020. * This function will remove the local cached buffer data from texture.
  49021. * It will save memory but will prevent the texture from being rebuilt
  49022. */
  49023. cleanCachedTextureBuffer(): void;
  49024. /**
  49025. * Get the world extend vectors with an optional filter
  49026. *
  49027. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  49028. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  49029. */
  49030. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  49031. min: Vector3;
  49032. max: Vector3;
  49033. };
  49034. /**
  49035. * Creates a ray that can be used to pick in the scene
  49036. * @param x defines the x coordinate of the origin (on-screen)
  49037. * @param y defines the y coordinate of the origin (on-screen)
  49038. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  49039. * @param camera defines the camera to use for the picking
  49040. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  49041. * @returns a Ray
  49042. */
  49043. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  49044. /**
  49045. * Creates a ray that can be used to pick in the scene
  49046. * @param x defines the x coordinate of the origin (on-screen)
  49047. * @param y defines the y coordinate of the origin (on-screen)
  49048. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  49049. * @param result defines the ray where to store the picking ray
  49050. * @param camera defines the camera to use for the picking
  49051. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  49052. * @returns the current scene
  49053. */
  49054. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  49055. /**
  49056. * Creates a ray that can be used to pick in the scene
  49057. * @param x defines the x coordinate of the origin (on-screen)
  49058. * @param y defines the y coordinate of the origin (on-screen)
  49059. * @param camera defines the camera to use for the picking
  49060. * @returns a Ray
  49061. */
  49062. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  49063. /**
  49064. * Creates a ray that can be used to pick in the scene
  49065. * @param x defines the x coordinate of the origin (on-screen)
  49066. * @param y defines the y coordinate of the origin (on-screen)
  49067. * @param result defines the ray where to store the picking ray
  49068. * @param camera defines the camera to use for the picking
  49069. * @returns the current scene
  49070. */
  49071. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  49072. /** Launch a ray to try to pick a mesh in the scene
  49073. * @param x position on screen
  49074. * @param y position on screen
  49075. * @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
  49076. * @param fastCheck defines if the first intersection will be used (and not the closest)
  49077. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  49078. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  49079. * @returns a PickingInfo
  49080. */
  49081. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  49082. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  49083. * @param x position on screen
  49084. * @param y position on screen
  49085. * @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
  49086. * @param fastCheck defines if the first intersection will be used (and not the closest)
  49087. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  49088. * @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)
  49089. */
  49090. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  49091. /** Use the given ray to pick a mesh in the scene
  49092. * @param ray The ray to use to pick meshes
  49093. * @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
  49094. * @param fastCheck defines if the first intersection will be used (and not the closest)
  49095. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  49096. * @returns a PickingInfo
  49097. */
  49098. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  49099. /**
  49100. * Launch a ray to try to pick a mesh in the scene
  49101. * @param x X position on screen
  49102. * @param y Y position on screen
  49103. * @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
  49104. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  49105. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  49106. * @returns an array of PickingInfo
  49107. */
  49108. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  49109. /**
  49110. * Launch a ray to try to pick a mesh in the scene
  49111. * @param ray Ray to use
  49112. * @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
  49113. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  49114. * @returns an array of PickingInfo
  49115. */
  49116. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  49117. /**
  49118. * Force the value of meshUnderPointer
  49119. * @param mesh defines the mesh to use
  49120. * @param pointerId optional pointer id when using more than one pointer
  49121. */
  49122. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  49123. /**
  49124. * Gets the mesh under the pointer
  49125. * @returns a Mesh or null if no mesh is under the pointer
  49126. */
  49127. getPointerOverMesh(): Nullable<AbstractMesh>;
  49128. /** @hidden */
  49129. _rebuildGeometries(): void;
  49130. /** @hidden */
  49131. _rebuildTextures(): void;
  49132. private _getByTags;
  49133. /**
  49134. * Get a list of meshes by tags
  49135. * @param tagsQuery defines the tags query to use
  49136. * @param forEach defines a predicate used to filter results
  49137. * @returns an array of Mesh
  49138. */
  49139. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  49140. /**
  49141. * Get a list of cameras by tags
  49142. * @param tagsQuery defines the tags query to use
  49143. * @param forEach defines a predicate used to filter results
  49144. * @returns an array of Camera
  49145. */
  49146. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  49147. /**
  49148. * Get a list of lights by tags
  49149. * @param tagsQuery defines the tags query to use
  49150. * @param forEach defines a predicate used to filter results
  49151. * @returns an array of Light
  49152. */
  49153. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  49154. /**
  49155. * Get a list of materials by tags
  49156. * @param tagsQuery defines the tags query to use
  49157. * @param forEach defines a predicate used to filter results
  49158. * @returns an array of Material
  49159. */
  49160. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  49161. /**
  49162. * Get a list of transform nodes by tags
  49163. * @param tagsQuery defines the tags query to use
  49164. * @param forEach defines a predicate used to filter results
  49165. * @returns an array of TransformNode
  49166. */
  49167. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  49168. /**
  49169. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  49170. * This allowed control for front to back rendering or reversly depending of the special needs.
  49171. *
  49172. * @param renderingGroupId The rendering group id corresponding to its index
  49173. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  49174. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  49175. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  49176. */
  49177. 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;
  49178. /**
  49179. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  49180. *
  49181. * @param renderingGroupId The rendering group id corresponding to its index
  49182. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  49183. * @param depth Automatically clears depth between groups if true and autoClear is true.
  49184. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  49185. */
  49186. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  49187. /**
  49188. * Gets the current auto clear configuration for one rendering group of the rendering
  49189. * manager.
  49190. * @param index the rendering group index to get the information for
  49191. * @returns The auto clear setup for the requested rendering group
  49192. */
  49193. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  49194. private _blockMaterialDirtyMechanism;
  49195. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  49196. get blockMaterialDirtyMechanism(): boolean;
  49197. set blockMaterialDirtyMechanism(value: boolean);
  49198. /**
  49199. * Will flag all materials as dirty to trigger new shader compilation
  49200. * @param flag defines the flag used to specify which material part must be marked as dirty
  49201. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  49202. */
  49203. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  49204. /** @hidden */
  49205. _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;
  49206. /** @hidden */
  49207. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  49208. /** @hidden */
  49209. _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;
  49210. /** @hidden */
  49211. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  49212. /** @hidden */
  49213. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  49214. /** @hidden */
  49215. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  49216. }
  49217. }
  49218. declare module "babylonjs/assetContainer" {
  49219. import { AbstractScene } from "babylonjs/abstractScene";
  49220. import { Scene } from "babylonjs/scene";
  49221. import { Mesh } from "babylonjs/Meshes/mesh";
  49222. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49223. import { Skeleton } from "babylonjs/Bones/skeleton";
  49224. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  49225. import { Animatable } from "babylonjs/Animations/animatable";
  49226. import { Nullable } from "babylonjs/types";
  49227. import { Node } from "babylonjs/node";
  49228. /**
  49229. * Set of assets to keep when moving a scene into an asset container.
  49230. */
  49231. export class KeepAssets extends AbstractScene {
  49232. }
  49233. /**
  49234. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  49235. */
  49236. export class InstantiatedEntries {
  49237. /**
  49238. * List of new root nodes (eg. nodes with no parent)
  49239. */
  49240. rootNodes: TransformNode[];
  49241. /**
  49242. * List of new skeletons
  49243. */
  49244. skeletons: Skeleton[];
  49245. /**
  49246. * List of new animation groups
  49247. */
  49248. animationGroups: AnimationGroup[];
  49249. }
  49250. /**
  49251. * Container with a set of assets that can be added or removed from a scene.
  49252. */
  49253. export class AssetContainer extends AbstractScene {
  49254. private _wasAddedToScene;
  49255. /**
  49256. * The scene the AssetContainer belongs to.
  49257. */
  49258. scene: Scene;
  49259. /**
  49260. * Instantiates an AssetContainer.
  49261. * @param scene The scene the AssetContainer belongs to.
  49262. */
  49263. constructor(scene: Scene);
  49264. /**
  49265. * Instantiate or clone all meshes and add the new ones to the scene.
  49266. * Skeletons and animation groups will all be cloned
  49267. * @param nameFunction defines an optional function used to get new names for clones
  49268. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  49269. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  49270. */
  49271. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  49272. /**
  49273. * Adds all the assets from the container to the scene.
  49274. */
  49275. addAllToScene(): void;
  49276. /**
  49277. * Removes all the assets in the container from the scene
  49278. */
  49279. removeAllFromScene(): void;
  49280. /**
  49281. * Disposes all the assets in the container
  49282. */
  49283. dispose(): void;
  49284. private _moveAssets;
  49285. /**
  49286. * Removes all the assets contained in the scene and adds them to the container.
  49287. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  49288. */
  49289. moveAllFromScene(keepAssets?: KeepAssets): void;
  49290. /**
  49291. * 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.
  49292. * @returns the root mesh
  49293. */
  49294. createRootMesh(): Mesh;
  49295. /**
  49296. * Merge animations (direct and animation groups) from this asset container into a scene
  49297. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49298. * @param animatables set of animatables to retarget to a node from the scene
  49299. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  49300. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  49301. */
  49302. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  49303. }
  49304. }
  49305. declare module "babylonjs/abstractScene" {
  49306. import { Scene } from "babylonjs/scene";
  49307. import { Nullable } from "babylonjs/types";
  49308. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49309. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49310. import { Geometry } from "babylonjs/Meshes/geometry";
  49311. import { Skeleton } from "babylonjs/Bones/skeleton";
  49312. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  49313. import { AssetContainer } from "babylonjs/assetContainer";
  49314. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  49315. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  49316. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49317. import { Material } from "babylonjs/Materials/material";
  49318. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  49319. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  49320. import { Camera } from "babylonjs/Cameras/camera";
  49321. import { Light } from "babylonjs/Lights/light";
  49322. import { Node } from "babylonjs/node";
  49323. import { Animation } from "babylonjs/Animations/animation";
  49324. /**
  49325. * Defines how the parser contract is defined.
  49326. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  49327. */
  49328. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  49329. /**
  49330. * Defines how the individual parser contract is defined.
  49331. * These parser can parse an individual asset
  49332. */
  49333. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  49334. /**
  49335. * Base class of the scene acting as a container for the different elements composing a scene.
  49336. * This class is dynamically extended by the different components of the scene increasing
  49337. * flexibility and reducing coupling
  49338. */
  49339. export abstract class AbstractScene {
  49340. /**
  49341. * Stores the list of available parsers in the application.
  49342. */
  49343. private static _BabylonFileParsers;
  49344. /**
  49345. * Stores the list of available individual parsers in the application.
  49346. */
  49347. private static _IndividualBabylonFileParsers;
  49348. /**
  49349. * Adds a parser in the list of available ones
  49350. * @param name Defines the name of the parser
  49351. * @param parser Defines the parser to add
  49352. */
  49353. static AddParser(name: string, parser: BabylonFileParser): void;
  49354. /**
  49355. * Gets a general parser from the list of avaialble ones
  49356. * @param name Defines the name of the parser
  49357. * @returns the requested parser or null
  49358. */
  49359. static GetParser(name: string): Nullable<BabylonFileParser>;
  49360. /**
  49361. * Adds n individual parser in the list of available ones
  49362. * @param name Defines the name of the parser
  49363. * @param parser Defines the parser to add
  49364. */
  49365. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  49366. /**
  49367. * Gets an individual parser from the list of avaialble ones
  49368. * @param name Defines the name of the parser
  49369. * @returns the requested parser or null
  49370. */
  49371. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  49372. /**
  49373. * Parser json data and populate both a scene and its associated container object
  49374. * @param jsonData Defines the data to parse
  49375. * @param scene Defines the scene to parse the data for
  49376. * @param container Defines the container attached to the parsing sequence
  49377. * @param rootUrl Defines the root url of the data
  49378. */
  49379. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  49380. /**
  49381. * Gets the list of root nodes (ie. nodes with no parent)
  49382. */
  49383. rootNodes: Node[];
  49384. /** All of the cameras added to this scene
  49385. * @see https://doc.babylonjs.com/babylon101/cameras
  49386. */
  49387. cameras: Camera[];
  49388. /**
  49389. * All of the lights added to this scene
  49390. * @see https://doc.babylonjs.com/babylon101/lights
  49391. */
  49392. lights: Light[];
  49393. /**
  49394. * All of the (abstract) meshes added to this scene
  49395. */
  49396. meshes: AbstractMesh[];
  49397. /**
  49398. * The list of skeletons added to the scene
  49399. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  49400. */
  49401. skeletons: Skeleton[];
  49402. /**
  49403. * All of the particle systems added to this scene
  49404. * @see https://doc.babylonjs.com/babylon101/particles
  49405. */
  49406. particleSystems: IParticleSystem[];
  49407. /**
  49408. * Gets a list of Animations associated with the scene
  49409. */
  49410. animations: Animation[];
  49411. /**
  49412. * All of the animation groups added to this scene
  49413. * @see https://doc.babylonjs.com/how_to/group
  49414. */
  49415. animationGroups: AnimationGroup[];
  49416. /**
  49417. * All of the multi-materials added to this scene
  49418. * @see https://doc.babylonjs.com/how_to/multi_materials
  49419. */
  49420. multiMaterials: MultiMaterial[];
  49421. /**
  49422. * All of the materials added to this scene
  49423. * In the context of a Scene, it is not supposed to be modified manually.
  49424. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  49425. * Note also that the order of the Material within the array is not significant and might change.
  49426. * @see https://doc.babylonjs.com/babylon101/materials
  49427. */
  49428. materials: Material[];
  49429. /**
  49430. * The list of morph target managers added to the scene
  49431. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  49432. */
  49433. morphTargetManagers: MorphTargetManager[];
  49434. /**
  49435. * The list of geometries used in the scene.
  49436. */
  49437. geometries: Geometry[];
  49438. /**
  49439. * All of the tranform nodes added to this scene
  49440. * In the context of a Scene, it is not supposed to be modified manually.
  49441. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  49442. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  49443. * @see https://doc.babylonjs.com/how_to/transformnode
  49444. */
  49445. transformNodes: TransformNode[];
  49446. /**
  49447. * ActionManagers available on the scene.
  49448. */
  49449. actionManagers: AbstractActionManager[];
  49450. /**
  49451. * Textures to keep.
  49452. */
  49453. textures: BaseTexture[];
  49454. /** @hidden */
  49455. protected _environmentTexture: Nullable<BaseTexture>;
  49456. /**
  49457. * Texture used in all pbr material as the reflection texture.
  49458. * As in the majority of the scene they are the same (exception for multi room and so on),
  49459. * this is easier to reference from here than from all the materials.
  49460. */
  49461. get environmentTexture(): Nullable<BaseTexture>;
  49462. set environmentTexture(value: Nullable<BaseTexture>);
  49463. /**
  49464. * The list of postprocesses added to the scene
  49465. */
  49466. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  49467. /**
  49468. * @returns all meshes, lights, cameras, transformNodes and bones
  49469. */
  49470. getNodes(): Array<Node>;
  49471. }
  49472. }
  49473. declare module "babylonjs/Audio/Interfaces/ISoundOptions" {
  49474. /**
  49475. * Interface used to define options for Sound class
  49476. */
  49477. export interface ISoundOptions {
  49478. /**
  49479. * Does the sound autoplay once loaded.
  49480. */
  49481. autoplay?: boolean;
  49482. /**
  49483. * Does the sound loop after it finishes playing once.
  49484. */
  49485. loop?: boolean;
  49486. /**
  49487. * Sound's volume
  49488. */
  49489. volume?: number;
  49490. /**
  49491. * Is it a spatial sound?
  49492. */
  49493. spatialSound?: boolean;
  49494. /**
  49495. * Maximum distance to hear that sound
  49496. */
  49497. maxDistance?: number;
  49498. /**
  49499. * Uses user defined attenuation function
  49500. */
  49501. useCustomAttenuation?: boolean;
  49502. /**
  49503. * Define the roll off factor of spatial sounds.
  49504. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49505. */
  49506. rolloffFactor?: number;
  49507. /**
  49508. * Define the reference distance the sound should be heard perfectly.
  49509. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49510. */
  49511. refDistance?: number;
  49512. /**
  49513. * Define the distance attenuation model the sound will follow.
  49514. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49515. */
  49516. distanceModel?: string;
  49517. /**
  49518. * Defines the playback speed (1 by default)
  49519. */
  49520. playbackRate?: number;
  49521. /**
  49522. * Defines if the sound is from a streaming source
  49523. */
  49524. streaming?: boolean;
  49525. /**
  49526. * Defines an optional length (in seconds) inside the sound file
  49527. */
  49528. length?: number;
  49529. /**
  49530. * Defines an optional offset (in seconds) inside the sound file
  49531. */
  49532. offset?: number;
  49533. /**
  49534. * If true, URLs will not be required to state the audio file codec to use.
  49535. */
  49536. skipCodecCheck?: boolean;
  49537. }
  49538. }
  49539. declare module "babylonjs/Audio/sound" {
  49540. import { Observable } from "babylonjs/Misc/observable";
  49541. import { Vector3 } from "babylonjs/Maths/math.vector";
  49542. import { Nullable } from "babylonjs/types";
  49543. import { Scene } from "babylonjs/scene";
  49544. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49545. import { ISoundOptions } from "babylonjs/Audio/Interfaces/ISoundOptions";
  49546. /**
  49547. * Defines a sound that can be played in the application.
  49548. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  49549. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  49550. */
  49551. export class Sound {
  49552. /**
  49553. * The name of the sound in the scene.
  49554. */
  49555. name: string;
  49556. /**
  49557. * Does the sound autoplay once loaded.
  49558. */
  49559. autoplay: boolean;
  49560. private _loop;
  49561. /**
  49562. * Does the sound loop after it finishes playing once.
  49563. */
  49564. get loop(): boolean;
  49565. set loop(value: boolean);
  49566. /**
  49567. * Does the sound use a custom attenuation curve to simulate the falloff
  49568. * happening when the source gets further away from the camera.
  49569. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  49570. */
  49571. useCustomAttenuation: boolean;
  49572. /**
  49573. * The sound track id this sound belongs to.
  49574. */
  49575. soundTrackId: number;
  49576. /**
  49577. * Is this sound currently played.
  49578. */
  49579. isPlaying: boolean;
  49580. /**
  49581. * Is this sound currently paused.
  49582. */
  49583. isPaused: boolean;
  49584. /**
  49585. * Does this sound enables spatial sound.
  49586. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49587. */
  49588. spatialSound: boolean;
  49589. /**
  49590. * Define the reference distance the sound should be heard perfectly.
  49591. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49592. */
  49593. refDistance: number;
  49594. /**
  49595. * Define the roll off factor of spatial sounds.
  49596. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49597. */
  49598. rolloffFactor: number;
  49599. /**
  49600. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  49601. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49602. */
  49603. maxDistance: number;
  49604. /**
  49605. * Define the distance attenuation model the sound will follow.
  49606. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49607. */
  49608. distanceModel: string;
  49609. /**
  49610. * @hidden
  49611. * Back Compat
  49612. **/
  49613. onended: () => any;
  49614. /**
  49615. * Gets or sets an object used to store user defined information for the sound.
  49616. */
  49617. metadata: any;
  49618. /**
  49619. * Observable event when the current playing sound finishes.
  49620. */
  49621. onEndedObservable: Observable<Sound>;
  49622. /**
  49623. * Gets the current time for the sound.
  49624. */
  49625. get currentTime(): number;
  49626. private _panningModel;
  49627. private _playbackRate;
  49628. private _streaming;
  49629. private _startTime;
  49630. private _startOffset;
  49631. private _position;
  49632. /** @hidden */
  49633. _positionInEmitterSpace: boolean;
  49634. private _localDirection;
  49635. private _volume;
  49636. private _isReadyToPlay;
  49637. private _isDirectional;
  49638. private _readyToPlayCallback;
  49639. private _audioBuffer;
  49640. private _soundSource;
  49641. private _streamingSource;
  49642. private _soundPanner;
  49643. private _soundGain;
  49644. private _inputAudioNode;
  49645. private _outputAudioNode;
  49646. private _coneInnerAngle;
  49647. private _coneOuterAngle;
  49648. private _coneOuterGain;
  49649. private _scene;
  49650. private _connectedTransformNode;
  49651. private _customAttenuationFunction;
  49652. private _registerFunc;
  49653. private _isOutputConnected;
  49654. private _htmlAudioElement;
  49655. private _urlType;
  49656. private _length?;
  49657. private _offset?;
  49658. /** @hidden */
  49659. static _SceneComponentInitialization: (scene: Scene) => void;
  49660. /**
  49661. * Create a sound and attach it to a scene
  49662. * @param name Name of your sound
  49663. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  49664. * @param scene defines the scene the sound belongs to
  49665. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  49666. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  49667. */
  49668. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  49669. /**
  49670. * Release the sound and its associated resources
  49671. */
  49672. dispose(): void;
  49673. /**
  49674. * Gets if the sounds is ready to be played or not.
  49675. * @returns true if ready, otherwise false
  49676. */
  49677. isReady(): boolean;
  49678. /**
  49679. * Get the current class name.
  49680. * @returns current class name
  49681. */
  49682. getClassName(): string;
  49683. private _soundLoaded;
  49684. /**
  49685. * Sets the data of the sound from an audiobuffer
  49686. * @param audioBuffer The audioBuffer containing the data
  49687. */
  49688. setAudioBuffer(audioBuffer: AudioBuffer): void;
  49689. /**
  49690. * Updates the current sounds options such as maxdistance, loop...
  49691. * @param options A JSON object containing values named as the object properties
  49692. */
  49693. updateOptions(options: ISoundOptions): void;
  49694. private _createSpatialParameters;
  49695. private _updateSpatialParameters;
  49696. /**
  49697. * Switch the panning model to HRTF:
  49698. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  49699. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49700. */
  49701. switchPanningModelToHRTF(): void;
  49702. /**
  49703. * Switch the panning model to Equal Power:
  49704. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  49705. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49706. */
  49707. switchPanningModelToEqualPower(): void;
  49708. private _switchPanningModel;
  49709. /**
  49710. * Connect this sound to a sound track audio node like gain...
  49711. * @param soundTrackAudioNode the sound track audio node to connect to
  49712. */
  49713. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  49714. /**
  49715. * Transform this sound into a directional source
  49716. * @param coneInnerAngle Size of the inner cone in degree
  49717. * @param coneOuterAngle Size of the outer cone in degree
  49718. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  49719. */
  49720. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  49721. /**
  49722. * Gets or sets the inner angle for the directional cone.
  49723. */
  49724. get directionalConeInnerAngle(): number;
  49725. /**
  49726. * Gets or sets the inner angle for the directional cone.
  49727. */
  49728. set directionalConeInnerAngle(value: number);
  49729. /**
  49730. * Gets or sets the outer angle for the directional cone.
  49731. */
  49732. get directionalConeOuterAngle(): number;
  49733. /**
  49734. * Gets or sets the outer angle for the directional cone.
  49735. */
  49736. set directionalConeOuterAngle(value: number);
  49737. /**
  49738. * Sets the position of the emitter if spatial sound is enabled
  49739. * @param newPosition Defines the new posisiton
  49740. */
  49741. setPosition(newPosition: Vector3): void;
  49742. /**
  49743. * Sets the local direction of the emitter if spatial sound is enabled
  49744. * @param newLocalDirection Defines the new local direction
  49745. */
  49746. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  49747. private _updateDirection;
  49748. /** @hidden */
  49749. updateDistanceFromListener(): void;
  49750. /**
  49751. * Sets a new custom attenuation function for the sound.
  49752. * @param callback Defines the function used for the attenuation
  49753. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  49754. */
  49755. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  49756. /**
  49757. * Play the sound
  49758. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  49759. * @param offset (optional) Start the sound at a specific time in seconds
  49760. * @param length (optional) Sound duration (in seconds)
  49761. */
  49762. play(time?: number, offset?: number, length?: number): void;
  49763. private _onended;
  49764. /**
  49765. * Stop the sound
  49766. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  49767. */
  49768. stop(time?: number): void;
  49769. /**
  49770. * Put the sound in pause
  49771. */
  49772. pause(): void;
  49773. /**
  49774. * Sets a dedicated volume for this sounds
  49775. * @param newVolume Define the new volume of the sound
  49776. * @param time Define time for gradual change to new volume
  49777. */
  49778. setVolume(newVolume: number, time?: number): void;
  49779. /**
  49780. * Set the sound play back rate
  49781. * @param newPlaybackRate Define the playback rate the sound should be played at
  49782. */
  49783. setPlaybackRate(newPlaybackRate: number): void;
  49784. /**
  49785. * Gets the volume of the sound.
  49786. * @returns the volume of the sound
  49787. */
  49788. getVolume(): number;
  49789. /**
  49790. * Attach the sound to a dedicated mesh
  49791. * @param transformNode The transform node to connect the sound with
  49792. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  49793. */
  49794. attachToMesh(transformNode: TransformNode): void;
  49795. /**
  49796. * Detach the sound from the previously attached mesh
  49797. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  49798. */
  49799. detachFromMesh(): void;
  49800. private _onRegisterAfterWorldMatrixUpdate;
  49801. /**
  49802. * Clone the current sound in the scene.
  49803. * @returns the new sound clone
  49804. */
  49805. clone(): Nullable<Sound>;
  49806. /**
  49807. * Gets the current underlying audio buffer containing the data
  49808. * @returns the audio buffer
  49809. */
  49810. getAudioBuffer(): Nullable<AudioBuffer>;
  49811. /**
  49812. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  49813. * @returns the source node
  49814. */
  49815. getSoundSource(): Nullable<AudioBufferSourceNode>;
  49816. /**
  49817. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  49818. * @returns the gain node
  49819. */
  49820. getSoundGain(): Nullable<GainNode>;
  49821. /**
  49822. * Serializes the Sound in a JSON representation
  49823. * @returns the JSON representation of the sound
  49824. */
  49825. serialize(): any;
  49826. /**
  49827. * Parse a JSON representation of a sound to innstantiate in a given scene
  49828. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  49829. * @param scene Define the scene the new parsed sound should be created in
  49830. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  49831. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  49832. * @returns the newly parsed sound
  49833. */
  49834. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  49835. }
  49836. }
  49837. declare module "babylonjs/Actions/directAudioActions" {
  49838. import { Action } from "babylonjs/Actions/action";
  49839. import { Condition } from "babylonjs/Actions/condition";
  49840. import { Sound } from "babylonjs/Audio/sound";
  49841. /**
  49842. * This defines an action helpful to play a defined sound on a triggered action.
  49843. */
  49844. export class PlaySoundAction extends Action {
  49845. private _sound;
  49846. /**
  49847. * Instantiate the action
  49848. * @param triggerOptions defines the trigger options
  49849. * @param sound defines the sound to play
  49850. * @param condition defines the trigger related conditions
  49851. */
  49852. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  49853. /** @hidden */
  49854. _prepare(): void;
  49855. /**
  49856. * Execute the action and play the sound.
  49857. */
  49858. execute(): void;
  49859. /**
  49860. * Serializes the actions and its related information.
  49861. * @param parent defines the object to serialize in
  49862. * @returns the serialized object
  49863. */
  49864. serialize(parent: any): any;
  49865. }
  49866. /**
  49867. * This defines an action helpful to stop a defined sound on a triggered action.
  49868. */
  49869. export class StopSoundAction extends Action {
  49870. private _sound;
  49871. /**
  49872. * Instantiate the action
  49873. * @param triggerOptions defines the trigger options
  49874. * @param sound defines the sound to stop
  49875. * @param condition defines the trigger related conditions
  49876. */
  49877. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  49878. /** @hidden */
  49879. _prepare(): void;
  49880. /**
  49881. * Execute the action and stop the sound.
  49882. */
  49883. execute(): void;
  49884. /**
  49885. * Serializes the actions and its related information.
  49886. * @param parent defines the object to serialize in
  49887. * @returns the serialized object
  49888. */
  49889. serialize(parent: any): any;
  49890. }
  49891. }
  49892. declare module "babylonjs/Actions/interpolateValueAction" {
  49893. import { Action } from "babylonjs/Actions/action";
  49894. import { Condition } from "babylonjs/Actions/condition";
  49895. import { Observable } from "babylonjs/Misc/observable";
  49896. /**
  49897. * This defines an action responsible to change the value of a property
  49898. * by interpolating between its current value and the newly set one once triggered.
  49899. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  49900. */
  49901. export class InterpolateValueAction extends Action {
  49902. /**
  49903. * Defines the path of the property where the value should be interpolated
  49904. */
  49905. propertyPath: string;
  49906. /**
  49907. * Defines the target value at the end of the interpolation.
  49908. */
  49909. value: any;
  49910. /**
  49911. * Defines the time it will take for the property to interpolate to the value.
  49912. */
  49913. duration: number;
  49914. /**
  49915. * Defines if the other scene animations should be stopped when the action has been triggered
  49916. */
  49917. stopOtherAnimations?: boolean;
  49918. /**
  49919. * Defines a callback raised once the interpolation animation has been done.
  49920. */
  49921. onInterpolationDone?: () => void;
  49922. /**
  49923. * Observable triggered once the interpolation animation has been done.
  49924. */
  49925. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  49926. private _target;
  49927. private _effectiveTarget;
  49928. private _property;
  49929. /**
  49930. * Instantiate the action
  49931. * @param triggerOptions defines the trigger options
  49932. * @param target defines the object containing the value to interpolate
  49933. * @param propertyPath defines the path to the property in the target object
  49934. * @param value defines the target value at the end of the interpolation
  49935. * @param duration deines the time it will take for the property to interpolate to the value.
  49936. * @param condition defines the trigger related conditions
  49937. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  49938. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  49939. */
  49940. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  49941. /** @hidden */
  49942. _prepare(): void;
  49943. /**
  49944. * Execute the action starts the value interpolation.
  49945. */
  49946. execute(): void;
  49947. /**
  49948. * Serializes the actions and its related information.
  49949. * @param parent defines the object to serialize in
  49950. * @returns the serialized object
  49951. */
  49952. serialize(parent: any): any;
  49953. }
  49954. }
  49955. declare module "babylonjs/Actions/index" {
  49956. export * from "babylonjs/Actions/abstractActionManager";
  49957. export * from "babylonjs/Actions/action";
  49958. export * from "babylonjs/Actions/actionEvent";
  49959. export * from "babylonjs/Actions/actionManager";
  49960. export * from "babylonjs/Actions/condition";
  49961. export * from "babylonjs/Actions/directActions";
  49962. export * from "babylonjs/Actions/directAudioActions";
  49963. export * from "babylonjs/Actions/interpolateValueAction";
  49964. }
  49965. declare module "babylonjs/Animations/index" {
  49966. export * from "babylonjs/Animations/animatable";
  49967. export * from "babylonjs/Animations/animation";
  49968. export * from "babylonjs/Animations/animationGroup";
  49969. export * from "babylonjs/Animations/animationPropertiesOverride";
  49970. export * from "babylonjs/Animations/easing";
  49971. export * from "babylonjs/Animations/runtimeAnimation";
  49972. export * from "babylonjs/Animations/animationEvent";
  49973. export * from "babylonjs/Animations/animationGroup";
  49974. export * from "babylonjs/Animations/animationKey";
  49975. export * from "babylonjs/Animations/animationRange";
  49976. export * from "babylonjs/Animations/animatable.interface";
  49977. }
  49978. declare module "babylonjs/Audio/audioEngine" {
  49979. import { Analyser } from "babylonjs/Audio/analyser";
  49980. import { Nullable } from "babylonjs/types";
  49981. import { Observable } from "babylonjs/Misc/observable";
  49982. import { IAudioEngine } from "babylonjs/Audio/Interfaces/IAudioEngine";
  49983. /**
  49984. * This represents the default audio engine used in babylon.
  49985. * It is responsible to play, synchronize and analyse sounds throughout the application.
  49986. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  49987. */
  49988. export class AudioEngine implements IAudioEngine {
  49989. private _audioContext;
  49990. private _audioContextInitialized;
  49991. private _muteButton;
  49992. private _hostElement;
  49993. /**
  49994. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  49995. */
  49996. canUseWebAudio: boolean;
  49997. /**
  49998. * The master gain node defines the global audio volume of your audio engine.
  49999. */
  50000. masterGain: GainNode;
  50001. /**
  50002. * Defines if Babylon should emit a warning if WebAudio is not supported.
  50003. * @ignoreNaming
  50004. */
  50005. WarnedWebAudioUnsupported: boolean;
  50006. /**
  50007. * Gets whether or not mp3 are supported by your browser.
  50008. */
  50009. isMP3supported: boolean;
  50010. /**
  50011. * Gets whether or not ogg are supported by your browser.
  50012. */
  50013. isOGGsupported: boolean;
  50014. /**
  50015. * Gets whether audio has been unlocked on the device.
  50016. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  50017. * a user interaction has happened.
  50018. */
  50019. unlocked: boolean;
  50020. /**
  50021. * Defines if the audio engine relies on a custom unlocked button.
  50022. * In this case, the embedded button will not be displayed.
  50023. */
  50024. useCustomUnlockedButton: boolean;
  50025. /**
  50026. * Event raised when audio has been unlocked on the browser.
  50027. */
  50028. onAudioUnlockedObservable: Observable<IAudioEngine>;
  50029. /**
  50030. * Event raised when audio has been locked on the browser.
  50031. */
  50032. onAudioLockedObservable: Observable<IAudioEngine>;
  50033. /**
  50034. * Gets the current AudioContext if available.
  50035. */
  50036. get audioContext(): Nullable<AudioContext>;
  50037. private _connectedAnalyser;
  50038. /**
  50039. * Instantiates a new audio engine.
  50040. *
  50041. * There should be only one per page as some browsers restrict the number
  50042. * of audio contexts you can create.
  50043. * @param hostElement defines the host element where to display the mute icon if necessary
  50044. */
  50045. constructor(hostElement?: Nullable<HTMLElement>);
  50046. /**
  50047. * Flags the audio engine in Locked state.
  50048. * This happens due to new browser policies preventing audio to autoplay.
  50049. */
  50050. lock(): void;
  50051. /**
  50052. * Unlocks the audio engine once a user action has been done on the dom.
  50053. * This is helpful to resume play once browser policies have been satisfied.
  50054. */
  50055. unlock(): void;
  50056. private _resumeAudioContext;
  50057. private _initializeAudioContext;
  50058. private _tryToRun;
  50059. private _triggerRunningState;
  50060. private _triggerSuspendedState;
  50061. private _displayMuteButton;
  50062. private _moveButtonToTopLeft;
  50063. private _onResize;
  50064. private _hideMuteButton;
  50065. /**
  50066. * Destroy and release the resources associated with the audio ccontext.
  50067. */
  50068. dispose(): void;
  50069. /**
  50070. * Gets the global volume sets on the master gain.
  50071. * @returns the global volume if set or -1 otherwise
  50072. */
  50073. getGlobalVolume(): number;
  50074. /**
  50075. * Sets the global volume of your experience (sets on the master gain).
  50076. * @param newVolume Defines the new global volume of the application
  50077. */
  50078. setGlobalVolume(newVolume: number): void;
  50079. /**
  50080. * Connect the audio engine to an audio analyser allowing some amazing
  50081. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  50082. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  50083. * @param analyser The analyser to connect to the engine
  50084. */
  50085. connectToAnalyser(analyser: Analyser): void;
  50086. }
  50087. }
  50088. declare module "babylonjs/Audio/soundTrack" {
  50089. import { Sound } from "babylonjs/Audio/sound";
  50090. import { Analyser } from "babylonjs/Audio/analyser";
  50091. import { Scene } from "babylonjs/scene";
  50092. /**
  50093. * Options allowed during the creation of a sound track.
  50094. */
  50095. export interface ISoundTrackOptions {
  50096. /**
  50097. * The volume the sound track should take during creation
  50098. */
  50099. volume?: number;
  50100. /**
  50101. * Define if the sound track is the main sound track of the scene
  50102. */
  50103. mainTrack?: boolean;
  50104. }
  50105. /**
  50106. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  50107. * It will be also used in a future release to apply effects on a specific track.
  50108. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  50109. */
  50110. export class SoundTrack {
  50111. /**
  50112. * The unique identifier of the sound track in the scene.
  50113. */
  50114. id: number;
  50115. /**
  50116. * The list of sounds included in the sound track.
  50117. */
  50118. soundCollection: Array<Sound>;
  50119. private _outputAudioNode;
  50120. private _scene;
  50121. private _connectedAnalyser;
  50122. private _options;
  50123. private _isInitialized;
  50124. /**
  50125. * Creates a new sound track.
  50126. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  50127. * @param scene Define the scene the sound track belongs to
  50128. * @param options
  50129. */
  50130. constructor(scene: Scene, options?: ISoundTrackOptions);
  50131. private _initializeSoundTrackAudioGraph;
  50132. /**
  50133. * Release the sound track and its associated resources
  50134. */
  50135. dispose(): void;
  50136. /**
  50137. * Adds a sound to this sound track
  50138. * @param sound define the cound to add
  50139. * @ignoreNaming
  50140. */
  50141. addSound(sound: Sound): void;
  50142. /**
  50143. * Removes a sound to this sound track
  50144. * @param sound define the cound to remove
  50145. * @ignoreNaming
  50146. */
  50147. removeSound(sound: Sound): void;
  50148. /**
  50149. * Set a global volume for the full sound track.
  50150. * @param newVolume Define the new volume of the sound track
  50151. */
  50152. setVolume(newVolume: number): void;
  50153. /**
  50154. * Switch the panning model to HRTF:
  50155. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  50156. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  50157. */
  50158. switchPanningModelToHRTF(): void;
  50159. /**
  50160. * Switch the panning model to Equal Power:
  50161. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  50162. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  50163. */
  50164. switchPanningModelToEqualPower(): void;
  50165. /**
  50166. * Connect the sound track to an audio analyser allowing some amazing
  50167. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  50168. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  50169. * @param analyser The analyser to connect to the engine
  50170. */
  50171. connectToAnalyser(analyser: Analyser): void;
  50172. }
  50173. }
  50174. declare module "babylonjs/Audio/audioSceneComponent" {
  50175. import { Sound } from "babylonjs/Audio/sound";
  50176. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  50177. import { Nullable } from "babylonjs/types";
  50178. import { Vector3 } from "babylonjs/Maths/math.vector";
  50179. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50180. import { Scene } from "babylonjs/scene";
  50181. import { AbstractScene } from "babylonjs/abstractScene";
  50182. import "babylonjs/Audio/audioEngine";
  50183. module "babylonjs/abstractScene" {
  50184. interface AbstractScene {
  50185. /**
  50186. * The list of sounds used in the scene.
  50187. */
  50188. sounds: Nullable<Array<Sound>>;
  50189. }
  50190. }
  50191. module "babylonjs/scene" {
  50192. interface Scene {
  50193. /**
  50194. * @hidden
  50195. * Backing field
  50196. */
  50197. _mainSoundTrack: SoundTrack;
  50198. /**
  50199. * The main sound track played by the scene.
  50200. * It cotains your primary collection of sounds.
  50201. */
  50202. mainSoundTrack: SoundTrack;
  50203. /**
  50204. * The list of sound tracks added to the scene
  50205. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  50206. */
  50207. soundTracks: Nullable<Array<SoundTrack>>;
  50208. /**
  50209. * Gets a sound using a given name
  50210. * @param name defines the name to search for
  50211. * @return the found sound or null if not found at all.
  50212. */
  50213. getSoundByName(name: string): Nullable<Sound>;
  50214. /**
  50215. * Gets or sets if audio support is enabled
  50216. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  50217. */
  50218. audioEnabled: boolean;
  50219. /**
  50220. * Gets or sets if audio will be output to headphones
  50221. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  50222. */
  50223. headphone: boolean;
  50224. /**
  50225. * Gets or sets custom audio listener position provider
  50226. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  50227. */
  50228. audioListenerPositionProvider: Nullable<() => Vector3>;
  50229. /**
  50230. * Gets or sets a refresh rate when using 3D audio positioning
  50231. */
  50232. audioPositioningRefreshRate: number;
  50233. }
  50234. }
  50235. /**
  50236. * Defines the sound scene component responsible to manage any sounds
  50237. * in a given scene.
  50238. */
  50239. export class AudioSceneComponent implements ISceneSerializableComponent {
  50240. private static _CameraDirectionLH;
  50241. private static _CameraDirectionRH;
  50242. /**
  50243. * The component name helpfull to identify the component in the list of scene components.
  50244. */
  50245. readonly name: string;
  50246. /**
  50247. * The scene the component belongs to.
  50248. */
  50249. scene: Scene;
  50250. private _audioEnabled;
  50251. /**
  50252. * Gets whether audio is enabled or not.
  50253. * Please use related enable/disable method to switch state.
  50254. */
  50255. get audioEnabled(): boolean;
  50256. private _headphone;
  50257. /**
  50258. * Gets whether audio is outputing to headphone or not.
  50259. * Please use the according Switch methods to change output.
  50260. */
  50261. get headphone(): boolean;
  50262. /**
  50263. * Gets or sets a refresh rate when using 3D audio positioning
  50264. */
  50265. audioPositioningRefreshRate: number;
  50266. private _audioListenerPositionProvider;
  50267. /**
  50268. * Gets the current audio listener position provider
  50269. */
  50270. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  50271. /**
  50272. * Sets a custom listener position for all sounds in the scene
  50273. * By default, this is the position of the first active camera
  50274. */
  50275. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  50276. /**
  50277. * Creates a new instance of the component for the given scene
  50278. * @param scene Defines the scene to register the component in
  50279. */
  50280. constructor(scene: Scene);
  50281. /**
  50282. * Registers the component in a given scene
  50283. */
  50284. register(): void;
  50285. /**
  50286. * Rebuilds the elements related to this component in case of
  50287. * context lost for instance.
  50288. */
  50289. rebuild(): void;
  50290. /**
  50291. * Serializes the component data to the specified json object
  50292. * @param serializationObject The object to serialize to
  50293. */
  50294. serialize(serializationObject: any): void;
  50295. /**
  50296. * Adds all the elements from the container to the scene
  50297. * @param container the container holding the elements
  50298. */
  50299. addFromContainer(container: AbstractScene): void;
  50300. /**
  50301. * Removes all the elements in the container from the scene
  50302. * @param container contains the elements to remove
  50303. * @param dispose if the removed element should be disposed (default: false)
  50304. */
  50305. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50306. /**
  50307. * Disposes the component and the associated ressources.
  50308. */
  50309. dispose(): void;
  50310. /**
  50311. * Disables audio in the associated scene.
  50312. */
  50313. disableAudio(): void;
  50314. /**
  50315. * Enables audio in the associated scene.
  50316. */
  50317. enableAudio(): void;
  50318. /**
  50319. * Switch audio to headphone output.
  50320. */
  50321. switchAudioModeForHeadphones(): void;
  50322. /**
  50323. * Switch audio to normal speakers.
  50324. */
  50325. switchAudioModeForNormalSpeakers(): void;
  50326. private _cachedCameraDirection;
  50327. private _cachedCameraPosition;
  50328. private _lastCheck;
  50329. private _afterRender;
  50330. }
  50331. }
  50332. declare module "babylonjs/Audio/weightedsound" {
  50333. import { Sound } from "babylonjs/Audio/sound";
  50334. /**
  50335. * Wraps one or more Sound objects and selects one with random weight for playback.
  50336. */
  50337. export class WeightedSound {
  50338. /** When true a Sound will be selected and played when the current playing Sound completes. */
  50339. loop: boolean;
  50340. private _coneInnerAngle;
  50341. private _coneOuterAngle;
  50342. private _volume;
  50343. /** A Sound is currently playing. */
  50344. isPlaying: boolean;
  50345. /** A Sound is currently paused. */
  50346. isPaused: boolean;
  50347. private _sounds;
  50348. private _weights;
  50349. private _currentIndex?;
  50350. /**
  50351. * Creates a new WeightedSound from the list of sounds given.
  50352. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  50353. * @param sounds Array of Sounds that will be selected from.
  50354. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  50355. */
  50356. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  50357. /**
  50358. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  50359. */
  50360. get directionalConeInnerAngle(): number;
  50361. /**
  50362. * The size of cone in degress for a directional sound in which there will be no attenuation.
  50363. */
  50364. set directionalConeInnerAngle(value: number);
  50365. /**
  50366. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  50367. * Listener angles between innerAngle and outerAngle will falloff linearly.
  50368. */
  50369. get directionalConeOuterAngle(): number;
  50370. /**
  50371. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  50372. * Listener angles between innerAngle and outerAngle will falloff linearly.
  50373. */
  50374. set directionalConeOuterAngle(value: number);
  50375. /**
  50376. * Playback volume.
  50377. */
  50378. get volume(): number;
  50379. /**
  50380. * Playback volume.
  50381. */
  50382. set volume(value: number);
  50383. private _onended;
  50384. /**
  50385. * Suspend playback
  50386. */
  50387. pause(): void;
  50388. /**
  50389. * Stop playback
  50390. */
  50391. stop(): void;
  50392. /**
  50393. * Start playback.
  50394. * @param startOffset Position the clip head at a specific time in seconds.
  50395. */
  50396. play(startOffset?: number): void;
  50397. }
  50398. }
  50399. declare module "babylonjs/Audio/index" {
  50400. export * from "babylonjs/Audio/Interfaces/IAudioEngine";
  50401. export * from "babylonjs/Audio/Interfaces/ISoundOptions";
  50402. export * from "babylonjs/Audio/analyser";
  50403. export * from "babylonjs/Audio/audioEngine";
  50404. export * from "babylonjs/Audio/audioSceneComponent";
  50405. export * from "babylonjs/Audio/sound";
  50406. export * from "babylonjs/Audio/soundTrack";
  50407. export * from "babylonjs/Audio/weightedsound";
  50408. }
  50409. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  50410. import { Behavior } from "babylonjs/Behaviors/behavior";
  50411. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  50412. import { BackEase } from "babylonjs/Animations/easing";
  50413. /**
  50414. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  50415. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  50416. */
  50417. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  50418. /**
  50419. * Gets the name of the behavior.
  50420. */
  50421. get name(): string;
  50422. /**
  50423. * The easing function used by animations
  50424. */
  50425. static EasingFunction: BackEase;
  50426. /**
  50427. * The easing mode used by animations
  50428. */
  50429. static EasingMode: number;
  50430. /**
  50431. * The duration of the animation, in milliseconds
  50432. */
  50433. transitionDuration: number;
  50434. /**
  50435. * Length of the distance animated by the transition when lower radius is reached
  50436. */
  50437. lowerRadiusTransitionRange: number;
  50438. /**
  50439. * Length of the distance animated by the transition when upper radius is reached
  50440. */
  50441. upperRadiusTransitionRange: number;
  50442. private _autoTransitionRange;
  50443. /**
  50444. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  50445. */
  50446. get autoTransitionRange(): boolean;
  50447. /**
  50448. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  50449. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  50450. */
  50451. set autoTransitionRange(value: boolean);
  50452. private _attachedCamera;
  50453. private _onAfterCheckInputsObserver;
  50454. private _onMeshTargetChangedObserver;
  50455. /**
  50456. * Initializes the behavior.
  50457. */
  50458. init(): void;
  50459. /**
  50460. * Attaches the behavior to its arc rotate camera.
  50461. * @param camera Defines the camera to attach the behavior to
  50462. */
  50463. attach(camera: ArcRotateCamera): void;
  50464. /**
  50465. * Detaches the behavior from its current arc rotate camera.
  50466. */
  50467. detach(): void;
  50468. private _radiusIsAnimating;
  50469. private _radiusBounceTransition;
  50470. private _animatables;
  50471. private _cachedWheelPrecision;
  50472. /**
  50473. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  50474. * @param radiusLimit The limit to check against.
  50475. * @return Bool to indicate if at limit.
  50476. */
  50477. private _isRadiusAtLimit;
  50478. /**
  50479. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  50480. * @param radiusDelta The delta by which to animate to. Can be negative.
  50481. */
  50482. private _applyBoundRadiusAnimation;
  50483. /**
  50484. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  50485. */
  50486. protected _clearAnimationLocks(): void;
  50487. /**
  50488. * Stops and removes all animations that have been applied to the camera
  50489. */
  50490. stopAllAnimations(): void;
  50491. }
  50492. }
  50493. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  50494. import { Behavior } from "babylonjs/Behaviors/behavior";
  50495. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  50496. import { ExponentialEase } from "babylonjs/Animations/easing";
  50497. import { Nullable } from "babylonjs/types";
  50498. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50499. import { Vector3 } from "babylonjs/Maths/math.vector";
  50500. /**
  50501. * 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.
  50502. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  50503. */
  50504. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  50505. /**
  50506. * Gets the name of the behavior.
  50507. */
  50508. get name(): string;
  50509. private _mode;
  50510. private _radiusScale;
  50511. private _positionScale;
  50512. private _defaultElevation;
  50513. private _elevationReturnTime;
  50514. private _elevationReturnWaitTime;
  50515. private _zoomStopsAnimation;
  50516. private _framingTime;
  50517. /**
  50518. * The easing function used by animations
  50519. */
  50520. static EasingFunction: ExponentialEase;
  50521. /**
  50522. * The easing mode used by animations
  50523. */
  50524. static EasingMode: number;
  50525. /**
  50526. * Sets the current mode used by the behavior
  50527. */
  50528. set mode(mode: number);
  50529. /**
  50530. * Gets current mode used by the behavior.
  50531. */
  50532. get mode(): number;
  50533. /**
  50534. * Sets the scale applied to the radius (1 by default)
  50535. */
  50536. set radiusScale(radius: number);
  50537. /**
  50538. * Gets the scale applied to the radius
  50539. */
  50540. get radiusScale(): number;
  50541. /**
  50542. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  50543. */
  50544. set positionScale(scale: number);
  50545. /**
  50546. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  50547. */
  50548. get positionScale(): number;
  50549. /**
  50550. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  50551. * behaviour is triggered, in radians.
  50552. */
  50553. set defaultElevation(elevation: number);
  50554. /**
  50555. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  50556. * behaviour is triggered, in radians.
  50557. */
  50558. get defaultElevation(): number;
  50559. /**
  50560. * Sets the time (in milliseconds) taken to return to the default beta position.
  50561. * Negative value indicates camera should not return to default.
  50562. */
  50563. set elevationReturnTime(speed: number);
  50564. /**
  50565. * Gets the time (in milliseconds) taken to return to the default beta position.
  50566. * Negative value indicates camera should not return to default.
  50567. */
  50568. get elevationReturnTime(): number;
  50569. /**
  50570. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  50571. */
  50572. set elevationReturnWaitTime(time: number);
  50573. /**
  50574. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  50575. */
  50576. get elevationReturnWaitTime(): number;
  50577. /**
  50578. * Sets the flag that indicates if user zooming should stop animation.
  50579. */
  50580. set zoomStopsAnimation(flag: boolean);
  50581. /**
  50582. * Gets the flag that indicates if user zooming should stop animation.
  50583. */
  50584. get zoomStopsAnimation(): boolean;
  50585. /**
  50586. * Sets the transition time when framing the mesh, in milliseconds
  50587. */
  50588. set framingTime(time: number);
  50589. /**
  50590. * Gets the transition time when framing the mesh, in milliseconds
  50591. */
  50592. get framingTime(): number;
  50593. /**
  50594. * Define if the behavior should automatically change the configured
  50595. * camera limits and sensibilities.
  50596. */
  50597. autoCorrectCameraLimitsAndSensibility: boolean;
  50598. private _onPrePointerObservableObserver;
  50599. private _onAfterCheckInputsObserver;
  50600. private _onMeshTargetChangedObserver;
  50601. private _attachedCamera;
  50602. private _isPointerDown;
  50603. private _lastInteractionTime;
  50604. /**
  50605. * Initializes the behavior.
  50606. */
  50607. init(): void;
  50608. /**
  50609. * Attaches the behavior to its arc rotate camera.
  50610. * @param camera Defines the camera to attach the behavior to
  50611. */
  50612. attach(camera: ArcRotateCamera): void;
  50613. /**
  50614. * Detaches the behavior from its current arc rotate camera.
  50615. */
  50616. detach(): void;
  50617. private _animatables;
  50618. private _betaIsAnimating;
  50619. private _betaTransition;
  50620. private _radiusTransition;
  50621. private _vectorTransition;
  50622. /**
  50623. * Targets the given mesh and updates zoom level accordingly.
  50624. * @param mesh The mesh to target.
  50625. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  50626. * @param onAnimationEnd Callback triggered at the end of the framing animation
  50627. */
  50628. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  50629. /**
  50630. * Targets the given mesh with its children and updates zoom level accordingly.
  50631. * @param mesh The mesh to target.
  50632. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  50633. * @param onAnimationEnd Callback triggered at the end of the framing animation
  50634. */
  50635. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  50636. /**
  50637. * Targets the given meshes with their children and updates zoom level accordingly.
  50638. * @param meshes The mesh to target.
  50639. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  50640. * @param onAnimationEnd Callback triggered at the end of the framing animation
  50641. */
  50642. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  50643. /**
  50644. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  50645. * @param minimumWorld Determines the smaller position of the bounding box extend
  50646. * @param maximumWorld Determines the bigger position of the bounding box extend
  50647. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  50648. * @param onAnimationEnd Callback triggered at the end of the framing animation
  50649. */
  50650. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  50651. /**
  50652. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  50653. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  50654. * frustum width.
  50655. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  50656. * to fully enclose the mesh in the viewing frustum.
  50657. */
  50658. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  50659. /**
  50660. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  50661. * is automatically returned to its default position (expected to be above ground plane).
  50662. */
  50663. private _maintainCameraAboveGround;
  50664. /**
  50665. * Returns the frustum slope based on the canvas ratio and camera FOV
  50666. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  50667. */
  50668. private _getFrustumSlope;
  50669. /**
  50670. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  50671. */
  50672. private _clearAnimationLocks;
  50673. /**
  50674. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  50675. */
  50676. private _applyUserInteraction;
  50677. /**
  50678. * Stops and removes all animations that have been applied to the camera
  50679. */
  50680. stopAllAnimations(): void;
  50681. /**
  50682. * Gets a value indicating if the user is moving the camera
  50683. */
  50684. get isUserIsMoving(): boolean;
  50685. /**
  50686. * The camera can move all the way towards the mesh.
  50687. */
  50688. static IgnoreBoundsSizeMode: number;
  50689. /**
  50690. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  50691. */
  50692. static FitFrustumSidesMode: number;
  50693. }
  50694. }
  50695. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  50696. import { Nullable } from "babylonjs/types";
  50697. import { Camera } from "babylonjs/Cameras/camera";
  50698. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50699. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  50700. /**
  50701. * Base class for Camera Pointer Inputs.
  50702. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  50703. * for example usage.
  50704. */
  50705. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  50706. /**
  50707. * Defines the camera the input is attached to.
  50708. */
  50709. abstract camera: Camera;
  50710. /**
  50711. * Whether keyboard modifier keys are pressed at time of last mouse event.
  50712. */
  50713. protected _altKey: boolean;
  50714. protected _ctrlKey: boolean;
  50715. protected _metaKey: boolean;
  50716. protected _shiftKey: boolean;
  50717. /**
  50718. * Which mouse buttons were pressed at time of last mouse event.
  50719. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  50720. */
  50721. protected _buttonsPressed: number;
  50722. /**
  50723. * Defines the buttons associated with the input to handle camera move.
  50724. */
  50725. buttons: number[];
  50726. /**
  50727. * Attach the input controls to a specific dom element to get the input from.
  50728. * @param element Defines the element the controls should be listened from
  50729. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50730. */
  50731. attachControl(noPreventDefault?: boolean): void;
  50732. /**
  50733. * Detach the current controls from the specified dom element.
  50734. */
  50735. detachControl(): void;
  50736. /**
  50737. * Gets the class name of the current input.
  50738. * @returns the class name
  50739. */
  50740. getClassName(): string;
  50741. /**
  50742. * Get the friendly name associated with the input class.
  50743. * @returns the input friendly name
  50744. */
  50745. getSimpleName(): string;
  50746. /**
  50747. * Called on pointer POINTERDOUBLETAP event.
  50748. * Override this method to provide functionality on POINTERDOUBLETAP event.
  50749. */
  50750. protected onDoubleTap(type: string): void;
  50751. /**
  50752. * Called on pointer POINTERMOVE event if only a single touch is active.
  50753. * Override this method to provide functionality.
  50754. */
  50755. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  50756. /**
  50757. * Called on pointer POINTERMOVE event if multiple touches are active.
  50758. * Override this method to provide functionality.
  50759. */
  50760. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  50761. /**
  50762. * Called on JS contextmenu event.
  50763. * Override this method to provide functionality.
  50764. */
  50765. protected onContextMenu(evt: PointerEvent): void;
  50766. /**
  50767. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  50768. * press.
  50769. * Override this method to provide functionality.
  50770. */
  50771. protected onButtonDown(evt: PointerEvent): void;
  50772. /**
  50773. * Called each time a new POINTERUP event occurs. Ie, for each button
  50774. * release.
  50775. * Override this method to provide functionality.
  50776. */
  50777. protected onButtonUp(evt: PointerEvent): void;
  50778. /**
  50779. * Called when window becomes inactive.
  50780. * Override this method to provide functionality.
  50781. */
  50782. protected onLostFocus(): void;
  50783. private _pointerInput;
  50784. private _observer;
  50785. private _onLostFocus;
  50786. private pointA;
  50787. private pointB;
  50788. }
  50789. }
  50790. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  50791. import { Nullable } from "babylonjs/types";
  50792. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  50793. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  50794. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  50795. /**
  50796. * Manage the pointers inputs to control an arc rotate camera.
  50797. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50798. */
  50799. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  50800. /**
  50801. * Defines the camera the input is attached to.
  50802. */
  50803. camera: ArcRotateCamera;
  50804. /**
  50805. * Gets the class name of the current input.
  50806. * @returns the class name
  50807. */
  50808. getClassName(): string;
  50809. /**
  50810. * Defines the buttons associated with the input to handle camera move.
  50811. */
  50812. buttons: number[];
  50813. /**
  50814. * Defines the pointer angular sensibility along the X axis or how fast is
  50815. * the camera rotating.
  50816. */
  50817. angularSensibilityX: number;
  50818. /**
  50819. * Defines the pointer angular sensibility along the Y axis or how fast is
  50820. * the camera rotating.
  50821. */
  50822. angularSensibilityY: number;
  50823. /**
  50824. * Defines the pointer pinch precision or how fast is the camera zooming.
  50825. */
  50826. pinchPrecision: number;
  50827. /**
  50828. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  50829. * from 0.
  50830. * It defines the percentage of current camera.radius to use as delta when
  50831. * pinch zoom is used.
  50832. */
  50833. pinchDeltaPercentage: number;
  50834. /**
  50835. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  50836. * that any object in the plane at the camera's target point will scale
  50837. * perfectly with finger motion.
  50838. * Overrides pinchDeltaPercentage and pinchPrecision.
  50839. */
  50840. useNaturalPinchZoom: boolean;
  50841. /**
  50842. * Defines the pointer panning sensibility or how fast is the camera moving.
  50843. */
  50844. panningSensibility: number;
  50845. /**
  50846. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  50847. */
  50848. multiTouchPanning: boolean;
  50849. /**
  50850. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  50851. * zoom (pinch) through multitouch.
  50852. */
  50853. multiTouchPanAndZoom: boolean;
  50854. /**
  50855. * Revers pinch action direction.
  50856. */
  50857. pinchInwards: boolean;
  50858. private _isPanClick;
  50859. private _twoFingerActivityCount;
  50860. private _isPinching;
  50861. /**
  50862. * Called on pointer POINTERMOVE event if only a single touch is active.
  50863. */
  50864. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  50865. /**
  50866. * Called on pointer POINTERDOUBLETAP event.
  50867. */
  50868. protected onDoubleTap(type: string): void;
  50869. /**
  50870. * Called on pointer POINTERMOVE event if multiple touches are active.
  50871. */
  50872. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  50873. /**
  50874. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  50875. * press.
  50876. */
  50877. protected onButtonDown(evt: PointerEvent): void;
  50878. /**
  50879. * Called each time a new POINTERUP event occurs. Ie, for each button
  50880. * release.
  50881. */
  50882. protected onButtonUp(evt: PointerEvent): void;
  50883. /**
  50884. * Called when window becomes inactive.
  50885. */
  50886. protected onLostFocus(): void;
  50887. }
  50888. }
  50889. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  50890. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  50891. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50892. /**
  50893. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  50894. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50895. */
  50896. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  50897. /**
  50898. * Defines the camera the input is attached to.
  50899. */
  50900. camera: ArcRotateCamera;
  50901. /**
  50902. * Defines the list of key codes associated with the up action (increase alpha)
  50903. */
  50904. keysUp: number[];
  50905. /**
  50906. * Defines the list of key codes associated with the down action (decrease alpha)
  50907. */
  50908. keysDown: number[];
  50909. /**
  50910. * Defines the list of key codes associated with the left action (increase beta)
  50911. */
  50912. keysLeft: number[];
  50913. /**
  50914. * Defines the list of key codes associated with the right action (decrease beta)
  50915. */
  50916. keysRight: number[];
  50917. /**
  50918. * Defines the list of key codes associated with the reset action.
  50919. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  50920. */
  50921. keysReset: number[];
  50922. /**
  50923. * Defines the panning sensibility of the inputs.
  50924. * (How fast is the camera panning)
  50925. */
  50926. panningSensibility: number;
  50927. /**
  50928. * Defines the zooming sensibility of the inputs.
  50929. * (How fast is the camera zooming)
  50930. */
  50931. zoomingSensibility: number;
  50932. /**
  50933. * Defines whether maintaining the alt key down switch the movement mode from
  50934. * orientation to zoom.
  50935. */
  50936. useAltToZoom: boolean;
  50937. /**
  50938. * Rotation speed of the camera
  50939. */
  50940. angularSpeed: number;
  50941. private _keys;
  50942. private _ctrlPressed;
  50943. private _altPressed;
  50944. private _onCanvasBlurObserver;
  50945. private _onKeyboardObserver;
  50946. private _engine;
  50947. private _scene;
  50948. /**
  50949. * Attach the input controls to a specific dom element to get the input from.
  50950. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50951. */
  50952. attachControl(noPreventDefault?: boolean): void;
  50953. /**
  50954. * Detach the current controls from the specified dom element.
  50955. */
  50956. detachControl(): void;
  50957. /**
  50958. * Update the current camera state depending on the inputs that have been used this frame.
  50959. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50960. */
  50961. checkInputs(): void;
  50962. /**
  50963. * Gets the class name of the current intput.
  50964. * @returns the class name
  50965. */
  50966. getClassName(): string;
  50967. /**
  50968. * Get the friendly name associated with the input class.
  50969. * @returns the input friendly name
  50970. */
  50971. getSimpleName(): string;
  50972. }
  50973. }
  50974. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  50975. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  50976. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50977. /**
  50978. * Manage the mouse wheel inputs to control an arc rotate camera.
  50979. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50980. */
  50981. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  50982. /**
  50983. * Defines the camera the input is attached to.
  50984. */
  50985. camera: ArcRotateCamera;
  50986. /**
  50987. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  50988. */
  50989. wheelPrecision: number;
  50990. /**
  50991. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  50992. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  50993. */
  50994. wheelDeltaPercentage: number;
  50995. private _wheel;
  50996. private _observer;
  50997. private computeDeltaFromMouseWheelLegacyEvent;
  50998. /**
  50999. * Attach the input controls to a specific dom element to get the input from.
  51000. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51001. */
  51002. attachControl(noPreventDefault?: boolean): void;
  51003. /**
  51004. * Detach the current controls from the specified dom element.
  51005. */
  51006. detachControl(): void;
  51007. /**
  51008. * Gets the class name of the current intput.
  51009. * @returns the class name
  51010. */
  51011. getClassName(): string;
  51012. /**
  51013. * Get the friendly name associated with the input class.
  51014. * @returns the input friendly name
  51015. */
  51016. getSimpleName(): string;
  51017. }
  51018. }
  51019. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  51020. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51021. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  51022. /**
  51023. * Default Inputs manager for the ArcRotateCamera.
  51024. * It groups all the default supported inputs for ease of use.
  51025. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51026. */
  51027. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  51028. /**
  51029. * Instantiates a new ArcRotateCameraInputsManager.
  51030. * @param camera Defines the camera the inputs belong to
  51031. */
  51032. constructor(camera: ArcRotateCamera);
  51033. /**
  51034. * Add mouse wheel input support to the input manager.
  51035. * @returns the current input manager
  51036. */
  51037. addMouseWheel(): ArcRotateCameraInputsManager;
  51038. /**
  51039. * Add pointers input support to the input manager.
  51040. * @returns the current input manager
  51041. */
  51042. addPointers(): ArcRotateCameraInputsManager;
  51043. /**
  51044. * Add keyboard input support to the input manager.
  51045. * @returns the current input manager
  51046. */
  51047. addKeyboard(): ArcRotateCameraInputsManager;
  51048. }
  51049. }
  51050. declare module "babylonjs/Cameras/arcRotateCamera" {
  51051. import { Observable } from "babylonjs/Misc/observable";
  51052. import { Nullable } from "babylonjs/types";
  51053. import { Scene } from "babylonjs/scene";
  51054. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  51055. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51056. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  51057. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  51058. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  51059. import { Camera } from "babylonjs/Cameras/camera";
  51060. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  51061. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  51062. import { Collider } from "babylonjs/Collisions/collider";
  51063. /**
  51064. * This represents an orbital type of camera.
  51065. *
  51066. * 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.
  51067. * 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.
  51068. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  51069. */
  51070. export class ArcRotateCamera extends TargetCamera {
  51071. /**
  51072. * Defines the rotation angle of the camera along the longitudinal axis.
  51073. */
  51074. alpha: number;
  51075. /**
  51076. * Defines the rotation angle of the camera along the latitudinal axis.
  51077. */
  51078. beta: number;
  51079. /**
  51080. * Defines the radius of the camera from it s target point.
  51081. */
  51082. radius: number;
  51083. protected _target: Vector3;
  51084. protected _targetHost: Nullable<AbstractMesh>;
  51085. /**
  51086. * Defines the target point of the camera.
  51087. * The camera looks towards it form the radius distance.
  51088. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  51089. */
  51090. get target(): Vector3;
  51091. set target(value: Vector3);
  51092. /**
  51093. * Define the current local position of the camera in the scene
  51094. */
  51095. get position(): Vector3;
  51096. set position(newPosition: Vector3);
  51097. protected _upToYMatrix: Matrix;
  51098. protected _YToUpMatrix: Matrix;
  51099. /**
  51100. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  51101. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  51102. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  51103. */
  51104. set upVector(vec: Vector3);
  51105. get upVector(): Vector3;
  51106. /**
  51107. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  51108. */
  51109. setMatUp(): void;
  51110. /**
  51111. * Current inertia value on the longitudinal axis.
  51112. * The bigger this number the longer it will take for the camera to stop.
  51113. */
  51114. inertialAlphaOffset: number;
  51115. /**
  51116. * Current inertia value on the latitudinal axis.
  51117. * The bigger this number the longer it will take for the camera to stop.
  51118. */
  51119. inertialBetaOffset: number;
  51120. /**
  51121. * Current inertia value on the radius axis.
  51122. * The bigger this number the longer it will take for the camera to stop.
  51123. */
  51124. inertialRadiusOffset: number;
  51125. /**
  51126. * Minimum allowed angle on the longitudinal axis.
  51127. * This can help limiting how the Camera is able to move in the scene.
  51128. */
  51129. lowerAlphaLimit: Nullable<number>;
  51130. /**
  51131. * Maximum allowed angle on the longitudinal axis.
  51132. * This can help limiting how the Camera is able to move in the scene.
  51133. */
  51134. upperAlphaLimit: Nullable<number>;
  51135. /**
  51136. * Minimum allowed angle on the latitudinal axis.
  51137. * This can help limiting how the Camera is able to move in the scene.
  51138. */
  51139. lowerBetaLimit: number;
  51140. /**
  51141. * Maximum allowed angle on the latitudinal axis.
  51142. * This can help limiting how the Camera is able to move in the scene.
  51143. */
  51144. upperBetaLimit: number;
  51145. /**
  51146. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  51147. * This can help limiting how the Camera is able to move in the scene.
  51148. */
  51149. lowerRadiusLimit: Nullable<number>;
  51150. /**
  51151. * Maximum allowed distance of the camera to the target (The camera can not get further).
  51152. * This can help limiting how the Camera is able to move in the scene.
  51153. */
  51154. upperRadiusLimit: Nullable<number>;
  51155. /**
  51156. * Defines the current inertia value used during panning of the camera along the X axis.
  51157. */
  51158. inertialPanningX: number;
  51159. /**
  51160. * Defines the current inertia value used during panning of the camera along the Y axis.
  51161. */
  51162. inertialPanningY: number;
  51163. /**
  51164. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  51165. * Basically if your fingers moves away from more than this distance you will be considered
  51166. * in pinch mode.
  51167. */
  51168. pinchToPanMaxDistance: number;
  51169. /**
  51170. * Defines the maximum distance the camera can pan.
  51171. * This could help keeping the cammera always in your scene.
  51172. */
  51173. panningDistanceLimit: Nullable<number>;
  51174. /**
  51175. * Defines the target of the camera before paning.
  51176. */
  51177. panningOriginTarget: Vector3;
  51178. /**
  51179. * Defines the value of the inertia used during panning.
  51180. * 0 would mean stop inertia and one would mean no decelleration at all.
  51181. */
  51182. panningInertia: number;
  51183. /**
  51184. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  51185. */
  51186. get angularSensibilityX(): number;
  51187. set angularSensibilityX(value: number);
  51188. /**
  51189. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  51190. */
  51191. get angularSensibilityY(): number;
  51192. set angularSensibilityY(value: number);
  51193. /**
  51194. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  51195. */
  51196. get pinchPrecision(): number;
  51197. set pinchPrecision(value: number);
  51198. /**
  51199. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  51200. * It will be used instead of pinchDeltaPrecision if different from 0.
  51201. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  51202. */
  51203. get pinchDeltaPercentage(): number;
  51204. set pinchDeltaPercentage(value: number);
  51205. /**
  51206. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  51207. * and pinch delta percentage.
  51208. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  51209. * that any object in the plane at the camera's target point will scale
  51210. * perfectly with finger motion.
  51211. */
  51212. get useNaturalPinchZoom(): boolean;
  51213. set useNaturalPinchZoom(value: boolean);
  51214. /**
  51215. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  51216. */
  51217. get panningSensibility(): number;
  51218. set panningSensibility(value: number);
  51219. /**
  51220. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  51221. */
  51222. get keysUp(): number[];
  51223. set keysUp(value: number[]);
  51224. /**
  51225. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  51226. */
  51227. get keysDown(): number[];
  51228. set keysDown(value: number[]);
  51229. /**
  51230. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  51231. */
  51232. get keysLeft(): number[];
  51233. set keysLeft(value: number[]);
  51234. /**
  51235. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  51236. */
  51237. get keysRight(): number[];
  51238. set keysRight(value: number[]);
  51239. /**
  51240. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  51241. */
  51242. get wheelPrecision(): number;
  51243. set wheelPrecision(value: number);
  51244. /**
  51245. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  51246. * It will be used instead of pinchDeltaPrecision if different from 0.
  51247. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  51248. */
  51249. get wheelDeltaPercentage(): number;
  51250. set wheelDeltaPercentage(value: number);
  51251. /**
  51252. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  51253. */
  51254. zoomOnFactor: number;
  51255. /**
  51256. * Defines a screen offset for the camera position.
  51257. */
  51258. targetScreenOffset: Vector2;
  51259. /**
  51260. * Allows the camera to be completely reversed.
  51261. * If false the camera can not arrive upside down.
  51262. */
  51263. allowUpsideDown: boolean;
  51264. /**
  51265. * Define if double tap/click is used to restore the previously saved state of the camera.
  51266. */
  51267. useInputToRestoreState: boolean;
  51268. /** @hidden */
  51269. _viewMatrix: Matrix;
  51270. /** @hidden */
  51271. _useCtrlForPanning: boolean;
  51272. /** @hidden */
  51273. _panningMouseButton: number;
  51274. /**
  51275. * Defines the input associated to the camera.
  51276. */
  51277. inputs: ArcRotateCameraInputsManager;
  51278. /** @hidden */
  51279. _reset: () => void;
  51280. /**
  51281. * Defines the allowed panning axis.
  51282. */
  51283. panningAxis: Vector3;
  51284. protected _transformedDirection: Vector3;
  51285. private _bouncingBehavior;
  51286. /**
  51287. * Gets the bouncing behavior of the camera if it has been enabled.
  51288. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  51289. */
  51290. get bouncingBehavior(): Nullable<BouncingBehavior>;
  51291. /**
  51292. * Defines if the bouncing behavior of the camera is enabled on the camera.
  51293. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  51294. */
  51295. get useBouncingBehavior(): boolean;
  51296. set useBouncingBehavior(value: boolean);
  51297. private _framingBehavior;
  51298. /**
  51299. * Gets the framing behavior of the camera if it has been enabled.
  51300. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  51301. */
  51302. get framingBehavior(): Nullable<FramingBehavior>;
  51303. /**
  51304. * Defines if the framing behavior of the camera is enabled on the camera.
  51305. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  51306. */
  51307. get useFramingBehavior(): boolean;
  51308. set useFramingBehavior(value: boolean);
  51309. private _autoRotationBehavior;
  51310. /**
  51311. * Gets the auto rotation behavior of the camera if it has been enabled.
  51312. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  51313. */
  51314. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  51315. /**
  51316. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  51317. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  51318. */
  51319. get useAutoRotationBehavior(): boolean;
  51320. set useAutoRotationBehavior(value: boolean);
  51321. /**
  51322. * Observable triggered when the mesh target has been changed on the camera.
  51323. */
  51324. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  51325. /**
  51326. * Event raised when the camera is colliding with a mesh.
  51327. */
  51328. onCollide: (collidedMesh: AbstractMesh) => void;
  51329. /**
  51330. * Defines whether the camera should check collision with the objects oh the scene.
  51331. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  51332. */
  51333. checkCollisions: boolean;
  51334. /**
  51335. * Defines the collision radius of the camera.
  51336. * This simulates a sphere around the camera.
  51337. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  51338. */
  51339. collisionRadius: Vector3;
  51340. protected _collider: Collider;
  51341. protected _previousPosition: Vector3;
  51342. protected _collisionVelocity: Vector3;
  51343. protected _newPosition: Vector3;
  51344. protected _previousAlpha: number;
  51345. protected _previousBeta: number;
  51346. protected _previousRadius: number;
  51347. protected _collisionTriggered: boolean;
  51348. protected _targetBoundingCenter: Nullable<Vector3>;
  51349. private _computationVector;
  51350. /**
  51351. * Instantiates a new ArcRotateCamera in a given scene
  51352. * @param name Defines the name of the camera
  51353. * @param alpha Defines the camera rotation along the logitudinal axis
  51354. * @param beta Defines the camera rotation along the latitudinal axis
  51355. * @param radius Defines the camera distance from its target
  51356. * @param target Defines the camera target
  51357. * @param scene Defines the scene the camera belongs to
  51358. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  51359. */
  51360. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  51361. /** @hidden */
  51362. _initCache(): void;
  51363. /** @hidden */
  51364. _updateCache(ignoreParentClass?: boolean): void;
  51365. protected _getTargetPosition(): Vector3;
  51366. private _storedAlpha;
  51367. private _storedBeta;
  51368. private _storedRadius;
  51369. private _storedTarget;
  51370. private _storedTargetScreenOffset;
  51371. /**
  51372. * Stores the current state of the camera (alpha, beta, radius and target)
  51373. * @returns the camera itself
  51374. */
  51375. storeState(): Camera;
  51376. /**
  51377. * @hidden
  51378. * Restored camera state. You must call storeState() first
  51379. */
  51380. _restoreStateValues(): boolean;
  51381. /** @hidden */
  51382. _isSynchronizedViewMatrix(): boolean;
  51383. /**
  51384. * Attach the input controls to a specific dom element to get the input from.
  51385. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51386. */
  51387. attachControl(noPreventDefault?: boolean): void;
  51388. /**
  51389. * Attach the input controls to a specific dom element to get the input from.
  51390. * @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
  51391. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51392. */
  51393. attachControl(ignored: any, noPreventDefault?: boolean): void;
  51394. /**
  51395. * Attached controls to the current camera.
  51396. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51397. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  51398. */
  51399. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  51400. /**
  51401. * Attached controls to the current camera.
  51402. * @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
  51403. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51404. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  51405. */
  51406. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  51407. /**
  51408. * Attached controls to the current camera.
  51409. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51410. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  51411. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  51412. */
  51413. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  51414. /**
  51415. * Detach the current controls from the specified dom element.
  51416. */
  51417. detachControl(): void;
  51418. /**
  51419. * Detach the current controls from the specified dom element.
  51420. * @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
  51421. */
  51422. detachControl(ignored: any): void;
  51423. /** @hidden */
  51424. _checkInputs(): void;
  51425. protected _checkLimits(): void;
  51426. /**
  51427. * Rebuilds angles (alpha, beta) and radius from the give position and target
  51428. */
  51429. rebuildAnglesAndRadius(): void;
  51430. /**
  51431. * Use a position to define the current camera related information like alpha, beta and radius
  51432. * @param position Defines the position to set the camera at
  51433. */
  51434. setPosition(position: Vector3): void;
  51435. /**
  51436. * Defines the target the camera should look at.
  51437. * This will automatically adapt alpha beta and radius to fit within the new target.
  51438. * @param target Defines the new target as a Vector or a mesh
  51439. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  51440. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  51441. */
  51442. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  51443. /** @hidden */
  51444. _getViewMatrix(): Matrix;
  51445. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  51446. /**
  51447. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  51448. * @param meshes Defines the mesh to zoom on
  51449. * @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)
  51450. */
  51451. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  51452. /**
  51453. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  51454. * The target will be changed but the radius
  51455. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  51456. * @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)
  51457. */
  51458. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  51459. min: Vector3;
  51460. max: Vector3;
  51461. distance: number;
  51462. }, doNotUpdateMaxZ?: boolean): void;
  51463. /**
  51464. * @override
  51465. * Override Camera.createRigCamera
  51466. */
  51467. createRigCamera(name: string, cameraIndex: number): Camera;
  51468. /**
  51469. * @hidden
  51470. * @override
  51471. * Override Camera._updateRigCameras
  51472. */
  51473. _updateRigCameras(): void;
  51474. /**
  51475. * Destroy the camera and release the current resources hold by it.
  51476. */
  51477. dispose(): void;
  51478. /**
  51479. * Gets the current object class name.
  51480. * @return the class name
  51481. */
  51482. getClassName(): string;
  51483. }
  51484. }
  51485. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  51486. import { Behavior } from "babylonjs/Behaviors/behavior";
  51487. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51488. /**
  51489. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  51490. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  51491. */
  51492. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  51493. /**
  51494. * Gets the name of the behavior.
  51495. */
  51496. get name(): string;
  51497. private _zoomStopsAnimation;
  51498. private _idleRotationSpeed;
  51499. private _idleRotationWaitTime;
  51500. private _idleRotationSpinupTime;
  51501. /**
  51502. * Sets the flag that indicates if user zooming should stop animation.
  51503. */
  51504. set zoomStopsAnimation(flag: boolean);
  51505. /**
  51506. * Gets the flag that indicates if user zooming should stop animation.
  51507. */
  51508. get zoomStopsAnimation(): boolean;
  51509. /**
  51510. * Sets the default speed at which the camera rotates around the model.
  51511. */
  51512. set idleRotationSpeed(speed: number);
  51513. /**
  51514. * Gets the default speed at which the camera rotates around the model.
  51515. */
  51516. get idleRotationSpeed(): number;
  51517. /**
  51518. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  51519. */
  51520. set idleRotationWaitTime(time: number);
  51521. /**
  51522. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  51523. */
  51524. get idleRotationWaitTime(): number;
  51525. /**
  51526. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  51527. */
  51528. set idleRotationSpinupTime(time: number);
  51529. /**
  51530. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  51531. */
  51532. get idleRotationSpinupTime(): number;
  51533. /**
  51534. * Gets a value indicating if the camera is currently rotating because of this behavior
  51535. */
  51536. get rotationInProgress(): boolean;
  51537. private _onPrePointerObservableObserver;
  51538. private _onAfterCheckInputsObserver;
  51539. private _attachedCamera;
  51540. private _isPointerDown;
  51541. private _lastFrameTime;
  51542. private _lastInteractionTime;
  51543. private _cameraRotationSpeed;
  51544. /**
  51545. * Initializes the behavior.
  51546. */
  51547. init(): void;
  51548. /**
  51549. * Attaches the behavior to its arc rotate camera.
  51550. * @param camera Defines the camera to attach the behavior to
  51551. */
  51552. attach(camera: ArcRotateCamera): void;
  51553. /**
  51554. * Detaches the behavior from its current arc rotate camera.
  51555. */
  51556. detach(): void;
  51557. /**
  51558. * Returns true if user is scrolling.
  51559. * @return true if user is scrolling.
  51560. */
  51561. private _userIsZooming;
  51562. private _lastFrameRadius;
  51563. private _shouldAnimationStopForInteraction;
  51564. /**
  51565. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  51566. */
  51567. private _applyUserInteraction;
  51568. private _userIsMoving;
  51569. }
  51570. }
  51571. declare module "babylonjs/Behaviors/Cameras/index" {
  51572. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  51573. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  51574. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  51575. }
  51576. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  51577. import { Mesh } from "babylonjs/Meshes/mesh";
  51578. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51579. import { Behavior } from "babylonjs/Behaviors/behavior";
  51580. /**
  51581. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  51582. */
  51583. export class AttachToBoxBehavior implements Behavior<Mesh> {
  51584. private ui;
  51585. /**
  51586. * The name of the behavior
  51587. */
  51588. name: string;
  51589. /**
  51590. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  51591. */
  51592. distanceAwayFromFace: number;
  51593. /**
  51594. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  51595. */
  51596. distanceAwayFromBottomOfFace: number;
  51597. private _faceVectors;
  51598. private _target;
  51599. private _scene;
  51600. private _onRenderObserver;
  51601. private _tmpMatrix;
  51602. private _tmpVector;
  51603. /**
  51604. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  51605. * @param ui The transform node that should be attched to the mesh
  51606. */
  51607. constructor(ui: TransformNode);
  51608. /**
  51609. * Initializes the behavior
  51610. */
  51611. init(): void;
  51612. private _closestFace;
  51613. private _zeroVector;
  51614. private _lookAtTmpMatrix;
  51615. private _lookAtToRef;
  51616. /**
  51617. * Attaches the AttachToBoxBehavior to the passed in mesh
  51618. * @param target The mesh that the specified node will be attached to
  51619. */
  51620. attach(target: Mesh): void;
  51621. /**
  51622. * Detaches the behavior from the mesh
  51623. */
  51624. detach(): void;
  51625. }
  51626. }
  51627. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  51628. import { Behavior } from "babylonjs/Behaviors/behavior";
  51629. import { Mesh } from "babylonjs/Meshes/mesh";
  51630. /**
  51631. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  51632. */
  51633. export class FadeInOutBehavior implements Behavior<Mesh> {
  51634. /**
  51635. * Time in milliseconds to delay before fading in (Default: 0)
  51636. */
  51637. delay: number;
  51638. /**
  51639. * Time in milliseconds for the mesh to fade in (Default: 300)
  51640. */
  51641. fadeInTime: number;
  51642. private _millisecondsPerFrame;
  51643. private _hovered;
  51644. private _hoverValue;
  51645. private _ownerNode;
  51646. /**
  51647. * Instatiates the FadeInOutBehavior
  51648. */
  51649. constructor();
  51650. /**
  51651. * The name of the behavior
  51652. */
  51653. get name(): string;
  51654. /**
  51655. * Initializes the behavior
  51656. */
  51657. init(): void;
  51658. /**
  51659. * Attaches the fade behavior on the passed in mesh
  51660. * @param ownerNode The mesh that will be faded in/out once attached
  51661. */
  51662. attach(ownerNode: Mesh): void;
  51663. /**
  51664. * Detaches the behavior from the mesh
  51665. */
  51666. detach(): void;
  51667. /**
  51668. * Triggers the mesh to begin fading in or out
  51669. * @param value if the object should fade in or out (true to fade in)
  51670. */
  51671. fadeIn(value: boolean): void;
  51672. private _update;
  51673. private _setAllVisibility;
  51674. }
  51675. }
  51676. declare module "babylonjs/Misc/pivotTools" {
  51677. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51678. /**
  51679. * Class containing a set of static utilities functions for managing Pivots
  51680. * @hidden
  51681. */
  51682. export class PivotTools {
  51683. private static _PivotCached;
  51684. private static _OldPivotPoint;
  51685. private static _PivotTranslation;
  51686. private static _PivotTmpVector;
  51687. private static _PivotPostMultiplyPivotMatrix;
  51688. /** @hidden */
  51689. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  51690. /** @hidden */
  51691. static _RestorePivotPoint(mesh: AbstractMesh): void;
  51692. }
  51693. }
  51694. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  51695. import { Scene } from "babylonjs/scene";
  51696. import { Vector4 } from "babylonjs/Maths/math.vector";
  51697. import { Mesh } from "babylonjs/Meshes/mesh";
  51698. import { Nullable } from "babylonjs/types";
  51699. import { Plane } from "babylonjs/Maths/math.plane";
  51700. /**
  51701. * Class containing static functions to help procedurally build meshes
  51702. */
  51703. export class PlaneBuilder {
  51704. /**
  51705. * Creates a plane mesh
  51706. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  51707. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  51708. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  51709. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51710. * * 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
  51711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51712. * @param name defines the name of the mesh
  51713. * @param options defines the options used to create the mesh
  51714. * @param scene defines the hosting scene
  51715. * @returns the plane mesh
  51716. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  51717. */
  51718. static CreatePlane(name: string, options: {
  51719. size?: number;
  51720. width?: number;
  51721. height?: number;
  51722. sideOrientation?: number;
  51723. frontUVs?: Vector4;
  51724. backUVs?: Vector4;
  51725. updatable?: boolean;
  51726. sourcePlane?: Plane;
  51727. }, scene?: Nullable<Scene>): Mesh;
  51728. }
  51729. }
  51730. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  51731. import { Behavior } from "babylonjs/Behaviors/behavior";
  51732. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51733. import { Observable } from "babylonjs/Misc/observable";
  51734. import { Vector3 } from "babylonjs/Maths/math.vector";
  51735. import { Ray } from "babylonjs/Culling/ray";
  51736. import "babylonjs/Meshes/Builders/planeBuilder";
  51737. /**
  51738. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  51739. */
  51740. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  51741. private static _AnyMouseID;
  51742. /**
  51743. * Abstract mesh the behavior is set on
  51744. */
  51745. attachedNode: AbstractMesh;
  51746. private _dragPlane;
  51747. private _scene;
  51748. private _pointerObserver;
  51749. private _beforeRenderObserver;
  51750. private static _planeScene;
  51751. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  51752. /**
  51753. * 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)
  51754. */
  51755. maxDragAngle: number;
  51756. /**
  51757. * @hidden
  51758. */
  51759. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  51760. /**
  51761. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  51762. */
  51763. currentDraggingPointerID: number;
  51764. /**
  51765. * The last position where the pointer hit the drag plane in world space
  51766. */
  51767. lastDragPosition: Vector3;
  51768. /**
  51769. * If the behavior is currently in a dragging state
  51770. */
  51771. dragging: boolean;
  51772. /**
  51773. * 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)
  51774. */
  51775. dragDeltaRatio: number;
  51776. /**
  51777. * If the drag plane orientation should be updated during the dragging (Default: true)
  51778. */
  51779. updateDragPlane: boolean;
  51780. private _debugMode;
  51781. private _moving;
  51782. /**
  51783. * Fires each time the attached mesh is dragged with the pointer
  51784. * * delta between last drag position and current drag position in world space
  51785. * * dragDistance along the drag axis
  51786. * * dragPlaneNormal normal of the current drag plane used during the drag
  51787. * * dragPlanePoint in world space where the drag intersects the drag plane
  51788. */
  51789. onDragObservable: Observable<{
  51790. delta: Vector3;
  51791. dragPlanePoint: Vector3;
  51792. dragPlaneNormal: Vector3;
  51793. dragDistance: number;
  51794. pointerId: number;
  51795. }>;
  51796. /**
  51797. * Fires each time a drag begins (eg. mouse down on mesh)
  51798. */
  51799. onDragStartObservable: Observable<{
  51800. dragPlanePoint: Vector3;
  51801. pointerId: number;
  51802. }>;
  51803. /**
  51804. * Fires each time a drag ends (eg. mouse release after drag)
  51805. */
  51806. onDragEndObservable: Observable<{
  51807. dragPlanePoint: Vector3;
  51808. pointerId: number;
  51809. }>;
  51810. /**
  51811. * If the attached mesh should be moved when dragged
  51812. */
  51813. moveAttached: boolean;
  51814. /**
  51815. * If the drag behavior will react to drag events (Default: true)
  51816. */
  51817. enabled: boolean;
  51818. /**
  51819. * If pointer events should start and release the drag (Default: true)
  51820. */
  51821. startAndReleaseDragOnPointerEvents: boolean;
  51822. /**
  51823. * If camera controls should be detached during the drag
  51824. */
  51825. detachCameraControls: boolean;
  51826. /**
  51827. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  51828. */
  51829. useObjectOrientationForDragging: boolean;
  51830. private _options;
  51831. /**
  51832. * Gets the options used by the behavior
  51833. */
  51834. get options(): {
  51835. dragAxis?: Vector3;
  51836. dragPlaneNormal?: Vector3;
  51837. };
  51838. /**
  51839. * Sets the options used by the behavior
  51840. */
  51841. set options(options: {
  51842. dragAxis?: Vector3;
  51843. dragPlaneNormal?: Vector3;
  51844. });
  51845. /**
  51846. * Creates a pointer drag behavior that can be attached to a mesh
  51847. * @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)
  51848. */
  51849. constructor(options?: {
  51850. dragAxis?: Vector3;
  51851. dragPlaneNormal?: Vector3;
  51852. });
  51853. /**
  51854. * Predicate to determine if it is valid to move the object to a new position when it is moved
  51855. */
  51856. validateDrag: (targetPosition: Vector3) => boolean;
  51857. /**
  51858. * The name of the behavior
  51859. */
  51860. get name(): string;
  51861. /**
  51862. * Initializes the behavior
  51863. */
  51864. init(): void;
  51865. private _tmpVector;
  51866. private _alternatePickedPoint;
  51867. private _worldDragAxis;
  51868. private _targetPosition;
  51869. private _attachedToElement;
  51870. /**
  51871. * Attaches the drag behavior the passed in mesh
  51872. * @param ownerNode The mesh that will be dragged around once attached
  51873. * @param predicate Predicate to use for pick filtering
  51874. */
  51875. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  51876. /**
  51877. * Force relase the drag action by code.
  51878. */
  51879. releaseDrag(): void;
  51880. private _startDragRay;
  51881. private _lastPointerRay;
  51882. /**
  51883. * Simulates the start of a pointer drag event on the behavior
  51884. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  51885. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  51886. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  51887. */
  51888. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  51889. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  51890. private _dragDelta;
  51891. protected _moveDrag(ray: Ray): void;
  51892. private _pickWithRayOnDragPlane;
  51893. private _pointA;
  51894. private _pointC;
  51895. private _localAxis;
  51896. private _lookAt;
  51897. private _updateDragPlanePosition;
  51898. /**
  51899. * Detaches the behavior from the mesh
  51900. */
  51901. detach(): void;
  51902. }
  51903. }
  51904. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  51905. import { Mesh } from "babylonjs/Meshes/mesh";
  51906. import { Behavior } from "babylonjs/Behaviors/behavior";
  51907. /**
  51908. * A behavior that when attached to a mesh will allow the mesh to be scaled
  51909. */
  51910. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  51911. private _dragBehaviorA;
  51912. private _dragBehaviorB;
  51913. private _startDistance;
  51914. private _initialScale;
  51915. private _targetScale;
  51916. private _ownerNode;
  51917. private _sceneRenderObserver;
  51918. /**
  51919. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  51920. */
  51921. constructor();
  51922. /**
  51923. * The name of the behavior
  51924. */
  51925. get name(): string;
  51926. /**
  51927. * Initializes the behavior
  51928. */
  51929. init(): void;
  51930. private _getCurrentDistance;
  51931. /**
  51932. * Attaches the scale behavior the passed in mesh
  51933. * @param ownerNode The mesh that will be scaled around once attached
  51934. */
  51935. attach(ownerNode: Mesh): void;
  51936. /**
  51937. * Detaches the behavior from the mesh
  51938. */
  51939. detach(): void;
  51940. }
  51941. }
  51942. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  51943. import { Behavior } from "babylonjs/Behaviors/behavior";
  51944. import { Mesh } from "babylonjs/Meshes/mesh";
  51945. import { Observable } from "babylonjs/Misc/observable";
  51946. /**
  51947. * 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
  51948. */
  51949. export class SixDofDragBehavior implements Behavior<Mesh> {
  51950. private static _virtualScene;
  51951. private _ownerNode;
  51952. private _sceneRenderObserver;
  51953. private _scene;
  51954. private _targetPosition;
  51955. private _virtualOriginMesh;
  51956. private _virtualDragMesh;
  51957. private _pointerObserver;
  51958. private _moving;
  51959. private _startingOrientation;
  51960. private _attachedToElement;
  51961. /**
  51962. * 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)
  51963. */
  51964. private zDragFactor;
  51965. /**
  51966. * If the object should rotate to face the drag origin
  51967. */
  51968. rotateDraggedObject: boolean;
  51969. /**
  51970. * If the behavior is currently in a dragging state
  51971. */
  51972. dragging: boolean;
  51973. /**
  51974. * 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)
  51975. */
  51976. dragDeltaRatio: number;
  51977. /**
  51978. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  51979. */
  51980. currentDraggingPointerID: number;
  51981. /**
  51982. * If camera controls should be detached during the drag
  51983. */
  51984. detachCameraControls: boolean;
  51985. /**
  51986. * Fires each time a drag starts
  51987. */
  51988. onDragStartObservable: Observable<{}>;
  51989. /**
  51990. * Fires each time a drag happens
  51991. */
  51992. onDragObservable: Observable<void>;
  51993. /**
  51994. * Fires each time a drag ends (eg. mouse release after drag)
  51995. */
  51996. onDragEndObservable: Observable<{}>;
  51997. /**
  51998. * 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
  51999. */
  52000. constructor();
  52001. /**
  52002. * The name of the behavior
  52003. */
  52004. get name(): string;
  52005. /**
  52006. * Initializes the behavior
  52007. */
  52008. init(): void;
  52009. /**
  52010. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  52011. */
  52012. private get _pointerCamera();
  52013. /**
  52014. * Attaches the scale behavior the passed in mesh
  52015. * @param ownerNode The mesh that will be scaled around once attached
  52016. */
  52017. attach(ownerNode: Mesh): void;
  52018. /**
  52019. * Detaches the behavior from the mesh
  52020. */
  52021. detach(): void;
  52022. }
  52023. }
  52024. declare module "babylonjs/Behaviors/Meshes/index" {
  52025. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  52026. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  52027. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  52028. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52029. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  52030. }
  52031. declare module "babylonjs/Behaviors/index" {
  52032. export * from "babylonjs/Behaviors/behavior";
  52033. export * from "babylonjs/Behaviors/Cameras/index";
  52034. export * from "babylonjs/Behaviors/Meshes/index";
  52035. }
  52036. declare module "babylonjs/Bones/boneIKController" {
  52037. import { Bone } from "babylonjs/Bones/bone";
  52038. import { Vector3 } from "babylonjs/Maths/math.vector";
  52039. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52040. import { Nullable } from "babylonjs/types";
  52041. /**
  52042. * Class used to apply inverse kinematics to bones
  52043. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  52044. */
  52045. export class BoneIKController {
  52046. private static _tmpVecs;
  52047. private static _tmpQuat;
  52048. private static _tmpMats;
  52049. /**
  52050. * Gets or sets the target mesh
  52051. */
  52052. targetMesh: AbstractMesh;
  52053. /** Gets or sets the mesh used as pole */
  52054. poleTargetMesh: AbstractMesh;
  52055. /**
  52056. * Gets or sets the bone used as pole
  52057. */
  52058. poleTargetBone: Nullable<Bone>;
  52059. /**
  52060. * Gets or sets the target position
  52061. */
  52062. targetPosition: Vector3;
  52063. /**
  52064. * Gets or sets the pole target position
  52065. */
  52066. poleTargetPosition: Vector3;
  52067. /**
  52068. * Gets or sets the pole target local offset
  52069. */
  52070. poleTargetLocalOffset: Vector3;
  52071. /**
  52072. * Gets or sets the pole angle
  52073. */
  52074. poleAngle: number;
  52075. /**
  52076. * Gets or sets the mesh associated with the controller
  52077. */
  52078. mesh: AbstractMesh;
  52079. /**
  52080. * 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)
  52081. */
  52082. slerpAmount: number;
  52083. private _bone1Quat;
  52084. private _bone1Mat;
  52085. private _bone2Ang;
  52086. private _bone1;
  52087. private _bone2;
  52088. private _bone1Length;
  52089. private _bone2Length;
  52090. private _maxAngle;
  52091. private _maxReach;
  52092. private _rightHandedSystem;
  52093. private _bendAxis;
  52094. private _slerping;
  52095. private _adjustRoll;
  52096. /**
  52097. * Gets or sets maximum allowed angle
  52098. */
  52099. get maxAngle(): number;
  52100. set maxAngle(value: number);
  52101. /**
  52102. * Creates a new BoneIKController
  52103. * @param mesh defines the mesh to control
  52104. * @param bone defines the bone to control
  52105. * @param options defines options to set up the controller
  52106. */
  52107. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  52108. targetMesh?: AbstractMesh;
  52109. poleTargetMesh?: AbstractMesh;
  52110. poleTargetBone?: Bone;
  52111. poleTargetLocalOffset?: Vector3;
  52112. poleAngle?: number;
  52113. bendAxis?: Vector3;
  52114. maxAngle?: number;
  52115. slerpAmount?: number;
  52116. });
  52117. private _setMaxAngle;
  52118. /**
  52119. * Force the controller to update the bones
  52120. */
  52121. update(): void;
  52122. }
  52123. }
  52124. declare module "babylonjs/Bones/boneLookController" {
  52125. import { Vector3 } from "babylonjs/Maths/math.vector";
  52126. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52127. import { Bone } from "babylonjs/Bones/bone";
  52128. import { Space } from "babylonjs/Maths/math.axis";
  52129. /**
  52130. * Class used to make a bone look toward a point in space
  52131. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  52132. */
  52133. export class BoneLookController {
  52134. private static _tmpVecs;
  52135. private static _tmpQuat;
  52136. private static _tmpMats;
  52137. /**
  52138. * The target Vector3 that the bone will look at
  52139. */
  52140. target: Vector3;
  52141. /**
  52142. * The mesh that the bone is attached to
  52143. */
  52144. mesh: AbstractMesh;
  52145. /**
  52146. * The bone that will be looking to the target
  52147. */
  52148. bone: Bone;
  52149. /**
  52150. * The up axis of the coordinate system that is used when the bone is rotated
  52151. */
  52152. upAxis: Vector3;
  52153. /**
  52154. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  52155. */
  52156. upAxisSpace: Space;
  52157. /**
  52158. * Used to make an adjustment to the yaw of the bone
  52159. */
  52160. adjustYaw: number;
  52161. /**
  52162. * Used to make an adjustment to the pitch of the bone
  52163. */
  52164. adjustPitch: number;
  52165. /**
  52166. * Used to make an adjustment to the roll of the bone
  52167. */
  52168. adjustRoll: number;
  52169. /**
  52170. * 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)
  52171. */
  52172. slerpAmount: number;
  52173. private _minYaw;
  52174. private _maxYaw;
  52175. private _minPitch;
  52176. private _maxPitch;
  52177. private _minYawSin;
  52178. private _minYawCos;
  52179. private _maxYawSin;
  52180. private _maxYawCos;
  52181. private _midYawConstraint;
  52182. private _minPitchTan;
  52183. private _maxPitchTan;
  52184. private _boneQuat;
  52185. private _slerping;
  52186. private _transformYawPitch;
  52187. private _transformYawPitchInv;
  52188. private _firstFrameSkipped;
  52189. private _yawRange;
  52190. private _fowardAxis;
  52191. /**
  52192. * Gets or sets the minimum yaw angle that the bone can look to
  52193. */
  52194. get minYaw(): number;
  52195. set minYaw(value: number);
  52196. /**
  52197. * Gets or sets the maximum yaw angle that the bone can look to
  52198. */
  52199. get maxYaw(): number;
  52200. set maxYaw(value: number);
  52201. /**
  52202. * Gets or sets the minimum pitch angle that the bone can look to
  52203. */
  52204. get minPitch(): number;
  52205. set minPitch(value: number);
  52206. /**
  52207. * Gets or sets the maximum pitch angle that the bone can look to
  52208. */
  52209. get maxPitch(): number;
  52210. set maxPitch(value: number);
  52211. /**
  52212. * Create a BoneLookController
  52213. * @param mesh the mesh that the bone belongs to
  52214. * @param bone the bone that will be looking to the target
  52215. * @param target the target Vector3 to look at
  52216. * @param options optional settings:
  52217. * * maxYaw: the maximum angle the bone will yaw to
  52218. * * minYaw: the minimum angle the bone will yaw to
  52219. * * maxPitch: the maximum angle the bone will pitch to
  52220. * * minPitch: the minimum angle the bone will yaw to
  52221. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  52222. * * upAxis: the up axis of the coordinate system
  52223. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  52224. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  52225. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  52226. * * adjustYaw: used to make an adjustment to the yaw of the bone
  52227. * * adjustPitch: used to make an adjustment to the pitch of the bone
  52228. * * adjustRoll: used to make an adjustment to the roll of the bone
  52229. **/
  52230. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  52231. maxYaw?: number;
  52232. minYaw?: number;
  52233. maxPitch?: number;
  52234. minPitch?: number;
  52235. slerpAmount?: number;
  52236. upAxis?: Vector3;
  52237. upAxisSpace?: Space;
  52238. yawAxis?: Vector3;
  52239. pitchAxis?: Vector3;
  52240. adjustYaw?: number;
  52241. adjustPitch?: number;
  52242. adjustRoll?: number;
  52243. });
  52244. /**
  52245. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  52246. */
  52247. update(): void;
  52248. private _getAngleDiff;
  52249. private _getAngleBetween;
  52250. private _isAngleBetween;
  52251. }
  52252. }
  52253. declare module "babylonjs/Bones/index" {
  52254. export * from "babylonjs/Bones/bone";
  52255. export * from "babylonjs/Bones/boneIKController";
  52256. export * from "babylonjs/Bones/boneLookController";
  52257. export * from "babylonjs/Bones/skeleton";
  52258. }
  52259. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  52260. import { Nullable } from "babylonjs/types";
  52261. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  52262. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  52263. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  52264. /**
  52265. * Manage the gamepad inputs to control an arc rotate camera.
  52266. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52267. */
  52268. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  52269. /**
  52270. * Defines the camera the input is attached to.
  52271. */
  52272. camera: ArcRotateCamera;
  52273. /**
  52274. * Defines the gamepad the input is gathering event from.
  52275. */
  52276. gamepad: Nullable<Gamepad>;
  52277. /**
  52278. * Defines the gamepad rotation sensiblity.
  52279. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  52280. */
  52281. gamepadRotationSensibility: number;
  52282. /**
  52283. * Defines the gamepad move sensiblity.
  52284. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  52285. */
  52286. gamepadMoveSensibility: number;
  52287. private _yAxisScale;
  52288. /**
  52289. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  52290. */
  52291. get invertYAxis(): boolean;
  52292. set invertYAxis(value: boolean);
  52293. private _onGamepadConnectedObserver;
  52294. private _onGamepadDisconnectedObserver;
  52295. /**
  52296. * Attach the input controls to a specific dom element to get the input from.
  52297. */
  52298. attachControl(): void;
  52299. /**
  52300. * Detach the current controls from the specified dom element.
  52301. */
  52302. detachControl(): void;
  52303. /**
  52304. * Update the current camera state depending on the inputs that have been used this frame.
  52305. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  52306. */
  52307. checkInputs(): void;
  52308. /**
  52309. * Gets the class name of the current intput.
  52310. * @returns the class name
  52311. */
  52312. getClassName(): string;
  52313. /**
  52314. * Get the friendly name associated with the input class.
  52315. * @returns the input friendly name
  52316. */
  52317. getSimpleName(): string;
  52318. }
  52319. }
  52320. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  52321. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  52322. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  52323. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  52324. interface ArcRotateCameraInputsManager {
  52325. /**
  52326. * Add orientation input support to the input manager.
  52327. * @returns the current input manager
  52328. */
  52329. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  52330. }
  52331. }
  52332. /**
  52333. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  52334. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52335. */
  52336. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  52337. /**
  52338. * Defines the camera the input is attached to.
  52339. */
  52340. camera: ArcRotateCamera;
  52341. /**
  52342. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  52343. */
  52344. alphaCorrection: number;
  52345. /**
  52346. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  52347. */
  52348. gammaCorrection: number;
  52349. private _alpha;
  52350. private _gamma;
  52351. private _dirty;
  52352. private _deviceOrientationHandler;
  52353. /**
  52354. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  52355. */
  52356. constructor();
  52357. /**
  52358. * Attach the input controls to a specific dom element to get the input from.
  52359. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  52360. */
  52361. attachControl(noPreventDefault?: boolean): void;
  52362. /** @hidden */
  52363. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  52364. /**
  52365. * Update the current camera state depending on the inputs that have been used this frame.
  52366. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  52367. */
  52368. checkInputs(): void;
  52369. /**
  52370. * Detach the current controls from the specified dom element.
  52371. */
  52372. detachControl(): void;
  52373. /**
  52374. * Gets the class name of the current intput.
  52375. * @returns the class name
  52376. */
  52377. getClassName(): string;
  52378. /**
  52379. * Get the friendly name associated with the input class.
  52380. * @returns the input friendly name
  52381. */
  52382. getSimpleName(): string;
  52383. }
  52384. }
  52385. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  52386. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  52387. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  52388. /**
  52389. * Listen to mouse events to control the camera.
  52390. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52391. */
  52392. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  52393. /**
  52394. * Defines the camera the input is attached to.
  52395. */
  52396. camera: FlyCamera;
  52397. /**
  52398. * Defines if touch is enabled. (Default is true.)
  52399. */
  52400. touchEnabled: boolean;
  52401. /**
  52402. * Defines the buttons associated with the input to handle camera rotation.
  52403. */
  52404. buttons: number[];
  52405. /**
  52406. * Assign buttons for Yaw control.
  52407. */
  52408. buttonsYaw: number[];
  52409. /**
  52410. * Assign buttons for Pitch control.
  52411. */
  52412. buttonsPitch: number[];
  52413. /**
  52414. * Assign buttons for Roll control.
  52415. */
  52416. buttonsRoll: number[];
  52417. /**
  52418. * Detect if any button is being pressed while mouse is moved.
  52419. * -1 = Mouse locked.
  52420. * 0 = Left button.
  52421. * 1 = Middle Button.
  52422. * 2 = Right Button.
  52423. */
  52424. activeButton: number;
  52425. /**
  52426. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  52427. * Higher values reduce its sensitivity.
  52428. */
  52429. angularSensibility: number;
  52430. private _observer;
  52431. private _rollObserver;
  52432. private previousPosition;
  52433. private noPreventDefault;
  52434. private element;
  52435. /**
  52436. * Listen to mouse events to control the camera.
  52437. * @param touchEnabled Define if touch is enabled. (Default is true.)
  52438. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52439. */
  52440. constructor(touchEnabled?: boolean);
  52441. /**
  52442. * Attach the mouse control to the HTML DOM element.
  52443. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  52444. */
  52445. attachControl(noPreventDefault?: boolean): void;
  52446. /**
  52447. * Detach the current controls from the specified dom element.
  52448. */
  52449. detachControl(): void;
  52450. /**
  52451. * Gets the class name of the current input.
  52452. * @returns the class name.
  52453. */
  52454. getClassName(): string;
  52455. /**
  52456. * Get the friendly name associated with the input class.
  52457. * @returns the input's friendly name.
  52458. */
  52459. getSimpleName(): string;
  52460. private _pointerInput;
  52461. private _onMouseMove;
  52462. /**
  52463. * Rotate camera by mouse offset.
  52464. */
  52465. private rotateCamera;
  52466. }
  52467. }
  52468. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  52469. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  52470. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  52471. /**
  52472. * Default Inputs manager for the FlyCamera.
  52473. * It groups all the default supported inputs for ease of use.
  52474. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52475. */
  52476. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  52477. /**
  52478. * Instantiates a new FlyCameraInputsManager.
  52479. * @param camera Defines the camera the inputs belong to.
  52480. */
  52481. constructor(camera: FlyCamera);
  52482. /**
  52483. * Add keyboard input support to the input manager.
  52484. * @returns the new FlyCameraKeyboardMoveInput().
  52485. */
  52486. addKeyboard(): FlyCameraInputsManager;
  52487. /**
  52488. * Add mouse input support to the input manager.
  52489. * @param touchEnabled Enable touch screen support.
  52490. * @returns the new FlyCameraMouseInput().
  52491. */
  52492. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  52493. }
  52494. }
  52495. declare module "babylonjs/Cameras/flyCamera" {
  52496. import { Scene } from "babylonjs/scene";
  52497. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52498. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52499. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  52500. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  52501. /**
  52502. * This is a flying camera, designed for 3D movement and rotation in all directions,
  52503. * such as in a 3D Space Shooter or a Flight Simulator.
  52504. */
  52505. export class FlyCamera extends TargetCamera {
  52506. /**
  52507. * Define the collision ellipsoid of the camera.
  52508. * This is helpful for simulating a camera body, like a player's body.
  52509. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  52510. */
  52511. ellipsoid: Vector3;
  52512. /**
  52513. * Define an offset for the position of the ellipsoid around the camera.
  52514. * This can be helpful if the camera is attached away from the player's body center,
  52515. * such as at its head.
  52516. */
  52517. ellipsoidOffset: Vector3;
  52518. /**
  52519. * Enable or disable collisions of the camera with the rest of the scene objects.
  52520. */
  52521. checkCollisions: boolean;
  52522. /**
  52523. * Enable or disable gravity on the camera.
  52524. */
  52525. applyGravity: boolean;
  52526. /**
  52527. * Define the current direction the camera is moving to.
  52528. */
  52529. cameraDirection: Vector3;
  52530. /**
  52531. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  52532. * This overrides and empties cameraRotation.
  52533. */
  52534. rotationQuaternion: Quaternion;
  52535. /**
  52536. * Track Roll to maintain the wanted Rolling when looking around.
  52537. */
  52538. _trackRoll: number;
  52539. /**
  52540. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  52541. */
  52542. rollCorrect: number;
  52543. /**
  52544. * Mimic a banked turn, Rolling the camera when Yawing.
  52545. * It's recommended to use rollCorrect = 10 for faster banking correction.
  52546. */
  52547. bankedTurn: boolean;
  52548. /**
  52549. * Limit in radians for how much Roll banking will add. (Default: 90°)
  52550. */
  52551. bankedTurnLimit: number;
  52552. /**
  52553. * Value of 0 disables the banked Roll.
  52554. * Value of 1 is equal to the Yaw angle in radians.
  52555. */
  52556. bankedTurnMultiplier: number;
  52557. /**
  52558. * The inputs manager loads all the input sources, such as keyboard and mouse.
  52559. */
  52560. inputs: FlyCameraInputsManager;
  52561. /**
  52562. * Gets the input sensibility for mouse input.
  52563. * Higher values reduce sensitivity.
  52564. */
  52565. get angularSensibility(): number;
  52566. /**
  52567. * Sets the input sensibility for a mouse input.
  52568. * Higher values reduce sensitivity.
  52569. */
  52570. set angularSensibility(value: number);
  52571. /**
  52572. * Get the keys for camera movement forward.
  52573. */
  52574. get keysForward(): number[];
  52575. /**
  52576. * Set the keys for camera movement forward.
  52577. */
  52578. set keysForward(value: number[]);
  52579. /**
  52580. * Get the keys for camera movement backward.
  52581. */
  52582. get keysBackward(): number[];
  52583. set keysBackward(value: number[]);
  52584. /**
  52585. * Get the keys for camera movement up.
  52586. */
  52587. get keysUp(): number[];
  52588. /**
  52589. * Set the keys for camera movement up.
  52590. */
  52591. set keysUp(value: number[]);
  52592. /**
  52593. * Get the keys for camera movement down.
  52594. */
  52595. get keysDown(): number[];
  52596. /**
  52597. * Set the keys for camera movement down.
  52598. */
  52599. set keysDown(value: number[]);
  52600. /**
  52601. * Get the keys for camera movement left.
  52602. */
  52603. get keysLeft(): number[];
  52604. /**
  52605. * Set the keys for camera movement left.
  52606. */
  52607. set keysLeft(value: number[]);
  52608. /**
  52609. * Set the keys for camera movement right.
  52610. */
  52611. get keysRight(): number[];
  52612. /**
  52613. * Set the keys for camera movement right.
  52614. */
  52615. set keysRight(value: number[]);
  52616. /**
  52617. * Event raised when the camera collides with a mesh in the scene.
  52618. */
  52619. onCollide: (collidedMesh: AbstractMesh) => void;
  52620. private _collider;
  52621. private _needMoveForGravity;
  52622. private _oldPosition;
  52623. private _diffPosition;
  52624. private _newPosition;
  52625. /** @hidden */
  52626. _localDirection: Vector3;
  52627. /** @hidden */
  52628. _transformedDirection: Vector3;
  52629. /**
  52630. * Instantiates a FlyCamera.
  52631. * This is a flying camera, designed for 3D movement and rotation in all directions,
  52632. * such as in a 3D Space Shooter or a Flight Simulator.
  52633. * @param name Define the name of the camera in the scene.
  52634. * @param position Define the starting position of the camera in the scene.
  52635. * @param scene Define the scene the camera belongs to.
  52636. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  52637. */
  52638. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  52639. /**
  52640. * Attach the input controls to a specific dom element to get the input from.
  52641. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  52642. */
  52643. attachControl(noPreventDefault?: boolean): void;
  52644. /**
  52645. * Detach a control from the HTML DOM element.
  52646. * The camera will stop reacting to that input.
  52647. */
  52648. detachControl(): void;
  52649. private _collisionMask;
  52650. /**
  52651. * Get the mask that the camera ignores in collision events.
  52652. */
  52653. get collisionMask(): number;
  52654. /**
  52655. * Set the mask that the camera ignores in collision events.
  52656. */
  52657. set collisionMask(mask: number);
  52658. /** @hidden */
  52659. _collideWithWorld(displacement: Vector3): void;
  52660. /** @hidden */
  52661. private _onCollisionPositionChange;
  52662. /** @hidden */
  52663. _checkInputs(): void;
  52664. /** @hidden */
  52665. _decideIfNeedsToMove(): boolean;
  52666. /** @hidden */
  52667. _updatePosition(): void;
  52668. /**
  52669. * Restore the Roll to its target value at the rate specified.
  52670. * @param rate - Higher means slower restoring.
  52671. * @hidden
  52672. */
  52673. restoreRoll(rate: number): void;
  52674. /**
  52675. * Destroy the camera and release the current resources held by it.
  52676. */
  52677. dispose(): void;
  52678. /**
  52679. * Get the current object class name.
  52680. * @returns the class name.
  52681. */
  52682. getClassName(): string;
  52683. }
  52684. }
  52685. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  52686. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  52687. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  52688. /**
  52689. * Listen to keyboard events to control the camera.
  52690. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52691. */
  52692. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  52693. /**
  52694. * Defines the camera the input is attached to.
  52695. */
  52696. camera: FlyCamera;
  52697. /**
  52698. * The list of keyboard keys used to control the forward move of the camera.
  52699. */
  52700. keysForward: number[];
  52701. /**
  52702. * The list of keyboard keys used to control the backward move of the camera.
  52703. */
  52704. keysBackward: number[];
  52705. /**
  52706. * The list of keyboard keys used to control the forward move of the camera.
  52707. */
  52708. keysUp: number[];
  52709. /**
  52710. * The list of keyboard keys used to control the backward move of the camera.
  52711. */
  52712. keysDown: number[];
  52713. /**
  52714. * The list of keyboard keys used to control the right strafe move of the camera.
  52715. */
  52716. keysRight: number[];
  52717. /**
  52718. * The list of keyboard keys used to control the left strafe move of the camera.
  52719. */
  52720. keysLeft: number[];
  52721. private _keys;
  52722. private _onCanvasBlurObserver;
  52723. private _onKeyboardObserver;
  52724. private _engine;
  52725. private _scene;
  52726. /**
  52727. * Attach the input controls to a specific dom element to get the input from.
  52728. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  52729. */
  52730. attachControl(noPreventDefault?: boolean): void;
  52731. /**
  52732. * Detach the current controls from the specified dom element.
  52733. */
  52734. detachControl(): void;
  52735. /**
  52736. * Gets the class name of the current intput.
  52737. * @returns the class name
  52738. */
  52739. getClassName(): string;
  52740. /** @hidden */
  52741. _onLostFocus(e: FocusEvent): void;
  52742. /**
  52743. * Get the friendly name associated with the input class.
  52744. * @returns the input friendly name
  52745. */
  52746. getSimpleName(): string;
  52747. /**
  52748. * Update the current camera state depending on the inputs that have been used this frame.
  52749. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  52750. */
  52751. checkInputs(): void;
  52752. }
  52753. }
  52754. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  52755. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  52756. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  52757. /**
  52758. * Manage the mouse wheel inputs to control a follow camera.
  52759. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52760. */
  52761. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  52762. /**
  52763. * Defines the camera the input is attached to.
  52764. */
  52765. camera: FollowCamera;
  52766. /**
  52767. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  52768. */
  52769. axisControlRadius: boolean;
  52770. /**
  52771. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  52772. */
  52773. axisControlHeight: boolean;
  52774. /**
  52775. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  52776. */
  52777. axisControlRotation: boolean;
  52778. /**
  52779. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  52780. * relation to mouseWheel events.
  52781. */
  52782. wheelPrecision: number;
  52783. /**
  52784. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  52785. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  52786. */
  52787. wheelDeltaPercentage: number;
  52788. private _wheel;
  52789. private _observer;
  52790. /**
  52791. * Attach the input controls to a specific dom element to get the input from.
  52792. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  52793. */
  52794. attachControl(noPreventDefault?: boolean): void;
  52795. /**
  52796. * Detach the current controls from the specified dom element.
  52797. */
  52798. detachControl(): void;
  52799. /**
  52800. * Gets the class name of the current intput.
  52801. * @returns the class name
  52802. */
  52803. getClassName(): string;
  52804. /**
  52805. * Get the friendly name associated with the input class.
  52806. * @returns the input friendly name
  52807. */
  52808. getSimpleName(): string;
  52809. }
  52810. }
  52811. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  52812. import { Nullable } from "babylonjs/types";
  52813. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  52814. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  52815. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  52816. /**
  52817. * Manage the pointers inputs to control an follow camera.
  52818. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52819. */
  52820. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  52821. /**
  52822. * Defines the camera the input is attached to.
  52823. */
  52824. camera: FollowCamera;
  52825. /**
  52826. * Gets the class name of the current input.
  52827. * @returns the class name
  52828. */
  52829. getClassName(): string;
  52830. /**
  52831. * Defines the pointer angular sensibility along the X axis or how fast is
  52832. * the camera rotating.
  52833. * A negative number will reverse the axis direction.
  52834. */
  52835. angularSensibilityX: number;
  52836. /**
  52837. * Defines the pointer angular sensibility along the Y axis or how fast is
  52838. * the camera rotating.
  52839. * A negative number will reverse the axis direction.
  52840. */
  52841. angularSensibilityY: number;
  52842. /**
  52843. * Defines the pointer pinch precision or how fast is the camera zooming.
  52844. * A negative number will reverse the axis direction.
  52845. */
  52846. pinchPrecision: number;
  52847. /**
  52848. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  52849. * from 0.
  52850. * It defines the percentage of current camera.radius to use as delta when
  52851. * pinch zoom is used.
  52852. */
  52853. pinchDeltaPercentage: number;
  52854. /**
  52855. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  52856. */
  52857. axisXControlRadius: boolean;
  52858. /**
  52859. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  52860. */
  52861. axisXControlHeight: boolean;
  52862. /**
  52863. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  52864. */
  52865. axisXControlRotation: boolean;
  52866. /**
  52867. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  52868. */
  52869. axisYControlRadius: boolean;
  52870. /**
  52871. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  52872. */
  52873. axisYControlHeight: boolean;
  52874. /**
  52875. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  52876. */
  52877. axisYControlRotation: boolean;
  52878. /**
  52879. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  52880. */
  52881. axisPinchControlRadius: boolean;
  52882. /**
  52883. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  52884. */
  52885. axisPinchControlHeight: boolean;
  52886. /**
  52887. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  52888. */
  52889. axisPinchControlRotation: boolean;
  52890. /**
  52891. * Log error messages if basic misconfiguration has occurred.
  52892. */
  52893. warningEnable: boolean;
  52894. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  52895. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  52896. private _warningCounter;
  52897. private _warning;
  52898. }
  52899. }
  52900. declare module "babylonjs/Cameras/followCameraInputsManager" {
  52901. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  52902. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  52903. /**
  52904. * Default Inputs manager for the FollowCamera.
  52905. * It groups all the default supported inputs for ease of use.
  52906. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52907. */
  52908. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  52909. /**
  52910. * Instantiates a new FollowCameraInputsManager.
  52911. * @param camera Defines the camera the inputs belong to
  52912. */
  52913. constructor(camera: FollowCamera);
  52914. /**
  52915. * Add keyboard input support to the input manager.
  52916. * @returns the current input manager
  52917. */
  52918. addKeyboard(): FollowCameraInputsManager;
  52919. /**
  52920. * Add mouse wheel input support to the input manager.
  52921. * @returns the current input manager
  52922. */
  52923. addMouseWheel(): FollowCameraInputsManager;
  52924. /**
  52925. * Add pointers input support to the input manager.
  52926. * @returns the current input manager
  52927. */
  52928. addPointers(): FollowCameraInputsManager;
  52929. /**
  52930. * Add orientation input support to the input manager.
  52931. * @returns the current input manager
  52932. */
  52933. addVRDeviceOrientation(): FollowCameraInputsManager;
  52934. }
  52935. }
  52936. declare module "babylonjs/Cameras/followCamera" {
  52937. import { Nullable } from "babylonjs/types";
  52938. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  52939. import { Scene } from "babylonjs/scene";
  52940. import { Vector3 } from "babylonjs/Maths/math.vector";
  52941. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52942. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  52943. /**
  52944. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  52945. * an arc rotate version arcFollowCamera are available.
  52946. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  52947. */
  52948. export class FollowCamera extends TargetCamera {
  52949. /**
  52950. * Distance the follow camera should follow an object at
  52951. */
  52952. radius: number;
  52953. /**
  52954. * Minimum allowed distance of the camera to the axis of rotation
  52955. * (The camera can not get closer).
  52956. * This can help limiting how the Camera is able to move in the scene.
  52957. */
  52958. lowerRadiusLimit: Nullable<number>;
  52959. /**
  52960. * Maximum allowed distance of the camera to the axis of rotation
  52961. * (The camera can not get further).
  52962. * This can help limiting how the Camera is able to move in the scene.
  52963. */
  52964. upperRadiusLimit: Nullable<number>;
  52965. /**
  52966. * Define a rotation offset between the camera and the object it follows
  52967. */
  52968. rotationOffset: number;
  52969. /**
  52970. * Minimum allowed angle to camera position relative to target object.
  52971. * This can help limiting how the Camera is able to move in the scene.
  52972. */
  52973. lowerRotationOffsetLimit: Nullable<number>;
  52974. /**
  52975. * Maximum allowed angle to camera position relative to target object.
  52976. * This can help limiting how the Camera is able to move in the scene.
  52977. */
  52978. upperRotationOffsetLimit: Nullable<number>;
  52979. /**
  52980. * Define a height offset between the camera and the object it follows.
  52981. * It can help following an object from the top (like a car chaing a plane)
  52982. */
  52983. heightOffset: number;
  52984. /**
  52985. * Minimum allowed height of camera position relative to target object.
  52986. * This can help limiting how the Camera is able to move in the scene.
  52987. */
  52988. lowerHeightOffsetLimit: Nullable<number>;
  52989. /**
  52990. * Maximum allowed height of camera position relative to target object.
  52991. * This can help limiting how the Camera is able to move in the scene.
  52992. */
  52993. upperHeightOffsetLimit: Nullable<number>;
  52994. /**
  52995. * Define how fast the camera can accelerate to follow it s target.
  52996. */
  52997. cameraAcceleration: number;
  52998. /**
  52999. * Define the speed limit of the camera following an object.
  53000. */
  53001. maxCameraSpeed: number;
  53002. /**
  53003. * Define the target of the camera.
  53004. */
  53005. lockedTarget: Nullable<AbstractMesh>;
  53006. /**
  53007. * Defines the input associated with the camera.
  53008. */
  53009. inputs: FollowCameraInputsManager;
  53010. /**
  53011. * Instantiates the follow camera.
  53012. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  53013. * @param name Define the name of the camera in the scene
  53014. * @param position Define the position of the camera
  53015. * @param scene Define the scene the camera belong to
  53016. * @param lockedTarget Define the target of the camera
  53017. */
  53018. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  53019. private _follow;
  53020. /**
  53021. * Attach the input controls to a specific dom element to get the input from.
  53022. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  53023. */
  53024. attachControl(noPreventDefault?: boolean): void;
  53025. /**
  53026. * Detach the current controls from the specified dom element.
  53027. */
  53028. detachControl(): void;
  53029. /** @hidden */
  53030. _checkInputs(): void;
  53031. private _checkLimits;
  53032. /**
  53033. * Gets the camera class name.
  53034. * @returns the class name
  53035. */
  53036. getClassName(): string;
  53037. }
  53038. /**
  53039. * Arc Rotate version of the follow camera.
  53040. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  53041. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  53042. */
  53043. export class ArcFollowCamera extends TargetCamera {
  53044. /** The longitudinal angle of the camera */
  53045. alpha: number;
  53046. /** The latitudinal angle of the camera */
  53047. beta: number;
  53048. /** The radius of the camera from its target */
  53049. radius: number;
  53050. private _cartesianCoordinates;
  53051. /** Define the camera target (the mesh it should follow) */
  53052. private _meshTarget;
  53053. /**
  53054. * Instantiates a new ArcFollowCamera
  53055. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  53056. * @param name Define the name of the camera
  53057. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  53058. * @param beta Define the rotation angle of the camera around the elevation axis
  53059. * @param radius Define the radius of the camera from its target point
  53060. * @param target Define the target of the camera
  53061. * @param scene Define the scene the camera belongs to
  53062. */
  53063. constructor(name: string,
  53064. /** The longitudinal angle of the camera */
  53065. alpha: number,
  53066. /** The latitudinal angle of the camera */
  53067. beta: number,
  53068. /** The radius of the camera from its target */
  53069. radius: number,
  53070. /** Define the camera target (the mesh it should follow) */
  53071. target: Nullable<AbstractMesh>, scene: Scene);
  53072. private _follow;
  53073. /** @hidden */
  53074. _checkInputs(): void;
  53075. /**
  53076. * Returns the class name of the object.
  53077. * It is mostly used internally for serialization purposes.
  53078. */
  53079. getClassName(): string;
  53080. }
  53081. }
  53082. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  53083. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  53084. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  53085. /**
  53086. * Manage the keyboard inputs to control the movement of a follow camera.
  53087. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  53088. */
  53089. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  53090. /**
  53091. * Defines the camera the input is attached to.
  53092. */
  53093. camera: FollowCamera;
  53094. /**
  53095. * Defines the list of key codes associated with the up action (increase heightOffset)
  53096. */
  53097. keysHeightOffsetIncr: number[];
  53098. /**
  53099. * Defines the list of key codes associated with the down action (decrease heightOffset)
  53100. */
  53101. keysHeightOffsetDecr: number[];
  53102. /**
  53103. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  53104. */
  53105. keysHeightOffsetModifierAlt: boolean;
  53106. /**
  53107. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  53108. */
  53109. keysHeightOffsetModifierCtrl: boolean;
  53110. /**
  53111. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  53112. */
  53113. keysHeightOffsetModifierShift: boolean;
  53114. /**
  53115. * Defines the list of key codes associated with the left action (increase rotationOffset)
  53116. */
  53117. keysRotationOffsetIncr: number[];
  53118. /**
  53119. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  53120. */
  53121. keysRotationOffsetDecr: number[];
  53122. /**
  53123. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  53124. */
  53125. keysRotationOffsetModifierAlt: boolean;
  53126. /**
  53127. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  53128. */
  53129. keysRotationOffsetModifierCtrl: boolean;
  53130. /**
  53131. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  53132. */
  53133. keysRotationOffsetModifierShift: boolean;
  53134. /**
  53135. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  53136. */
  53137. keysRadiusIncr: number[];
  53138. /**
  53139. * Defines the list of key codes associated with the zoom-out action (increase radius)
  53140. */
  53141. keysRadiusDecr: number[];
  53142. /**
  53143. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  53144. */
  53145. keysRadiusModifierAlt: boolean;
  53146. /**
  53147. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  53148. */
  53149. keysRadiusModifierCtrl: boolean;
  53150. /**
  53151. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  53152. */
  53153. keysRadiusModifierShift: boolean;
  53154. /**
  53155. * Defines the rate of change of heightOffset.
  53156. */
  53157. heightSensibility: number;
  53158. /**
  53159. * Defines the rate of change of rotationOffset.
  53160. */
  53161. rotationSensibility: number;
  53162. /**
  53163. * Defines the rate of change of radius.
  53164. */
  53165. radiusSensibility: number;
  53166. private _keys;
  53167. private _ctrlPressed;
  53168. private _altPressed;
  53169. private _shiftPressed;
  53170. private _onCanvasBlurObserver;
  53171. private _onKeyboardObserver;
  53172. private _engine;
  53173. private _scene;
  53174. /**
  53175. * Attach the input controls to a specific dom element to get the input from.
  53176. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  53177. */
  53178. attachControl(noPreventDefault?: boolean): void;
  53179. /**
  53180. * Detach the current controls from the specified dom element.
  53181. */
  53182. detachControl(): void;
  53183. /**
  53184. * Update the current camera state depending on the inputs that have been used this frame.
  53185. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  53186. */
  53187. checkInputs(): void;
  53188. /**
  53189. * Gets the class name of the current input.
  53190. * @returns the class name
  53191. */
  53192. getClassName(): string;
  53193. /**
  53194. * Get the friendly name associated with the input class.
  53195. * @returns the input friendly name
  53196. */
  53197. getSimpleName(): string;
  53198. /**
  53199. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  53200. * allow modification of the heightOffset value.
  53201. */
  53202. private _modifierHeightOffset;
  53203. /**
  53204. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  53205. * allow modification of the rotationOffset value.
  53206. */
  53207. private _modifierRotationOffset;
  53208. /**
  53209. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  53210. * allow modification of the radius value.
  53211. */
  53212. private _modifierRadius;
  53213. }
  53214. }
  53215. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  53216. import { Nullable } from "babylonjs/types";
  53217. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  53218. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  53219. import { Observable } from "babylonjs/Misc/observable";
  53220. module "babylonjs/Cameras/freeCameraInputsManager" {
  53221. interface FreeCameraInputsManager {
  53222. /**
  53223. * @hidden
  53224. */
  53225. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  53226. /**
  53227. * Add orientation input support to the input manager.
  53228. * @returns the current input manager
  53229. */
  53230. addDeviceOrientation(): FreeCameraInputsManager;
  53231. }
  53232. }
  53233. /**
  53234. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  53235. * Screen rotation is taken into account.
  53236. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  53237. */
  53238. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  53239. private _camera;
  53240. private _screenOrientationAngle;
  53241. private _constantTranform;
  53242. private _screenQuaternion;
  53243. private _alpha;
  53244. private _beta;
  53245. private _gamma;
  53246. /**
  53247. * Can be used to detect if a device orientation sensor is available on a device
  53248. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  53249. * @returns a promise that will resolve on orientation change
  53250. */
  53251. static WaitForOrientationChangeAsync(timeout?: number): Promise<void>;
  53252. /**
  53253. * @hidden
  53254. */
  53255. _onDeviceOrientationChangedObservable: Observable<void>;
  53256. /**
  53257. * Instantiates a new input
  53258. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  53259. */
  53260. constructor();
  53261. /**
  53262. * Define the camera controlled by the input.
  53263. */
  53264. get camera(): FreeCamera;
  53265. set camera(camera: FreeCamera);
  53266. /**
  53267. * Attach the input controls to a specific dom element to get the input from.
  53268. */
  53269. attachControl(): void;
  53270. private _orientationChanged;
  53271. private _deviceOrientation;
  53272. /**
  53273. * Detach the current controls from the specified dom element.
  53274. */
  53275. detachControl(): void;
  53276. /**
  53277. * Update the current camera state depending on the inputs that have been used this frame.
  53278. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  53279. */
  53280. checkInputs(): void;
  53281. /**
  53282. * Gets the class name of the current intput.
  53283. * @returns the class name
  53284. */
  53285. getClassName(): string;
  53286. /**
  53287. * Get the friendly name associated with the input class.
  53288. * @returns the input friendly name
  53289. */
  53290. getSimpleName(): string;
  53291. }
  53292. }
  53293. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  53294. import { Nullable } from "babylonjs/types";
  53295. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  53296. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  53297. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  53298. /**
  53299. * Manage the gamepad inputs to control a free camera.
  53300. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  53301. */
  53302. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  53303. /**
  53304. * Define the camera the input is attached to.
  53305. */
  53306. camera: FreeCamera;
  53307. /**
  53308. * Define the Gamepad controlling the input
  53309. */
  53310. gamepad: Nullable<Gamepad>;
  53311. /**
  53312. * Defines the gamepad rotation sensiblity.
  53313. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  53314. */
  53315. gamepadAngularSensibility: number;
  53316. /**
  53317. * Defines the gamepad move sensiblity.
  53318. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  53319. */
  53320. gamepadMoveSensibility: number;
  53321. private _yAxisScale;
  53322. /**
  53323. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  53324. */
  53325. get invertYAxis(): boolean;
  53326. set invertYAxis(value: boolean);
  53327. private _onGamepadConnectedObserver;
  53328. private _onGamepadDisconnectedObserver;
  53329. private _cameraTransform;
  53330. private _deltaTransform;
  53331. private _vector3;
  53332. private _vector2;
  53333. /**
  53334. * Attach the input controls to a specific dom element to get the input from.
  53335. */
  53336. attachControl(): void;
  53337. /**
  53338. * Detach the current controls from the specified dom element.
  53339. */
  53340. detachControl(): void;
  53341. /**
  53342. * Update the current camera state depending on the inputs that have been used this frame.
  53343. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  53344. */
  53345. checkInputs(): void;
  53346. /**
  53347. * Gets the class name of the current intput.
  53348. * @returns the class name
  53349. */
  53350. getClassName(): string;
  53351. /**
  53352. * Get the friendly name associated with the input class.
  53353. * @returns the input friendly name
  53354. */
  53355. getSimpleName(): string;
  53356. }
  53357. }
  53358. declare module "babylonjs/Misc/virtualJoystick" {
  53359. import { Nullable } from "babylonjs/types";
  53360. import { Vector3 } from "babylonjs/Maths/math.vector";
  53361. /**
  53362. * Defines the potential axis of a Joystick
  53363. */
  53364. export enum JoystickAxis {
  53365. /** X axis */
  53366. X = 0,
  53367. /** Y axis */
  53368. Y = 1,
  53369. /** Z axis */
  53370. Z = 2
  53371. }
  53372. /**
  53373. * Represents the different customization options available
  53374. * for VirtualJoystick
  53375. */
  53376. interface VirtualJoystickCustomizations {
  53377. /**
  53378. * Size of the joystick's puck
  53379. */
  53380. puckSize: number;
  53381. /**
  53382. * Size of the joystick's container
  53383. */
  53384. containerSize: number;
  53385. /**
  53386. * Color of the joystick && puck
  53387. */
  53388. color: string;
  53389. /**
  53390. * Image URL for the joystick's puck
  53391. */
  53392. puckImage?: string;
  53393. /**
  53394. * Image URL for the joystick's container
  53395. */
  53396. containerImage?: string;
  53397. /**
  53398. * Defines the unmoving position of the joystick container
  53399. */
  53400. position?: {
  53401. x: number;
  53402. y: number;
  53403. };
  53404. /**
  53405. * Defines whether or not the joystick container is always visible
  53406. */
  53407. alwaysVisible: boolean;
  53408. /**
  53409. * Defines whether or not to limit the movement of the puck to the joystick's container
  53410. */
  53411. limitToContainer: boolean;
  53412. }
  53413. /**
  53414. * Class used to define virtual joystick (used in touch mode)
  53415. */
  53416. export class VirtualJoystick {
  53417. /**
  53418. * Gets or sets a boolean indicating that left and right values must be inverted
  53419. */
  53420. reverseLeftRight: boolean;
  53421. /**
  53422. * Gets or sets a boolean indicating that up and down values must be inverted
  53423. */
  53424. reverseUpDown: boolean;
  53425. /**
  53426. * Gets the offset value for the position (ie. the change of the position value)
  53427. */
  53428. deltaPosition: Vector3;
  53429. /**
  53430. * Gets a boolean indicating if the virtual joystick was pressed
  53431. */
  53432. pressed: boolean;
  53433. /**
  53434. * Canvas the virtual joystick will render onto, default z-index of this is 5
  53435. */
  53436. static Canvas: Nullable<HTMLCanvasElement>;
  53437. /**
  53438. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  53439. */
  53440. limitToContainer: boolean;
  53441. private static _globalJoystickIndex;
  53442. private static _alwaysVisibleSticks;
  53443. private static vjCanvasContext;
  53444. private static vjCanvasWidth;
  53445. private static vjCanvasHeight;
  53446. private static halfWidth;
  53447. private static _GetDefaultOptions;
  53448. private _action;
  53449. private _axisTargetedByLeftAndRight;
  53450. private _axisTargetedByUpAndDown;
  53451. private _joystickSensibility;
  53452. private _inversedSensibility;
  53453. private _joystickPointerID;
  53454. private _joystickColor;
  53455. private _joystickPointerPos;
  53456. private _joystickPreviousPointerPos;
  53457. private _joystickPointerStartPos;
  53458. private _deltaJoystickVector;
  53459. private _leftJoystick;
  53460. private _touches;
  53461. private _joystickPosition;
  53462. private _alwaysVisible;
  53463. private _puckImage;
  53464. private _containerImage;
  53465. private _joystickPuckSize;
  53466. private _joystickContainerSize;
  53467. private _clearPuckSize;
  53468. private _clearContainerSize;
  53469. private _clearPuckSizeOffset;
  53470. private _clearContainerSizeOffset;
  53471. private _onPointerDownHandlerRef;
  53472. private _onPointerMoveHandlerRef;
  53473. private _onPointerUpHandlerRef;
  53474. private _onResize;
  53475. /**
  53476. * Creates a new virtual joystick
  53477. * @param leftJoystick defines that the joystick is for left hand (false by default)
  53478. * @param customizations Defines the options we want to customize the VirtualJoystick
  53479. */
  53480. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  53481. /**
  53482. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  53483. * @param newJoystickSensibility defines the new sensibility
  53484. */
  53485. setJoystickSensibility(newJoystickSensibility: number): void;
  53486. private _onPointerDown;
  53487. private _onPointerMove;
  53488. private _onPointerUp;
  53489. /**
  53490. * Change the color of the virtual joystick
  53491. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  53492. */
  53493. setJoystickColor(newColor: string): void;
  53494. /**
  53495. * Size of the joystick's container
  53496. */
  53497. set containerSize(newSize: number);
  53498. get containerSize(): number;
  53499. /**
  53500. * Size of the joystick's puck
  53501. */
  53502. set puckSize(newSize: number);
  53503. get puckSize(): number;
  53504. /**
  53505. * Clears the set position of the joystick
  53506. */
  53507. clearPosition(): void;
  53508. /**
  53509. * Defines whether or not the joystick container is always visible
  53510. */
  53511. set alwaysVisible(value: boolean);
  53512. get alwaysVisible(): boolean;
  53513. /**
  53514. * Sets the constant position of the Joystick container
  53515. * @param x X axis coordinate
  53516. * @param y Y axis coordinate
  53517. */
  53518. setPosition(x: number, y: number): void;
  53519. /**
  53520. * Defines a callback to call when the joystick is touched
  53521. * @param action defines the callback
  53522. */
  53523. setActionOnTouch(action: () => any): void;
  53524. /**
  53525. * Defines which axis you'd like to control for left & right
  53526. * @param axis defines the axis to use
  53527. */
  53528. setAxisForLeftRight(axis: JoystickAxis): void;
  53529. /**
  53530. * Defines which axis you'd like to control for up & down
  53531. * @param axis defines the axis to use
  53532. */
  53533. setAxisForUpDown(axis: JoystickAxis): void;
  53534. /**
  53535. * Clears the canvas from the previous puck / container draw
  53536. */
  53537. private _clearPreviousDraw;
  53538. /**
  53539. * Loads `urlPath` to be used for the container's image
  53540. * @param urlPath defines the urlPath of an image to use
  53541. */
  53542. setContainerImage(urlPath: string): void;
  53543. /**
  53544. * Loads `urlPath` to be used for the puck's image
  53545. * @param urlPath defines the urlPath of an image to use
  53546. */
  53547. setPuckImage(urlPath: string): void;
  53548. /**
  53549. * Draws the Virtual Joystick's container
  53550. */
  53551. private _drawContainer;
  53552. /**
  53553. * Draws the Virtual Joystick's puck
  53554. */
  53555. private _drawPuck;
  53556. private _drawVirtualJoystick;
  53557. /**
  53558. * Release internal HTML canvas
  53559. */
  53560. releaseCanvas(): void;
  53561. }
  53562. }
  53563. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  53564. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  53565. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  53566. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  53567. module "babylonjs/Cameras/freeCameraInputsManager" {
  53568. interface FreeCameraInputsManager {
  53569. /**
  53570. * Add virtual joystick input support to the input manager.
  53571. * @returns the current input manager
  53572. */
  53573. addVirtualJoystick(): FreeCameraInputsManager;
  53574. }
  53575. }
  53576. /**
  53577. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  53578. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  53579. */
  53580. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  53581. /**
  53582. * Defines the camera the input is attached to.
  53583. */
  53584. camera: FreeCamera;
  53585. private _leftjoystick;
  53586. private _rightjoystick;
  53587. /**
  53588. * Gets the left stick of the virtual joystick.
  53589. * @returns The virtual Joystick
  53590. */
  53591. getLeftJoystick(): VirtualJoystick;
  53592. /**
  53593. * Gets the right stick of the virtual joystick.
  53594. * @returns The virtual Joystick
  53595. */
  53596. getRightJoystick(): VirtualJoystick;
  53597. /**
  53598. * Update the current camera state depending on the inputs that have been used this frame.
  53599. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  53600. */
  53601. checkInputs(): void;
  53602. /**
  53603. * Attach the input controls to a specific dom element to get the input from.
  53604. */
  53605. attachControl(): void;
  53606. /**
  53607. * Detach the current controls from the specified dom element.
  53608. */
  53609. detachControl(): void;
  53610. /**
  53611. * Gets the class name of the current intput.
  53612. * @returns the class name
  53613. */
  53614. getClassName(): string;
  53615. /**
  53616. * Get the friendly name associated with the input class.
  53617. * @returns the input friendly name
  53618. */
  53619. getSimpleName(): string;
  53620. }
  53621. }
  53622. declare module "babylonjs/Cameras/Inputs/index" {
  53623. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  53624. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  53625. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  53626. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  53627. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  53628. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  53629. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  53630. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  53631. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  53632. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  53633. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  53634. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  53635. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  53636. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  53637. export * from "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput";
  53638. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  53639. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  53640. }
  53641. declare module "babylonjs/Cameras/touchCamera" {
  53642. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  53643. import { Scene } from "babylonjs/scene";
  53644. import { Vector3 } from "babylonjs/Maths/math.vector";
  53645. /**
  53646. * This represents a FPS type of camera controlled by touch.
  53647. * This is like a universal camera minus the Gamepad controls.
  53648. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  53649. */
  53650. export class TouchCamera extends FreeCamera {
  53651. /**
  53652. * Defines the touch sensibility for rotation.
  53653. * The higher the faster.
  53654. */
  53655. get touchAngularSensibility(): number;
  53656. set touchAngularSensibility(value: number);
  53657. /**
  53658. * Defines the touch sensibility for move.
  53659. * The higher the faster.
  53660. */
  53661. get touchMoveSensibility(): number;
  53662. set touchMoveSensibility(value: number);
  53663. /**
  53664. * Instantiates a new touch camera.
  53665. * This represents a FPS type of camera controlled by touch.
  53666. * This is like a universal camera minus the Gamepad controls.
  53667. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  53668. * @param name Define the name of the camera in the scene
  53669. * @param position Define the start position of the camera in the scene
  53670. * @param scene Define the scene the camera belongs to
  53671. */
  53672. constructor(name: string, position: Vector3, scene: Scene);
  53673. /**
  53674. * Gets the current object class name.
  53675. * @return the class name
  53676. */
  53677. getClassName(): string;
  53678. /** @hidden */
  53679. _setupInputs(): void;
  53680. }
  53681. }
  53682. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  53683. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  53684. import { Scene } from "babylonjs/scene";
  53685. import { Vector3 } from "babylonjs/Maths/math.vector";
  53686. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  53687. import { Axis } from "babylonjs/Maths/math.axis";
  53688. /**
  53689. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  53690. * being tilted forward or back and left or right.
  53691. */
  53692. export class DeviceOrientationCamera extends FreeCamera {
  53693. private _initialQuaternion;
  53694. private _quaternionCache;
  53695. private _tmpDragQuaternion;
  53696. private _disablePointerInputWhenUsingDeviceOrientation;
  53697. /**
  53698. * Creates a new device orientation camera
  53699. * @param name The name of the camera
  53700. * @param position The start position camera
  53701. * @param scene The scene the camera belongs to
  53702. */
  53703. constructor(name: string, position: Vector3, scene: Scene);
  53704. /**
  53705. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  53706. */
  53707. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  53708. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  53709. private _dragFactor;
  53710. /**
  53711. * Enabled turning on the y axis when the orientation sensor is active
  53712. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  53713. */
  53714. enableHorizontalDragging(dragFactor?: number): void;
  53715. /**
  53716. * Gets the current instance class name ("DeviceOrientationCamera").
  53717. * This helps avoiding instanceof at run time.
  53718. * @returns the class name
  53719. */
  53720. getClassName(): string;
  53721. /**
  53722. * @hidden
  53723. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  53724. */
  53725. _checkInputs(): void;
  53726. /**
  53727. * Reset the camera to its default orientation on the specified axis only.
  53728. * @param axis The axis to reset
  53729. */
  53730. resetToCurrentRotation(axis?: Axis): void;
  53731. }
  53732. }
  53733. declare module "babylonjs/Gamepads/xboxGamepad" {
  53734. import { Observable } from "babylonjs/Misc/observable";
  53735. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  53736. /**
  53737. * Defines supported buttons for XBox360 compatible gamepads
  53738. */
  53739. export enum Xbox360Button {
  53740. /** A */
  53741. A = 0,
  53742. /** B */
  53743. B = 1,
  53744. /** X */
  53745. X = 2,
  53746. /** Y */
  53747. Y = 3,
  53748. /** Left button */
  53749. LB = 4,
  53750. /** Right button */
  53751. RB = 5,
  53752. /** Back */
  53753. Back = 8,
  53754. /** Start */
  53755. Start = 9,
  53756. /** Left stick */
  53757. LeftStick = 10,
  53758. /** Right stick */
  53759. RightStick = 11
  53760. }
  53761. /** Defines values for XBox360 DPad */
  53762. export enum Xbox360Dpad {
  53763. /** Up */
  53764. Up = 12,
  53765. /** Down */
  53766. Down = 13,
  53767. /** Left */
  53768. Left = 14,
  53769. /** Right */
  53770. Right = 15
  53771. }
  53772. /**
  53773. * Defines a XBox360 gamepad
  53774. */
  53775. export class Xbox360Pad extends Gamepad {
  53776. private _leftTrigger;
  53777. private _rightTrigger;
  53778. private _onlefttriggerchanged;
  53779. private _onrighttriggerchanged;
  53780. private _onbuttondown;
  53781. private _onbuttonup;
  53782. private _ondpaddown;
  53783. private _ondpadup;
  53784. /** Observable raised when a button is pressed */
  53785. onButtonDownObservable: Observable<Xbox360Button>;
  53786. /** Observable raised when a button is released */
  53787. onButtonUpObservable: Observable<Xbox360Button>;
  53788. /** Observable raised when a pad is pressed */
  53789. onPadDownObservable: Observable<Xbox360Dpad>;
  53790. /** Observable raised when a pad is released */
  53791. onPadUpObservable: Observable<Xbox360Dpad>;
  53792. private _buttonA;
  53793. private _buttonB;
  53794. private _buttonX;
  53795. private _buttonY;
  53796. private _buttonBack;
  53797. private _buttonStart;
  53798. private _buttonLB;
  53799. private _buttonRB;
  53800. private _buttonLeftStick;
  53801. private _buttonRightStick;
  53802. private _dPadUp;
  53803. private _dPadDown;
  53804. private _dPadLeft;
  53805. private _dPadRight;
  53806. private _isXboxOnePad;
  53807. /**
  53808. * Creates a new XBox360 gamepad object
  53809. * @param id defines the id of this gamepad
  53810. * @param index defines its index
  53811. * @param gamepad defines the internal HTML gamepad object
  53812. * @param xboxOne defines if it is a XBox One gamepad
  53813. */
  53814. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  53815. /**
  53816. * Defines the callback to call when left trigger is pressed
  53817. * @param callback defines the callback to use
  53818. */
  53819. onlefttriggerchanged(callback: (value: number) => void): void;
  53820. /**
  53821. * Defines the callback to call when right trigger is pressed
  53822. * @param callback defines the callback to use
  53823. */
  53824. onrighttriggerchanged(callback: (value: number) => void): void;
  53825. /**
  53826. * Gets the left trigger value
  53827. */
  53828. get leftTrigger(): number;
  53829. /**
  53830. * Sets the left trigger value
  53831. */
  53832. set leftTrigger(newValue: number);
  53833. /**
  53834. * Gets the right trigger value
  53835. */
  53836. get rightTrigger(): number;
  53837. /**
  53838. * Sets the right trigger value
  53839. */
  53840. set rightTrigger(newValue: number);
  53841. /**
  53842. * Defines the callback to call when a button is pressed
  53843. * @param callback defines the callback to use
  53844. */
  53845. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  53846. /**
  53847. * Defines the callback to call when a button is released
  53848. * @param callback defines the callback to use
  53849. */
  53850. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  53851. /**
  53852. * Defines the callback to call when a pad is pressed
  53853. * @param callback defines the callback to use
  53854. */
  53855. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  53856. /**
  53857. * Defines the callback to call when a pad is released
  53858. * @param callback defines the callback to use
  53859. */
  53860. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  53861. private _setButtonValue;
  53862. private _setDPadValue;
  53863. /**
  53864. * Gets the value of the `A` button
  53865. */
  53866. get buttonA(): number;
  53867. /**
  53868. * Sets the value of the `A` button
  53869. */
  53870. set buttonA(value: number);
  53871. /**
  53872. * Gets the value of the `B` button
  53873. */
  53874. get buttonB(): number;
  53875. /**
  53876. * Sets the value of the `B` button
  53877. */
  53878. set buttonB(value: number);
  53879. /**
  53880. * Gets the value of the `X` button
  53881. */
  53882. get buttonX(): number;
  53883. /**
  53884. * Sets the value of the `X` button
  53885. */
  53886. set buttonX(value: number);
  53887. /**
  53888. * Gets the value of the `Y` button
  53889. */
  53890. get buttonY(): number;
  53891. /**
  53892. * Sets the value of the `Y` button
  53893. */
  53894. set buttonY(value: number);
  53895. /**
  53896. * Gets the value of the `Start` button
  53897. */
  53898. get buttonStart(): number;
  53899. /**
  53900. * Sets the value of the `Start` button
  53901. */
  53902. set buttonStart(value: number);
  53903. /**
  53904. * Gets the value of the `Back` button
  53905. */
  53906. get buttonBack(): number;
  53907. /**
  53908. * Sets the value of the `Back` button
  53909. */
  53910. set buttonBack(value: number);
  53911. /**
  53912. * Gets the value of the `Left` button
  53913. */
  53914. get buttonLB(): number;
  53915. /**
  53916. * Sets the value of the `Left` button
  53917. */
  53918. set buttonLB(value: number);
  53919. /**
  53920. * Gets the value of the `Right` button
  53921. */
  53922. get buttonRB(): number;
  53923. /**
  53924. * Sets the value of the `Right` button
  53925. */
  53926. set buttonRB(value: number);
  53927. /**
  53928. * Gets the value of the Left joystick
  53929. */
  53930. get buttonLeftStick(): number;
  53931. /**
  53932. * Sets the value of the Left joystick
  53933. */
  53934. set buttonLeftStick(value: number);
  53935. /**
  53936. * Gets the value of the Right joystick
  53937. */
  53938. get buttonRightStick(): number;
  53939. /**
  53940. * Sets the value of the Right joystick
  53941. */
  53942. set buttonRightStick(value: number);
  53943. /**
  53944. * Gets the value of D-pad up
  53945. */
  53946. get dPadUp(): number;
  53947. /**
  53948. * Sets the value of D-pad up
  53949. */
  53950. set dPadUp(value: number);
  53951. /**
  53952. * Gets the value of D-pad down
  53953. */
  53954. get dPadDown(): number;
  53955. /**
  53956. * Sets the value of D-pad down
  53957. */
  53958. set dPadDown(value: number);
  53959. /**
  53960. * Gets the value of D-pad left
  53961. */
  53962. get dPadLeft(): number;
  53963. /**
  53964. * Sets the value of D-pad left
  53965. */
  53966. set dPadLeft(value: number);
  53967. /**
  53968. * Gets the value of D-pad right
  53969. */
  53970. get dPadRight(): number;
  53971. /**
  53972. * Sets the value of D-pad right
  53973. */
  53974. set dPadRight(value: number);
  53975. /**
  53976. * Force the gamepad to synchronize with device values
  53977. */
  53978. update(): void;
  53979. /**
  53980. * Disposes the gamepad
  53981. */
  53982. dispose(): void;
  53983. }
  53984. }
  53985. declare module "babylonjs/Gamepads/dualShockGamepad" {
  53986. import { Observable } from "babylonjs/Misc/observable";
  53987. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  53988. /**
  53989. * Defines supported buttons for DualShock compatible gamepads
  53990. */
  53991. export enum DualShockButton {
  53992. /** Cross */
  53993. Cross = 0,
  53994. /** Circle */
  53995. Circle = 1,
  53996. /** Square */
  53997. Square = 2,
  53998. /** Triangle */
  53999. Triangle = 3,
  54000. /** L1 */
  54001. L1 = 4,
  54002. /** R1 */
  54003. R1 = 5,
  54004. /** Share */
  54005. Share = 8,
  54006. /** Options */
  54007. Options = 9,
  54008. /** Left stick */
  54009. LeftStick = 10,
  54010. /** Right stick */
  54011. RightStick = 11
  54012. }
  54013. /** Defines values for DualShock DPad */
  54014. export enum DualShockDpad {
  54015. /** Up */
  54016. Up = 12,
  54017. /** Down */
  54018. Down = 13,
  54019. /** Left */
  54020. Left = 14,
  54021. /** Right */
  54022. Right = 15
  54023. }
  54024. /**
  54025. * Defines a DualShock gamepad
  54026. */
  54027. export class DualShockPad extends Gamepad {
  54028. private _leftTrigger;
  54029. private _rightTrigger;
  54030. private _onlefttriggerchanged;
  54031. private _onrighttriggerchanged;
  54032. private _onbuttondown;
  54033. private _onbuttonup;
  54034. private _ondpaddown;
  54035. private _ondpadup;
  54036. /** Observable raised when a button is pressed */
  54037. onButtonDownObservable: Observable<DualShockButton>;
  54038. /** Observable raised when a button is released */
  54039. onButtonUpObservable: Observable<DualShockButton>;
  54040. /** Observable raised when a pad is pressed */
  54041. onPadDownObservable: Observable<DualShockDpad>;
  54042. /** Observable raised when a pad is released */
  54043. onPadUpObservable: Observable<DualShockDpad>;
  54044. private _buttonCross;
  54045. private _buttonCircle;
  54046. private _buttonSquare;
  54047. private _buttonTriangle;
  54048. private _buttonShare;
  54049. private _buttonOptions;
  54050. private _buttonL1;
  54051. private _buttonR1;
  54052. private _buttonLeftStick;
  54053. private _buttonRightStick;
  54054. private _dPadUp;
  54055. private _dPadDown;
  54056. private _dPadLeft;
  54057. private _dPadRight;
  54058. /**
  54059. * Creates a new DualShock gamepad object
  54060. * @param id defines the id of this gamepad
  54061. * @param index defines its index
  54062. * @param gamepad defines the internal HTML gamepad object
  54063. */
  54064. constructor(id: string, index: number, gamepad: any);
  54065. /**
  54066. * Defines the callback to call when left trigger is pressed
  54067. * @param callback defines the callback to use
  54068. */
  54069. onlefttriggerchanged(callback: (value: number) => void): void;
  54070. /**
  54071. * Defines the callback to call when right trigger is pressed
  54072. * @param callback defines the callback to use
  54073. */
  54074. onrighttriggerchanged(callback: (value: number) => void): void;
  54075. /**
  54076. * Gets the left trigger value
  54077. */
  54078. get leftTrigger(): number;
  54079. /**
  54080. * Sets the left trigger value
  54081. */
  54082. set leftTrigger(newValue: number);
  54083. /**
  54084. * Gets the right trigger value
  54085. */
  54086. get rightTrigger(): number;
  54087. /**
  54088. * Sets the right trigger value
  54089. */
  54090. set rightTrigger(newValue: number);
  54091. /**
  54092. * Defines the callback to call when a button is pressed
  54093. * @param callback defines the callback to use
  54094. */
  54095. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  54096. /**
  54097. * Defines the callback to call when a button is released
  54098. * @param callback defines the callback to use
  54099. */
  54100. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  54101. /**
  54102. * Defines the callback to call when a pad is pressed
  54103. * @param callback defines the callback to use
  54104. */
  54105. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  54106. /**
  54107. * Defines the callback to call when a pad is released
  54108. * @param callback defines the callback to use
  54109. */
  54110. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  54111. private _setButtonValue;
  54112. private _setDPadValue;
  54113. /**
  54114. * Gets the value of the `Cross` button
  54115. */
  54116. get buttonCross(): number;
  54117. /**
  54118. * Sets the value of the `Cross` button
  54119. */
  54120. set buttonCross(value: number);
  54121. /**
  54122. * Gets the value of the `Circle` button
  54123. */
  54124. get buttonCircle(): number;
  54125. /**
  54126. * Sets the value of the `Circle` button
  54127. */
  54128. set buttonCircle(value: number);
  54129. /**
  54130. * Gets the value of the `Square` button
  54131. */
  54132. get buttonSquare(): number;
  54133. /**
  54134. * Sets the value of the `Square` button
  54135. */
  54136. set buttonSquare(value: number);
  54137. /**
  54138. * Gets the value of the `Triangle` button
  54139. */
  54140. get buttonTriangle(): number;
  54141. /**
  54142. * Sets the value of the `Triangle` button
  54143. */
  54144. set buttonTriangle(value: number);
  54145. /**
  54146. * Gets the value of the `Options` button
  54147. */
  54148. get buttonOptions(): number;
  54149. /**
  54150. * Sets the value of the `Options` button
  54151. */
  54152. set buttonOptions(value: number);
  54153. /**
  54154. * Gets the value of the `Share` button
  54155. */
  54156. get buttonShare(): number;
  54157. /**
  54158. * Sets the value of the `Share` button
  54159. */
  54160. set buttonShare(value: number);
  54161. /**
  54162. * Gets the value of the `L1` button
  54163. */
  54164. get buttonL1(): number;
  54165. /**
  54166. * Sets the value of the `L1` button
  54167. */
  54168. set buttonL1(value: number);
  54169. /**
  54170. * Gets the value of the `R1` button
  54171. */
  54172. get buttonR1(): number;
  54173. /**
  54174. * Sets the value of the `R1` button
  54175. */
  54176. set buttonR1(value: number);
  54177. /**
  54178. * Gets the value of the Left joystick
  54179. */
  54180. get buttonLeftStick(): number;
  54181. /**
  54182. * Sets the value of the Left joystick
  54183. */
  54184. set buttonLeftStick(value: number);
  54185. /**
  54186. * Gets the value of the Right joystick
  54187. */
  54188. get buttonRightStick(): number;
  54189. /**
  54190. * Sets the value of the Right joystick
  54191. */
  54192. set buttonRightStick(value: number);
  54193. /**
  54194. * Gets the value of D-pad up
  54195. */
  54196. get dPadUp(): number;
  54197. /**
  54198. * Sets the value of D-pad up
  54199. */
  54200. set dPadUp(value: number);
  54201. /**
  54202. * Gets the value of D-pad down
  54203. */
  54204. get dPadDown(): number;
  54205. /**
  54206. * Sets the value of D-pad down
  54207. */
  54208. set dPadDown(value: number);
  54209. /**
  54210. * Gets the value of D-pad left
  54211. */
  54212. get dPadLeft(): number;
  54213. /**
  54214. * Sets the value of D-pad left
  54215. */
  54216. set dPadLeft(value: number);
  54217. /**
  54218. * Gets the value of D-pad right
  54219. */
  54220. get dPadRight(): number;
  54221. /**
  54222. * Sets the value of D-pad right
  54223. */
  54224. set dPadRight(value: number);
  54225. /**
  54226. * Force the gamepad to synchronize with device values
  54227. */
  54228. update(): void;
  54229. /**
  54230. * Disposes the gamepad
  54231. */
  54232. dispose(): void;
  54233. }
  54234. }
  54235. declare module "babylonjs/Gamepads/gamepadManager" {
  54236. import { Observable } from "babylonjs/Misc/observable";
  54237. import { Nullable } from "babylonjs/types";
  54238. import { Scene } from "babylonjs/scene";
  54239. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  54240. /**
  54241. * Manager for handling gamepads
  54242. */
  54243. export class GamepadManager {
  54244. private _scene?;
  54245. private _babylonGamepads;
  54246. private _oneGamepadConnected;
  54247. /** @hidden */
  54248. _isMonitoring: boolean;
  54249. private _gamepadEventSupported;
  54250. private _gamepadSupport?;
  54251. /**
  54252. * observable to be triggered when the gamepad controller has been connected
  54253. */
  54254. onGamepadConnectedObservable: Observable<Gamepad>;
  54255. /**
  54256. * observable to be triggered when the gamepad controller has been disconnected
  54257. */
  54258. onGamepadDisconnectedObservable: Observable<Gamepad>;
  54259. private _onGamepadConnectedEvent;
  54260. private _onGamepadDisconnectedEvent;
  54261. /**
  54262. * Initializes the gamepad manager
  54263. * @param _scene BabylonJS scene
  54264. */
  54265. constructor(_scene?: Scene | undefined);
  54266. /**
  54267. * The gamepads in the game pad manager
  54268. */
  54269. get gamepads(): Gamepad[];
  54270. /**
  54271. * Get the gamepad controllers based on type
  54272. * @param type The type of gamepad controller
  54273. * @returns Nullable gamepad
  54274. */
  54275. getGamepadByType(type?: number): Nullable<Gamepad>;
  54276. /**
  54277. * Disposes the gamepad manager
  54278. */
  54279. dispose(): void;
  54280. private _addNewGamepad;
  54281. private _startMonitoringGamepads;
  54282. private _stopMonitoringGamepads;
  54283. /** @hidden */
  54284. _checkGamepadsStatus(): void;
  54285. private _updateGamepadObjects;
  54286. }
  54287. }
  54288. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  54289. import { Nullable } from "babylonjs/types";
  54290. import { Scene } from "babylonjs/scene";
  54291. import { ISceneComponent } from "babylonjs/sceneComponent";
  54292. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  54293. module "babylonjs/scene" {
  54294. interface Scene {
  54295. /** @hidden */
  54296. _gamepadManager: Nullable<GamepadManager>;
  54297. /**
  54298. * Gets the gamepad manager associated with the scene
  54299. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  54300. */
  54301. gamepadManager: GamepadManager;
  54302. }
  54303. }
  54304. module "babylonjs/Cameras/freeCameraInputsManager" {
  54305. /**
  54306. * Interface representing a free camera inputs manager
  54307. */
  54308. interface FreeCameraInputsManager {
  54309. /**
  54310. * Adds gamepad input support to the FreeCameraInputsManager.
  54311. * @returns the FreeCameraInputsManager
  54312. */
  54313. addGamepad(): FreeCameraInputsManager;
  54314. }
  54315. }
  54316. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  54317. /**
  54318. * Interface representing an arc rotate camera inputs manager
  54319. */
  54320. interface ArcRotateCameraInputsManager {
  54321. /**
  54322. * Adds gamepad input support to the ArcRotateCamera InputManager.
  54323. * @returns the camera inputs manager
  54324. */
  54325. addGamepad(): ArcRotateCameraInputsManager;
  54326. }
  54327. }
  54328. /**
  54329. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  54330. */
  54331. export class GamepadSystemSceneComponent implements ISceneComponent {
  54332. /**
  54333. * The component name helpfull to identify the component in the list of scene components.
  54334. */
  54335. readonly name: string;
  54336. /**
  54337. * The scene the component belongs to.
  54338. */
  54339. scene: Scene;
  54340. /**
  54341. * Creates a new instance of the component for the given scene
  54342. * @param scene Defines the scene to register the component in
  54343. */
  54344. constructor(scene: Scene);
  54345. /**
  54346. * Registers the component in a given scene
  54347. */
  54348. register(): void;
  54349. /**
  54350. * Rebuilds the elements related to this component in case of
  54351. * context lost for instance.
  54352. */
  54353. rebuild(): void;
  54354. /**
  54355. * Disposes the component and the associated ressources
  54356. */
  54357. dispose(): void;
  54358. private _beforeCameraUpdate;
  54359. }
  54360. }
  54361. declare module "babylonjs/Cameras/universalCamera" {
  54362. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  54363. import { Scene } from "babylonjs/scene";
  54364. import { Vector3 } from "babylonjs/Maths/math.vector";
  54365. import "babylonjs/Gamepads/gamepadSceneComponent";
  54366. /**
  54367. * 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,
  54368. * which still works and will still be found in many Playgrounds.
  54369. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  54370. */
  54371. export class UniversalCamera extends TouchCamera {
  54372. /**
  54373. * Defines the gamepad rotation sensiblity.
  54374. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  54375. */
  54376. get gamepadAngularSensibility(): number;
  54377. set gamepadAngularSensibility(value: number);
  54378. /**
  54379. * Defines the gamepad move sensiblity.
  54380. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  54381. */
  54382. get gamepadMoveSensibility(): number;
  54383. set gamepadMoveSensibility(value: number);
  54384. /**
  54385. * 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,
  54386. * which still works and will still be found in many Playgrounds.
  54387. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  54388. * @param name Define the name of the camera in the scene
  54389. * @param position Define the start position of the camera in the scene
  54390. * @param scene Define the scene the camera belongs to
  54391. */
  54392. constructor(name: string, position: Vector3, scene: Scene);
  54393. /**
  54394. * Gets the current object class name.
  54395. * @return the class name
  54396. */
  54397. getClassName(): string;
  54398. }
  54399. }
  54400. declare module "babylonjs/Cameras/gamepadCamera" {
  54401. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  54402. import { Scene } from "babylonjs/scene";
  54403. import { Vector3 } from "babylonjs/Maths/math.vector";
  54404. /**
  54405. * This represents a FPS type of camera. This is only here for back compat purpose.
  54406. * Please use the UniversalCamera instead as both are identical.
  54407. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  54408. */
  54409. export class GamepadCamera extends UniversalCamera {
  54410. /**
  54411. * Instantiates a new Gamepad Camera
  54412. * This represents a FPS type of camera. This is only here for back compat purpose.
  54413. * Please use the UniversalCamera instead as both are identical.
  54414. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  54415. * @param name Define the name of the camera in the scene
  54416. * @param position Define the start position of the camera in the scene
  54417. * @param scene Define the scene the camera belongs to
  54418. */
  54419. constructor(name: string, position: Vector3, scene: Scene);
  54420. /**
  54421. * Gets the current object class name.
  54422. * @return the class name
  54423. */
  54424. getClassName(): string;
  54425. }
  54426. }
  54427. declare module "babylonjs/Shaders/anaglyph.fragment" {
  54428. /** @hidden */
  54429. export var anaglyphPixelShader: {
  54430. name: string;
  54431. shader: string;
  54432. };
  54433. }
  54434. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  54435. import { Engine } from "babylonjs/Engines/engine";
  54436. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54437. import { Camera } from "babylonjs/Cameras/camera";
  54438. import "babylonjs/Shaders/anaglyph.fragment";
  54439. /**
  54440. * Postprocess used to generate anaglyphic rendering
  54441. */
  54442. export class AnaglyphPostProcess extends PostProcess {
  54443. private _passedProcess;
  54444. /**
  54445. * Gets a string identifying the name of the class
  54446. * @returns "AnaglyphPostProcess" string
  54447. */
  54448. getClassName(): string;
  54449. /**
  54450. * Creates a new AnaglyphPostProcess
  54451. * @param name defines postprocess name
  54452. * @param options defines creation options or target ratio scale
  54453. * @param rigCameras defines cameras using this postprocess
  54454. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  54455. * @param engine defines hosting engine
  54456. * @param reusable defines if the postprocess will be reused multiple times per frame
  54457. */
  54458. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  54459. }
  54460. }
  54461. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  54462. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  54463. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  54464. import { Scene } from "babylonjs/scene";
  54465. import { Vector3 } from "babylonjs/Maths/math.vector";
  54466. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  54467. /**
  54468. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  54469. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  54470. */
  54471. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  54472. /**
  54473. * Creates a new AnaglyphArcRotateCamera
  54474. * @param name defines camera name
  54475. * @param alpha defines alpha angle (in radians)
  54476. * @param beta defines beta angle (in radians)
  54477. * @param radius defines radius
  54478. * @param target defines camera target
  54479. * @param interaxialDistance defines distance between each color axis
  54480. * @param scene defines the hosting scene
  54481. */
  54482. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  54483. /**
  54484. * Gets camera class name
  54485. * @returns AnaglyphArcRotateCamera
  54486. */
  54487. getClassName(): string;
  54488. }
  54489. }
  54490. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  54491. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  54492. import { Scene } from "babylonjs/scene";
  54493. import { Vector3 } from "babylonjs/Maths/math.vector";
  54494. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  54495. /**
  54496. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  54497. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  54498. */
  54499. export class AnaglyphFreeCamera extends FreeCamera {
  54500. /**
  54501. * Creates a new AnaglyphFreeCamera
  54502. * @param name defines camera name
  54503. * @param position defines initial position
  54504. * @param interaxialDistance defines distance between each color axis
  54505. * @param scene defines the hosting scene
  54506. */
  54507. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  54508. /**
  54509. * Gets camera class name
  54510. * @returns AnaglyphFreeCamera
  54511. */
  54512. getClassName(): string;
  54513. }
  54514. }
  54515. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  54516. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  54517. import { Scene } from "babylonjs/scene";
  54518. import { Vector3 } from "babylonjs/Maths/math.vector";
  54519. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  54520. /**
  54521. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  54522. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  54523. */
  54524. export class AnaglyphGamepadCamera extends GamepadCamera {
  54525. /**
  54526. * Creates a new AnaglyphGamepadCamera
  54527. * @param name defines camera name
  54528. * @param position defines initial position
  54529. * @param interaxialDistance defines distance between each color axis
  54530. * @param scene defines the hosting scene
  54531. */
  54532. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  54533. /**
  54534. * Gets camera class name
  54535. * @returns AnaglyphGamepadCamera
  54536. */
  54537. getClassName(): string;
  54538. }
  54539. }
  54540. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  54541. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  54542. import { Scene } from "babylonjs/scene";
  54543. import { Vector3 } from "babylonjs/Maths/math.vector";
  54544. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  54545. /**
  54546. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  54547. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  54548. */
  54549. export class AnaglyphUniversalCamera extends UniversalCamera {
  54550. /**
  54551. * Creates a new AnaglyphUniversalCamera
  54552. * @param name defines camera name
  54553. * @param position defines initial position
  54554. * @param interaxialDistance defines distance between each color axis
  54555. * @param scene defines the hosting scene
  54556. */
  54557. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  54558. /**
  54559. * Gets camera class name
  54560. * @returns AnaglyphUniversalCamera
  54561. */
  54562. getClassName(): string;
  54563. }
  54564. }
  54565. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  54566. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  54567. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  54568. import { Scene } from "babylonjs/scene";
  54569. import { Vector3 } from "babylonjs/Maths/math.vector";
  54570. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  54571. /**
  54572. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  54573. * @see https://doc.babylonjs.com/features/cameras
  54574. */
  54575. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  54576. /**
  54577. * Creates a new StereoscopicArcRotateCamera
  54578. * @param name defines camera name
  54579. * @param alpha defines alpha angle (in radians)
  54580. * @param beta defines beta angle (in radians)
  54581. * @param radius defines radius
  54582. * @param target defines camera target
  54583. * @param interaxialDistance defines distance between each color axis
  54584. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  54585. * @param scene defines the hosting scene
  54586. */
  54587. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  54588. /**
  54589. * Gets camera class name
  54590. * @returns StereoscopicArcRotateCamera
  54591. */
  54592. getClassName(): string;
  54593. }
  54594. }
  54595. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  54596. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  54597. import { Scene } from "babylonjs/scene";
  54598. import { Vector3 } from "babylonjs/Maths/math.vector";
  54599. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  54600. /**
  54601. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  54602. * @see https://doc.babylonjs.com/features/cameras
  54603. */
  54604. export class StereoscopicFreeCamera extends FreeCamera {
  54605. /**
  54606. * Creates a new StereoscopicFreeCamera
  54607. * @param name defines camera name
  54608. * @param position defines initial position
  54609. * @param interaxialDistance defines distance between each color axis
  54610. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  54611. * @param scene defines the hosting scene
  54612. */
  54613. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  54614. /**
  54615. * Gets camera class name
  54616. * @returns StereoscopicFreeCamera
  54617. */
  54618. getClassName(): string;
  54619. }
  54620. }
  54621. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  54622. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  54623. import { Scene } from "babylonjs/scene";
  54624. import { Vector3 } from "babylonjs/Maths/math.vector";
  54625. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  54626. /**
  54627. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  54628. * @see https://doc.babylonjs.com/features/cameras
  54629. */
  54630. export class StereoscopicGamepadCamera extends GamepadCamera {
  54631. /**
  54632. * Creates a new StereoscopicGamepadCamera
  54633. * @param name defines camera name
  54634. * @param position defines initial position
  54635. * @param interaxialDistance defines distance between each color axis
  54636. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  54637. * @param scene defines the hosting scene
  54638. */
  54639. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  54640. /**
  54641. * Gets camera class name
  54642. * @returns StereoscopicGamepadCamera
  54643. */
  54644. getClassName(): string;
  54645. }
  54646. }
  54647. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  54648. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  54649. import { Scene } from "babylonjs/scene";
  54650. import { Vector3 } from "babylonjs/Maths/math.vector";
  54651. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  54652. /**
  54653. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  54654. * @see https://doc.babylonjs.com/features/cameras
  54655. */
  54656. export class StereoscopicUniversalCamera extends UniversalCamera {
  54657. /**
  54658. * Creates a new StereoscopicUniversalCamera
  54659. * @param name defines camera name
  54660. * @param position defines initial position
  54661. * @param interaxialDistance defines distance between each color axis
  54662. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  54663. * @param scene defines the hosting scene
  54664. */
  54665. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  54666. /**
  54667. * Gets camera class name
  54668. * @returns StereoscopicUniversalCamera
  54669. */
  54670. getClassName(): string;
  54671. }
  54672. }
  54673. declare module "babylonjs/Cameras/Stereoscopic/index" {
  54674. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  54675. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  54676. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  54677. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  54678. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  54679. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  54680. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  54681. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  54682. }
  54683. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  54684. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  54685. import { Scene } from "babylonjs/scene";
  54686. import { Vector3 } from "babylonjs/Maths/math.vector";
  54687. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  54688. /**
  54689. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  54690. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  54691. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  54692. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  54693. */
  54694. export class VirtualJoysticksCamera extends FreeCamera {
  54695. /**
  54696. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  54697. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  54698. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  54699. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  54700. * @param name Define the name of the camera in the scene
  54701. * @param position Define the start position of the camera in the scene
  54702. * @param scene Define the scene the camera belongs to
  54703. */
  54704. constructor(name: string, position: Vector3, scene: Scene);
  54705. /**
  54706. * Gets the current object class name.
  54707. * @return the class name
  54708. */
  54709. getClassName(): string;
  54710. }
  54711. }
  54712. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  54713. import { Matrix } from "babylonjs/Maths/math.vector";
  54714. /**
  54715. * This represents all the required metrics to create a VR camera.
  54716. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  54717. */
  54718. export class VRCameraMetrics {
  54719. /**
  54720. * Define the horizontal resolution off the screen.
  54721. */
  54722. hResolution: number;
  54723. /**
  54724. * Define the vertical resolution off the screen.
  54725. */
  54726. vResolution: number;
  54727. /**
  54728. * Define the horizontal screen size.
  54729. */
  54730. hScreenSize: number;
  54731. /**
  54732. * Define the vertical screen size.
  54733. */
  54734. vScreenSize: number;
  54735. /**
  54736. * Define the vertical screen center position.
  54737. */
  54738. vScreenCenter: number;
  54739. /**
  54740. * Define the distance of the eyes to the screen.
  54741. */
  54742. eyeToScreenDistance: number;
  54743. /**
  54744. * Define the distance between both lenses
  54745. */
  54746. lensSeparationDistance: number;
  54747. /**
  54748. * Define the distance between both viewer's eyes.
  54749. */
  54750. interpupillaryDistance: number;
  54751. /**
  54752. * Define the distortion factor of the VR postprocess.
  54753. * Please, touch with care.
  54754. */
  54755. distortionK: number[];
  54756. /**
  54757. * Define the chromatic aberration correction factors for the VR post process.
  54758. */
  54759. chromaAbCorrection: number[];
  54760. /**
  54761. * Define the scale factor of the post process.
  54762. * The smaller the better but the slower.
  54763. */
  54764. postProcessScaleFactor: number;
  54765. /**
  54766. * Define an offset for the lens center.
  54767. */
  54768. lensCenterOffset: number;
  54769. /**
  54770. * Define if the current vr camera should compensate the distortion of the lense or not.
  54771. */
  54772. compensateDistortion: boolean;
  54773. /**
  54774. * Defines if multiview should be enabled when rendering (Default: false)
  54775. */
  54776. multiviewEnabled: boolean;
  54777. /**
  54778. * Gets the rendering aspect ratio based on the provided resolutions.
  54779. */
  54780. get aspectRatio(): number;
  54781. /**
  54782. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  54783. */
  54784. get aspectRatioFov(): number;
  54785. /**
  54786. * @hidden
  54787. */
  54788. get leftHMatrix(): Matrix;
  54789. /**
  54790. * @hidden
  54791. */
  54792. get rightHMatrix(): Matrix;
  54793. /**
  54794. * @hidden
  54795. */
  54796. get leftPreViewMatrix(): Matrix;
  54797. /**
  54798. * @hidden
  54799. */
  54800. get rightPreViewMatrix(): Matrix;
  54801. /**
  54802. * Get the default VRMetrics based on the most generic setup.
  54803. * @returns the default vr metrics
  54804. */
  54805. static GetDefault(): VRCameraMetrics;
  54806. }
  54807. }
  54808. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  54809. /** @hidden */
  54810. export var vrDistortionCorrectionPixelShader: {
  54811. name: string;
  54812. shader: string;
  54813. };
  54814. }
  54815. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  54816. import { Camera } from "babylonjs/Cameras/camera";
  54817. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  54818. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54819. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  54820. /**
  54821. * VRDistortionCorrectionPostProcess used for mobile VR
  54822. */
  54823. export class VRDistortionCorrectionPostProcess extends PostProcess {
  54824. private _isRightEye;
  54825. private _distortionFactors;
  54826. private _postProcessScaleFactor;
  54827. private _lensCenterOffset;
  54828. private _scaleIn;
  54829. private _scaleFactor;
  54830. private _lensCenter;
  54831. /**
  54832. * Gets a string identifying the name of the class
  54833. * @returns "VRDistortionCorrectionPostProcess" string
  54834. */
  54835. getClassName(): string;
  54836. /**
  54837. * Initializes the VRDistortionCorrectionPostProcess
  54838. * @param name The name of the effect.
  54839. * @param camera The camera to apply the render pass to.
  54840. * @param isRightEye If this is for the right eye distortion
  54841. * @param vrMetrics All the required metrics for the VR camera
  54842. */
  54843. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  54844. }
  54845. }
  54846. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  54847. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  54848. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  54849. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  54850. import { Scene } from "babylonjs/scene";
  54851. import { Vector3 } from "babylonjs/Maths/math.vector";
  54852. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  54853. import "babylonjs/Cameras/RigModes/vrRigMode";
  54854. /**
  54855. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  54856. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  54857. */
  54858. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  54859. /**
  54860. * Creates a new VRDeviceOrientationArcRotateCamera
  54861. * @param name defines camera name
  54862. * @param alpha defines the camera rotation along the logitudinal axis
  54863. * @param beta defines the camera rotation along the latitudinal axis
  54864. * @param radius defines the camera distance from its target
  54865. * @param target defines the camera target
  54866. * @param scene defines the scene the camera belongs to
  54867. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  54868. * @param vrCameraMetrics defines the vr metrics associated to the camera
  54869. */
  54870. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  54871. /**
  54872. * Gets camera class name
  54873. * @returns VRDeviceOrientationArcRotateCamera
  54874. */
  54875. getClassName(): string;
  54876. }
  54877. }
  54878. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  54879. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  54880. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  54881. import { Scene } from "babylonjs/scene";
  54882. import { Vector3 } from "babylonjs/Maths/math.vector";
  54883. import "babylonjs/Cameras/RigModes/vrRigMode";
  54884. /**
  54885. * Camera used to simulate VR rendering (based on FreeCamera)
  54886. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  54887. */
  54888. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  54889. /**
  54890. * Creates a new VRDeviceOrientationFreeCamera
  54891. * @param name defines camera name
  54892. * @param position defines the start position of the camera
  54893. * @param scene defines the scene the camera belongs to
  54894. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  54895. * @param vrCameraMetrics defines the vr metrics associated to the camera
  54896. */
  54897. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  54898. /**
  54899. * Gets camera class name
  54900. * @returns VRDeviceOrientationFreeCamera
  54901. */
  54902. getClassName(): string;
  54903. }
  54904. }
  54905. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  54906. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  54907. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  54908. import { Scene } from "babylonjs/scene";
  54909. import { Vector3 } from "babylonjs/Maths/math.vector";
  54910. import "babylonjs/Gamepads/gamepadSceneComponent";
  54911. /**
  54912. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  54913. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  54914. */
  54915. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  54916. /**
  54917. * Creates a new VRDeviceOrientationGamepadCamera
  54918. * @param name defines camera name
  54919. * @param position defines the start position of the camera
  54920. * @param scene defines the scene the camera belongs to
  54921. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  54922. * @param vrCameraMetrics defines the vr metrics associated to the camera
  54923. */
  54924. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  54925. /**
  54926. * Gets camera class name
  54927. * @returns VRDeviceOrientationGamepadCamera
  54928. */
  54929. getClassName(): string;
  54930. }
  54931. }
  54932. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  54933. import { Scene } from "babylonjs/scene";
  54934. import { Texture } from "babylonjs/Materials/Textures/texture";
  54935. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  54936. /**
  54937. * A class extending Texture allowing drawing on a texture
  54938. * @see https://doc.babylonjs.com/how_to/dynamictexture
  54939. */
  54940. export class DynamicTexture extends Texture {
  54941. private _generateMipMaps;
  54942. private _canvas;
  54943. private _context;
  54944. /**
  54945. * Creates a DynamicTexture
  54946. * @param name defines the name of the texture
  54947. * @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
  54948. * @param scene defines the scene where you want the texture
  54949. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  54950. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54951. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  54952. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  54953. */
  54954. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  54955. /**
  54956. * Get the current class name of the texture useful for serialization or dynamic coding.
  54957. * @returns "DynamicTexture"
  54958. */
  54959. getClassName(): string;
  54960. /**
  54961. * Gets the current state of canRescale
  54962. */
  54963. get canRescale(): boolean;
  54964. private _recreate;
  54965. /**
  54966. * Scales the texture
  54967. * @param ratio the scale factor to apply to both width and height
  54968. */
  54969. scale(ratio: number): void;
  54970. /**
  54971. * Resizes the texture
  54972. * @param width the new width
  54973. * @param height the new height
  54974. */
  54975. scaleTo(width: number, height: number): void;
  54976. /**
  54977. * Gets the context of the canvas used by the texture
  54978. * @returns the canvas context of the dynamic texture
  54979. */
  54980. getContext(): CanvasRenderingContext2D;
  54981. /**
  54982. * Clears the texture
  54983. */
  54984. clear(): void;
  54985. /**
  54986. * Updates the texture
  54987. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  54988. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  54989. */
  54990. update(invertY?: boolean, premulAlpha?: boolean): void;
  54991. /**
  54992. * Draws text onto the texture
  54993. * @param text defines the text to be drawn
  54994. * @param x defines the placement of the text from the left
  54995. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  54996. * @param font defines the font to be used with font-style, font-size, font-name
  54997. * @param color defines the color used for the text
  54998. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  54999. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  55000. * @param update defines whether texture is immediately update (default is true)
  55001. */
  55002. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  55003. /**
  55004. * Clones the texture
  55005. * @returns the clone of the texture.
  55006. */
  55007. clone(): DynamicTexture;
  55008. /**
  55009. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  55010. * @returns a serialized dynamic texture object
  55011. */
  55012. serialize(): any;
  55013. private _IsCanvasElement;
  55014. /** @hidden */
  55015. _rebuild(): void;
  55016. }
  55017. }
  55018. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  55019. import { Scene } from "babylonjs/scene";
  55020. import { Color3 } from "babylonjs/Maths/math.color";
  55021. import { Mesh } from "babylonjs/Meshes/mesh";
  55022. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  55023. import { Nullable } from "babylonjs/types";
  55024. /**
  55025. * Class containing static functions to help procedurally build meshes
  55026. */
  55027. export class GroundBuilder {
  55028. /**
  55029. * Creates a ground mesh
  55030. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  55031. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  55032. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55033. * @param name defines the name of the mesh
  55034. * @param options defines the options used to create the mesh
  55035. * @param scene defines the hosting scene
  55036. * @returns the ground mesh
  55037. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  55038. */
  55039. static CreateGround(name: string, options: {
  55040. width?: number;
  55041. height?: number;
  55042. subdivisions?: number;
  55043. subdivisionsX?: number;
  55044. subdivisionsY?: number;
  55045. updatable?: boolean;
  55046. }, scene: any): Mesh;
  55047. /**
  55048. * Creates a tiled ground mesh
  55049. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  55050. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  55051. * * 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
  55052. * * 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
  55053. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55054. * @param name defines the name of the mesh
  55055. * @param options defines the options used to create the mesh
  55056. * @param scene defines the hosting scene
  55057. * @returns the tiled ground mesh
  55058. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  55059. */
  55060. static CreateTiledGround(name: string, options: {
  55061. xmin: number;
  55062. zmin: number;
  55063. xmax: number;
  55064. zmax: number;
  55065. subdivisions?: {
  55066. w: number;
  55067. h: number;
  55068. };
  55069. precision?: {
  55070. w: number;
  55071. h: number;
  55072. };
  55073. updatable?: boolean;
  55074. }, scene?: Nullable<Scene>): Mesh;
  55075. /**
  55076. * Creates a ground mesh from a height map
  55077. * * The parameter `url` sets the URL of the height map image resource.
  55078. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  55079. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  55080. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  55081. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  55082. * * 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.
  55083. * * 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).
  55084. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  55085. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55086. * @param name defines the name of the mesh
  55087. * @param url defines the url to the height map
  55088. * @param options defines the options used to create the mesh
  55089. * @param scene defines the hosting scene
  55090. * @returns the ground mesh
  55091. * @see https://doc.babylonjs.com/babylon101/height_map
  55092. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  55093. */
  55094. static CreateGroundFromHeightMap(name: string, url: string, options: {
  55095. width?: number;
  55096. height?: number;
  55097. subdivisions?: number;
  55098. minHeight?: number;
  55099. maxHeight?: number;
  55100. colorFilter?: Color3;
  55101. alphaFilter?: number;
  55102. updatable?: boolean;
  55103. onReady?: (mesh: GroundMesh) => void;
  55104. }, scene?: Nullable<Scene>): GroundMesh;
  55105. }
  55106. }
  55107. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  55108. import { Vector4 } from "babylonjs/Maths/math.vector";
  55109. import { Mesh } from "babylonjs/Meshes/mesh";
  55110. /**
  55111. * Class containing static functions to help procedurally build meshes
  55112. */
  55113. export class TorusBuilder {
  55114. /**
  55115. * Creates a torus mesh
  55116. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  55117. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  55118. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  55119. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55120. * * 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
  55121. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55122. * @param name defines the name of the mesh
  55123. * @param options defines the options used to create the mesh
  55124. * @param scene defines the hosting scene
  55125. * @returns the torus mesh
  55126. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  55127. */
  55128. static CreateTorus(name: string, options: {
  55129. diameter?: number;
  55130. thickness?: number;
  55131. tessellation?: number;
  55132. updatable?: boolean;
  55133. sideOrientation?: number;
  55134. frontUVs?: Vector4;
  55135. backUVs?: Vector4;
  55136. }, scene: any): Mesh;
  55137. }
  55138. }
  55139. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  55140. import { Vector4 } from "babylonjs/Maths/math.vector";
  55141. import { Color4 } from "babylonjs/Maths/math.color";
  55142. import { Mesh } from "babylonjs/Meshes/mesh";
  55143. /**
  55144. * Class containing static functions to help procedurally build meshes
  55145. */
  55146. export class CylinderBuilder {
  55147. /**
  55148. * Creates a cylinder or a cone mesh
  55149. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  55150. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  55151. * * 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.
  55152. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  55153. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  55154. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  55155. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  55156. * * 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).
  55157. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  55158. * * 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).
  55159. * * 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
  55160. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  55161. * * 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
  55162. * * 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.
  55163. * * If `enclose` is false, a ring surface is one element.
  55164. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  55165. * * 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
  55166. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55167. * * 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
  55168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55169. * @param name defines the name of the mesh
  55170. * @param options defines the options used to create the mesh
  55171. * @param scene defines the hosting scene
  55172. * @returns the cylinder mesh
  55173. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  55174. */
  55175. static CreateCylinder(name: string, options: {
  55176. height?: number;
  55177. diameterTop?: number;
  55178. diameterBottom?: number;
  55179. diameter?: number;
  55180. tessellation?: number;
  55181. subdivisions?: number;
  55182. arc?: number;
  55183. faceColors?: Color4[];
  55184. faceUV?: Vector4[];
  55185. updatable?: boolean;
  55186. hasRings?: boolean;
  55187. enclose?: boolean;
  55188. cap?: number;
  55189. sideOrientation?: number;
  55190. frontUVs?: Vector4;
  55191. backUVs?: Vector4;
  55192. }, scene: any): Mesh;
  55193. }
  55194. }
  55195. declare module "babylonjs/XR/webXRTypes" {
  55196. import { Nullable } from "babylonjs/types";
  55197. import { IDisposable } from "babylonjs/scene";
  55198. /**
  55199. * States of the webXR experience
  55200. */
  55201. export enum WebXRState {
  55202. /**
  55203. * Transitioning to being in XR mode
  55204. */
  55205. ENTERING_XR = 0,
  55206. /**
  55207. * Transitioning to non XR mode
  55208. */
  55209. EXITING_XR = 1,
  55210. /**
  55211. * In XR mode and presenting
  55212. */
  55213. IN_XR = 2,
  55214. /**
  55215. * Not entered XR mode
  55216. */
  55217. NOT_IN_XR = 3
  55218. }
  55219. /**
  55220. * The state of the XR camera's tracking
  55221. */
  55222. export enum WebXRTrackingState {
  55223. /**
  55224. * No transformation received, device is not being tracked
  55225. */
  55226. NOT_TRACKING = 0,
  55227. /**
  55228. * Tracking lost - using emulated position
  55229. */
  55230. TRACKING_LOST = 1,
  55231. /**
  55232. * Transformation tracking works normally
  55233. */
  55234. TRACKING = 2
  55235. }
  55236. /**
  55237. * Abstraction of the XR render target
  55238. */
  55239. export interface WebXRRenderTarget extends IDisposable {
  55240. /**
  55241. * xrpresent context of the canvas which can be used to display/mirror xr content
  55242. */
  55243. canvasContext: WebGLRenderingContext;
  55244. /**
  55245. * xr layer for the canvas
  55246. */
  55247. xrLayer: Nullable<XRWebGLLayer>;
  55248. /**
  55249. * Initializes the xr layer for the session
  55250. * @param xrSession xr session
  55251. * @returns a promise that will resolve once the XR Layer has been created
  55252. */
  55253. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  55254. }
  55255. }
  55256. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  55257. import { Nullable } from "babylonjs/types";
  55258. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  55259. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  55260. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  55261. import { Observable } from "babylonjs/Misc/observable";
  55262. /**
  55263. * COnfiguration object for WebXR output canvas
  55264. */
  55265. export class WebXRManagedOutputCanvasOptions {
  55266. /**
  55267. * An optional canvas in case you wish to create it yourself and provide it here.
  55268. * If not provided, a new canvas will be created
  55269. */
  55270. canvasElement?: HTMLCanvasElement;
  55271. /**
  55272. * Options for this XR Layer output
  55273. */
  55274. canvasOptions?: XRWebGLLayerInit;
  55275. /**
  55276. * CSS styling for a newly created canvas (if not provided)
  55277. */
  55278. newCanvasCssStyle?: string;
  55279. /**
  55280. * Get the default values of the configuration object
  55281. * @param engine defines the engine to use (can be null)
  55282. * @returns default values of this configuration object
  55283. */
  55284. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  55285. }
  55286. /**
  55287. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  55288. */
  55289. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  55290. private _options;
  55291. private _canvas;
  55292. private _engine;
  55293. private _originalCanvasSize;
  55294. /**
  55295. * Rendering context of the canvas which can be used to display/mirror xr content
  55296. */
  55297. canvasContext: WebGLRenderingContext;
  55298. /**
  55299. * xr layer for the canvas
  55300. */
  55301. xrLayer: Nullable<XRWebGLLayer>;
  55302. /**
  55303. * Obseervers registered here will be triggered when the xr layer was initialized
  55304. */
  55305. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  55306. /**
  55307. * Initializes the canvas to be added/removed upon entering/exiting xr
  55308. * @param _xrSessionManager The XR Session manager
  55309. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  55310. */
  55311. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  55312. /**
  55313. * Disposes of the object
  55314. */
  55315. dispose(): void;
  55316. /**
  55317. * Initializes the xr layer for the session
  55318. * @param xrSession xr session
  55319. * @returns a promise that will resolve once the XR Layer has been created
  55320. */
  55321. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  55322. private _addCanvas;
  55323. private _removeCanvas;
  55324. private _setCanvasSize;
  55325. private _setManagedOutputCanvas;
  55326. }
  55327. }
  55328. declare module "babylonjs/XR/webXRSessionManager" {
  55329. import { Observable } from "babylonjs/Misc/observable";
  55330. import { Nullable } from "babylonjs/types";
  55331. import { IDisposable, Scene } from "babylonjs/scene";
  55332. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55333. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  55334. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  55335. /**
  55336. * Manages an XRSession to work with Babylon's engine
  55337. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  55338. */
  55339. export class WebXRSessionManager implements IDisposable {
  55340. /** The scene which the session should be created for */
  55341. scene: Scene;
  55342. private _referenceSpace;
  55343. private _rttProvider;
  55344. private _sessionEnded;
  55345. private _xrNavigator;
  55346. private baseLayer;
  55347. /**
  55348. * The base reference space from which the session started. good if you want to reset your
  55349. * reference space
  55350. */
  55351. baseReferenceSpace: XRReferenceSpace;
  55352. /**
  55353. * Current XR frame
  55354. */
  55355. currentFrame: Nullable<XRFrame>;
  55356. /** WebXR timestamp updated every frame */
  55357. currentTimestamp: number;
  55358. /**
  55359. * Used just in case of a failure to initialize an immersive session.
  55360. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  55361. */
  55362. defaultHeightCompensation: number;
  55363. /**
  55364. * Fires every time a new xrFrame arrives which can be used to update the camera
  55365. */
  55366. onXRFrameObservable: Observable<XRFrame>;
  55367. /**
  55368. * Fires when the reference space changed
  55369. */
  55370. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  55371. /**
  55372. * Fires when the xr session is ended either by the device or manually done
  55373. */
  55374. onXRSessionEnded: Observable<any>;
  55375. /**
  55376. * Fires when the xr session is ended either by the device or manually done
  55377. */
  55378. onXRSessionInit: Observable<XRSession>;
  55379. /**
  55380. * Underlying xr session
  55381. */
  55382. session: XRSession;
  55383. /**
  55384. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  55385. * or get the offset the player is currently at.
  55386. */
  55387. viewerReferenceSpace: XRReferenceSpace;
  55388. /**
  55389. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  55390. * @param scene The scene which the session should be created for
  55391. */
  55392. constructor(
  55393. /** The scene which the session should be created for */
  55394. scene: Scene);
  55395. /**
  55396. * The current reference space used in this session. This reference space can constantly change!
  55397. * It is mainly used to offset the camera's position.
  55398. */
  55399. get referenceSpace(): XRReferenceSpace;
  55400. /**
  55401. * Set a new reference space and triggers the observable
  55402. */
  55403. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  55404. /**
  55405. * Disposes of the session manager
  55406. */
  55407. dispose(): void;
  55408. /**
  55409. * Stops the xrSession and restores the render loop
  55410. * @returns Promise which resolves after it exits XR
  55411. */
  55412. exitXRAsync(): Promise<void>;
  55413. /**
  55414. * Gets the correct render target texture to be rendered this frame for this eye
  55415. * @param eye the eye for which to get the render target
  55416. * @returns the render target for the specified eye
  55417. */
  55418. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  55419. /**
  55420. * Creates a WebXRRenderTarget object for the XR session
  55421. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  55422. * @param options optional options to provide when creating a new render target
  55423. * @returns a WebXR render target to which the session can render
  55424. */
  55425. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  55426. /**
  55427. * Initializes the manager
  55428. * After initialization enterXR can be called to start an XR session
  55429. * @returns Promise which resolves after it is initialized
  55430. */
  55431. initializeAsync(): Promise<void>;
  55432. /**
  55433. * Initializes an xr session
  55434. * @param xrSessionMode mode to initialize
  55435. * @param xrSessionInit defines optional and required values to pass to the session builder
  55436. * @returns a promise which will resolve once the session has been initialized
  55437. */
  55438. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  55439. /**
  55440. * Checks if a session would be supported for the creation options specified
  55441. * @param sessionMode session mode to check if supported eg. immersive-vr
  55442. * @returns A Promise that resolves to true if supported and false if not
  55443. */
  55444. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  55445. /**
  55446. * Resets the reference space to the one started the session
  55447. */
  55448. resetReferenceSpace(): void;
  55449. /**
  55450. * Starts rendering to the xr layer
  55451. */
  55452. runXRRenderLoop(): void;
  55453. /**
  55454. * Sets the reference space on the xr session
  55455. * @param referenceSpaceType space to set
  55456. * @returns a promise that will resolve once the reference space has been set
  55457. */
  55458. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  55459. /**
  55460. * Updates the render state of the session
  55461. * @param state state to set
  55462. * @returns a promise that resolves once the render state has been updated
  55463. */
  55464. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  55465. /**
  55466. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  55467. * @param sessionMode defines the session to test
  55468. * @returns a promise with boolean as final value
  55469. */
  55470. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  55471. /**
  55472. * Returns true if Babylon.js is using the BabylonNative backend, otherwise false
  55473. */
  55474. get isNative(): boolean;
  55475. private _createRenderTargetTexture;
  55476. }
  55477. }
  55478. declare module "babylonjs/XR/webXRCamera" {
  55479. import { Vector3 } from "babylonjs/Maths/math.vector";
  55480. import { Scene } from "babylonjs/scene";
  55481. import { Camera } from "babylonjs/Cameras/camera";
  55482. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  55483. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  55484. import { Observable } from "babylonjs/Misc/observable";
  55485. import { WebXRTrackingState } from "babylonjs/XR/webXRTypes";
  55486. /**
  55487. * WebXR Camera which holds the views for the xrSession
  55488. * @see https://doc.babylonjs.com/how_to/webxr_camera
  55489. */
  55490. export class WebXRCamera extends FreeCamera {
  55491. private _xrSessionManager;
  55492. private _firstFrame;
  55493. private _referenceQuaternion;
  55494. private _referencedPosition;
  55495. private _xrInvPositionCache;
  55496. private _xrInvQuaternionCache;
  55497. private _trackingState;
  55498. /**
  55499. * Observable raised before camera teleportation
  55500. */
  55501. onBeforeCameraTeleport: Observable<Vector3>;
  55502. /**
  55503. * Observable raised after camera teleportation
  55504. */
  55505. onAfterCameraTeleport: Observable<Vector3>;
  55506. /**
  55507. * Notifies when the camera's tracking state has changed.
  55508. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  55509. */
  55510. onTrackingStateChanged: Observable<WebXRTrackingState>;
  55511. /**
  55512. * Should position compensation execute on first frame.
  55513. * This is used when copying the position from a native (non XR) camera
  55514. */
  55515. compensateOnFirstFrame: boolean;
  55516. /**
  55517. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  55518. * @param name the name of the camera
  55519. * @param scene the scene to add the camera to
  55520. * @param _xrSessionManager a constructed xr session manager
  55521. */
  55522. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  55523. /**
  55524. * Get the current XR tracking state of the camera
  55525. */
  55526. get trackingState(): WebXRTrackingState;
  55527. private _setTrackingState;
  55528. /**
  55529. * Return the user's height, unrelated to the current ground.
  55530. * This will be the y position of this camera, when ground level is 0.
  55531. */
  55532. get realWorldHeight(): number;
  55533. /** @hidden */
  55534. _updateForDualEyeDebugging(): void;
  55535. /**
  55536. * Sets this camera's transformation based on a non-vr camera
  55537. * @param otherCamera the non-vr camera to copy the transformation from
  55538. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  55539. */
  55540. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  55541. /**
  55542. * Gets the current instance class name ("WebXRCamera").
  55543. * @returns the class name
  55544. */
  55545. getClassName(): string;
  55546. private _rotate180;
  55547. private _updateFromXRSession;
  55548. private _updateNumberOfRigCameras;
  55549. private _updateReferenceSpace;
  55550. private _updateReferenceSpaceOffset;
  55551. }
  55552. }
  55553. declare module "babylonjs/XR/webXRFeaturesManager" {
  55554. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  55555. import { IDisposable } from "babylonjs/scene";
  55556. /**
  55557. * Defining the interface required for a (webxr) feature
  55558. */
  55559. export interface IWebXRFeature extends IDisposable {
  55560. /**
  55561. * Is this feature attached
  55562. */
  55563. attached: boolean;
  55564. /**
  55565. * Should auto-attach be disabled?
  55566. */
  55567. disableAutoAttach: boolean;
  55568. /**
  55569. * Attach the feature to the session
  55570. * Will usually be called by the features manager
  55571. *
  55572. * @param force should attachment be forced (even when already attached)
  55573. * @returns true if successful.
  55574. */
  55575. attach(force?: boolean): boolean;
  55576. /**
  55577. * Detach the feature from the session
  55578. * Will usually be called by the features manager
  55579. *
  55580. * @returns true if successful.
  55581. */
  55582. detach(): boolean;
  55583. /**
  55584. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  55585. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  55586. *
  55587. * @returns whether or not the feature is compatible in this environment
  55588. */
  55589. isCompatible(): boolean;
  55590. /**
  55591. * Was this feature disposed;
  55592. */
  55593. isDisposed: boolean;
  55594. /**
  55595. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  55596. */
  55597. xrNativeFeatureName?: string;
  55598. /**
  55599. * A list of (Babylon WebXR) features this feature depends on
  55600. */
  55601. dependsOn?: string[];
  55602. }
  55603. /**
  55604. * A list of the currently available features without referencing them
  55605. */
  55606. export class WebXRFeatureName {
  55607. /**
  55608. * The name of the anchor system feature
  55609. */
  55610. static readonly ANCHOR_SYSTEM: string;
  55611. /**
  55612. * The name of the background remover feature
  55613. */
  55614. static readonly BACKGROUND_REMOVER: string;
  55615. /**
  55616. * The name of the hit test feature
  55617. */
  55618. static readonly HIT_TEST: string;
  55619. /**
  55620. * The name of the mesh detection feature
  55621. */
  55622. static readonly MESH_DETECTION: string;
  55623. /**
  55624. * physics impostors for xr controllers feature
  55625. */
  55626. static readonly PHYSICS_CONTROLLERS: string;
  55627. /**
  55628. * The name of the plane detection feature
  55629. */
  55630. static readonly PLANE_DETECTION: string;
  55631. /**
  55632. * The name of the pointer selection feature
  55633. */
  55634. static readonly POINTER_SELECTION: string;
  55635. /**
  55636. * The name of the teleportation feature
  55637. */
  55638. static readonly TELEPORTATION: string;
  55639. /**
  55640. * The name of the feature points feature.
  55641. */
  55642. static readonly FEATURE_POINTS: string;
  55643. /**
  55644. * The name of the hand tracking feature.
  55645. */
  55646. static readonly HAND_TRACKING: string;
  55647. }
  55648. /**
  55649. * Defining the constructor of a feature. Used to register the modules.
  55650. */
  55651. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  55652. /**
  55653. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  55654. * It is mainly used in AR sessions.
  55655. *
  55656. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  55657. */
  55658. export class WebXRFeaturesManager implements IDisposable {
  55659. private _xrSessionManager;
  55660. private static readonly _AvailableFeatures;
  55661. private _features;
  55662. /**
  55663. * constructs a new features manages.
  55664. *
  55665. * @param _xrSessionManager an instance of WebXRSessionManager
  55666. */
  55667. constructor(_xrSessionManager: WebXRSessionManager);
  55668. /**
  55669. * Used to register a module. After calling this function a developer can use this feature in the scene.
  55670. * Mainly used internally.
  55671. *
  55672. * @param featureName the name of the feature to register
  55673. * @param constructorFunction the function used to construct the module
  55674. * @param version the (babylon) version of the module
  55675. * @param stable is that a stable version of this module
  55676. */
  55677. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  55678. /**
  55679. * Returns a constructor of a specific feature.
  55680. *
  55681. * @param featureName the name of the feature to construct
  55682. * @param version the version of the feature to load
  55683. * @param xrSessionManager the xrSessionManager. Used to construct the module
  55684. * @param options optional options provided to the module.
  55685. * @returns a function that, when called, will return a new instance of this feature
  55686. */
  55687. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  55688. /**
  55689. * Can be used to return the list of features currently registered
  55690. *
  55691. * @returns an Array of available features
  55692. */
  55693. static GetAvailableFeatures(): string[];
  55694. /**
  55695. * Gets the versions available for a specific feature
  55696. * @param featureName the name of the feature
  55697. * @returns an array with the available versions
  55698. */
  55699. static GetAvailableVersions(featureName: string): string[];
  55700. /**
  55701. * Return the latest unstable version of this feature
  55702. * @param featureName the name of the feature to search
  55703. * @returns the version number. if not found will return -1
  55704. */
  55705. static GetLatestVersionOfFeature(featureName: string): number;
  55706. /**
  55707. * Return the latest stable version of this feature
  55708. * @param featureName the name of the feature to search
  55709. * @returns the version number. if not found will return -1
  55710. */
  55711. static GetStableVersionOfFeature(featureName: string): number;
  55712. /**
  55713. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  55714. * Can be used during a session to start a feature
  55715. * @param featureName the name of feature to attach
  55716. */
  55717. attachFeature(featureName: string): void;
  55718. /**
  55719. * Can be used inside a session or when the session ends to detach a specific feature
  55720. * @param featureName the name of the feature to detach
  55721. */
  55722. detachFeature(featureName: string): void;
  55723. /**
  55724. * Used to disable an already-enabled feature
  55725. * The feature will be disposed and will be recreated once enabled.
  55726. * @param featureName the feature to disable
  55727. * @returns true if disable was successful
  55728. */
  55729. disableFeature(featureName: string | {
  55730. Name: string;
  55731. }): boolean;
  55732. /**
  55733. * dispose this features manager
  55734. */
  55735. dispose(): void;
  55736. /**
  55737. * 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.
  55738. * 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.
  55739. *
  55740. * @param featureName the name of the feature to load or the class of the feature
  55741. * @param version optional version to load. if not provided the latest version will be enabled
  55742. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  55743. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  55744. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  55745. * @returns a new constructed feature or throws an error if feature not found.
  55746. */
  55747. enableFeature(featureName: string | {
  55748. Name: string;
  55749. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  55750. /**
  55751. * get the implementation of an enabled feature.
  55752. * @param featureName the name of the feature to load
  55753. * @returns the feature class, if found
  55754. */
  55755. getEnabledFeature(featureName: string): IWebXRFeature;
  55756. /**
  55757. * Get the list of enabled features
  55758. * @returns an array of enabled features
  55759. */
  55760. getEnabledFeatures(): string[];
  55761. /**
  55762. * This function will exten the session creation configuration object with enabled features.
  55763. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  55764. * according to the defined "required" variable, provided during enableFeature call
  55765. * @param xrSessionInit the xr Session init object to extend
  55766. *
  55767. * @returns an extended XRSessionInit object
  55768. */
  55769. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  55770. }
  55771. }
  55772. declare module "babylonjs/XR/webXRExperienceHelper" {
  55773. import { Observable } from "babylonjs/Misc/observable";
  55774. import { IDisposable, Scene } from "babylonjs/scene";
  55775. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  55776. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  55777. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  55778. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  55779. /**
  55780. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  55781. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  55782. */
  55783. export class WebXRExperienceHelper implements IDisposable {
  55784. private scene;
  55785. private _nonVRCamera;
  55786. private _originalSceneAutoClear;
  55787. private _supported;
  55788. /**
  55789. * Camera used to render xr content
  55790. */
  55791. camera: WebXRCamera;
  55792. /** A features manager for this xr session */
  55793. featuresManager: WebXRFeaturesManager;
  55794. /**
  55795. * Observers registered here will be triggered after the camera's initial transformation is set
  55796. * This can be used to set a different ground level or an extra rotation.
  55797. *
  55798. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  55799. * to the position set after this observable is done executing.
  55800. */
  55801. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  55802. /**
  55803. * Fires when the state of the experience helper has changed
  55804. */
  55805. onStateChangedObservable: Observable<WebXRState>;
  55806. /** Session manager used to keep track of xr session */
  55807. sessionManager: WebXRSessionManager;
  55808. /**
  55809. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  55810. */
  55811. state: WebXRState;
  55812. /**
  55813. * Creates a WebXRExperienceHelper
  55814. * @param scene The scene the helper should be created in
  55815. */
  55816. private constructor();
  55817. /**
  55818. * Creates the experience helper
  55819. * @param scene the scene to attach the experience helper to
  55820. * @returns a promise for the experience helper
  55821. */
  55822. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  55823. /**
  55824. * Disposes of the experience helper
  55825. */
  55826. dispose(): void;
  55827. /**
  55828. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  55829. * @param sessionMode options for the XR session
  55830. * @param referenceSpaceType frame of reference of the XR session
  55831. * @param renderTarget the output canvas that will be used to enter XR mode
  55832. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  55833. * @returns promise that resolves after xr mode has entered
  55834. */
  55835. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  55836. /**
  55837. * Exits XR mode and returns the scene to its original state
  55838. * @returns promise that resolves after xr mode has exited
  55839. */
  55840. exitXRAsync(): Promise<void>;
  55841. private _nonXRToXRCamera;
  55842. private _setState;
  55843. }
  55844. }
  55845. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  55846. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  55847. import { Observable } from "babylonjs/Misc/observable";
  55848. import { IDisposable } from "babylonjs/scene";
  55849. /**
  55850. * X-Y values for axes in WebXR
  55851. */
  55852. export interface IWebXRMotionControllerAxesValue {
  55853. /**
  55854. * The value of the x axis
  55855. */
  55856. x: number;
  55857. /**
  55858. * The value of the y-axis
  55859. */
  55860. y: number;
  55861. }
  55862. /**
  55863. * changed / previous values for the values of this component
  55864. */
  55865. export interface IWebXRMotionControllerComponentChangesValues<T> {
  55866. /**
  55867. * current (this frame) value
  55868. */
  55869. current: T;
  55870. /**
  55871. * previous (last change) value
  55872. */
  55873. previous: T;
  55874. }
  55875. /**
  55876. * Represents changes in the component between current frame and last values recorded
  55877. */
  55878. export interface IWebXRMotionControllerComponentChanges {
  55879. /**
  55880. * will be populated with previous and current values if axes changed
  55881. */
  55882. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  55883. /**
  55884. * will be populated with previous and current values if pressed changed
  55885. */
  55886. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  55887. /**
  55888. * will be populated with previous and current values if touched changed
  55889. */
  55890. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  55891. /**
  55892. * will be populated with previous and current values if value changed
  55893. */
  55894. value?: IWebXRMotionControllerComponentChangesValues<number>;
  55895. }
  55896. /**
  55897. * This class represents a single component (for example button or thumbstick) of a motion controller
  55898. */
  55899. export class WebXRControllerComponent implements IDisposable {
  55900. /**
  55901. * the id of this component
  55902. */
  55903. id: string;
  55904. /**
  55905. * the type of the component
  55906. */
  55907. type: MotionControllerComponentType;
  55908. private _buttonIndex;
  55909. private _axesIndices;
  55910. private _axes;
  55911. private _changes;
  55912. private _currentValue;
  55913. private _hasChanges;
  55914. private _pressed;
  55915. private _touched;
  55916. /**
  55917. * button component type
  55918. */
  55919. static BUTTON_TYPE: MotionControllerComponentType;
  55920. /**
  55921. * squeeze component type
  55922. */
  55923. static SQUEEZE_TYPE: MotionControllerComponentType;
  55924. /**
  55925. * Thumbstick component type
  55926. */
  55927. static THUMBSTICK_TYPE: MotionControllerComponentType;
  55928. /**
  55929. * Touchpad component type
  55930. */
  55931. static TOUCHPAD_TYPE: MotionControllerComponentType;
  55932. /**
  55933. * trigger component type
  55934. */
  55935. static TRIGGER_TYPE: MotionControllerComponentType;
  55936. /**
  55937. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  55938. * the axes data changes
  55939. */
  55940. onAxisValueChangedObservable: Observable<{
  55941. x: number;
  55942. y: number;
  55943. }>;
  55944. /**
  55945. * Observers registered here will be triggered when the state of a button changes
  55946. * State change is either pressed / touched / value
  55947. */
  55948. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  55949. /**
  55950. * Creates a new component for a motion controller.
  55951. * It is created by the motion controller itself
  55952. *
  55953. * @param id the id of this component
  55954. * @param type the type of the component
  55955. * @param _buttonIndex index in the buttons array of the gamepad
  55956. * @param _axesIndices indices of the values in the axes array of the gamepad
  55957. */
  55958. constructor(
  55959. /**
  55960. * the id of this component
  55961. */
  55962. id: string,
  55963. /**
  55964. * the type of the component
  55965. */
  55966. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  55967. /**
  55968. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  55969. */
  55970. get axes(): IWebXRMotionControllerAxesValue;
  55971. /**
  55972. * Get the changes. Elements will be populated only if they changed with their previous and current value
  55973. */
  55974. get changes(): IWebXRMotionControllerComponentChanges;
  55975. /**
  55976. * Return whether or not the component changed the last frame
  55977. */
  55978. get hasChanges(): boolean;
  55979. /**
  55980. * is the button currently pressed
  55981. */
  55982. get pressed(): boolean;
  55983. /**
  55984. * is the button currently touched
  55985. */
  55986. get touched(): boolean;
  55987. /**
  55988. * Get the current value of this component
  55989. */
  55990. get value(): number;
  55991. /**
  55992. * Dispose this component
  55993. */
  55994. dispose(): void;
  55995. /**
  55996. * Are there axes correlating to this component
  55997. * @return true is axes data is available
  55998. */
  55999. isAxes(): boolean;
  56000. /**
  56001. * Is this component a button (hence - pressable)
  56002. * @returns true if can be pressed
  56003. */
  56004. isButton(): boolean;
  56005. /**
  56006. * update this component using the gamepad object it is in. Called on every frame
  56007. * @param nativeController the native gamepad controller object
  56008. */
  56009. update(nativeController: IMinimalMotionControllerObject): void;
  56010. }
  56011. }
  56012. declare module "babylonjs/Loading/sceneLoader" {
  56013. import { Observable } from "babylonjs/Misc/observable";
  56014. import { Nullable } from "babylonjs/types";
  56015. import { Scene } from "babylonjs/scene";
  56016. import { Engine } from "babylonjs/Engines/engine";
  56017. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56018. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  56019. import { AssetContainer } from "babylonjs/assetContainer";
  56020. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56021. import { Skeleton } from "babylonjs/Bones/skeleton";
  56022. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  56023. import { WebRequest } from "babylonjs/Misc/webRequest";
  56024. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56025. import { Geometry } from "babylonjs/Meshes/geometry";
  56026. import { Light } from "babylonjs/Lights/light";
  56027. /**
  56028. * Type used for the success callback of ImportMesh
  56029. */
  56030. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  56031. /**
  56032. * Interface used for the result of ImportMeshAsync
  56033. */
  56034. export interface ISceneLoaderAsyncResult {
  56035. /**
  56036. * The array of loaded meshes
  56037. */
  56038. readonly meshes: AbstractMesh[];
  56039. /**
  56040. * The array of loaded particle systems
  56041. */
  56042. readonly particleSystems: IParticleSystem[];
  56043. /**
  56044. * The array of loaded skeletons
  56045. */
  56046. readonly skeletons: Skeleton[];
  56047. /**
  56048. * The array of loaded animation groups
  56049. */
  56050. readonly animationGroups: AnimationGroup[];
  56051. /**
  56052. * The array of loaded transform nodes
  56053. */
  56054. readonly transformNodes: TransformNode[];
  56055. /**
  56056. * The array of loaded geometries
  56057. */
  56058. readonly geometries: Geometry[];
  56059. /**
  56060. * The array of loaded lights
  56061. */
  56062. readonly lights: Light[];
  56063. }
  56064. /**
  56065. * Interface used to represent data loading progression
  56066. */
  56067. export interface ISceneLoaderProgressEvent {
  56068. /**
  56069. * Defines if data length to load can be evaluated
  56070. */
  56071. readonly lengthComputable: boolean;
  56072. /**
  56073. * Defines the loaded data length
  56074. */
  56075. readonly loaded: number;
  56076. /**
  56077. * Defines the data length to load
  56078. */
  56079. readonly total: number;
  56080. }
  56081. /**
  56082. * Interface used by SceneLoader plugins to define supported file extensions
  56083. */
  56084. export interface ISceneLoaderPluginExtensions {
  56085. /**
  56086. * Defines the list of supported extensions
  56087. */
  56088. [extension: string]: {
  56089. isBinary: boolean;
  56090. };
  56091. }
  56092. /**
  56093. * Interface used by SceneLoader plugin factory
  56094. */
  56095. export interface ISceneLoaderPluginFactory {
  56096. /**
  56097. * Defines the name of the factory
  56098. */
  56099. name: string;
  56100. /**
  56101. * Function called to create a new plugin
  56102. * @return the new plugin
  56103. */
  56104. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  56105. /**
  56106. * The callback that returns true if the data can be directly loaded.
  56107. * @param data string containing the file data
  56108. * @returns if the data can be loaded directly
  56109. */
  56110. canDirectLoad?(data: string): boolean;
  56111. }
  56112. /**
  56113. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  56114. */
  56115. export interface ISceneLoaderPluginBase {
  56116. /**
  56117. * The friendly name of this plugin.
  56118. */
  56119. name: string;
  56120. /**
  56121. * The file extensions supported by this plugin.
  56122. */
  56123. extensions: string | ISceneLoaderPluginExtensions;
  56124. /**
  56125. * The callback called when loading from a url.
  56126. * @param scene scene loading this url
  56127. * @param url url to load
  56128. * @param onSuccess callback called when the file successfully loads
  56129. * @param onProgress callback called while file is loading (if the server supports this mode)
  56130. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  56131. * @param onError callback called when the file fails to load
  56132. * @returns a file request object
  56133. */
  56134. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  56135. /**
  56136. * The callback called when loading from a file object.
  56137. * @param scene scene loading this file
  56138. * @param file defines the file to load
  56139. * @param onSuccess defines the callback to call when data is loaded
  56140. * @param onProgress defines the callback to call during loading process
  56141. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  56142. * @param onError defines the callback to call when an error occurs
  56143. * @returns a file request object
  56144. */
  56145. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  56146. /**
  56147. * The callback that returns true if the data can be directly loaded.
  56148. * @param data string containing the file data
  56149. * @returns if the data can be loaded directly
  56150. */
  56151. canDirectLoad?(data: string): boolean;
  56152. /**
  56153. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  56154. * @param scene scene loading this data
  56155. * @param data string containing the data
  56156. * @returns data to pass to the plugin
  56157. */
  56158. directLoad?(scene: Scene, data: string): any;
  56159. /**
  56160. * The callback that allows custom handling of the root url based on the response url.
  56161. * @param rootUrl the original root url
  56162. * @param responseURL the response url if available
  56163. * @returns the new root url
  56164. */
  56165. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  56166. }
  56167. /**
  56168. * Interface used to define a SceneLoader plugin
  56169. */
  56170. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  56171. /**
  56172. * Import meshes into a scene.
  56173. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  56174. * @param scene The scene to import into
  56175. * @param data The data to import
  56176. * @param rootUrl The root url for scene and resources
  56177. * @param meshes The meshes array to import into
  56178. * @param particleSystems The particle systems array to import into
  56179. * @param skeletons The skeletons array to import into
  56180. * @param onError The callback when import fails
  56181. * @returns True if successful or false otherwise
  56182. */
  56183. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  56184. /**
  56185. * Load into a scene.
  56186. * @param scene The scene to load into
  56187. * @param data The data to import
  56188. * @param rootUrl The root url for scene and resources
  56189. * @param onError The callback when import fails
  56190. * @returns True if successful or false otherwise
  56191. */
  56192. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  56193. /**
  56194. * Load into an asset container.
  56195. * @param scene The scene to load into
  56196. * @param data The data to import
  56197. * @param rootUrl The root url for scene and resources
  56198. * @param onError The callback when import fails
  56199. * @returns The loaded asset container
  56200. */
  56201. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  56202. }
  56203. /**
  56204. * Interface used to define an async SceneLoader plugin
  56205. */
  56206. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  56207. /**
  56208. * Import meshes into a scene.
  56209. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  56210. * @param scene The scene to import into
  56211. * @param data The data to import
  56212. * @param rootUrl The root url for scene and resources
  56213. * @param onProgress The callback when the load progresses
  56214. * @param fileName Defines the name of the file to load
  56215. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  56216. */
  56217. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  56218. /**
  56219. * Load into a scene.
  56220. * @param scene The scene to load into
  56221. * @param data The data to import
  56222. * @param rootUrl The root url for scene and resources
  56223. * @param onProgress The callback when the load progresses
  56224. * @param fileName Defines the name of the file to load
  56225. * @returns Nothing
  56226. */
  56227. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  56228. /**
  56229. * Load into an asset container.
  56230. * @param scene The scene to load into
  56231. * @param data The data to import
  56232. * @param rootUrl The root url for scene and resources
  56233. * @param onProgress The callback when the load progresses
  56234. * @param fileName Defines the name of the file to load
  56235. * @returns The loaded asset container
  56236. */
  56237. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  56238. }
  56239. /**
  56240. * Mode that determines how to handle old animation groups before loading new ones.
  56241. */
  56242. export enum SceneLoaderAnimationGroupLoadingMode {
  56243. /**
  56244. * Reset all old animations to initial state then dispose them.
  56245. */
  56246. Clean = 0,
  56247. /**
  56248. * Stop all old animations.
  56249. */
  56250. Stop = 1,
  56251. /**
  56252. * Restart old animations from first frame.
  56253. */
  56254. Sync = 2,
  56255. /**
  56256. * Old animations remains untouched.
  56257. */
  56258. NoSync = 3
  56259. }
  56260. /**
  56261. * Defines a plugin registered by the SceneLoader
  56262. */
  56263. interface IRegisteredPlugin {
  56264. /**
  56265. * Defines the plugin to use
  56266. */
  56267. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  56268. /**
  56269. * Defines if the plugin supports binary data
  56270. */
  56271. isBinary: boolean;
  56272. }
  56273. /**
  56274. * Class used to load scene from various file formats using registered plugins
  56275. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  56276. */
  56277. export class SceneLoader {
  56278. /**
  56279. * No logging while loading
  56280. */
  56281. static readonly NO_LOGGING: number;
  56282. /**
  56283. * Minimal logging while loading
  56284. */
  56285. static readonly MINIMAL_LOGGING: number;
  56286. /**
  56287. * Summary logging while loading
  56288. */
  56289. static readonly SUMMARY_LOGGING: number;
  56290. /**
  56291. * Detailled logging while loading
  56292. */
  56293. static readonly DETAILED_LOGGING: number;
  56294. /**
  56295. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  56296. */
  56297. static get ForceFullSceneLoadingForIncremental(): boolean;
  56298. static set ForceFullSceneLoadingForIncremental(value: boolean);
  56299. /**
  56300. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  56301. */
  56302. static get ShowLoadingScreen(): boolean;
  56303. static set ShowLoadingScreen(value: boolean);
  56304. /**
  56305. * Defines the current logging level (while loading the scene)
  56306. * @ignorenaming
  56307. */
  56308. static get loggingLevel(): number;
  56309. static set loggingLevel(value: number);
  56310. /**
  56311. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  56312. */
  56313. static get CleanBoneMatrixWeights(): boolean;
  56314. static set CleanBoneMatrixWeights(value: boolean);
  56315. /**
  56316. * Event raised when a plugin is used to load a scene
  56317. */
  56318. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  56319. private static _registeredPlugins;
  56320. private static _showingLoadingScreen;
  56321. /**
  56322. * Gets the default plugin (used to load Babylon files)
  56323. * @returns the .babylon plugin
  56324. */
  56325. static GetDefaultPlugin(): IRegisteredPlugin;
  56326. private static _GetPluginForExtension;
  56327. private static _GetPluginForDirectLoad;
  56328. private static _GetPluginForFilename;
  56329. private static _GetDirectLoad;
  56330. private static _LoadData;
  56331. private static _GetFileInfo;
  56332. /**
  56333. * Gets a plugin that can load the given extension
  56334. * @param extension defines the extension to load
  56335. * @returns a plugin or null if none works
  56336. */
  56337. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  56338. /**
  56339. * Gets a boolean indicating that the given extension can be loaded
  56340. * @param extension defines the extension to load
  56341. * @returns true if the extension is supported
  56342. */
  56343. static IsPluginForExtensionAvailable(extension: string): boolean;
  56344. /**
  56345. * Adds a new plugin to the list of registered plugins
  56346. * @param plugin defines the plugin to add
  56347. */
  56348. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  56349. /**
  56350. * Import meshes into a scene
  56351. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  56352. * @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)
  56353. * @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)
  56354. * @param scene the instance of BABYLON.Scene to append to
  56355. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  56356. * @param onProgress a callback with a progress event for each file being loaded
  56357. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  56358. * @param pluginExtension the extension used to determine the plugin
  56359. * @returns The loaded plugin
  56360. */
  56361. 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>;
  56362. /**
  56363. * Import meshes into a scene
  56364. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  56365. * @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)
  56366. * @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)
  56367. * @param scene the instance of BABYLON.Scene to append to
  56368. * @param onProgress a callback with a progress event for each file being loaded
  56369. * @param pluginExtension the extension used to determine the plugin
  56370. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  56371. */
  56372. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  56373. /**
  56374. * Load a scene
  56375. * @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)
  56376. * @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)
  56377. * @param engine is the instance of BABYLON.Engine to use to create the scene
  56378. * @param onSuccess a callback with the scene when import succeeds
  56379. * @param onProgress a callback with a progress event for each file being loaded
  56380. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  56381. * @param pluginExtension the extension used to determine the plugin
  56382. * @returns The loaded plugin
  56383. */
  56384. 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>;
  56385. /**
  56386. * Load a scene
  56387. * @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)
  56388. * @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)
  56389. * @param engine is the instance of BABYLON.Engine to use to create the scene
  56390. * @param onProgress a callback with a progress event for each file being loaded
  56391. * @param pluginExtension the extension used to determine the plugin
  56392. * @returns The loaded scene
  56393. */
  56394. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  56395. /**
  56396. * Append a scene
  56397. * @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)
  56398. * @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)
  56399. * @param scene is the instance of BABYLON.Scene to append to
  56400. * @param onSuccess a callback with the scene when import succeeds
  56401. * @param onProgress a callback with a progress event for each file being loaded
  56402. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  56403. * @param pluginExtension the extension used to determine the plugin
  56404. * @returns The loaded plugin
  56405. */
  56406. 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>;
  56407. /**
  56408. * Append a scene
  56409. * @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)
  56410. * @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)
  56411. * @param scene is the instance of BABYLON.Scene to append to
  56412. * @param onProgress a callback with a progress event for each file being loaded
  56413. * @param pluginExtension the extension used to determine the plugin
  56414. * @returns The given scene
  56415. */
  56416. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  56417. /**
  56418. * Load a scene into an asset container
  56419. * @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)
  56420. * @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)
  56421. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  56422. * @param onSuccess a callback with the scene when import succeeds
  56423. * @param onProgress a callback with a progress event for each file being loaded
  56424. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  56425. * @param pluginExtension the extension used to determine the plugin
  56426. * @returns The loaded plugin
  56427. */
  56428. 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>;
  56429. /**
  56430. * Load a scene into an asset container
  56431. * @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)
  56432. * @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)
  56433. * @param scene is the instance of Scene to append to
  56434. * @param onProgress a callback with a progress event for each file being loaded
  56435. * @param pluginExtension the extension used to determine the plugin
  56436. * @returns The loaded asset container
  56437. */
  56438. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  56439. /**
  56440. * Import animations from a file into a scene
  56441. * @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)
  56442. * @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)
  56443. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  56444. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  56445. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  56446. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  56447. * @param onSuccess a callback with the scene when import succeeds
  56448. * @param onProgress a callback with a progress event for each file being loaded
  56449. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  56450. * @param pluginExtension the extension used to determine the plugin
  56451. */
  56452. 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;
  56453. /**
  56454. * Import animations from a file into a scene
  56455. * @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)
  56456. * @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)
  56457. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  56458. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  56459. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  56460. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  56461. * @param onSuccess a callback with the scene when import succeeds
  56462. * @param onProgress a callback with a progress event for each file being loaded
  56463. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  56464. * @param pluginExtension the extension used to determine the plugin
  56465. * @returns the updated scene with imported animations
  56466. */
  56467. 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>;
  56468. }
  56469. }
  56470. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  56471. import { IDisposable, Scene } from "babylonjs/scene";
  56472. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  56473. import { Observable } from "babylonjs/Misc/observable";
  56474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56475. import { Nullable } from "babylonjs/types";
  56476. /**
  56477. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  56478. */
  56479. export type MotionControllerHandedness = "none" | "left" | "right";
  56480. /**
  56481. * The type of components available in motion controllers.
  56482. * This is not the name of the component.
  56483. */
  56484. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  56485. /**
  56486. * The state of a controller component
  56487. */
  56488. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  56489. /**
  56490. * The schema of motion controller layout.
  56491. * No object will be initialized using this interface
  56492. * This is used just to define the profile.
  56493. */
  56494. export interface IMotionControllerLayout {
  56495. /**
  56496. * Path to load the assets. Usually relative to the base path
  56497. */
  56498. assetPath: string;
  56499. /**
  56500. * Available components (unsorted)
  56501. */
  56502. components: {
  56503. /**
  56504. * A map of component Ids
  56505. */
  56506. [componentId: string]: {
  56507. /**
  56508. * The type of input the component outputs
  56509. */
  56510. type: MotionControllerComponentType;
  56511. /**
  56512. * The indices of this component in the gamepad object
  56513. */
  56514. gamepadIndices: {
  56515. /**
  56516. * Index of button
  56517. */
  56518. button?: number;
  56519. /**
  56520. * If available, index of x-axis
  56521. */
  56522. xAxis?: number;
  56523. /**
  56524. * If available, index of y-axis
  56525. */
  56526. yAxis?: number;
  56527. };
  56528. /**
  56529. * The mesh's root node name
  56530. */
  56531. rootNodeName: string;
  56532. /**
  56533. * Animation definitions for this model
  56534. */
  56535. visualResponses: {
  56536. [stateKey: string]: {
  56537. /**
  56538. * What property will be animated
  56539. */
  56540. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  56541. /**
  56542. * What states influence this visual response
  56543. */
  56544. states: MotionControllerComponentStateType[];
  56545. /**
  56546. * Type of animation - movement or visibility
  56547. */
  56548. valueNodeProperty: "transform" | "visibility";
  56549. /**
  56550. * Base node name to move. Its position will be calculated according to the min and max nodes
  56551. */
  56552. valueNodeName?: string;
  56553. /**
  56554. * Minimum movement node
  56555. */
  56556. minNodeName?: string;
  56557. /**
  56558. * Max movement node
  56559. */
  56560. maxNodeName?: string;
  56561. };
  56562. };
  56563. /**
  56564. * If touch enabled, what is the name of node to display user feedback
  56565. */
  56566. touchPointNodeName?: string;
  56567. };
  56568. };
  56569. /**
  56570. * Is it xr standard mapping or not
  56571. */
  56572. gamepadMapping: "" | "xr-standard";
  56573. /**
  56574. * Base root node of this entire model
  56575. */
  56576. rootNodeName: string;
  56577. /**
  56578. * Defines the main button component id
  56579. */
  56580. selectComponentId: string;
  56581. }
  56582. /**
  56583. * A definition for the layout map in the input profile
  56584. */
  56585. export interface IMotionControllerLayoutMap {
  56586. /**
  56587. * Layouts with handedness type as a key
  56588. */
  56589. [handedness: string]: IMotionControllerLayout;
  56590. }
  56591. /**
  56592. * The XR Input profile schema
  56593. * Profiles can be found here:
  56594. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  56595. */
  56596. export interface IMotionControllerProfile {
  56597. /**
  56598. * fallback profiles for this profileId
  56599. */
  56600. fallbackProfileIds: string[];
  56601. /**
  56602. * The layout map, with handedness as key
  56603. */
  56604. layouts: IMotionControllerLayoutMap;
  56605. /**
  56606. * The id of this profile
  56607. * correlates to the profile(s) in the xrInput.profiles array
  56608. */
  56609. profileId: string;
  56610. }
  56611. /**
  56612. * A helper-interface for the 3 meshes needed for controller button animation
  56613. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  56614. */
  56615. export interface IMotionControllerButtonMeshMap {
  56616. /**
  56617. * the mesh that defines the pressed value mesh position.
  56618. * This is used to find the max-position of this button
  56619. */
  56620. pressedMesh: AbstractMesh;
  56621. /**
  56622. * the mesh that defines the unpressed value mesh position.
  56623. * This is used to find the min (or initial) position of this button
  56624. */
  56625. unpressedMesh: AbstractMesh;
  56626. /**
  56627. * The mesh that will be changed when value changes
  56628. */
  56629. valueMesh: AbstractMesh;
  56630. }
  56631. /**
  56632. * A helper-interface for the 3 meshes needed for controller axis animation.
  56633. * This will be expanded when touchpad animations are fully supported
  56634. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  56635. */
  56636. export interface IMotionControllerMeshMap {
  56637. /**
  56638. * the mesh that defines the maximum value mesh position.
  56639. */
  56640. maxMesh?: AbstractMesh;
  56641. /**
  56642. * the mesh that defines the minimum value mesh position.
  56643. */
  56644. minMesh?: AbstractMesh;
  56645. /**
  56646. * The mesh that will be changed when axis value changes
  56647. */
  56648. valueMesh?: AbstractMesh;
  56649. }
  56650. /**
  56651. * The elements needed for change-detection of the gamepad objects in motion controllers
  56652. */
  56653. export interface IMinimalMotionControllerObject {
  56654. /**
  56655. * Available axes of this controller
  56656. */
  56657. axes: number[];
  56658. /**
  56659. * An array of available buttons
  56660. */
  56661. buttons: Array<{
  56662. /**
  56663. * Value of the button/trigger
  56664. */
  56665. value: number;
  56666. /**
  56667. * If the button/trigger is currently touched
  56668. */
  56669. touched: boolean;
  56670. /**
  56671. * If the button/trigger is currently pressed
  56672. */
  56673. pressed: boolean;
  56674. }>;
  56675. /**
  56676. * EXPERIMENTAL haptic support.
  56677. */
  56678. hapticActuators?: Array<{
  56679. pulse: (value: number, duration: number) => Promise<boolean>;
  56680. }>;
  56681. }
  56682. /**
  56683. * An Abstract Motion controller
  56684. * This class receives an xrInput and a profile layout and uses those to initialize the components
  56685. * Each component has an observable to check for changes in value and state
  56686. */
  56687. export abstract class WebXRAbstractMotionController implements IDisposable {
  56688. protected scene: Scene;
  56689. protected layout: IMotionControllerLayout;
  56690. /**
  56691. * The gamepad object correlating to this controller
  56692. */
  56693. gamepadObject: IMinimalMotionControllerObject;
  56694. /**
  56695. * handedness (left/right/none) of this controller
  56696. */
  56697. handedness: MotionControllerHandedness;
  56698. private _initComponent;
  56699. private _modelReady;
  56700. /**
  56701. * A map of components (WebXRControllerComponent) in this motion controller
  56702. * Components have a ComponentType and can also have both button and axis definitions
  56703. */
  56704. readonly components: {
  56705. [id: string]: WebXRControllerComponent;
  56706. };
  56707. /**
  56708. * Disable the model's animation. Can be set at any time.
  56709. */
  56710. disableAnimation: boolean;
  56711. /**
  56712. * Observers registered here will be triggered when the model of this controller is done loading
  56713. */
  56714. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  56715. /**
  56716. * The profile id of this motion controller
  56717. */
  56718. abstract profileId: string;
  56719. /**
  56720. * The root mesh of the model. It is null if the model was not yet initialized
  56721. */
  56722. rootMesh: Nullable<AbstractMesh>;
  56723. /**
  56724. * constructs a new abstract motion controller
  56725. * @param scene the scene to which the model of the controller will be added
  56726. * @param layout The profile layout to load
  56727. * @param gamepadObject The gamepad object correlating to this controller
  56728. * @param handedness handedness (left/right/none) of this controller
  56729. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  56730. */
  56731. constructor(scene: Scene, layout: IMotionControllerLayout,
  56732. /**
  56733. * The gamepad object correlating to this controller
  56734. */
  56735. gamepadObject: IMinimalMotionControllerObject,
  56736. /**
  56737. * handedness (left/right/none) of this controller
  56738. */
  56739. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  56740. /**
  56741. * Dispose this controller, the model mesh and all its components
  56742. */
  56743. dispose(): void;
  56744. /**
  56745. * Returns all components of specific type
  56746. * @param type the type to search for
  56747. * @return an array of components with this type
  56748. */
  56749. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  56750. /**
  56751. * get a component based an its component id as defined in layout.components
  56752. * @param id the id of the component
  56753. * @returns the component correlates to the id or undefined if not found
  56754. */
  56755. getComponent(id: string): WebXRControllerComponent;
  56756. /**
  56757. * Get the list of components available in this motion controller
  56758. * @returns an array of strings correlating to available components
  56759. */
  56760. getComponentIds(): string[];
  56761. /**
  56762. * Get the first component of specific type
  56763. * @param type type of component to find
  56764. * @return a controller component or null if not found
  56765. */
  56766. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  56767. /**
  56768. * Get the main (Select) component of this controller as defined in the layout
  56769. * @returns the main component of this controller
  56770. */
  56771. getMainComponent(): WebXRControllerComponent;
  56772. /**
  56773. * Loads the model correlating to this controller
  56774. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  56775. * @returns A promise fulfilled with the result of the model loading
  56776. */
  56777. loadModel(): Promise<boolean>;
  56778. /**
  56779. * Update this model using the current XRFrame
  56780. * @param xrFrame the current xr frame to use and update the model
  56781. */
  56782. updateFromXRFrame(xrFrame: XRFrame): void;
  56783. /**
  56784. * Backwards compatibility due to a deeply-integrated typo
  56785. */
  56786. get handness(): XREye;
  56787. /**
  56788. * Pulse (vibrate) this controller
  56789. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  56790. * Consecutive calls to this function will cancel the last pulse call
  56791. *
  56792. * @param value the strength of the pulse in 0.0...1.0 range
  56793. * @param duration Duration of the pulse in milliseconds
  56794. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  56795. * @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
  56796. */
  56797. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  56798. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  56799. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  56800. /**
  56801. * Moves the axis on the controller mesh based on its current state
  56802. * @param axis the index of the axis
  56803. * @param axisValue the value of the axis which determines the meshes new position
  56804. * @hidden
  56805. */
  56806. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  56807. /**
  56808. * Update the model itself with the current frame data
  56809. * @param xrFrame the frame to use for updating the model mesh
  56810. */
  56811. protected updateModel(xrFrame: XRFrame): void;
  56812. /**
  56813. * Get the filename and path for this controller's model
  56814. * @returns a map of filename and path
  56815. */
  56816. protected abstract _getFilenameAndPath(): {
  56817. filename: string;
  56818. path: string;
  56819. };
  56820. /**
  56821. * This function is called before the mesh is loaded. It checks for loading constraints.
  56822. * For example, this function can check if the GLB loader is available
  56823. * If this function returns false, the generic controller will be loaded instead
  56824. * @returns Is the client ready to load the mesh
  56825. */
  56826. protected abstract _getModelLoadingConstraints(): boolean;
  56827. /**
  56828. * This function will be called after the model was successfully loaded and can be used
  56829. * for mesh transformations before it is available for the user
  56830. * @param meshes the loaded meshes
  56831. */
  56832. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  56833. /**
  56834. * Set the root mesh for this controller. Important for the WebXR controller class
  56835. * @param meshes the loaded meshes
  56836. */
  56837. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  56838. /**
  56839. * A function executed each frame that updates the mesh (if needed)
  56840. * @param xrFrame the current xrFrame
  56841. */
  56842. protected abstract _updateModel(xrFrame: XRFrame): void;
  56843. private _getGenericFilenameAndPath;
  56844. private _getGenericParentMesh;
  56845. }
  56846. }
  56847. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  56848. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  56849. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56850. import { Scene } from "babylonjs/scene";
  56851. /**
  56852. * A generic trigger-only motion controller for WebXR
  56853. */
  56854. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  56855. /**
  56856. * Static version of the profile id of this controller
  56857. */
  56858. static ProfileId: string;
  56859. profileId: string;
  56860. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  56861. protected _getFilenameAndPath(): {
  56862. filename: string;
  56863. path: string;
  56864. };
  56865. protected _getModelLoadingConstraints(): boolean;
  56866. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  56867. protected _setRootMesh(meshes: AbstractMesh[]): void;
  56868. protected _updateModel(): void;
  56869. }
  56870. }
  56871. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  56872. import { Vector4 } from "babylonjs/Maths/math.vector";
  56873. import { Mesh } from "babylonjs/Meshes/mesh";
  56874. import { Scene } from "babylonjs/scene";
  56875. import { Nullable } from "babylonjs/types";
  56876. /**
  56877. * Class containing static functions to help procedurally build meshes
  56878. */
  56879. export class SphereBuilder {
  56880. /**
  56881. * Creates a sphere mesh
  56882. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  56883. * * 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`)
  56884. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  56885. * * 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
  56886. * * 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)
  56887. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56888. * * 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
  56889. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56890. * @param name defines the name of the mesh
  56891. * @param options defines the options used to create the mesh
  56892. * @param scene defines the hosting scene
  56893. * @returns the sphere mesh
  56894. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  56895. */
  56896. static CreateSphere(name: string, options: {
  56897. segments?: number;
  56898. diameter?: number;
  56899. diameterX?: number;
  56900. diameterY?: number;
  56901. diameterZ?: number;
  56902. arc?: number;
  56903. slice?: number;
  56904. sideOrientation?: number;
  56905. frontUVs?: Vector4;
  56906. backUVs?: Vector4;
  56907. updatable?: boolean;
  56908. }, scene?: Nullable<Scene>): Mesh;
  56909. }
  56910. }
  56911. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  56912. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56913. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  56914. import { Scene } from "babylonjs/scene";
  56915. /**
  56916. * A profiled motion controller has its profile loaded from an online repository.
  56917. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  56918. */
  56919. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  56920. private _repositoryUrl;
  56921. private _buttonMeshMapping;
  56922. private _touchDots;
  56923. /**
  56924. * The profile ID of this controller. Will be populated when the controller initializes.
  56925. */
  56926. profileId: string;
  56927. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  56928. dispose(): void;
  56929. protected _getFilenameAndPath(): {
  56930. filename: string;
  56931. path: string;
  56932. };
  56933. protected _getModelLoadingConstraints(): boolean;
  56934. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  56935. protected _setRootMesh(meshes: AbstractMesh[]): void;
  56936. protected _updateModel(_xrFrame: XRFrame): void;
  56937. }
  56938. }
  56939. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  56940. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  56941. import { Scene } from "babylonjs/scene";
  56942. /**
  56943. * A construction function type to create a new controller based on an xrInput object
  56944. */
  56945. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  56946. /**
  56947. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  56948. *
  56949. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  56950. * it should be replaced with auto-loaded controllers.
  56951. *
  56952. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  56953. */
  56954. export class WebXRMotionControllerManager {
  56955. private static _AvailableControllers;
  56956. private static _Fallbacks;
  56957. private static _ProfileLoadingPromises;
  56958. private static _ProfilesList;
  56959. /**
  56960. * The base URL of the online controller repository. Can be changed at any time.
  56961. */
  56962. static BaseRepositoryUrl: string;
  56963. /**
  56964. * Which repository gets priority - local or online
  56965. */
  56966. static PrioritizeOnlineRepository: boolean;
  56967. /**
  56968. * Use the online repository, or use only locally-defined controllers
  56969. */
  56970. static UseOnlineRepository: boolean;
  56971. /**
  56972. * Clear the cache used for profile loading and reload when requested again
  56973. */
  56974. static ClearProfilesCache(): void;
  56975. /**
  56976. * Register the default fallbacks.
  56977. * This function is called automatically when this file is imported.
  56978. */
  56979. static DefaultFallbacks(): void;
  56980. /**
  56981. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  56982. * @param profileId the profile to which a fallback needs to be found
  56983. * @return an array with corresponding fallback profiles
  56984. */
  56985. static FindFallbackWithProfileId(profileId: string): string[];
  56986. /**
  56987. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  56988. * The order of search:
  56989. *
  56990. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  56991. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  56992. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  56993. * 4) return the generic trigger controller if none were found
  56994. *
  56995. * @param xrInput the xrInput to which a new controller is initialized
  56996. * @param scene the scene to which the model will be added
  56997. * @param forceProfile force a certain profile for this controller
  56998. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  56999. */
  57000. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  57001. /**
  57002. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  57003. *
  57004. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  57005. *
  57006. * @param type the profile type to register
  57007. * @param constructFunction the function to be called when loading this profile
  57008. */
  57009. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  57010. /**
  57011. * Register a fallback to a specific profile.
  57012. * @param profileId the profileId that will receive the fallbacks
  57013. * @param fallbacks A list of fallback profiles
  57014. */
  57015. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  57016. /**
  57017. * Will update the list of profiles available in the repository
  57018. * @return a promise that resolves to a map of profiles available online
  57019. */
  57020. static UpdateProfilesList(): Promise<{
  57021. [profile: string]: string;
  57022. }>;
  57023. private static _LoadProfileFromRepository;
  57024. private static _LoadProfilesFromAvailableControllers;
  57025. }
  57026. }
  57027. declare module "babylonjs/XR/webXRInputSource" {
  57028. import { Observable } from "babylonjs/Misc/observable";
  57029. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57030. import { Ray } from "babylonjs/Culling/ray";
  57031. import { Scene } from "babylonjs/scene";
  57032. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  57033. /**
  57034. * Configuration options for the WebXR controller creation
  57035. */
  57036. export interface IWebXRControllerOptions {
  57037. /**
  57038. * Should the controller mesh be animated when a user interacts with it
  57039. * The pressed buttons / thumbstick and touchpad animations will be disabled
  57040. */
  57041. disableMotionControllerAnimation?: boolean;
  57042. /**
  57043. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  57044. */
  57045. doNotLoadControllerMesh?: boolean;
  57046. /**
  57047. * Force a specific controller type for this controller.
  57048. * This can be used when creating your own profile or when testing different controllers
  57049. */
  57050. forceControllerProfile?: string;
  57051. /**
  57052. * Defines a rendering group ID for meshes that will be loaded.
  57053. * This is for the default controllers only.
  57054. */
  57055. renderingGroupId?: number;
  57056. }
  57057. /**
  57058. * Represents an XR controller
  57059. */
  57060. export class WebXRInputSource {
  57061. private _scene;
  57062. /** The underlying input source for the controller */
  57063. inputSource: XRInputSource;
  57064. private _options;
  57065. private _tmpVector;
  57066. private _uniqueId;
  57067. private _disposed;
  57068. /**
  57069. * 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
  57070. */
  57071. grip?: AbstractMesh;
  57072. /**
  57073. * If available, this is the gamepad object related to this controller.
  57074. * Using this object it is possible to get click events and trackpad changes of the
  57075. * webxr controller that is currently being used.
  57076. */
  57077. motionController?: WebXRAbstractMotionController;
  57078. /**
  57079. * Event that fires when the controller is removed/disposed.
  57080. * The object provided as event data is this controller, after associated assets were disposed.
  57081. * uniqueId is still available.
  57082. */
  57083. onDisposeObservable: Observable<WebXRInputSource>;
  57084. /**
  57085. * Will be triggered when the mesh associated with the motion controller is done loading.
  57086. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  57087. * A shortened version of controller -> motion controller -> on mesh loaded.
  57088. */
  57089. onMeshLoadedObservable: Observable<AbstractMesh>;
  57090. /**
  57091. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  57092. */
  57093. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  57094. /**
  57095. * Pointer which can be used to select objects or attach a visible laser to
  57096. */
  57097. pointer: AbstractMesh;
  57098. /**
  57099. * Creates the input source object
  57100. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  57101. * @param _scene the scene which the controller should be associated to
  57102. * @param inputSource the underlying input source for the controller
  57103. * @param _options options for this controller creation
  57104. */
  57105. constructor(_scene: Scene,
  57106. /** The underlying input source for the controller */
  57107. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  57108. /**
  57109. * Get this controllers unique id
  57110. */
  57111. get uniqueId(): string;
  57112. /**
  57113. * Disposes of the object
  57114. */
  57115. dispose(): void;
  57116. /**
  57117. * Gets a world space ray coming from the pointer or grip
  57118. * @param result the resulting ray
  57119. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  57120. */
  57121. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  57122. /**
  57123. * Updates the controller pose based on the given XRFrame
  57124. * @param xrFrame xr frame to update the pose with
  57125. * @param referenceSpace reference space to use
  57126. */
  57127. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  57128. }
  57129. }
  57130. declare module "babylonjs/XR/webXRInput" {
  57131. import { Observable } from "babylonjs/Misc/observable";
  57132. import { IDisposable } from "babylonjs/scene";
  57133. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  57134. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  57135. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  57136. /**
  57137. * The schema for initialization options of the XR Input class
  57138. */
  57139. export interface IWebXRInputOptions {
  57140. /**
  57141. * If set to true no model will be automatically loaded
  57142. */
  57143. doNotLoadControllerMeshes?: boolean;
  57144. /**
  57145. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  57146. * If not found, the xr input profile data will be used.
  57147. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  57148. */
  57149. forceInputProfile?: string;
  57150. /**
  57151. * Do not send a request to the controller repository to load the profile.
  57152. *
  57153. * Instead, use the controllers available in babylon itself.
  57154. */
  57155. disableOnlineControllerRepository?: boolean;
  57156. /**
  57157. * A custom URL for the controllers repository
  57158. */
  57159. customControllersRepositoryURL?: string;
  57160. /**
  57161. * Should the controller model's components not move according to the user input
  57162. */
  57163. disableControllerAnimation?: boolean;
  57164. /**
  57165. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  57166. */
  57167. controllerOptions?: IWebXRControllerOptions;
  57168. }
  57169. /**
  57170. * XR input used to track XR inputs such as controllers/rays
  57171. */
  57172. export class WebXRInput implements IDisposable {
  57173. /**
  57174. * the xr session manager for this session
  57175. */
  57176. xrSessionManager: WebXRSessionManager;
  57177. /**
  57178. * the WebXR camera for this session. Mainly used for teleportation
  57179. */
  57180. xrCamera: WebXRCamera;
  57181. private readonly options;
  57182. /**
  57183. * XR controllers being tracked
  57184. */
  57185. controllers: Array<WebXRInputSource>;
  57186. private _frameObserver;
  57187. private _sessionEndedObserver;
  57188. private _sessionInitObserver;
  57189. /**
  57190. * Event when a controller has been connected/added
  57191. */
  57192. onControllerAddedObservable: Observable<WebXRInputSource>;
  57193. /**
  57194. * Event when a controller has been removed/disconnected
  57195. */
  57196. onControllerRemovedObservable: Observable<WebXRInputSource>;
  57197. /**
  57198. * Initializes the WebXRInput
  57199. * @param xrSessionManager the xr session manager for this session
  57200. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  57201. * @param options = initialization options for this xr input
  57202. */
  57203. constructor(
  57204. /**
  57205. * the xr session manager for this session
  57206. */
  57207. xrSessionManager: WebXRSessionManager,
  57208. /**
  57209. * the WebXR camera for this session. Mainly used for teleportation
  57210. */
  57211. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  57212. private _onInputSourcesChange;
  57213. private _addAndRemoveControllers;
  57214. /**
  57215. * Disposes of the object
  57216. */
  57217. dispose(): void;
  57218. }
  57219. }
  57220. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  57221. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  57222. import { Observable, EventState } from "babylonjs/Misc/observable";
  57223. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  57224. /**
  57225. * This is the base class for all WebXR features.
  57226. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  57227. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  57228. */
  57229. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  57230. protected _xrSessionManager: WebXRSessionManager;
  57231. private _attached;
  57232. private _removeOnDetach;
  57233. /**
  57234. * Is this feature disposed?
  57235. */
  57236. isDisposed: boolean;
  57237. /**
  57238. * Should auto-attach be disabled?
  57239. */
  57240. disableAutoAttach: boolean;
  57241. /**
  57242. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  57243. */
  57244. xrNativeFeatureName: string;
  57245. /**
  57246. * Construct a new (abstract) WebXR feature
  57247. * @param _xrSessionManager the xr session manager for this feature
  57248. */
  57249. constructor(_xrSessionManager: WebXRSessionManager);
  57250. /**
  57251. * Is this feature attached
  57252. */
  57253. get attached(): boolean;
  57254. /**
  57255. * attach this feature
  57256. *
  57257. * @param force should attachment be forced (even when already attached)
  57258. * @returns true if successful, false is failed or already attached
  57259. */
  57260. attach(force?: boolean): boolean;
  57261. /**
  57262. * detach this feature.
  57263. *
  57264. * @returns true if successful, false if failed or already detached
  57265. */
  57266. detach(): boolean;
  57267. /**
  57268. * Dispose this feature and all of the resources attached
  57269. */
  57270. dispose(): void;
  57271. /**
  57272. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  57273. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  57274. *
  57275. * @returns whether or not the feature is compatible in this environment
  57276. */
  57277. isCompatible(): boolean;
  57278. /**
  57279. * This is used to register callbacks that will automatically be removed when detach is called.
  57280. * @param observable the observable to which the observer will be attached
  57281. * @param callback the callback to register
  57282. */
  57283. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  57284. /**
  57285. * Code in this function will be executed on each xrFrame received from the browser.
  57286. * This function will not execute after the feature is detached.
  57287. * @param _xrFrame the current frame
  57288. */
  57289. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  57290. }
  57291. }
  57292. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  57293. import { IDisposable, Scene } from "babylonjs/scene";
  57294. import { Nullable } from "babylonjs/types";
  57295. import { Observable } from "babylonjs/Misc/observable";
  57296. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57297. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  57298. import { Camera } from "babylonjs/Cameras/camera";
  57299. /**
  57300. * Renders a layer on top of an existing scene
  57301. */
  57302. export class UtilityLayerRenderer implements IDisposable {
  57303. /** the original scene that will be rendered on top of */
  57304. originalScene: Scene;
  57305. private _pointerCaptures;
  57306. private _lastPointerEvents;
  57307. private static _DefaultUtilityLayer;
  57308. private static _DefaultKeepDepthUtilityLayer;
  57309. private _sharedGizmoLight;
  57310. private _renderCamera;
  57311. /**
  57312. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  57313. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  57314. * @returns the camera that is used when rendering the utility layer
  57315. */
  57316. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  57317. /**
  57318. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  57319. * @param cam the camera that should be used when rendering the utility layer
  57320. */
  57321. setRenderCamera(cam: Nullable<Camera>): void;
  57322. /**
  57323. * @hidden
  57324. * Light which used by gizmos to get light shading
  57325. */
  57326. _getSharedGizmoLight(): HemisphericLight;
  57327. /**
  57328. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  57329. */
  57330. pickUtilitySceneFirst: boolean;
  57331. /**
  57332. * 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)
  57333. */
  57334. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  57335. /**
  57336. * 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)
  57337. */
  57338. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  57339. /**
  57340. * The scene that is rendered on top of the original scene
  57341. */
  57342. utilityLayerScene: Scene;
  57343. /**
  57344. * If the utility layer should automatically be rendered on top of existing scene
  57345. */
  57346. shouldRender: boolean;
  57347. /**
  57348. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  57349. */
  57350. onlyCheckPointerDownEvents: boolean;
  57351. /**
  57352. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  57353. */
  57354. processAllEvents: boolean;
  57355. /**
  57356. * Observable raised when the pointer move from the utility layer scene to the main scene
  57357. */
  57358. onPointerOutObservable: Observable<number>;
  57359. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  57360. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  57361. private _afterRenderObserver;
  57362. private _sceneDisposeObserver;
  57363. private _originalPointerObserver;
  57364. /**
  57365. * Instantiates a UtilityLayerRenderer
  57366. * @param originalScene the original scene that will be rendered on top of
  57367. * @param handleEvents boolean indicating if the utility layer should handle events
  57368. */
  57369. constructor(
  57370. /** the original scene that will be rendered on top of */
  57371. originalScene: Scene, handleEvents?: boolean);
  57372. private _notifyObservers;
  57373. /**
  57374. * Renders the utility layers scene on top of the original scene
  57375. */
  57376. render(): void;
  57377. /**
  57378. * Disposes of the renderer
  57379. */
  57380. dispose(): void;
  57381. private _updateCamera;
  57382. }
  57383. }
  57384. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  57385. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  57386. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57387. import { WebXRInput } from "babylonjs/XR/webXRInput";
  57388. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  57389. import { Scene } from "babylonjs/scene";
  57390. import { Nullable } from "babylonjs/types";
  57391. import { Color3 } from "babylonjs/Maths/math.color";
  57392. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  57393. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  57394. /**
  57395. * Options interface for the pointer selection module
  57396. */
  57397. export interface IWebXRControllerPointerSelectionOptions {
  57398. /**
  57399. * if provided, this scene will be used to render meshes.
  57400. */
  57401. customUtilityLayerScene?: Scene;
  57402. /**
  57403. * 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)
  57404. * If not disabled, the last picked point will be used to execute a pointer up event
  57405. * If disabled, pointer up event will be triggered right after the pointer down event.
  57406. * Used in screen and gaze target ray mode only
  57407. */
  57408. disablePointerUpOnTouchOut: boolean;
  57409. /**
  57410. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  57411. */
  57412. forceGazeMode: boolean;
  57413. /**
  57414. * 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
  57415. * to start a new countdown to the pointer down event.
  57416. * Defaults to 1.
  57417. */
  57418. gazeModePointerMovedFactor?: number;
  57419. /**
  57420. * Different button type to use instead of the main component
  57421. */
  57422. overrideButtonId?: string;
  57423. /**
  57424. * use this rendering group id for the meshes (optional)
  57425. */
  57426. renderingGroupId?: number;
  57427. /**
  57428. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  57429. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  57430. * 3000 means 3 seconds between pointing at something and selecting it
  57431. */
  57432. timeToSelect?: number;
  57433. /**
  57434. * Should meshes created here be added to a utility layer or the main scene
  57435. */
  57436. useUtilityLayer?: boolean;
  57437. /**
  57438. * Optional WebXR camera to be used for gaze selection
  57439. */
  57440. gazeCamera?: WebXRCamera;
  57441. /**
  57442. * the xr input to use with this pointer selection
  57443. */
  57444. xrInput: WebXRInput;
  57445. /**
  57446. * Should the scene pointerX and pointerY update be disabled
  57447. * This is required for fullscreen AR GUI, but might slow down other experiences.
  57448. * Disable in VR, if not needed.
  57449. * The first rig camera (left eye) will be used to calculate the projection
  57450. */
  57451. disableScenePointerVectorUpdate: boolean;
  57452. /**
  57453. * Enable pointer selection on all controllers instead of switching between them
  57454. */
  57455. enablePointerSelectionOnAllControllers?: boolean;
  57456. /**
  57457. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  57458. * If switch is enabled, it will still allow the user to switch between the different controllers
  57459. */
  57460. preferredHandedness?: XRHandedness;
  57461. /**
  57462. * Disable switching the pointer selection from one controller to the other.
  57463. * 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
  57464. */
  57465. disableSwitchOnClick?: boolean;
  57466. /**
  57467. * The maximum distance of the pointer selection feature. Defaults to 100.
  57468. */
  57469. maxPointerDistance?: number;
  57470. }
  57471. /**
  57472. * A module that will enable pointer selection for motion controllers of XR Input Sources
  57473. */
  57474. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  57475. private readonly _options;
  57476. private static _idCounter;
  57477. private _attachController;
  57478. private _controllers;
  57479. private _scene;
  57480. private _tmpVectorForPickCompare;
  57481. private _attachedController;
  57482. /**
  57483. * The module's name
  57484. */
  57485. static readonly Name: string;
  57486. /**
  57487. * The (Babylon) version of this module.
  57488. * This is an integer representing the implementation version.
  57489. * This number does not correspond to the WebXR specs version
  57490. */
  57491. static readonly Version: number;
  57492. /**
  57493. * Disable lighting on the laser pointer (so it will always be visible)
  57494. */
  57495. disablePointerLighting: boolean;
  57496. /**
  57497. * Disable lighting on the selection mesh (so it will always be visible)
  57498. */
  57499. disableSelectionMeshLighting: boolean;
  57500. /**
  57501. * Should the laser pointer be displayed
  57502. */
  57503. displayLaserPointer: boolean;
  57504. /**
  57505. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  57506. */
  57507. displaySelectionMesh: boolean;
  57508. /**
  57509. * This color will be set to the laser pointer when selection is triggered
  57510. */
  57511. laserPointerPickedColor: Color3;
  57512. /**
  57513. * Default color of the laser pointer
  57514. */
  57515. laserPointerDefaultColor: Color3;
  57516. /**
  57517. * default color of the selection ring
  57518. */
  57519. selectionMeshDefaultColor: Color3;
  57520. /**
  57521. * This color will be applied to the selection ring when selection is triggered
  57522. */
  57523. selectionMeshPickedColor: Color3;
  57524. /**
  57525. * Optional filter to be used for ray selection. This predicate shares behavior with
  57526. * scene.pointerMovePredicate which takes priority if it is also assigned.
  57527. */
  57528. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  57529. /**
  57530. * constructs a new background remover module
  57531. * @param _xrSessionManager the session manager for this module
  57532. * @param _options read-only options to be used in this module
  57533. */
  57534. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  57535. /**
  57536. * attach this feature
  57537. * Will usually be called by the features manager
  57538. *
  57539. * @returns true if successful.
  57540. */
  57541. attach(): boolean;
  57542. /**
  57543. * detach this feature.
  57544. * Will usually be called by the features manager
  57545. *
  57546. * @returns true if successful.
  57547. */
  57548. detach(): boolean;
  57549. /**
  57550. * Will get the mesh under a specific pointer.
  57551. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  57552. * @param controllerId the controllerId to check
  57553. * @returns The mesh under pointer or null if no mesh is under the pointer
  57554. */
  57555. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  57556. /**
  57557. * Get the xr controller that correlates to the pointer id in the pointer event
  57558. *
  57559. * @param id the pointer id to search for
  57560. * @returns the controller that correlates to this id or null if not found
  57561. */
  57562. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  57563. private _identityMatrix;
  57564. private _screenCoordinatesRef;
  57565. private _viewportRef;
  57566. protected _onXRFrame(_xrFrame: XRFrame): void;
  57567. private _attachGazeMode;
  57568. private _attachScreenRayMode;
  57569. private _attachTrackedPointerRayMode;
  57570. private _convertNormalToDirectionOfRay;
  57571. private _detachController;
  57572. private _generateNewMeshPair;
  57573. private _pickingMoved;
  57574. private _updatePointerDistance;
  57575. /** @hidden */
  57576. get lasterPointerDefaultColor(): Color3;
  57577. }
  57578. }
  57579. declare module "babylonjs/XR/webXREnterExitUI" {
  57580. import { Nullable } from "babylonjs/types";
  57581. import { Observable } from "babylonjs/Misc/observable";
  57582. import { IDisposable, Scene } from "babylonjs/scene";
  57583. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  57584. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  57585. /**
  57586. * Button which can be used to enter a different mode of XR
  57587. */
  57588. export class WebXREnterExitUIButton {
  57589. /** button element */
  57590. element: HTMLElement;
  57591. /** XR initialization options for the button */
  57592. sessionMode: XRSessionMode;
  57593. /** Reference space type */
  57594. referenceSpaceType: XRReferenceSpaceType;
  57595. /**
  57596. * Creates a WebXREnterExitUIButton
  57597. * @param element button element
  57598. * @param sessionMode XR initialization session mode
  57599. * @param referenceSpaceType the type of reference space to be used
  57600. */
  57601. constructor(
  57602. /** button element */
  57603. element: HTMLElement,
  57604. /** XR initialization options for the button */
  57605. sessionMode: XRSessionMode,
  57606. /** Reference space type */
  57607. referenceSpaceType: XRReferenceSpaceType);
  57608. /**
  57609. * Extendable function which can be used to update the button's visuals when the state changes
  57610. * @param activeButton the current active button in the UI
  57611. */
  57612. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  57613. }
  57614. /**
  57615. * Options to create the webXR UI
  57616. */
  57617. export class WebXREnterExitUIOptions {
  57618. /**
  57619. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  57620. */
  57621. customButtons?: Array<WebXREnterExitUIButton>;
  57622. /**
  57623. * A reference space type to use when creating the default button.
  57624. * Default is local-floor
  57625. */
  57626. referenceSpaceType?: XRReferenceSpaceType;
  57627. /**
  57628. * Context to enter xr with
  57629. */
  57630. renderTarget?: Nullable<WebXRRenderTarget>;
  57631. /**
  57632. * A session mode to use when creating the default button.
  57633. * Default is immersive-vr
  57634. */
  57635. sessionMode?: XRSessionMode;
  57636. /**
  57637. * A list of optional features to init the session with
  57638. */
  57639. optionalFeatures?: string[];
  57640. /**
  57641. * A list of optional features to init the session with
  57642. */
  57643. requiredFeatures?: string[];
  57644. /**
  57645. * If defined, this function will be executed if the UI encounters an error when entering XR
  57646. */
  57647. onError?: (error: any) => void;
  57648. }
  57649. /**
  57650. * UI to allow the user to enter/exit XR mode
  57651. */
  57652. export class WebXREnterExitUI implements IDisposable {
  57653. private scene;
  57654. /** version of the options passed to this UI */
  57655. options: WebXREnterExitUIOptions;
  57656. private _activeButton;
  57657. private _buttons;
  57658. /**
  57659. * The HTML Div Element to which buttons are added.
  57660. */
  57661. readonly overlay: HTMLDivElement;
  57662. /**
  57663. * Fired every time the active button is changed.
  57664. *
  57665. * When xr is entered via a button that launches xr that button will be the callback parameter
  57666. *
  57667. * When exiting xr the callback parameter will be null)
  57668. */
  57669. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  57670. /**
  57671. *
  57672. * @param scene babylon scene object to use
  57673. * @param options (read-only) version of the options passed to this UI
  57674. */
  57675. private constructor();
  57676. /**
  57677. * Creates UI to allow the user to enter/exit XR mode
  57678. * @param scene the scene to add the ui to
  57679. * @param helper the xr experience helper to enter/exit xr with
  57680. * @param options options to configure the UI
  57681. * @returns the created ui
  57682. */
  57683. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  57684. /**
  57685. * Disposes of the XR UI component
  57686. */
  57687. dispose(): void;
  57688. private _updateButtons;
  57689. }
  57690. }
  57691. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  57692. import { Vector3 } from "babylonjs/Maths/math.vector";
  57693. import { Color4 } from "babylonjs/Maths/math.color";
  57694. import { Nullable } from "babylonjs/types";
  57695. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  57696. import { Scene } from "babylonjs/scene";
  57697. /**
  57698. * Class containing static functions to help procedurally build meshes
  57699. */
  57700. export class LinesBuilder {
  57701. /**
  57702. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  57703. * * 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
  57704. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  57705. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  57706. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  57707. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  57708. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  57709. * * 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
  57710. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  57711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57712. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  57713. * @param name defines the name of the new line system
  57714. * @param options defines the options used to create the line system
  57715. * @param scene defines the hosting scene
  57716. * @returns a new line system mesh
  57717. */
  57718. static CreateLineSystem(name: string, options: {
  57719. lines: Vector3[][];
  57720. updatable?: boolean;
  57721. instance?: Nullable<LinesMesh>;
  57722. colors?: Nullable<Color4[][]>;
  57723. useVertexAlpha?: boolean;
  57724. }, scene: Nullable<Scene>): LinesMesh;
  57725. /**
  57726. * Creates a line mesh
  57727. * 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
  57728. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  57729. * * The parameter `points` is an array successive Vector3
  57730. * * 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
  57731. * * The optional parameter `colors` is an array of successive Color4, one per line point
  57732. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  57733. * * When updating an instance, remember that only point positions can change, not the number of points
  57734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57735. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  57736. * @param name defines the name of the new line system
  57737. * @param options defines the options used to create the line system
  57738. * @param scene defines the hosting scene
  57739. * @returns a new line mesh
  57740. */
  57741. static CreateLines(name: string, options: {
  57742. points: Vector3[];
  57743. updatable?: boolean;
  57744. instance?: Nullable<LinesMesh>;
  57745. colors?: Color4[];
  57746. useVertexAlpha?: boolean;
  57747. }, scene?: Nullable<Scene>): LinesMesh;
  57748. /**
  57749. * Creates a dashed line mesh
  57750. * * 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
  57751. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  57752. * * The parameter `points` is an array successive Vector3
  57753. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  57754. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  57755. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  57756. * * 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
  57757. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  57758. * * When updating an instance, remember that only point positions can change, not the number of points
  57759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57760. * @param name defines the name of the mesh
  57761. * @param options defines the options used to create the mesh
  57762. * @param scene defines the hosting scene
  57763. * @returns the dashed line mesh
  57764. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  57765. */
  57766. static CreateDashedLines(name: string, options: {
  57767. points: Vector3[];
  57768. dashSize?: number;
  57769. gapSize?: number;
  57770. dashNb?: number;
  57771. updatable?: boolean;
  57772. instance?: LinesMesh;
  57773. useVertexAlpha?: boolean;
  57774. }, scene?: Nullable<Scene>): LinesMesh;
  57775. }
  57776. }
  57777. declare module "babylonjs/Misc/timer" {
  57778. import { Observable, Observer } from "babylonjs/Misc/observable";
  57779. import { Nullable } from "babylonjs/types";
  57780. import { IDisposable } from "babylonjs/scene";
  57781. /**
  57782. * Construction options for a timer
  57783. */
  57784. export interface ITimerOptions<T> {
  57785. /**
  57786. * Time-to-end
  57787. */
  57788. timeout: number;
  57789. /**
  57790. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  57791. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  57792. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  57793. */
  57794. contextObservable: Observable<T>;
  57795. /**
  57796. * Optional parameters when adding an observer to the observable
  57797. */
  57798. observableParameters?: {
  57799. mask?: number;
  57800. insertFirst?: boolean;
  57801. scope?: any;
  57802. };
  57803. /**
  57804. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  57805. */
  57806. breakCondition?: (data?: ITimerData<T>) => boolean;
  57807. /**
  57808. * Will be triggered when the time condition has met
  57809. */
  57810. onEnded?: (data: ITimerData<any>) => void;
  57811. /**
  57812. * Will be triggered when the break condition has met (prematurely ended)
  57813. */
  57814. onAborted?: (data: ITimerData<any>) => void;
  57815. /**
  57816. * Optional function to execute on each tick (or count)
  57817. */
  57818. onTick?: (data: ITimerData<any>) => void;
  57819. }
  57820. /**
  57821. * An interface defining the data sent by the timer
  57822. */
  57823. export interface ITimerData<T> {
  57824. /**
  57825. * When did it start
  57826. */
  57827. startTime: number;
  57828. /**
  57829. * Time now
  57830. */
  57831. currentTime: number;
  57832. /**
  57833. * Time passed since started
  57834. */
  57835. deltaTime: number;
  57836. /**
  57837. * How much is completed, in [0.0...1.0].
  57838. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  57839. */
  57840. completeRate: number;
  57841. /**
  57842. * What the registered observable sent in the last count
  57843. */
  57844. payload: T;
  57845. }
  57846. /**
  57847. * The current state of the timer
  57848. */
  57849. export enum TimerState {
  57850. /**
  57851. * Timer initialized, not yet started
  57852. */
  57853. INIT = 0,
  57854. /**
  57855. * Timer started and counting
  57856. */
  57857. STARTED = 1,
  57858. /**
  57859. * Timer ended (whether aborted or time reached)
  57860. */
  57861. ENDED = 2
  57862. }
  57863. /**
  57864. * A simple version of the timer. Will take options and start the timer immediately after calling it
  57865. *
  57866. * @param options options with which to initialize this timer
  57867. */
  57868. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  57869. /**
  57870. * An advanced implementation of a timer class
  57871. */
  57872. export class AdvancedTimer<T = any> implements IDisposable {
  57873. /**
  57874. * Will notify each time the timer calculates the remaining time
  57875. */
  57876. onEachCountObservable: Observable<ITimerData<T>>;
  57877. /**
  57878. * Will trigger when the timer was aborted due to the break condition
  57879. */
  57880. onTimerAbortedObservable: Observable<ITimerData<T>>;
  57881. /**
  57882. * Will trigger when the timer ended successfully
  57883. */
  57884. onTimerEndedObservable: Observable<ITimerData<T>>;
  57885. /**
  57886. * Will trigger when the timer state has changed
  57887. */
  57888. onStateChangedObservable: Observable<TimerState>;
  57889. private _observer;
  57890. private _contextObservable;
  57891. private _observableParameters;
  57892. private _startTime;
  57893. private _timer;
  57894. private _state;
  57895. private _breakCondition;
  57896. private _timeToEnd;
  57897. private _breakOnNextTick;
  57898. /**
  57899. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  57900. * @param options construction options for this advanced timer
  57901. */
  57902. constructor(options: ITimerOptions<T>);
  57903. /**
  57904. * set a breaking condition for this timer. Default is to never break during count
  57905. * @param predicate the new break condition. Returns true to break, false otherwise
  57906. */
  57907. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  57908. /**
  57909. * Reset ALL associated observables in this advanced timer
  57910. */
  57911. clearObservables(): void;
  57912. /**
  57913. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  57914. *
  57915. * @param timeToEnd how much time to measure until timer ended
  57916. */
  57917. start(timeToEnd?: number): void;
  57918. /**
  57919. * Will force a stop on the next tick.
  57920. */
  57921. stop(): void;
  57922. /**
  57923. * Dispose this timer, clearing all resources
  57924. */
  57925. dispose(): void;
  57926. private _setState;
  57927. private _tick;
  57928. private _stop;
  57929. }
  57930. }
  57931. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  57932. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  57933. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  57934. import { Nullable } from "babylonjs/types";
  57935. import { WebXRInput } from "babylonjs/XR/webXRInput";
  57936. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57937. import { Vector3 } from "babylonjs/Maths/math.vector";
  57938. import { Material } from "babylonjs/Materials/material";
  57939. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  57940. import { Scene } from "babylonjs/scene";
  57941. /**
  57942. * The options container for the teleportation module
  57943. */
  57944. export interface IWebXRTeleportationOptions {
  57945. /**
  57946. * if provided, this scene will be used to render meshes.
  57947. */
  57948. customUtilityLayerScene?: Scene;
  57949. /**
  57950. * Values to configure the default target mesh
  57951. */
  57952. defaultTargetMeshOptions?: {
  57953. /**
  57954. * Fill color of the teleportation area
  57955. */
  57956. teleportationFillColor?: string;
  57957. /**
  57958. * Border color for the teleportation area
  57959. */
  57960. teleportationBorderColor?: string;
  57961. /**
  57962. * Disable the mesh's animation sequence
  57963. */
  57964. disableAnimation?: boolean;
  57965. /**
  57966. * Disable lighting on the material or the ring and arrow
  57967. */
  57968. disableLighting?: boolean;
  57969. /**
  57970. * Override the default material of the torus and arrow
  57971. */
  57972. torusArrowMaterial?: Material;
  57973. };
  57974. /**
  57975. * A list of meshes to use as floor meshes.
  57976. * Meshes can be added and removed after initializing the feature using the
  57977. * addFloorMesh and removeFloorMesh functions
  57978. * If empty, rotation will still work
  57979. */
  57980. floorMeshes?: AbstractMesh[];
  57981. /**
  57982. * use this rendering group id for the meshes (optional)
  57983. */
  57984. renderingGroupId?: number;
  57985. /**
  57986. * Should teleportation move only to snap points
  57987. */
  57988. snapPointsOnly?: boolean;
  57989. /**
  57990. * An array of points to which the teleportation will snap to.
  57991. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  57992. */
  57993. snapPositions?: Vector3[];
  57994. /**
  57995. * How close should the teleportation ray be in order to snap to position.
  57996. * Default to 0.8 units (meters)
  57997. */
  57998. snapToPositionRadius?: number;
  57999. /**
  58000. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  58001. * If you want to support rotation, make sure your mesh has a direction indicator.
  58002. *
  58003. * When left untouched, the default mesh will be initialized.
  58004. */
  58005. teleportationTargetMesh?: AbstractMesh;
  58006. /**
  58007. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  58008. */
  58009. timeToTeleport?: number;
  58010. /**
  58011. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  58012. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  58013. */
  58014. useMainComponentOnly?: boolean;
  58015. /**
  58016. * Should meshes created here be added to a utility layer or the main scene
  58017. */
  58018. useUtilityLayer?: boolean;
  58019. /**
  58020. * Babylon XR Input class for controller
  58021. */
  58022. xrInput: WebXRInput;
  58023. /**
  58024. * Meshes that the teleportation ray cannot go through
  58025. */
  58026. pickBlockerMeshes?: AbstractMesh[];
  58027. /**
  58028. * Should teleport work only on a specific hand?
  58029. */
  58030. forceHandedness?: XRHandedness;
  58031. /**
  58032. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  58033. */
  58034. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  58035. }
  58036. /**
  58037. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  58038. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  58039. * the input of the attached controllers.
  58040. */
  58041. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  58042. private _options;
  58043. private _controllers;
  58044. private _currentTeleportationControllerId;
  58045. private _floorMeshes;
  58046. private _quadraticBezierCurve;
  58047. private _selectionFeature;
  58048. private _snapToPositions;
  58049. private _snappedToPoint;
  58050. private _teleportationRingMaterial?;
  58051. private _tmpRay;
  58052. private _tmpVector;
  58053. private _tmpQuaternion;
  58054. /**
  58055. * The module's name
  58056. */
  58057. static readonly Name: string;
  58058. /**
  58059. * The (Babylon) version of this module.
  58060. * This is an integer representing the implementation version.
  58061. * This number does not correspond to the webxr specs version
  58062. */
  58063. static readonly Version: number;
  58064. /**
  58065. * Is movement backwards enabled
  58066. */
  58067. backwardsMovementEnabled: boolean;
  58068. /**
  58069. * Distance to travel when moving backwards
  58070. */
  58071. backwardsTeleportationDistance: number;
  58072. /**
  58073. * The distance from the user to the inspection point in the direction of the controller
  58074. * A higher number will allow the user to move further
  58075. * defaults to 5 (meters, in xr units)
  58076. */
  58077. parabolicCheckRadius: number;
  58078. /**
  58079. * Should the module support parabolic ray on top of direct ray
  58080. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  58081. * Very helpful when moving between floors / different heights
  58082. */
  58083. parabolicRayEnabled: boolean;
  58084. /**
  58085. * The second type of ray - straight line.
  58086. * Should it be enabled or should the parabolic line be the only one.
  58087. */
  58088. straightRayEnabled: boolean;
  58089. /**
  58090. * How much rotation should be applied when rotating right and left
  58091. */
  58092. rotationAngle: number;
  58093. private _rotationEnabled;
  58094. /**
  58095. * Is rotation enabled when moving forward?
  58096. * Disabling this feature will prevent the user from deciding the direction when teleporting
  58097. */
  58098. get rotationEnabled(): boolean;
  58099. /**
  58100. * Sets wether rotation is enabled or not
  58101. * @param enabled is rotation enabled when teleportation is shown
  58102. */
  58103. set rotationEnabled(enabled: boolean);
  58104. /**
  58105. * Exposes the currently set teleportation target mesh.
  58106. */
  58107. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  58108. /**
  58109. * constructs a new anchor system
  58110. * @param _xrSessionManager an instance of WebXRSessionManager
  58111. * @param _options configuration object for this feature
  58112. */
  58113. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  58114. /**
  58115. * Get the snapPointsOnly flag
  58116. */
  58117. get snapPointsOnly(): boolean;
  58118. /**
  58119. * Sets the snapPointsOnly flag
  58120. * @param snapToPoints should teleportation be exclusively to snap points
  58121. */
  58122. set snapPointsOnly(snapToPoints: boolean);
  58123. /**
  58124. * Add a new mesh to the floor meshes array
  58125. * @param mesh the mesh to use as floor mesh
  58126. */
  58127. addFloorMesh(mesh: AbstractMesh): void;
  58128. /**
  58129. * Add a new snap-to point to fix teleportation to this position
  58130. * @param newSnapPoint The new Snap-To point
  58131. */
  58132. addSnapPoint(newSnapPoint: Vector3): void;
  58133. attach(): boolean;
  58134. detach(): boolean;
  58135. dispose(): void;
  58136. /**
  58137. * Remove a mesh from the floor meshes array
  58138. * @param mesh the mesh to remove
  58139. */
  58140. removeFloorMesh(mesh: AbstractMesh): void;
  58141. /**
  58142. * Remove a mesh from the floor meshes array using its name
  58143. * @param name the mesh name to remove
  58144. */
  58145. removeFloorMeshByName(name: string): void;
  58146. /**
  58147. * 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
  58148. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  58149. * @returns was the point found and removed or not
  58150. */
  58151. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  58152. /**
  58153. * This function sets a selection feature that will be disabled when
  58154. * the forward ray is shown and will be reattached when hidden.
  58155. * This is used to remove the selection rays when moving.
  58156. * @param selectionFeature the feature to disable when forward movement is enabled
  58157. */
  58158. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  58159. protected _onXRFrame(_xrFrame: XRFrame): void;
  58160. private _attachController;
  58161. private _createDefaultTargetMesh;
  58162. private _detachController;
  58163. private _findClosestSnapPointWithRadius;
  58164. private _setTargetMeshPosition;
  58165. private _setTargetMeshVisibility;
  58166. private _showParabolicPath;
  58167. private _teleportForward;
  58168. }
  58169. }
  58170. declare module "babylonjs/XR/webXRDefaultExperience" {
  58171. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  58172. import { Scene } from "babylonjs/scene";
  58173. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  58174. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  58175. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  58176. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  58177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58178. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  58179. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  58180. /**
  58181. * Options for the default xr helper
  58182. */
  58183. export class WebXRDefaultExperienceOptions {
  58184. /**
  58185. * Enable or disable default UI to enter XR
  58186. */
  58187. disableDefaultUI?: boolean;
  58188. /**
  58189. * Should teleportation not initialize. defaults to false.
  58190. */
  58191. disableTeleportation?: boolean;
  58192. /**
  58193. * Floor meshes that will be used for teleport
  58194. */
  58195. floorMeshes?: Array<AbstractMesh>;
  58196. /**
  58197. * If set to true, the first frame will not be used to reset position
  58198. * The first frame is mainly used when copying transformation from the old camera
  58199. * Mainly used in AR
  58200. */
  58201. ignoreNativeCameraTransformation?: boolean;
  58202. /**
  58203. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  58204. */
  58205. inputOptions?: IWebXRInputOptions;
  58206. /**
  58207. * optional configuration for the output canvas
  58208. */
  58209. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  58210. /**
  58211. * optional UI options. This can be used among other to change session mode and reference space type
  58212. */
  58213. uiOptions?: WebXREnterExitUIOptions;
  58214. /**
  58215. * When loading teleportation and pointer select, use stable versions instead of latest.
  58216. */
  58217. useStablePlugins?: boolean;
  58218. /**
  58219. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  58220. */
  58221. renderingGroupId?: number;
  58222. /**
  58223. * A list of optional features to init the session with
  58224. * If set to true, all features we support will be added
  58225. */
  58226. optionalFeatures?: boolean | string[];
  58227. }
  58228. /**
  58229. * Default experience which provides a similar setup to the previous webVRExperience
  58230. */
  58231. export class WebXRDefaultExperience {
  58232. /**
  58233. * Base experience
  58234. */
  58235. baseExperience: WebXRExperienceHelper;
  58236. /**
  58237. * Enables ui for entering/exiting xr
  58238. */
  58239. enterExitUI: WebXREnterExitUI;
  58240. /**
  58241. * Input experience extension
  58242. */
  58243. input: WebXRInput;
  58244. /**
  58245. * Enables laser pointer and selection
  58246. */
  58247. pointerSelection: WebXRControllerPointerSelection;
  58248. /**
  58249. * Default target xr should render to
  58250. */
  58251. renderTarget: WebXRRenderTarget;
  58252. /**
  58253. * Enables teleportation
  58254. */
  58255. teleportation: WebXRMotionControllerTeleportation;
  58256. private constructor();
  58257. /**
  58258. * Creates the default xr experience
  58259. * @param scene scene
  58260. * @param options options for basic configuration
  58261. * @returns resulting WebXRDefaultExperience
  58262. */
  58263. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  58264. /**
  58265. * DIsposes of the experience helper
  58266. */
  58267. dispose(): void;
  58268. }
  58269. }
  58270. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  58271. import { Observable } from "babylonjs/Misc/observable";
  58272. import { Nullable } from "babylonjs/types";
  58273. import { Camera } from "babylonjs/Cameras/camera";
  58274. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  58275. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  58276. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  58277. import { Scene } from "babylonjs/scene";
  58278. import { Vector3 } from "babylonjs/Maths/math.vector";
  58279. import { Color3 } from "babylonjs/Maths/math.color";
  58280. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58281. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58282. import { Mesh } from "babylonjs/Meshes/mesh";
  58283. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  58284. import { EasingFunction } from "babylonjs/Animations/easing";
  58285. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  58286. import "babylonjs/Meshes/Builders/groundBuilder";
  58287. import "babylonjs/Meshes/Builders/torusBuilder";
  58288. import "babylonjs/Meshes/Builders/cylinderBuilder";
  58289. import "babylonjs/Gamepads/gamepadSceneComponent";
  58290. import "babylonjs/Animations/animatable";
  58291. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  58292. /**
  58293. * Options to modify the vr teleportation behavior.
  58294. */
  58295. export interface VRTeleportationOptions {
  58296. /**
  58297. * The name of the mesh which should be used as the teleportation floor. (default: null)
  58298. */
  58299. floorMeshName?: string;
  58300. /**
  58301. * A list of meshes to be used as the teleportation floor. (default: empty)
  58302. */
  58303. floorMeshes?: Mesh[];
  58304. /**
  58305. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  58306. */
  58307. teleportationMode?: number;
  58308. /**
  58309. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  58310. */
  58311. teleportationTime?: number;
  58312. /**
  58313. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  58314. */
  58315. teleportationSpeed?: number;
  58316. /**
  58317. * The easing function used in the animation or null for Linear. (default CircleEase)
  58318. */
  58319. easingFunction?: EasingFunction;
  58320. }
  58321. /**
  58322. * Options to modify the vr experience helper's behavior.
  58323. */
  58324. export interface VRExperienceHelperOptions extends WebVROptions {
  58325. /**
  58326. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  58327. */
  58328. createDeviceOrientationCamera?: boolean;
  58329. /**
  58330. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  58331. */
  58332. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  58333. /**
  58334. * Uses the main button on the controller to toggle the laser casted. (default: true)
  58335. */
  58336. laserToggle?: boolean;
  58337. /**
  58338. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  58339. */
  58340. floorMeshes?: Mesh[];
  58341. /**
  58342. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  58343. */
  58344. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  58345. /**
  58346. * Defines if WebXR should be used instead of WebVR (if available)
  58347. */
  58348. useXR?: boolean;
  58349. }
  58350. /**
  58351. * Event containing information after VR has been entered
  58352. */
  58353. export class OnAfterEnteringVRObservableEvent {
  58354. /**
  58355. * If entering vr was successful
  58356. */
  58357. success: boolean;
  58358. }
  58359. /**
  58360. * Helps to quickly add VR support to an existing scene.
  58361. * See https://doc.babylonjs.com/how_to/webvr_helper
  58362. */
  58363. export class VRExperienceHelper {
  58364. /** Options to modify the vr experience helper's behavior. */
  58365. webVROptions: VRExperienceHelperOptions;
  58366. private _scene;
  58367. private _position;
  58368. private _btnVR;
  58369. private _btnVRDisplayed;
  58370. private _webVRsupported;
  58371. private _webVRready;
  58372. private _webVRrequesting;
  58373. private _webVRpresenting;
  58374. private _hasEnteredVR;
  58375. private _fullscreenVRpresenting;
  58376. private _inputElement;
  58377. private _webVRCamera;
  58378. private _vrDeviceOrientationCamera;
  58379. private _deviceOrientationCamera;
  58380. private _existingCamera;
  58381. private _onKeyDown;
  58382. private _onVrDisplayPresentChange;
  58383. private _onVRDisplayChanged;
  58384. private _onVRRequestPresentStart;
  58385. private _onVRRequestPresentComplete;
  58386. /**
  58387. * 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)
  58388. */
  58389. enableGazeEvenWhenNoPointerLock: boolean;
  58390. /**
  58391. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  58392. */
  58393. exitVROnDoubleTap: boolean;
  58394. /**
  58395. * Observable raised right before entering VR.
  58396. */
  58397. onEnteringVRObservable: Observable<VRExperienceHelper>;
  58398. /**
  58399. * Observable raised when entering VR has completed.
  58400. */
  58401. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  58402. /**
  58403. * Observable raised when exiting VR.
  58404. */
  58405. onExitingVRObservable: Observable<VRExperienceHelper>;
  58406. /**
  58407. * Observable raised when controller mesh is loaded.
  58408. */
  58409. onControllerMeshLoadedObservable: Observable<WebVRController>;
  58410. /** Return this.onEnteringVRObservable
  58411. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  58412. */
  58413. get onEnteringVR(): Observable<VRExperienceHelper>;
  58414. /** Return this.onExitingVRObservable
  58415. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  58416. */
  58417. get onExitingVR(): Observable<VRExperienceHelper>;
  58418. /** Return this.onControllerMeshLoadedObservable
  58419. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  58420. */
  58421. get onControllerMeshLoaded(): Observable<WebVRController>;
  58422. private _rayLength;
  58423. private _useCustomVRButton;
  58424. private _teleportationRequested;
  58425. private _teleportActive;
  58426. private _floorMeshName;
  58427. private _floorMeshesCollection;
  58428. private _teleportationMode;
  58429. private _teleportationTime;
  58430. private _teleportationSpeed;
  58431. private _teleportationEasing;
  58432. private _rotationAllowed;
  58433. private _teleportBackwardsVector;
  58434. private _teleportationTarget;
  58435. private _isDefaultTeleportationTarget;
  58436. private _postProcessMove;
  58437. private _teleportationFillColor;
  58438. private _teleportationBorderColor;
  58439. private _rotationAngle;
  58440. private _haloCenter;
  58441. private _cameraGazer;
  58442. private _padSensibilityUp;
  58443. private _padSensibilityDown;
  58444. private _leftController;
  58445. private _rightController;
  58446. private _gazeColor;
  58447. private _laserColor;
  58448. private _pickedLaserColor;
  58449. private _pickedGazeColor;
  58450. /**
  58451. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  58452. */
  58453. onNewMeshSelected: Observable<AbstractMesh>;
  58454. /**
  58455. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  58456. * This observable will provide the mesh and the controller used to select the mesh
  58457. */
  58458. onMeshSelectedWithController: Observable<{
  58459. mesh: AbstractMesh;
  58460. controller: WebVRController;
  58461. }>;
  58462. /**
  58463. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  58464. */
  58465. onNewMeshPicked: Observable<PickingInfo>;
  58466. private _circleEase;
  58467. /**
  58468. * Observable raised before camera teleportation
  58469. */
  58470. onBeforeCameraTeleport: Observable<Vector3>;
  58471. /**
  58472. * Observable raised after camera teleportation
  58473. */
  58474. onAfterCameraTeleport: Observable<Vector3>;
  58475. /**
  58476. * Observable raised when current selected mesh gets unselected
  58477. */
  58478. onSelectedMeshUnselected: Observable<AbstractMesh>;
  58479. private _raySelectionPredicate;
  58480. /**
  58481. * To be optionaly changed by user to define custom ray selection
  58482. */
  58483. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  58484. /**
  58485. * To be optionaly changed by user to define custom selection logic (after ray selection)
  58486. */
  58487. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  58488. /**
  58489. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  58490. */
  58491. teleportationEnabled: boolean;
  58492. private _defaultHeight;
  58493. private _teleportationInitialized;
  58494. private _interactionsEnabled;
  58495. private _interactionsRequested;
  58496. private _displayGaze;
  58497. private _displayLaserPointer;
  58498. /**
  58499. * The mesh used to display where the user is going to teleport.
  58500. */
  58501. get teleportationTarget(): Mesh;
  58502. /**
  58503. * Sets the mesh to be used to display where the user is going to teleport.
  58504. */
  58505. set teleportationTarget(value: Mesh);
  58506. /**
  58507. * 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
  58508. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  58509. * See https://doc.babylonjs.com/resources/baking_transformations
  58510. */
  58511. get gazeTrackerMesh(): Mesh;
  58512. set gazeTrackerMesh(value: Mesh);
  58513. /**
  58514. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  58515. */
  58516. updateGazeTrackerScale: boolean;
  58517. /**
  58518. * If the gaze trackers color should be updated when selecting meshes
  58519. */
  58520. updateGazeTrackerColor: boolean;
  58521. /**
  58522. * If the controller laser color should be updated when selecting meshes
  58523. */
  58524. updateControllerLaserColor: boolean;
  58525. /**
  58526. * The gaze tracking mesh corresponding to the left controller
  58527. */
  58528. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  58529. /**
  58530. * The gaze tracking mesh corresponding to the right controller
  58531. */
  58532. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  58533. /**
  58534. * If the ray of the gaze should be displayed.
  58535. */
  58536. get displayGaze(): boolean;
  58537. /**
  58538. * Sets if the ray of the gaze should be displayed.
  58539. */
  58540. set displayGaze(value: boolean);
  58541. /**
  58542. * If the ray of the LaserPointer should be displayed.
  58543. */
  58544. get displayLaserPointer(): boolean;
  58545. /**
  58546. * Sets if the ray of the LaserPointer should be displayed.
  58547. */
  58548. set displayLaserPointer(value: boolean);
  58549. /**
  58550. * The deviceOrientationCamera used as the camera when not in VR.
  58551. */
  58552. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  58553. /**
  58554. * Based on the current WebVR support, returns the current VR camera used.
  58555. */
  58556. get currentVRCamera(): Nullable<Camera>;
  58557. /**
  58558. * The webVRCamera which is used when in VR.
  58559. */
  58560. get webVRCamera(): WebVRFreeCamera;
  58561. /**
  58562. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  58563. */
  58564. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  58565. /**
  58566. * The html button that is used to trigger entering into VR.
  58567. */
  58568. get vrButton(): Nullable<HTMLButtonElement>;
  58569. private get _teleportationRequestInitiated();
  58570. /**
  58571. * Defines whether or not Pointer lock should be requested when switching to
  58572. * full screen.
  58573. */
  58574. requestPointerLockOnFullScreen: boolean;
  58575. /**
  58576. * If asking to force XR, this will be populated with the default xr experience
  58577. */
  58578. xr: WebXRDefaultExperience;
  58579. /**
  58580. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  58581. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  58582. */
  58583. xrTestDone: boolean;
  58584. /**
  58585. * Instantiates a VRExperienceHelper.
  58586. * Helps to quickly add VR support to an existing scene.
  58587. * @param scene The scene the VRExperienceHelper belongs to.
  58588. * @param webVROptions Options to modify the vr experience helper's behavior.
  58589. */
  58590. constructor(scene: Scene,
  58591. /** Options to modify the vr experience helper's behavior. */
  58592. webVROptions?: VRExperienceHelperOptions);
  58593. private completeVRInit;
  58594. private _onDefaultMeshLoaded;
  58595. private _onResize;
  58596. private _onFullscreenChange;
  58597. /**
  58598. * Gets a value indicating if we are currently in VR mode.
  58599. */
  58600. get isInVRMode(): boolean;
  58601. private onVrDisplayPresentChange;
  58602. private onVRDisplayChanged;
  58603. private moveButtonToBottomRight;
  58604. private displayVRButton;
  58605. private updateButtonVisibility;
  58606. private _cachedAngularSensibility;
  58607. /**
  58608. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  58609. * Otherwise, will use the fullscreen API.
  58610. */
  58611. enterVR(): void;
  58612. /**
  58613. * Attempt to exit VR, or fullscreen.
  58614. */
  58615. exitVR(): void;
  58616. /**
  58617. * The position of the vr experience helper.
  58618. */
  58619. get position(): Vector3;
  58620. /**
  58621. * Sets the position of the vr experience helper.
  58622. */
  58623. set position(value: Vector3);
  58624. /**
  58625. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  58626. */
  58627. enableInteractions(): void;
  58628. private get _noControllerIsActive();
  58629. private beforeRender;
  58630. private _isTeleportationFloor;
  58631. /**
  58632. * Adds a floor mesh to be used for teleportation.
  58633. * @param floorMesh the mesh to be used for teleportation.
  58634. */
  58635. addFloorMesh(floorMesh: Mesh): void;
  58636. /**
  58637. * Removes a floor mesh from being used for teleportation.
  58638. * @param floorMesh the mesh to be removed.
  58639. */
  58640. removeFloorMesh(floorMesh: Mesh): void;
  58641. /**
  58642. * Enables interactions and teleportation using the VR controllers and gaze.
  58643. * @param vrTeleportationOptions options to modify teleportation behavior.
  58644. */
  58645. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  58646. private _onNewGamepadConnected;
  58647. private _tryEnableInteractionOnController;
  58648. private _onNewGamepadDisconnected;
  58649. private _enableInteractionOnController;
  58650. private _checkTeleportWithRay;
  58651. private _checkRotate;
  58652. private _checkTeleportBackwards;
  58653. private _enableTeleportationOnController;
  58654. private _createTeleportationCircles;
  58655. private _displayTeleportationTarget;
  58656. private _hideTeleportationTarget;
  58657. private _rotateCamera;
  58658. private _moveTeleportationSelectorTo;
  58659. private _workingVector;
  58660. private _workingQuaternion;
  58661. private _workingMatrix;
  58662. /**
  58663. * Time Constant Teleportation Mode
  58664. */
  58665. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  58666. /**
  58667. * Speed Constant Teleportation Mode
  58668. */
  58669. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  58670. /**
  58671. * Teleports the users feet to the desired location
  58672. * @param location The location where the user's feet should be placed
  58673. */
  58674. teleportCamera(location: Vector3): void;
  58675. private _convertNormalToDirectionOfRay;
  58676. private _castRayAndSelectObject;
  58677. private _notifySelectedMeshUnselected;
  58678. /**
  58679. * Permanently set new colors for the laser pointer
  58680. * @param color the new laser color
  58681. * @param pickedColor the new laser color when picked mesh detected
  58682. */
  58683. setLaserColor(color: Color3, pickedColor?: Color3): void;
  58684. /**
  58685. * Set lighting enabled / disabled on the laser pointer of both controllers
  58686. * @param enabled should the lighting be enabled on the laser pointer
  58687. */
  58688. setLaserLightingState(enabled?: boolean): void;
  58689. /**
  58690. * Permanently set new colors for the gaze pointer
  58691. * @param color the new gaze color
  58692. * @param pickedColor the new gaze color when picked mesh detected
  58693. */
  58694. setGazeColor(color: Color3, pickedColor?: Color3): void;
  58695. /**
  58696. * Sets the color of the laser ray from the vr controllers.
  58697. * @param color new color for the ray.
  58698. */
  58699. changeLaserColor(color: Color3): void;
  58700. /**
  58701. * Sets the color of the ray from the vr headsets gaze.
  58702. * @param color new color for the ray.
  58703. */
  58704. changeGazeColor(color: Color3): void;
  58705. /**
  58706. * Exits VR and disposes of the vr experience helper
  58707. */
  58708. dispose(): void;
  58709. /**
  58710. * Gets the name of the VRExperienceHelper class
  58711. * @returns "VRExperienceHelper"
  58712. */
  58713. getClassName(): string;
  58714. }
  58715. }
  58716. declare module "babylonjs/Cameras/VR/index" {
  58717. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  58718. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  58719. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  58720. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  58721. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  58722. export * from "babylonjs/Cameras/VR/webVRCamera";
  58723. }
  58724. declare module "babylonjs/Cameras/RigModes/index" {
  58725. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  58726. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  58727. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  58728. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  58729. }
  58730. declare module "babylonjs/Cameras/index" {
  58731. export * from "babylonjs/Cameras/Inputs/index";
  58732. export * from "babylonjs/Cameras/cameraInputsManager";
  58733. export * from "babylonjs/Cameras/camera";
  58734. export * from "babylonjs/Cameras/targetCamera";
  58735. export * from "babylonjs/Cameras/freeCamera";
  58736. export * from "babylonjs/Cameras/freeCameraInputsManager";
  58737. export * from "babylonjs/Cameras/touchCamera";
  58738. export * from "babylonjs/Cameras/arcRotateCamera";
  58739. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  58740. export * from "babylonjs/Cameras/deviceOrientationCamera";
  58741. export * from "babylonjs/Cameras/flyCamera";
  58742. export * from "babylonjs/Cameras/flyCameraInputsManager";
  58743. export * from "babylonjs/Cameras/followCamera";
  58744. export * from "babylonjs/Cameras/followCameraInputsManager";
  58745. export * from "babylonjs/Cameras/gamepadCamera";
  58746. export * from "babylonjs/Cameras/Stereoscopic/index";
  58747. export * from "babylonjs/Cameras/universalCamera";
  58748. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  58749. export * from "babylonjs/Cameras/VR/index";
  58750. export * from "babylonjs/Cameras/RigModes/index";
  58751. }
  58752. declare module "babylonjs/Collisions/index" {
  58753. export * from "babylonjs/Collisions/collider";
  58754. export * from "babylonjs/Collisions/collisionCoordinator";
  58755. export * from "babylonjs/Collisions/pickingInfo";
  58756. export * from "babylonjs/Collisions/intersectionInfo";
  58757. export * from "babylonjs/Collisions/meshCollisionData";
  58758. }
  58759. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  58760. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  58761. import { Vector3 } from "babylonjs/Maths/math.vector";
  58762. import { Ray } from "babylonjs/Culling/ray";
  58763. import { Plane } from "babylonjs/Maths/math.plane";
  58764. /**
  58765. * Contains an array of blocks representing the octree
  58766. */
  58767. export interface IOctreeContainer<T> {
  58768. /**
  58769. * Blocks within the octree
  58770. */
  58771. blocks: Array<OctreeBlock<T>>;
  58772. }
  58773. /**
  58774. * Class used to store a cell in an octree
  58775. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  58776. */
  58777. export class OctreeBlock<T> {
  58778. /**
  58779. * Gets the content of the current block
  58780. */
  58781. entries: T[];
  58782. /**
  58783. * Gets the list of block children
  58784. */
  58785. blocks: Array<OctreeBlock<T>>;
  58786. private _depth;
  58787. private _maxDepth;
  58788. private _capacity;
  58789. private _minPoint;
  58790. private _maxPoint;
  58791. private _boundingVectors;
  58792. private _creationFunc;
  58793. /**
  58794. * Creates a new block
  58795. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  58796. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  58797. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  58798. * @param depth defines the current depth of this block in the octree
  58799. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  58800. * @param creationFunc defines a callback to call when an element is added to the block
  58801. */
  58802. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  58803. /**
  58804. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  58805. */
  58806. get capacity(): number;
  58807. /**
  58808. * Gets the minimum vector (in world space) of the block's bounding box
  58809. */
  58810. get minPoint(): Vector3;
  58811. /**
  58812. * Gets the maximum vector (in world space) of the block's bounding box
  58813. */
  58814. get maxPoint(): Vector3;
  58815. /**
  58816. * Add a new element to this block
  58817. * @param entry defines the element to add
  58818. */
  58819. addEntry(entry: T): void;
  58820. /**
  58821. * Remove an element from this block
  58822. * @param entry defines the element to remove
  58823. */
  58824. removeEntry(entry: T): void;
  58825. /**
  58826. * Add an array of elements to this block
  58827. * @param entries defines the array of elements to add
  58828. */
  58829. addEntries(entries: T[]): void;
  58830. /**
  58831. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  58832. * @param frustumPlanes defines the frustum planes to test
  58833. * @param selection defines the array to store current content if selection is positive
  58834. * @param allowDuplicate defines if the selection array can contains duplicated entries
  58835. */
  58836. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  58837. /**
  58838. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  58839. * @param sphereCenter defines the bounding sphere center
  58840. * @param sphereRadius defines the bounding sphere radius
  58841. * @param selection defines the array to store current content if selection is positive
  58842. * @param allowDuplicate defines if the selection array can contains duplicated entries
  58843. */
  58844. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  58845. /**
  58846. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  58847. * @param ray defines the ray to test with
  58848. * @param selection defines the array to store current content if selection is positive
  58849. */
  58850. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  58851. /**
  58852. * Subdivide the content into child blocks (this block will then be empty)
  58853. */
  58854. createInnerBlocks(): void;
  58855. /**
  58856. * @hidden
  58857. */
  58858. 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;
  58859. }
  58860. }
  58861. declare module "babylonjs/Culling/Octrees/octree" {
  58862. import { SmartArray } from "babylonjs/Misc/smartArray";
  58863. import { Vector3 } from "babylonjs/Maths/math.vector";
  58864. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58865. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58866. import { Ray } from "babylonjs/Culling/ray";
  58867. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  58868. import { Plane } from "babylonjs/Maths/math.plane";
  58869. /**
  58870. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  58871. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  58872. */
  58873. export class Octree<T> {
  58874. /** 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.) */
  58875. maxDepth: number;
  58876. /**
  58877. * Blocks within the octree containing objects
  58878. */
  58879. blocks: Array<OctreeBlock<T>>;
  58880. /**
  58881. * Content stored in the octree
  58882. */
  58883. dynamicContent: T[];
  58884. private _maxBlockCapacity;
  58885. private _selectionContent;
  58886. private _creationFunc;
  58887. /**
  58888. * Creates a octree
  58889. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  58890. * @param creationFunc function to be used to instatiate the octree
  58891. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  58892. * @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.)
  58893. */
  58894. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  58895. /** 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.) */
  58896. maxDepth?: number);
  58897. /**
  58898. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  58899. * @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);
  58900. * @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);
  58901. * @param entries meshes to be added to the octree blocks
  58902. */
  58903. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  58904. /**
  58905. * Adds a mesh to the octree
  58906. * @param entry Mesh to add to the octree
  58907. */
  58908. addMesh(entry: T): void;
  58909. /**
  58910. * Remove an element from the octree
  58911. * @param entry defines the element to remove
  58912. */
  58913. removeMesh(entry: T): void;
  58914. /**
  58915. * Selects an array of meshes within the frustum
  58916. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  58917. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  58918. * @returns array of meshes within the frustum
  58919. */
  58920. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  58921. /**
  58922. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  58923. * @param sphereCenter defines the bounding sphere center
  58924. * @param sphereRadius defines the bounding sphere radius
  58925. * @param allowDuplicate defines if the selection array can contains duplicated entries
  58926. * @returns an array of objects that intersect the sphere
  58927. */
  58928. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  58929. /**
  58930. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  58931. * @param ray defines the ray to test with
  58932. * @returns array of intersected objects
  58933. */
  58934. intersectsRay(ray: Ray): SmartArray<T>;
  58935. /**
  58936. * Adds a mesh into the octree block if it intersects the block
  58937. */
  58938. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  58939. /**
  58940. * Adds a submesh into the octree block if it intersects the block
  58941. */
  58942. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  58943. }
  58944. }
  58945. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  58946. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  58947. import { Scene } from "babylonjs/scene";
  58948. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58949. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58950. import { Ray } from "babylonjs/Culling/ray";
  58951. import { Octree } from "babylonjs/Culling/Octrees/octree";
  58952. import { Collider } from "babylonjs/Collisions/collider";
  58953. module "babylonjs/scene" {
  58954. interface Scene {
  58955. /**
  58956. * @hidden
  58957. * Backing Filed
  58958. */
  58959. _selectionOctree: Octree<AbstractMesh>;
  58960. /**
  58961. * Gets the octree used to boost mesh selection (picking)
  58962. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  58963. */
  58964. selectionOctree: Octree<AbstractMesh>;
  58965. /**
  58966. * Creates or updates the octree used to boost selection (picking)
  58967. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  58968. * @param maxCapacity defines the maximum capacity per leaf
  58969. * @param maxDepth defines the maximum depth of the octree
  58970. * @returns an octree of AbstractMesh
  58971. */
  58972. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  58973. }
  58974. }
  58975. module "babylonjs/Meshes/abstractMesh" {
  58976. interface AbstractMesh {
  58977. /**
  58978. * @hidden
  58979. * Backing Field
  58980. */
  58981. _submeshesOctree: Octree<SubMesh>;
  58982. /**
  58983. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  58984. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  58985. * @param maxCapacity defines the maximum size of each block (64 by default)
  58986. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  58987. * @returns the new octree
  58988. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  58989. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  58990. */
  58991. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  58992. }
  58993. }
  58994. /**
  58995. * Defines the octree scene component responsible to manage any octrees
  58996. * in a given scene.
  58997. */
  58998. export class OctreeSceneComponent {
  58999. /**
  59000. * The component name help to identify the component in the list of scene components.
  59001. */
  59002. readonly name: string;
  59003. /**
  59004. * The scene the component belongs to.
  59005. */
  59006. scene: Scene;
  59007. /**
  59008. * Indicates if the meshes have been checked to make sure they are isEnabled()
  59009. */
  59010. readonly checksIsEnabled: boolean;
  59011. /**
  59012. * Creates a new instance of the component for the given scene
  59013. * @param scene Defines the scene to register the component in
  59014. */
  59015. constructor(scene: Scene);
  59016. /**
  59017. * Registers the component in a given scene
  59018. */
  59019. register(): void;
  59020. /**
  59021. * Return the list of active meshes
  59022. * @returns the list of active meshes
  59023. */
  59024. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  59025. /**
  59026. * Return the list of active sub meshes
  59027. * @param mesh The mesh to get the candidates sub meshes from
  59028. * @returns the list of active sub meshes
  59029. */
  59030. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  59031. private _tempRay;
  59032. /**
  59033. * Return the list of sub meshes intersecting with a given local ray
  59034. * @param mesh defines the mesh to find the submesh for
  59035. * @param localRay defines the ray in local space
  59036. * @returns the list of intersecting sub meshes
  59037. */
  59038. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  59039. /**
  59040. * Return the list of sub meshes colliding with a collider
  59041. * @param mesh defines the mesh to find the submesh for
  59042. * @param collider defines the collider to evaluate the collision against
  59043. * @returns the list of colliding sub meshes
  59044. */
  59045. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  59046. /**
  59047. * Rebuilds the elements related to this component in case of
  59048. * context lost for instance.
  59049. */
  59050. rebuild(): void;
  59051. /**
  59052. * Disposes the component and the associated ressources.
  59053. */
  59054. dispose(): void;
  59055. }
  59056. }
  59057. declare module "babylonjs/Culling/Octrees/index" {
  59058. export * from "babylonjs/Culling/Octrees/octree";
  59059. export * from "babylonjs/Culling/Octrees/octreeBlock";
  59060. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  59061. }
  59062. declare module "babylonjs/Culling/index" {
  59063. export * from "babylonjs/Culling/boundingBox";
  59064. export * from "babylonjs/Culling/boundingInfo";
  59065. export * from "babylonjs/Culling/boundingSphere";
  59066. export * from "babylonjs/Culling/Octrees/index";
  59067. export * from "babylonjs/Culling/ray";
  59068. }
  59069. declare module "babylonjs/Gizmos/gizmo" {
  59070. import { Observer } from "babylonjs/Misc/observable";
  59071. import { Nullable } from "babylonjs/types";
  59072. import { IDisposable } from "babylonjs/scene";
  59073. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59074. import { Mesh } from "babylonjs/Meshes/mesh";
  59075. import { Node } from "babylonjs/node";
  59076. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59077. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  59078. import { PointerInfo } from "babylonjs/Events/pointerEvents";
  59079. /**
  59080. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  59081. */
  59082. export interface GizmoAxisCache {
  59083. /** Mesh used to runder the Gizmo */
  59084. gizmoMeshes: Mesh[];
  59085. /** Mesh used to detect user interaction with Gizmo */
  59086. colliderMeshes: Mesh[];
  59087. /** Material used to inicate color of gizmo mesh */
  59088. material: StandardMaterial;
  59089. /** Material used to inicate hover state of the Gizmo */
  59090. hoverMaterial: StandardMaterial;
  59091. /** Material used to inicate disabled state of the Gizmo */
  59092. disableMaterial: StandardMaterial;
  59093. /** Used to indicate Active state of the Gizmo */
  59094. active: boolean;
  59095. }
  59096. /**
  59097. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  59098. */
  59099. export class Gizmo implements IDisposable {
  59100. /** The utility layer the gizmo will be added to */
  59101. gizmoLayer: UtilityLayerRenderer;
  59102. /**
  59103. * The root mesh of the gizmo
  59104. */
  59105. _rootMesh: Mesh;
  59106. private _attachedMesh;
  59107. private _attachedNode;
  59108. /**
  59109. * Ratio for the scale of the gizmo (Default: 1)
  59110. */
  59111. protected _scaleRatio: number;
  59112. /**
  59113. * boolean updated by pointermove when a gizmo mesh is hovered
  59114. */
  59115. protected _isHovered: boolean;
  59116. /**
  59117. * Ratio for the scale of the gizmo (Default: 1)
  59118. */
  59119. set scaleRatio(value: number);
  59120. get scaleRatio(): number;
  59121. /**
  59122. * True when the mouse pointer is hovered a gizmo mesh
  59123. */
  59124. get isHovered(): boolean;
  59125. /**
  59126. * If a custom mesh has been set (Default: false)
  59127. */
  59128. protected _customMeshSet: boolean;
  59129. /**
  59130. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  59131. * * When set, interactions will be enabled
  59132. */
  59133. get attachedMesh(): Nullable<AbstractMesh>;
  59134. set attachedMesh(value: Nullable<AbstractMesh>);
  59135. /**
  59136. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  59137. * * When set, interactions will be enabled
  59138. */
  59139. get attachedNode(): Nullable<Node>;
  59140. set attachedNode(value: Nullable<Node>);
  59141. /**
  59142. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  59143. * @param mesh The mesh to replace the default mesh of the gizmo
  59144. */
  59145. setCustomMesh(mesh: Mesh): void;
  59146. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  59147. /**
  59148. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  59149. */
  59150. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  59151. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  59152. /**
  59153. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  59154. */
  59155. updateGizmoPositionToMatchAttachedMesh: boolean;
  59156. /**
  59157. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  59158. */
  59159. updateScale: boolean;
  59160. protected _interactionsEnabled: boolean;
  59161. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59162. private _beforeRenderObserver;
  59163. private _tempQuaternion;
  59164. private _tempVector;
  59165. private _tempVector2;
  59166. private _tempMatrix1;
  59167. private _tempMatrix2;
  59168. private _rightHandtoLeftHandMatrix;
  59169. /**
  59170. * Creates a gizmo
  59171. * @param gizmoLayer The utility layer the gizmo will be added to
  59172. */
  59173. constructor(
  59174. /** The utility layer the gizmo will be added to */
  59175. gizmoLayer?: UtilityLayerRenderer);
  59176. /**
  59177. * Updates the gizmo to match the attached mesh's position/rotation
  59178. */
  59179. protected _update(): void;
  59180. /**
  59181. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  59182. * @param value Node, TransformNode or mesh
  59183. */
  59184. protected _matrixChanged(): void;
  59185. /**
  59186. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  59187. * @param gizmoLayer The utility layer the gizmo will be added to
  59188. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  59189. * @returns {Observer<PointerInfo>} pointerObserver
  59190. */
  59191. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  59192. /**
  59193. * Disposes of the gizmo
  59194. */
  59195. dispose(): void;
  59196. }
  59197. }
  59198. declare module "babylonjs/Gizmos/planeDragGizmo" {
  59199. import { Observable } from "babylonjs/Misc/observable";
  59200. import { Nullable } from "babylonjs/types";
  59201. import { Vector3 } from "babylonjs/Maths/math.vector";
  59202. import { Color3 } from "babylonjs/Maths/math.color";
  59203. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59204. import { Node } from "babylonjs/node";
  59205. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  59206. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59207. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59208. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  59209. import { Scene } from "babylonjs/scene";
  59210. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  59211. /**
  59212. * Single plane drag gizmo
  59213. */
  59214. export class PlaneDragGizmo extends Gizmo {
  59215. /**
  59216. * Drag behavior responsible for the gizmos dragging interactions
  59217. */
  59218. dragBehavior: PointerDragBehavior;
  59219. private _pointerObserver;
  59220. /**
  59221. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59222. */
  59223. snapDistance: number;
  59224. /**
  59225. * Event that fires each time the gizmo snaps to a new location.
  59226. * * snapDistance is the the change in distance
  59227. */
  59228. onSnapObservable: Observable<{
  59229. snapDistance: number;
  59230. }>;
  59231. private _gizmoMesh;
  59232. private _coloredMaterial;
  59233. private _hoverMaterial;
  59234. private _disableMaterial;
  59235. private _isEnabled;
  59236. private _parent;
  59237. private _dragging;
  59238. /** @hidden */
  59239. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  59240. /**
  59241. * Creates a PlaneDragGizmo
  59242. * @param gizmoLayer The utility layer the gizmo will be added to
  59243. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  59244. * @param color The color of the gizmo
  59245. */
  59246. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  59247. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59248. /**
  59249. * If the gizmo is enabled
  59250. */
  59251. set isEnabled(value: boolean);
  59252. get isEnabled(): boolean;
  59253. /**
  59254. * Disposes of the gizmo
  59255. */
  59256. dispose(): void;
  59257. }
  59258. }
  59259. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  59260. import { Observable } from "babylonjs/Misc/observable";
  59261. import { Nullable } from "babylonjs/types";
  59262. import { Vector3 } from "babylonjs/Maths/math.vector";
  59263. import { Color3 } from "babylonjs/Maths/math.color";
  59264. import "babylonjs/Meshes/Builders/linesBuilder";
  59265. import { Node } from "babylonjs/node";
  59266. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  59267. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59268. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59269. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  59270. /**
  59271. * Single plane rotation gizmo
  59272. */
  59273. export class PlaneRotationGizmo extends Gizmo {
  59274. /**
  59275. * Drag behavior responsible for the gizmos dragging interactions
  59276. */
  59277. dragBehavior: PointerDragBehavior;
  59278. private _pointerObserver;
  59279. /**
  59280. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  59281. */
  59282. snapDistance: number;
  59283. /**
  59284. * Event that fires each time the gizmo snaps to a new location.
  59285. * * snapDistance is the the change in distance
  59286. */
  59287. onSnapObservable: Observable<{
  59288. snapDistance: number;
  59289. }>;
  59290. private _isEnabled;
  59291. private _parent;
  59292. private _coloredMaterial;
  59293. private _hoverMaterial;
  59294. private _disableMaterial;
  59295. private _gizmoMesh;
  59296. private _rotationCircle;
  59297. private _dragging;
  59298. private static _CircleConstants;
  59299. /**
  59300. * Creates a PlaneRotationGizmo
  59301. * @param gizmoLayer The utility layer the gizmo will be added to
  59302. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  59303. * @param color The color of the gizmo
  59304. * @param tessellation Amount of tessellation to be used when creating rotation circles
  59305. * @param useEulerRotation Use and update Euler angle instead of quaternion
  59306. * @param thickness display gizmo axis thickness
  59307. */
  59308. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  59309. /** Create Geometry for Gizmo */
  59310. private _createGizmoMesh;
  59311. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59312. private setupRotationCircle;
  59313. private updateRotationPath;
  59314. private updateRotationCircle;
  59315. /**
  59316. * If the gizmo is enabled
  59317. */
  59318. set isEnabled(value: boolean);
  59319. get isEnabled(): boolean;
  59320. /**
  59321. * Disposes of the gizmo
  59322. */
  59323. dispose(): void;
  59324. }
  59325. }
  59326. declare module "babylonjs/Gizmos/rotationGizmo" {
  59327. import { Observable } from "babylonjs/Misc/observable";
  59328. import { Nullable } from "babylonjs/types";
  59329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59330. import { Mesh } from "babylonjs/Meshes/mesh";
  59331. import { Gizmo, GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  59332. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  59333. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59334. import { Node } from "babylonjs/node";
  59335. import { GizmoManager } from "babylonjs/Gizmos/gizmoManager";
  59336. /**
  59337. * Gizmo that enables rotating a mesh along 3 axis
  59338. */
  59339. export class RotationGizmo extends Gizmo {
  59340. /**
  59341. * Internal gizmo used for interactions on the x axis
  59342. */
  59343. xGizmo: PlaneRotationGizmo;
  59344. /**
  59345. * Internal gizmo used for interactions on the y axis
  59346. */
  59347. yGizmo: PlaneRotationGizmo;
  59348. /**
  59349. * Internal gizmo used for interactions on the z axis
  59350. */
  59351. zGizmo: PlaneRotationGizmo;
  59352. /** Fires an event when any of it's sub gizmos are dragged */
  59353. onDragStartObservable: Observable<unknown>;
  59354. /** Fires an event when any of it's sub gizmos are released from dragging */
  59355. onDragEndObservable: Observable<unknown>;
  59356. private _meshAttached;
  59357. private _nodeAttached;
  59358. private _observables;
  59359. /** Node Caching for quick lookup */
  59360. private _gizmoAxisCache;
  59361. get attachedMesh(): Nullable<AbstractMesh>;
  59362. set attachedMesh(mesh: Nullable<AbstractMesh>);
  59363. get attachedNode(): Nullable<Node>;
  59364. set attachedNode(node: Nullable<Node>);
  59365. protected _checkBillboardTransform(): void;
  59366. /**
  59367. * True when the mouse pointer is hovering a gizmo mesh
  59368. */
  59369. get isHovered(): boolean;
  59370. /**
  59371. * Creates a RotationGizmo
  59372. * @param gizmoLayer The utility layer the gizmo will be added to
  59373. * @param tessellation Amount of tessellation to be used when creating rotation circles
  59374. * @param useEulerRotation Use and update Euler angle instead of quaternion
  59375. * @param thickness display gizmo axis thickness
  59376. */
  59377. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  59378. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  59379. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  59380. /**
  59381. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59382. */
  59383. set snapDistance(value: number);
  59384. get snapDistance(): number;
  59385. /**
  59386. * Ratio for the scale of the gizmo (Default: 1)
  59387. */
  59388. set scaleRatio(value: number);
  59389. get scaleRatio(): number;
  59390. /**
  59391. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  59392. * @param mesh Axis gizmo mesh
  59393. * @param cache Gizmo axis definition used for reactive gizmo UI
  59394. */
  59395. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  59396. /**
  59397. * Disposes of the gizmo
  59398. */
  59399. dispose(): void;
  59400. /**
  59401. * CustomMeshes are not supported by this gizmo
  59402. * @param mesh The mesh to replace the default mesh of the gizmo
  59403. */
  59404. setCustomMesh(mesh: Mesh): void;
  59405. }
  59406. }
  59407. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  59408. import { Scene } from "babylonjs/scene";
  59409. import { Vector4 } from "babylonjs/Maths/math.vector";
  59410. import { Color4 } from "babylonjs/Maths/math.color";
  59411. import { Mesh } from "babylonjs/Meshes/mesh";
  59412. import { Nullable } from "babylonjs/types";
  59413. /**
  59414. * Class containing static functions to help procedurally build meshes
  59415. */
  59416. export class PolyhedronBuilder {
  59417. /**
  59418. * Creates a polyhedron mesh
  59419. * * 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
  59420. * * The parameter `size` (positive float, default 1) sets the polygon size
  59421. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  59422. * * 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`
  59423. * * 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
  59424. * * 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)`)
  59425. * * 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
  59426. * * 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
  59427. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59428. * * 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
  59429. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59430. * @param name defines the name of the mesh
  59431. * @param options defines the options used to create the mesh
  59432. * @param scene defines the hosting scene
  59433. * @returns the polyhedron mesh
  59434. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  59435. */
  59436. static CreatePolyhedron(name: string, options: {
  59437. type?: number;
  59438. size?: number;
  59439. sizeX?: number;
  59440. sizeY?: number;
  59441. sizeZ?: number;
  59442. custom?: any;
  59443. faceUV?: Vector4[];
  59444. faceColors?: Color4[];
  59445. flat?: boolean;
  59446. updatable?: boolean;
  59447. sideOrientation?: number;
  59448. frontUVs?: Vector4;
  59449. backUVs?: Vector4;
  59450. }, scene?: Nullable<Scene>): Mesh;
  59451. }
  59452. }
  59453. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  59454. import { Nullable } from "babylonjs/types";
  59455. import { Scene } from "babylonjs/scene";
  59456. import { Vector4 } from "babylonjs/Maths/math.vector";
  59457. import { Color4 } from "babylonjs/Maths/math.color";
  59458. import { Mesh } from "babylonjs/Meshes/mesh";
  59459. /**
  59460. * Class containing static functions to help procedurally build meshes
  59461. */
  59462. export class BoxBuilder {
  59463. /**
  59464. * Creates a box mesh
  59465. * * The parameter `size` sets the size (float) of each box side (default 1)
  59466. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  59467. * * 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)
  59468. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59469. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59470. * * 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
  59471. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59472. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59473. * @param name defines the name of the mesh
  59474. * @param options defines the options used to create the mesh
  59475. * @param scene defines the hosting scene
  59476. * @returns the box mesh
  59477. */
  59478. static CreateBox(name: string, options: {
  59479. size?: number;
  59480. width?: number;
  59481. height?: number;
  59482. depth?: number;
  59483. faceUV?: Vector4[];
  59484. faceColors?: Color4[];
  59485. sideOrientation?: number;
  59486. frontUVs?: Vector4;
  59487. backUVs?: Vector4;
  59488. wrap?: boolean;
  59489. topBaseAt?: number;
  59490. bottomBaseAt?: number;
  59491. updatable?: boolean;
  59492. }, scene?: Nullable<Scene>): Mesh;
  59493. }
  59494. }
  59495. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  59496. import { Observable } from "babylonjs/Misc/observable";
  59497. import { Nullable } from "babylonjs/types";
  59498. import { Vector3 } from "babylonjs/Maths/math.vector";
  59499. import { Node } from "babylonjs/node";
  59500. import { Mesh } from "babylonjs/Meshes/mesh";
  59501. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  59502. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59503. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59504. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  59505. import { Color3 } from "babylonjs/Maths/math.color";
  59506. /**
  59507. * Single axis scale gizmo
  59508. */
  59509. export class AxisScaleGizmo extends Gizmo {
  59510. /**
  59511. * Drag behavior responsible for the gizmos dragging interactions
  59512. */
  59513. dragBehavior: PointerDragBehavior;
  59514. private _pointerObserver;
  59515. /**
  59516. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59517. */
  59518. snapDistance: number;
  59519. /**
  59520. * Event that fires each time the gizmo snaps to a new location.
  59521. * * snapDistance is the the change in distance
  59522. */
  59523. onSnapObservable: Observable<{
  59524. snapDistance: number;
  59525. }>;
  59526. /**
  59527. * If the scaling operation should be done on all axis (default: false)
  59528. */
  59529. uniformScaling: boolean;
  59530. /**
  59531. * Custom sensitivity value for the drag strength
  59532. */
  59533. sensitivity: number;
  59534. private _isEnabled;
  59535. private _parent;
  59536. private _gizmoMesh;
  59537. private _coloredMaterial;
  59538. private _hoverMaterial;
  59539. private _disableMaterial;
  59540. private _dragging;
  59541. private _tmpVector;
  59542. private _tmpMatrix;
  59543. private _tmpMatrix2;
  59544. /**
  59545. * Creates an AxisScaleGizmo
  59546. * @param gizmoLayer The utility layer the gizmo will be added to
  59547. * @param dragAxis The axis which the gizmo will be able to scale on
  59548. * @param color The color of the gizmo
  59549. * @param thickness display gizmo axis thickness
  59550. */
  59551. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  59552. /** Create Geometry for Gizmo */
  59553. private _createGizmoMesh;
  59554. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59555. /**
  59556. * If the gizmo is enabled
  59557. */
  59558. set isEnabled(value: boolean);
  59559. get isEnabled(): boolean;
  59560. /**
  59561. * Disposes of the gizmo
  59562. */
  59563. dispose(): void;
  59564. /**
  59565. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  59566. * @param mesh The mesh to replace the default mesh of the gizmo
  59567. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  59568. */
  59569. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  59570. }
  59571. }
  59572. declare module "babylonjs/Gizmos/scaleGizmo" {
  59573. import { Observable } from "babylonjs/Misc/observable";
  59574. import { Nullable } from "babylonjs/types";
  59575. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59576. import { Gizmo, GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  59577. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  59578. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59579. import { Mesh } from "babylonjs/Meshes/mesh";
  59580. import { Node } from "babylonjs/node";
  59581. import { GizmoManager } from "babylonjs/Gizmos/gizmoManager";
  59582. /**
  59583. * Gizmo that enables scaling a mesh along 3 axis
  59584. */
  59585. export class ScaleGizmo extends Gizmo {
  59586. /**
  59587. * Internal gizmo used for interactions on the x axis
  59588. */
  59589. xGizmo: AxisScaleGizmo;
  59590. /**
  59591. * Internal gizmo used for interactions on the y axis
  59592. */
  59593. yGizmo: AxisScaleGizmo;
  59594. /**
  59595. * Internal gizmo used for interactions on the z axis
  59596. */
  59597. zGizmo: AxisScaleGizmo;
  59598. /**
  59599. * Internal gizmo used to scale all axis equally
  59600. */
  59601. uniformScaleGizmo: AxisScaleGizmo;
  59602. private _meshAttached;
  59603. private _nodeAttached;
  59604. private _snapDistance;
  59605. private _uniformScalingMesh;
  59606. private _octahedron;
  59607. private _sensitivity;
  59608. private _coloredMaterial;
  59609. private _hoverMaterial;
  59610. private _disableMaterial;
  59611. private _observables;
  59612. /** Node Caching for quick lookup */
  59613. private _gizmoAxisCache;
  59614. /** Fires an event when any of it's sub gizmos are dragged */
  59615. onDragStartObservable: Observable<unknown>;
  59616. /** Fires an event when any of it's sub gizmos are released from dragging */
  59617. onDragEndObservable: Observable<unknown>;
  59618. get attachedMesh(): Nullable<AbstractMesh>;
  59619. set attachedMesh(mesh: Nullable<AbstractMesh>);
  59620. get attachedNode(): Nullable<Node>;
  59621. set attachedNode(node: Nullable<Node>);
  59622. /**
  59623. * True when the mouse pointer is hovering a gizmo mesh
  59624. */
  59625. get isHovered(): boolean;
  59626. /**
  59627. * Creates a ScaleGizmo
  59628. * @param gizmoLayer The utility layer the gizmo will be added to
  59629. * @param thickness display gizmo axis thickness
  59630. */
  59631. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  59632. /** Create Geometry for Gizmo */
  59633. private _createUniformScaleMesh;
  59634. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  59635. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  59636. /**
  59637. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59638. */
  59639. set snapDistance(value: number);
  59640. get snapDistance(): number;
  59641. /**
  59642. * Ratio for the scale of the gizmo (Default: 1)
  59643. */
  59644. set scaleRatio(value: number);
  59645. get scaleRatio(): number;
  59646. /**
  59647. * Sensitivity factor for dragging (Default: 1)
  59648. */
  59649. set sensitivity(value: number);
  59650. get sensitivity(): number;
  59651. /**
  59652. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  59653. * @param mesh Axis gizmo mesh
  59654. * @param cache Gizmo axis definition used for reactive gizmo UI
  59655. */
  59656. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  59657. /**
  59658. * Disposes of the gizmo
  59659. */
  59660. dispose(): void;
  59661. }
  59662. }
  59663. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  59664. import { Observable } from "babylonjs/Misc/observable";
  59665. import { Nullable } from "babylonjs/types";
  59666. import { Vector3 } from "babylonjs/Maths/math.vector";
  59667. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59668. import { Mesh } from "babylonjs/Meshes/mesh";
  59669. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59670. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59671. import { Color3 } from "babylonjs/Maths/math.color";
  59672. import "babylonjs/Meshes/Builders/boxBuilder";
  59673. /**
  59674. * Bounding box gizmo
  59675. */
  59676. export class BoundingBoxGizmo extends Gizmo {
  59677. private _lineBoundingBox;
  59678. private _rotateSpheresParent;
  59679. private _scaleBoxesParent;
  59680. private _boundingDimensions;
  59681. private _renderObserver;
  59682. private _pointerObserver;
  59683. private _scaleDragSpeed;
  59684. private _tmpQuaternion;
  59685. private _tmpVector;
  59686. private _tmpRotationMatrix;
  59687. /**
  59688. * 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)
  59689. */
  59690. ignoreChildren: boolean;
  59691. /**
  59692. * 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)
  59693. */
  59694. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  59695. /**
  59696. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  59697. */
  59698. rotationSphereSize: number;
  59699. /**
  59700. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  59701. */
  59702. scaleBoxSize: number;
  59703. /**
  59704. * 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)
  59705. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  59706. */
  59707. fixedDragMeshScreenSize: boolean;
  59708. /**
  59709. * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box
  59710. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  59711. */
  59712. fixedDragMeshBoundsSize: boolean;
  59713. /**
  59714. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  59715. */
  59716. fixedDragMeshScreenSizeDistanceFactor: number;
  59717. /**
  59718. * Fired when a rotation sphere or scale box is dragged
  59719. */
  59720. onDragStartObservable: Observable<{}>;
  59721. /**
  59722. * Fired when a scale box is dragged
  59723. */
  59724. onScaleBoxDragObservable: Observable<{}>;
  59725. /**
  59726. * Fired when a scale box drag is ended
  59727. */
  59728. onScaleBoxDragEndObservable: Observable<{}>;
  59729. /**
  59730. * Fired when a rotation sphere is dragged
  59731. */
  59732. onRotationSphereDragObservable: Observable<{}>;
  59733. /**
  59734. * Fired when a rotation sphere drag is ended
  59735. */
  59736. onRotationSphereDragEndObservable: Observable<{}>;
  59737. /**
  59738. * 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)
  59739. */
  59740. scalePivot: Nullable<Vector3>;
  59741. /**
  59742. * Mesh used as a pivot to rotate the attached node
  59743. */
  59744. private _anchorMesh;
  59745. private _existingMeshScale;
  59746. private _dragMesh;
  59747. private pointerDragBehavior;
  59748. private coloredMaterial;
  59749. private hoverColoredMaterial;
  59750. /**
  59751. * Sets the color of the bounding box gizmo
  59752. * @param color the color to set
  59753. */
  59754. setColor(color: Color3): void;
  59755. /**
  59756. * Creates an BoundingBoxGizmo
  59757. * @param gizmoLayer The utility layer the gizmo will be added to
  59758. * @param color The color of the gizmo
  59759. */
  59760. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  59761. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  59762. private _selectNode;
  59763. /**
  59764. * Updates the bounding box information for the Gizmo
  59765. */
  59766. updateBoundingBox(): void;
  59767. private _updateRotationSpheres;
  59768. private _updateScaleBoxes;
  59769. /**
  59770. * Enables rotation on the specified axis and disables rotation on the others
  59771. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  59772. */
  59773. setEnabledRotationAxis(axis: string): void;
  59774. /**
  59775. * Enables/disables scaling
  59776. * @param enable if scaling should be enabled
  59777. * @param homogeneousScaling defines if scaling should only be homogeneous
  59778. */
  59779. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  59780. private _updateDummy;
  59781. /**
  59782. * Enables a pointer drag behavior on the bounding box of the gizmo
  59783. */
  59784. enableDragBehavior(): void;
  59785. /**
  59786. * Disposes of the gizmo
  59787. */
  59788. dispose(): void;
  59789. /**
  59790. * 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)
  59791. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  59792. * @returns the bounding box mesh with the passed in mesh as a child
  59793. */
  59794. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  59795. /**
  59796. * CustomMeshes are not supported by this gizmo
  59797. * @param mesh The mesh to replace the default mesh of the gizmo
  59798. */
  59799. setCustomMesh(mesh: Mesh): void;
  59800. }
  59801. }
  59802. declare module "babylonjs/Gizmos/gizmoManager" {
  59803. import { Observable } from "babylonjs/Misc/observable";
  59804. import { Nullable } from "babylonjs/types";
  59805. import { Scene, IDisposable } from "babylonjs/scene";
  59806. import { Node } from "babylonjs/node";
  59807. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59808. import { Mesh } from "babylonjs/Meshes/mesh";
  59809. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59810. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  59811. import { GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  59812. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  59813. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  59814. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  59815. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  59816. /**
  59817. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  59818. */
  59819. export class GizmoManager implements IDisposable {
  59820. private scene;
  59821. /**
  59822. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  59823. */
  59824. gizmos: {
  59825. positionGizmo: Nullable<PositionGizmo>;
  59826. rotationGizmo: Nullable<RotationGizmo>;
  59827. scaleGizmo: Nullable<ScaleGizmo>;
  59828. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  59829. };
  59830. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  59831. clearGizmoOnEmptyPointerEvent: boolean;
  59832. /** Fires an event when the manager is attached to a mesh */
  59833. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  59834. /** Fires an event when the manager is attached to a node */
  59835. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  59836. private _gizmosEnabled;
  59837. private _pointerObservers;
  59838. private _attachedMesh;
  59839. private _attachedNode;
  59840. private _boundingBoxColor;
  59841. private _defaultUtilityLayer;
  59842. private _defaultKeepDepthUtilityLayer;
  59843. private _thickness;
  59844. /** Node Caching for quick lookup */
  59845. private _gizmoAxisCache;
  59846. /**
  59847. * When bounding box gizmo is enabled, this can be used to track drag/end events
  59848. */
  59849. boundingBoxDragBehavior: SixDofDragBehavior;
  59850. /**
  59851. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  59852. */
  59853. attachableMeshes: Nullable<Array<AbstractMesh>>;
  59854. /**
  59855. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  59856. */
  59857. attachableNodes: Nullable<Array<Node>>;
  59858. /**
  59859. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  59860. */
  59861. usePointerToAttachGizmos: boolean;
  59862. /**
  59863. * Utility layer that the bounding box gizmo belongs to
  59864. */
  59865. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  59866. /**
  59867. * Utility layer that all gizmos besides bounding box belong to
  59868. */
  59869. get utilityLayer(): UtilityLayerRenderer;
  59870. /**
  59871. * True when the mouse pointer is hovering a gizmo mesh
  59872. */
  59873. get isHovered(): boolean;
  59874. /**
  59875. * Instatiates a gizmo manager
  59876. * @param scene the scene to overlay the gizmos on top of
  59877. * @param thickness display gizmo axis thickness
  59878. * @param utilityLayer the layer where gizmos are rendered
  59879. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  59880. */
  59881. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  59882. /**
  59883. * Subscribes to pointer down events, for attaching and detaching mesh
  59884. * @param scene The sceme layer the observer will be added to
  59885. */
  59886. private _attachToMeshPointerObserver;
  59887. /**
  59888. * Attaches a set of gizmos to the specified mesh
  59889. * @param mesh The mesh the gizmo's should be attached to
  59890. */
  59891. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  59892. /**
  59893. * Attaches a set of gizmos to the specified node
  59894. * @param node The node the gizmo's should be attached to
  59895. */
  59896. attachToNode(node: Nullable<Node>): void;
  59897. /**
  59898. * If the position gizmo is enabled
  59899. */
  59900. set positionGizmoEnabled(value: boolean);
  59901. get positionGizmoEnabled(): boolean;
  59902. /**
  59903. * If the rotation gizmo is enabled
  59904. */
  59905. set rotationGizmoEnabled(value: boolean);
  59906. get rotationGizmoEnabled(): boolean;
  59907. /**
  59908. * If the scale gizmo is enabled
  59909. */
  59910. set scaleGizmoEnabled(value: boolean);
  59911. get scaleGizmoEnabled(): boolean;
  59912. /**
  59913. * If the boundingBox gizmo is enabled
  59914. */
  59915. set boundingBoxGizmoEnabled(value: boolean);
  59916. get boundingBoxGizmoEnabled(): boolean;
  59917. /**
  59918. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  59919. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  59920. */
  59921. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  59922. /**
  59923. * Disposes of the gizmo manager
  59924. */
  59925. dispose(): void;
  59926. }
  59927. }
  59928. declare module "babylonjs/Gizmos/positionGizmo" {
  59929. import { Observable } from "babylonjs/Misc/observable";
  59930. import { Nullable } from "babylonjs/types";
  59931. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59932. import { Node } from "babylonjs/node";
  59933. import { Mesh } from "babylonjs/Meshes/mesh";
  59934. import { Gizmo, GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  59935. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  59936. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  59937. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59938. import { GizmoManager } from "babylonjs/Gizmos/gizmoManager";
  59939. /**
  59940. * Gizmo that enables dragging a mesh along 3 axis
  59941. */
  59942. export class PositionGizmo extends Gizmo {
  59943. /**
  59944. * Internal gizmo used for interactions on the x axis
  59945. */
  59946. xGizmo: AxisDragGizmo;
  59947. /**
  59948. * Internal gizmo used for interactions on the y axis
  59949. */
  59950. yGizmo: AxisDragGizmo;
  59951. /**
  59952. * Internal gizmo used for interactions on the z axis
  59953. */
  59954. zGizmo: AxisDragGizmo;
  59955. /**
  59956. * Internal gizmo used for interactions on the yz plane
  59957. */
  59958. xPlaneGizmo: PlaneDragGizmo;
  59959. /**
  59960. * Internal gizmo used for interactions on the xz plane
  59961. */
  59962. yPlaneGizmo: PlaneDragGizmo;
  59963. /**
  59964. * Internal gizmo used for interactions on the xy plane
  59965. */
  59966. zPlaneGizmo: PlaneDragGizmo;
  59967. /**
  59968. * private variables
  59969. */
  59970. private _meshAttached;
  59971. private _nodeAttached;
  59972. private _snapDistance;
  59973. private _observables;
  59974. /** Node Caching for quick lookup */
  59975. private _gizmoAxisCache;
  59976. /** Fires an event when any of it's sub gizmos are dragged */
  59977. onDragStartObservable: Observable<unknown>;
  59978. /** Fires an event when any of it's sub gizmos are released from dragging */
  59979. onDragEndObservable: Observable<unknown>;
  59980. /**
  59981. * If set to true, planar drag is enabled
  59982. */
  59983. private _planarGizmoEnabled;
  59984. get attachedMesh(): Nullable<AbstractMesh>;
  59985. set attachedMesh(mesh: Nullable<AbstractMesh>);
  59986. get attachedNode(): Nullable<Node>;
  59987. set attachedNode(node: Nullable<Node>);
  59988. /**
  59989. * True when the mouse pointer is hovering a gizmo mesh
  59990. */
  59991. get isHovered(): boolean;
  59992. /**
  59993. * Creates a PositionGizmo
  59994. * @param gizmoLayer The utility layer the gizmo will be added to
  59995. @param thickness display gizmo axis thickness
  59996. */
  59997. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  59998. /**
  59999. * If the planar drag gizmo is enabled
  60000. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  60001. */
  60002. set planarGizmoEnabled(value: boolean);
  60003. get planarGizmoEnabled(): boolean;
  60004. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  60005. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  60006. /**
  60007. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  60008. */
  60009. set snapDistance(value: number);
  60010. get snapDistance(): number;
  60011. /**
  60012. * Ratio for the scale of the gizmo (Default: 1)
  60013. */
  60014. set scaleRatio(value: number);
  60015. get scaleRatio(): number;
  60016. /**
  60017. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  60018. * @param mesh Axis gizmo mesh
  60019. * @param cache Gizmo axis definition used for reactive gizmo UI
  60020. */
  60021. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  60022. /**
  60023. * Disposes of the gizmo
  60024. */
  60025. dispose(): void;
  60026. /**
  60027. * CustomMeshes are not supported by this gizmo
  60028. * @param mesh The mesh to replace the default mesh of the gizmo
  60029. */
  60030. setCustomMesh(mesh: Mesh): void;
  60031. }
  60032. }
  60033. declare module "babylonjs/Gizmos/axisDragGizmo" {
  60034. import { Observable } from "babylonjs/Misc/observable";
  60035. import { Nullable } from "babylonjs/types";
  60036. import { Vector3 } from "babylonjs/Maths/math.vector";
  60037. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60038. import { Node } from "babylonjs/node";
  60039. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  60040. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  60041. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  60042. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  60043. import { Scene } from "babylonjs/scene";
  60044. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  60045. import { Color3 } from "babylonjs/Maths/math.color";
  60046. /**
  60047. * Single axis drag gizmo
  60048. */
  60049. export class AxisDragGizmo extends Gizmo {
  60050. /**
  60051. * Drag behavior responsible for the gizmos dragging interactions
  60052. */
  60053. dragBehavior: PointerDragBehavior;
  60054. private _pointerObserver;
  60055. /**
  60056. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  60057. */
  60058. snapDistance: number;
  60059. /**
  60060. * Event that fires each time the gizmo snaps to a new location.
  60061. * * snapDistance is the the change in distance
  60062. */
  60063. onSnapObservable: Observable<{
  60064. snapDistance: number;
  60065. }>;
  60066. private _isEnabled;
  60067. private _parent;
  60068. private _gizmoMesh;
  60069. private _coloredMaterial;
  60070. private _hoverMaterial;
  60071. private _disableMaterial;
  60072. private _dragging;
  60073. /** @hidden */
  60074. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  60075. /** @hidden */
  60076. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  60077. /**
  60078. * Creates an AxisDragGizmo
  60079. * @param gizmoLayer The utility layer the gizmo will be added to
  60080. * @param dragAxis The axis which the gizmo will be able to drag on
  60081. * @param color The color of the gizmo
  60082. * @param thickness display gizmo axis thickness
  60083. */
  60084. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  60085. protected _attachedNodeChanged(value: Nullable<Node>): void;
  60086. /**
  60087. * If the gizmo is enabled
  60088. */
  60089. set isEnabled(value: boolean);
  60090. get isEnabled(): boolean;
  60091. /**
  60092. * Disposes of the gizmo
  60093. */
  60094. dispose(): void;
  60095. }
  60096. }
  60097. declare module "babylonjs/Debug/axesViewer" {
  60098. import { Vector3 } from "babylonjs/Maths/math.vector";
  60099. import { Nullable } from "babylonjs/types";
  60100. import { Scene } from "babylonjs/scene";
  60101. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60102. /**
  60103. * The Axes viewer will show 3 axes in a specific point in space
  60104. */
  60105. export class AxesViewer {
  60106. private _xAxis;
  60107. private _yAxis;
  60108. private _zAxis;
  60109. private _scaleLinesFactor;
  60110. private _instanced;
  60111. /**
  60112. * Gets the hosting scene
  60113. */
  60114. scene: Nullable<Scene>;
  60115. /**
  60116. * Gets or sets a number used to scale line length
  60117. */
  60118. scaleLines: number;
  60119. /** Gets the node hierarchy used to render x-axis */
  60120. get xAxis(): TransformNode;
  60121. /** Gets the node hierarchy used to render y-axis */
  60122. get yAxis(): TransformNode;
  60123. /** Gets the node hierarchy used to render z-axis */
  60124. get zAxis(): TransformNode;
  60125. /**
  60126. * Creates a new AxesViewer
  60127. * @param scene defines the hosting scene
  60128. * @param scaleLines defines a number used to scale line length (1 by default)
  60129. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  60130. * @param xAxis defines the node hierarchy used to render the x-axis
  60131. * @param yAxis defines the node hierarchy used to render the y-axis
  60132. * @param zAxis defines the node hierarchy used to render the z-axis
  60133. */
  60134. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  60135. /**
  60136. * Force the viewer to update
  60137. * @param position defines the position of the viewer
  60138. * @param xaxis defines the x axis of the viewer
  60139. * @param yaxis defines the y axis of the viewer
  60140. * @param zaxis defines the z axis of the viewer
  60141. */
  60142. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  60143. /**
  60144. * Creates an instance of this axes viewer.
  60145. * @returns a new axes viewer with instanced meshes
  60146. */
  60147. createInstance(): AxesViewer;
  60148. /** Releases resources */
  60149. dispose(): void;
  60150. private static _SetRenderingGroupId;
  60151. }
  60152. }
  60153. declare module "babylonjs/Debug/boneAxesViewer" {
  60154. import { Nullable } from "babylonjs/types";
  60155. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  60156. import { Vector3 } from "babylonjs/Maths/math.vector";
  60157. import { Mesh } from "babylonjs/Meshes/mesh";
  60158. import { Bone } from "babylonjs/Bones/bone";
  60159. import { Scene } from "babylonjs/scene";
  60160. /**
  60161. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  60162. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  60163. */
  60164. export class BoneAxesViewer extends AxesViewer {
  60165. /**
  60166. * Gets or sets the target mesh where to display the axes viewer
  60167. */
  60168. mesh: Nullable<Mesh>;
  60169. /**
  60170. * Gets or sets the target bone where to display the axes viewer
  60171. */
  60172. bone: Nullable<Bone>;
  60173. /** Gets current position */
  60174. pos: Vector3;
  60175. /** Gets direction of X axis */
  60176. xaxis: Vector3;
  60177. /** Gets direction of Y axis */
  60178. yaxis: Vector3;
  60179. /** Gets direction of Z axis */
  60180. zaxis: Vector3;
  60181. /**
  60182. * Creates a new BoneAxesViewer
  60183. * @param scene defines the hosting scene
  60184. * @param bone defines the target bone
  60185. * @param mesh defines the target mesh
  60186. * @param scaleLines defines a scaling factor for line length (1 by default)
  60187. */
  60188. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  60189. /**
  60190. * Force the viewer to update
  60191. */
  60192. update(): void;
  60193. /** Releases resources */
  60194. dispose(): void;
  60195. }
  60196. }
  60197. declare module "babylonjs/Debug/debugLayer" {
  60198. import { Scene } from "babylonjs/scene";
  60199. /**
  60200. * Interface used to define scene explorer extensibility option
  60201. */
  60202. export interface IExplorerExtensibilityOption {
  60203. /**
  60204. * Define the option label
  60205. */
  60206. label: string;
  60207. /**
  60208. * Defines the action to execute on click
  60209. */
  60210. action: (entity: any) => void;
  60211. }
  60212. /**
  60213. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  60214. */
  60215. export interface IExplorerExtensibilityGroup {
  60216. /**
  60217. * Defines a predicate to test if a given type mut be extended
  60218. */
  60219. predicate: (entity: any) => boolean;
  60220. /**
  60221. * Gets the list of options added to a type
  60222. */
  60223. entries: IExplorerExtensibilityOption[];
  60224. }
  60225. /**
  60226. * Interface used to define the options to use to create the Inspector
  60227. */
  60228. export interface IInspectorOptions {
  60229. /**
  60230. * Display in overlay mode (default: false)
  60231. */
  60232. overlay?: boolean;
  60233. /**
  60234. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  60235. */
  60236. globalRoot?: HTMLElement;
  60237. /**
  60238. * Display the Scene explorer
  60239. */
  60240. showExplorer?: boolean;
  60241. /**
  60242. * Display the property inspector
  60243. */
  60244. showInspector?: boolean;
  60245. /**
  60246. * Display in embed mode (both panes on the right)
  60247. */
  60248. embedMode?: boolean;
  60249. /**
  60250. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  60251. */
  60252. handleResize?: boolean;
  60253. /**
  60254. * Allow the panes to popup (default: true)
  60255. */
  60256. enablePopup?: boolean;
  60257. /**
  60258. * Allow the panes to be closed by users (default: true)
  60259. */
  60260. enableClose?: boolean;
  60261. /**
  60262. * Optional list of extensibility entries
  60263. */
  60264. explorerExtensibility?: IExplorerExtensibilityGroup[];
  60265. /**
  60266. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  60267. */
  60268. inspectorURL?: string;
  60269. /**
  60270. * Optional initial tab (default to DebugLayerTab.Properties)
  60271. */
  60272. initialTab?: DebugLayerTab;
  60273. }
  60274. module "babylonjs/scene" {
  60275. interface Scene {
  60276. /**
  60277. * @hidden
  60278. * Backing field
  60279. */
  60280. _debugLayer: DebugLayer;
  60281. /**
  60282. * Gets the debug layer (aka Inspector) associated with the scene
  60283. * @see https://doc.babylonjs.com/features/playground_debuglayer
  60284. */
  60285. debugLayer: DebugLayer;
  60286. }
  60287. }
  60288. /**
  60289. * Enum of inspector action tab
  60290. */
  60291. export enum DebugLayerTab {
  60292. /**
  60293. * Properties tag (default)
  60294. */
  60295. Properties = 0,
  60296. /**
  60297. * Debug tab
  60298. */
  60299. Debug = 1,
  60300. /**
  60301. * Statistics tab
  60302. */
  60303. Statistics = 2,
  60304. /**
  60305. * Tools tab
  60306. */
  60307. Tools = 3,
  60308. /**
  60309. * Settings tab
  60310. */
  60311. Settings = 4
  60312. }
  60313. /**
  60314. * The debug layer (aka Inspector) is the go to tool in order to better understand
  60315. * what is happening in your scene
  60316. * @see https://doc.babylonjs.com/features/playground_debuglayer
  60317. */
  60318. export class DebugLayer {
  60319. /**
  60320. * Define the url to get the inspector script from.
  60321. * By default it uses the babylonjs CDN.
  60322. * @ignoreNaming
  60323. */
  60324. static InspectorURL: string;
  60325. private _scene;
  60326. private BJSINSPECTOR;
  60327. private _onPropertyChangedObservable?;
  60328. /**
  60329. * Observable triggered when a property is changed through the inspector.
  60330. */
  60331. get onPropertyChangedObservable(): any;
  60332. /**
  60333. * Instantiates a new debug layer.
  60334. * The debug layer (aka Inspector) is the go to tool in order to better understand
  60335. * what is happening in your scene
  60336. * @see https://doc.babylonjs.com/features/playground_debuglayer
  60337. * @param scene Defines the scene to inspect
  60338. */
  60339. constructor(scene: Scene);
  60340. /** Creates the inspector window. */
  60341. private _createInspector;
  60342. /**
  60343. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  60344. * @param entity defines the entity to select
  60345. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  60346. */
  60347. select(entity: any, lineContainerTitles?: string | string[]): void;
  60348. /** Get the inspector from bundle or global */
  60349. private _getGlobalInspector;
  60350. /**
  60351. * Get if the inspector is visible or not.
  60352. * @returns true if visible otherwise, false
  60353. */
  60354. isVisible(): boolean;
  60355. /**
  60356. * Hide the inspector and close its window.
  60357. */
  60358. hide(): void;
  60359. /**
  60360. * Update the scene in the inspector
  60361. */
  60362. setAsActiveScene(): void;
  60363. /**
  60364. * Launch the debugLayer.
  60365. * @param config Define the configuration of the inspector
  60366. * @return a promise fulfilled when the debug layer is visible
  60367. */
  60368. show(config?: IInspectorOptions): Promise<DebugLayer>;
  60369. }
  60370. }
  60371. declare module "babylonjs/Debug/physicsViewer" {
  60372. import { Nullable } from "babylonjs/types";
  60373. import { Scene } from "babylonjs/scene";
  60374. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60375. import { Mesh } from "babylonjs/Meshes/mesh";
  60376. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  60377. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  60378. /**
  60379. * Used to show the physics impostor around the specific mesh
  60380. */
  60381. export class PhysicsViewer {
  60382. /** @hidden */
  60383. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  60384. /** @hidden */
  60385. protected _meshes: Array<Nullable<AbstractMesh>>;
  60386. /** @hidden */
  60387. protected _scene: Nullable<Scene>;
  60388. /** @hidden */
  60389. protected _numMeshes: number;
  60390. /** @hidden */
  60391. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  60392. private _renderFunction;
  60393. private _utilityLayer;
  60394. private _debugBoxMesh;
  60395. private _debugSphereMesh;
  60396. private _debugCylinderMesh;
  60397. private _debugMaterial;
  60398. private _debugMeshMeshes;
  60399. /**
  60400. * Creates a new PhysicsViewer
  60401. * @param scene defines the hosting scene
  60402. */
  60403. constructor(scene: Scene);
  60404. /** @hidden */
  60405. protected _updateDebugMeshes(): void;
  60406. /**
  60407. * Renders a specified physic impostor
  60408. * @param impostor defines the impostor to render
  60409. * @param targetMesh defines the mesh represented by the impostor
  60410. * @returns the new debug mesh used to render the impostor
  60411. */
  60412. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  60413. /**
  60414. * Hides a specified physic impostor
  60415. * @param impostor defines the impostor to hide
  60416. */
  60417. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  60418. private _getDebugMaterial;
  60419. private _getDebugBoxMesh;
  60420. private _getDebugSphereMesh;
  60421. private _getDebugCylinderMesh;
  60422. private _getDebugMeshMesh;
  60423. private _getDebugMesh;
  60424. /** Releases all resources */
  60425. dispose(): void;
  60426. }
  60427. }
  60428. declare module "babylonjs/Debug/rayHelper" {
  60429. import { Nullable } from "babylonjs/types";
  60430. import { Ray } from "babylonjs/Culling/ray";
  60431. import { Vector3 } from "babylonjs/Maths/math.vector";
  60432. import { Color3 } from "babylonjs/Maths/math.color";
  60433. import { Scene } from "babylonjs/scene";
  60434. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60435. import "babylonjs/Meshes/Builders/linesBuilder";
  60436. /**
  60437. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  60438. * in order to better appreciate the issue one might have.
  60439. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  60440. */
  60441. export class RayHelper {
  60442. /**
  60443. * Defines the ray we are currently tryin to visualize.
  60444. */
  60445. ray: Nullable<Ray>;
  60446. private _renderPoints;
  60447. private _renderLine;
  60448. private _renderFunction;
  60449. private _scene;
  60450. private _onAfterRenderObserver;
  60451. private _onAfterStepObserver;
  60452. private _attachedToMesh;
  60453. private _meshSpaceDirection;
  60454. private _meshSpaceOrigin;
  60455. /**
  60456. * Helper function to create a colored helper in a scene in one line.
  60457. * @param ray Defines the ray we are currently tryin to visualize
  60458. * @param scene Defines the scene the ray is used in
  60459. * @param color Defines the color we want to see the ray in
  60460. * @returns The newly created ray helper.
  60461. */
  60462. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  60463. /**
  60464. * Instantiate a new ray helper.
  60465. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  60466. * in order to better appreciate the issue one might have.
  60467. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  60468. * @param ray Defines the ray we are currently tryin to visualize
  60469. */
  60470. constructor(ray: Ray);
  60471. /**
  60472. * Shows the ray we are willing to debug.
  60473. * @param scene Defines the scene the ray needs to be rendered in
  60474. * @param color Defines the color the ray needs to be rendered in
  60475. */
  60476. show(scene: Scene, color?: Color3): void;
  60477. /**
  60478. * Hides the ray we are debugging.
  60479. */
  60480. hide(): void;
  60481. private _render;
  60482. /**
  60483. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  60484. * @param mesh Defines the mesh we want the helper attached to
  60485. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  60486. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  60487. * @param length Defines the length of the ray
  60488. */
  60489. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  60490. /**
  60491. * Detach the ray helper from the mesh it has previously been attached to.
  60492. */
  60493. detachFromMesh(): void;
  60494. private _updateToMesh;
  60495. /**
  60496. * Dispose the helper and release its associated resources.
  60497. */
  60498. dispose(): void;
  60499. }
  60500. }
  60501. declare module "babylonjs/Debug/ISkeletonViewer" {
  60502. import { Skeleton } from "babylonjs/Bones/skeleton";
  60503. import { Color3 } from "babylonjs/Maths/math.color";
  60504. /**
  60505. * Defines the options associated with the creation of a SkeletonViewer.
  60506. */
  60507. export interface ISkeletonViewerOptions {
  60508. /** Should the system pause animations before building the Viewer? */
  60509. pauseAnimations: boolean;
  60510. /** Should the system return the skeleton to rest before building? */
  60511. returnToRest: boolean;
  60512. /** public Display Mode of the Viewer */
  60513. displayMode: number;
  60514. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  60515. displayOptions: ISkeletonViewerDisplayOptions;
  60516. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  60517. computeBonesUsingShaders: boolean;
  60518. /** Flag ignore non weighted bones */
  60519. useAllBones: boolean;
  60520. }
  60521. /**
  60522. * Defines how to display the various bone meshes for the viewer.
  60523. */
  60524. export interface ISkeletonViewerDisplayOptions {
  60525. /** How far down to start tapering the bone spurs */
  60526. midStep?: number;
  60527. /** How big is the midStep? */
  60528. midStepFactor?: number;
  60529. /** Base for the Sphere Size */
  60530. sphereBaseSize?: number;
  60531. /** The ratio of the sphere to the longest bone in units */
  60532. sphereScaleUnit?: number;
  60533. /** Ratio for the Sphere Size */
  60534. sphereFactor?: number;
  60535. /** Whether a spur should attach its far end to the child bone position */
  60536. spurFollowsChild?: boolean;
  60537. /** Whether to show local axes or not */
  60538. showLocalAxes?: boolean;
  60539. /** Length of each local axis */
  60540. localAxesSize?: number;
  60541. }
  60542. /**
  60543. * Defines the constructor options for the BoneWeight Shader.
  60544. */
  60545. export interface IBoneWeightShaderOptions {
  60546. /** Skeleton to Map */
  60547. skeleton: Skeleton;
  60548. /** Colors for Uninfluenced bones */
  60549. colorBase?: Color3;
  60550. /** Colors for 0.0-0.25 Weight bones */
  60551. colorZero?: Color3;
  60552. /** Color for 0.25-0.5 Weight Influence */
  60553. colorQuarter?: Color3;
  60554. /** Color for 0.5-0.75 Weight Influence */
  60555. colorHalf?: Color3;
  60556. /** Color for 0.75-1 Weight Influence */
  60557. colorFull?: Color3;
  60558. /** Color for Zero Weight Influence */
  60559. targetBoneIndex?: number;
  60560. }
  60561. /**
  60562. * Simple structure of the gradient steps for the Color Map.
  60563. */
  60564. export interface ISkeletonMapShaderColorMapKnot {
  60565. /** Color of the Knot */
  60566. color: Color3;
  60567. /** Location of the Knot */
  60568. location: number;
  60569. }
  60570. /**
  60571. * Defines the constructor options for the SkeletonMap Shader.
  60572. */
  60573. export interface ISkeletonMapShaderOptions {
  60574. /** Skeleton to Map */
  60575. skeleton: Skeleton;
  60576. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  60577. colorMap?: ISkeletonMapShaderColorMapKnot[];
  60578. }
  60579. }
  60580. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  60581. import { Nullable } from "babylonjs/types";
  60582. import { Scene } from "babylonjs/scene";
  60583. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  60584. import { Color4 } from "babylonjs/Maths/math.color";
  60585. import { Mesh } from "babylonjs/Meshes/mesh";
  60586. /**
  60587. * Class containing static functions to help procedurally build meshes
  60588. */
  60589. export class RibbonBuilder {
  60590. /**
  60591. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60592. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  60593. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  60594. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  60595. * * 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
  60596. * * 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
  60597. * * 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
  60598. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60599. * * 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
  60600. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60601. * * 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
  60602. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  60603. * * 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
  60604. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  60605. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60606. * @param name defines the name of the mesh
  60607. * @param options defines the options used to create the mesh
  60608. * @param scene defines the hosting scene
  60609. * @returns the ribbon mesh
  60610. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  60611. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60612. */
  60613. static CreateRibbon(name: string, options: {
  60614. pathArray: Vector3[][];
  60615. closeArray?: boolean;
  60616. closePath?: boolean;
  60617. offset?: number;
  60618. updatable?: boolean;
  60619. sideOrientation?: number;
  60620. frontUVs?: Vector4;
  60621. backUVs?: Vector4;
  60622. instance?: Mesh;
  60623. invertUV?: boolean;
  60624. uvs?: Vector2[];
  60625. colors?: Color4[];
  60626. }, scene?: Nullable<Scene>): Mesh;
  60627. }
  60628. }
  60629. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  60630. import { Nullable } from "babylonjs/types";
  60631. import { Scene } from "babylonjs/scene";
  60632. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60633. import { Mesh } from "babylonjs/Meshes/mesh";
  60634. /**
  60635. * Class containing static functions to help procedurally build meshes
  60636. */
  60637. export class ShapeBuilder {
  60638. /**
  60639. * 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.
  60640. * * 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.
  60641. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60642. * * 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.
  60643. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  60644. * * 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
  60645. * * 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
  60646. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  60647. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60648. * * 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
  60649. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  60650. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60651. * @param name defines the name of the mesh
  60652. * @param options defines the options used to create the mesh
  60653. * @param scene defines the hosting scene
  60654. * @returns the extruded shape mesh
  60655. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60656. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60657. */
  60658. static ExtrudeShape(name: string, options: {
  60659. shape: Vector3[];
  60660. path: Vector3[];
  60661. scale?: number;
  60662. rotation?: number;
  60663. cap?: number;
  60664. updatable?: boolean;
  60665. sideOrientation?: number;
  60666. frontUVs?: Vector4;
  60667. backUVs?: Vector4;
  60668. instance?: Mesh;
  60669. invertUV?: boolean;
  60670. }, scene?: Nullable<Scene>): Mesh;
  60671. /**
  60672. * Creates an custom extruded shape mesh.
  60673. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  60674. * * 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.
  60675. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60676. * * 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
  60677. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  60678. * * 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
  60679. * * It must returns a float value that will be the scale value applied to the shape on each path point
  60680. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  60681. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  60682. * * 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
  60683. * * 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
  60684. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  60685. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60686. * * 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
  60687. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60688. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60689. * @param name defines the name of the mesh
  60690. * @param options defines the options used to create the mesh
  60691. * @param scene defines the hosting scene
  60692. * @returns the custom extruded shape mesh
  60693. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  60694. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60695. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60696. */
  60697. static ExtrudeShapeCustom(name: string, options: {
  60698. shape: Vector3[];
  60699. path: Vector3[];
  60700. scaleFunction?: any;
  60701. rotationFunction?: any;
  60702. ribbonCloseArray?: boolean;
  60703. ribbonClosePath?: boolean;
  60704. cap?: number;
  60705. updatable?: boolean;
  60706. sideOrientation?: number;
  60707. frontUVs?: Vector4;
  60708. backUVs?: Vector4;
  60709. instance?: Mesh;
  60710. invertUV?: boolean;
  60711. }, scene?: Nullable<Scene>): Mesh;
  60712. private static _ExtrudeShapeGeneric;
  60713. }
  60714. }
  60715. declare module "babylonjs/Debug/skeletonViewer" {
  60716. import { Color3 } from "babylonjs/Maths/math.color";
  60717. import { Scene } from "babylonjs/scene";
  60718. import { Nullable } from "babylonjs/types";
  60719. import { Skeleton } from "babylonjs/Bones/skeleton";
  60720. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60721. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  60722. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  60723. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  60724. import { ISkeletonViewerOptions, IBoneWeightShaderOptions, ISkeletonMapShaderOptions } from "babylonjs/Debug/ISkeletonViewer";
  60725. /**
  60726. * Class used to render a debug view of a given skeleton
  60727. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  60728. */
  60729. export class SkeletonViewer {
  60730. /** defines the skeleton to render */
  60731. skeleton: Skeleton;
  60732. /** defines the mesh attached to the skeleton */
  60733. mesh: AbstractMesh;
  60734. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  60735. autoUpdateBonesMatrices: boolean;
  60736. /** defines the rendering group id to use with the viewer */
  60737. renderingGroupId: number;
  60738. /** is the options for the viewer */
  60739. options: Partial<ISkeletonViewerOptions>;
  60740. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  60741. static readonly DISPLAY_LINES: number;
  60742. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  60743. static readonly DISPLAY_SPHERES: number;
  60744. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  60745. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  60746. /** public static method to create a BoneWeight Shader
  60747. * @param options The constructor options
  60748. * @param scene The scene that the shader is scoped to
  60749. * @returns The created ShaderMaterial
  60750. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  60751. */
  60752. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  60753. /** public static method to create a BoneWeight Shader
  60754. * @param options The constructor options
  60755. * @param scene The scene that the shader is scoped to
  60756. * @returns The created ShaderMaterial
  60757. */
  60758. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  60759. /** private static method to create a BoneWeight Shader
  60760. * @param size The size of the buffer to create (usually the bone count)
  60761. * @param colorMap The gradient data to generate
  60762. * @param scene The scene that the shader is scoped to
  60763. * @returns an Array of floats from the color gradient values
  60764. */
  60765. private static _CreateBoneMapColorBuffer;
  60766. /** If SkeletonViewer scene scope. */
  60767. private _scene;
  60768. /** Gets or sets the color used to render the skeleton */
  60769. color: Color3;
  60770. /** Array of the points of the skeleton fo the line view. */
  60771. private _debugLines;
  60772. /** The SkeletonViewers Mesh. */
  60773. private _debugMesh;
  60774. /** The local axes Meshes. */
  60775. private _localAxes;
  60776. /** If SkeletonViewer is enabled. */
  60777. private _isEnabled;
  60778. /** If SkeletonViewer is ready. */
  60779. private _ready;
  60780. /** SkeletonViewer render observable. */
  60781. private _obs;
  60782. /** The Utility Layer to render the gizmos in. */
  60783. private _utilityLayer;
  60784. private _boneIndices;
  60785. /** Gets the Scene. */
  60786. get scene(): Scene;
  60787. /** Gets the utilityLayer. */
  60788. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  60789. /** Checks Ready Status. */
  60790. get isReady(): Boolean;
  60791. /** Sets Ready Status. */
  60792. set ready(value: boolean);
  60793. /** Gets the debugMesh */
  60794. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  60795. /** Sets the debugMesh */
  60796. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  60797. /** Gets the displayMode */
  60798. get displayMode(): number;
  60799. /** Sets the displayMode */
  60800. set displayMode(value: number);
  60801. /**
  60802. * Creates a new SkeletonViewer
  60803. * @param skeleton defines the skeleton to render
  60804. * @param mesh defines the mesh attached to the skeleton
  60805. * @param scene defines the hosting scene
  60806. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  60807. * @param renderingGroupId defines the rendering group id to use with the viewer
  60808. * @param options All of the extra constructor options for the SkeletonViewer
  60809. */
  60810. constructor(
  60811. /** defines the skeleton to render */
  60812. skeleton: Skeleton,
  60813. /** defines the mesh attached to the skeleton */
  60814. mesh: AbstractMesh,
  60815. /** The Scene scope*/
  60816. scene: Scene,
  60817. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  60818. autoUpdateBonesMatrices?: boolean,
  60819. /** defines the rendering group id to use with the viewer */
  60820. renderingGroupId?: number,
  60821. /** is the options for the viewer */
  60822. options?: Partial<ISkeletonViewerOptions>);
  60823. /** The Dynamic bindings for the update functions */
  60824. private _bindObs;
  60825. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  60826. update(): void;
  60827. /** Gets or sets a boolean indicating if the viewer is enabled */
  60828. set isEnabled(value: boolean);
  60829. get isEnabled(): boolean;
  60830. private _getBonePosition;
  60831. private _getLinesForBonesWithLength;
  60832. private _getLinesForBonesNoLength;
  60833. /** function to revert the mesh and scene back to the initial state. */
  60834. private _revert;
  60835. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  60836. private _getAbsoluteBindPoseToRef;
  60837. /** function to build and bind sphere joint points and spur bone representations. */
  60838. private _buildSpheresAndSpurs;
  60839. private _buildLocalAxes;
  60840. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  60841. private _displayLinesUpdate;
  60842. /** Changes the displayMode of the skeleton viewer
  60843. * @param mode The displayMode numerical value
  60844. */
  60845. changeDisplayMode(mode: number): void;
  60846. /** Sets a display option of the skeleton viewer
  60847. *
  60848. * | Option | Type | Default | Description |
  60849. * | ---------------- | ------- | ------- | ----------- |
  60850. * | 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`. |
  60851. * | 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`. |
  60852. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  60853. * | 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`. |
  60854. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  60855. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  60856. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  60857. *
  60858. * @param option String of the option name
  60859. * @param value The numerical option value
  60860. */
  60861. changeDisplayOptions(option: string, value: number): void;
  60862. /** Release associated resources */
  60863. dispose(): void;
  60864. }
  60865. }
  60866. declare module "babylonjs/Debug/index" {
  60867. export * from "babylonjs/Debug/axesViewer";
  60868. export * from "babylonjs/Debug/boneAxesViewer";
  60869. export * from "babylonjs/Debug/debugLayer";
  60870. export * from "babylonjs/Debug/physicsViewer";
  60871. export * from "babylonjs/Debug/rayHelper";
  60872. export * from "babylonjs/Debug/skeletonViewer";
  60873. export * from "babylonjs/Debug/ISkeletonViewer";
  60874. }
  60875. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  60876. /**
  60877. * Enum for Device Types
  60878. */
  60879. export enum DeviceType {
  60880. /** Generic */
  60881. Generic = 0,
  60882. /** Keyboard */
  60883. Keyboard = 1,
  60884. /** Mouse */
  60885. Mouse = 2,
  60886. /** Touch Pointers */
  60887. Touch = 3,
  60888. /** PS4 Dual Shock */
  60889. DualShock = 4,
  60890. /** Xbox */
  60891. Xbox = 5,
  60892. /** Switch Controller */
  60893. Switch = 6
  60894. }
  60895. /**
  60896. * Enum for All Pointers (Touch/Mouse)
  60897. */
  60898. export enum PointerInput {
  60899. /** Horizontal Axis */
  60900. Horizontal = 0,
  60901. /** Vertical Axis */
  60902. Vertical = 1,
  60903. /** Left Click or Touch */
  60904. LeftClick = 2,
  60905. /** Middle Click */
  60906. MiddleClick = 3,
  60907. /** Right Click */
  60908. RightClick = 4,
  60909. /** Browser Back */
  60910. BrowserBack = 5,
  60911. /** Browser Forward */
  60912. BrowserForward = 6
  60913. }
  60914. /**
  60915. * Enum for Dual Shock Gamepad
  60916. */
  60917. export enum DualShockInput {
  60918. /** Cross */
  60919. Cross = 0,
  60920. /** Circle */
  60921. Circle = 1,
  60922. /** Square */
  60923. Square = 2,
  60924. /** Triangle */
  60925. Triangle = 3,
  60926. /** L1 */
  60927. L1 = 4,
  60928. /** R1 */
  60929. R1 = 5,
  60930. /** L2 */
  60931. L2 = 6,
  60932. /** R2 */
  60933. R2 = 7,
  60934. /** Share */
  60935. Share = 8,
  60936. /** Options */
  60937. Options = 9,
  60938. /** L3 */
  60939. L3 = 10,
  60940. /** R3 */
  60941. R3 = 11,
  60942. /** DPadUp */
  60943. DPadUp = 12,
  60944. /** DPadDown */
  60945. DPadDown = 13,
  60946. /** DPadLeft */
  60947. DPadLeft = 14,
  60948. /** DRight */
  60949. DPadRight = 15,
  60950. /** Home */
  60951. Home = 16,
  60952. /** TouchPad */
  60953. TouchPad = 17,
  60954. /** LStickXAxis */
  60955. LStickXAxis = 18,
  60956. /** LStickYAxis */
  60957. LStickYAxis = 19,
  60958. /** RStickXAxis */
  60959. RStickXAxis = 20,
  60960. /** RStickYAxis */
  60961. RStickYAxis = 21
  60962. }
  60963. /**
  60964. * Enum for Xbox Gamepad
  60965. */
  60966. export enum XboxInput {
  60967. /** A */
  60968. A = 0,
  60969. /** B */
  60970. B = 1,
  60971. /** X */
  60972. X = 2,
  60973. /** Y */
  60974. Y = 3,
  60975. /** LB */
  60976. LB = 4,
  60977. /** RB */
  60978. RB = 5,
  60979. /** LT */
  60980. LT = 6,
  60981. /** RT */
  60982. RT = 7,
  60983. /** Back */
  60984. Back = 8,
  60985. /** Start */
  60986. Start = 9,
  60987. /** LS */
  60988. LS = 10,
  60989. /** RS */
  60990. RS = 11,
  60991. /** DPadUp */
  60992. DPadUp = 12,
  60993. /** DPadDown */
  60994. DPadDown = 13,
  60995. /** DPadLeft */
  60996. DPadLeft = 14,
  60997. /** DRight */
  60998. DPadRight = 15,
  60999. /** Home */
  61000. Home = 16,
  61001. /** LStickXAxis */
  61002. LStickXAxis = 17,
  61003. /** LStickYAxis */
  61004. LStickYAxis = 18,
  61005. /** RStickXAxis */
  61006. RStickXAxis = 19,
  61007. /** RStickYAxis */
  61008. RStickYAxis = 20
  61009. }
  61010. /**
  61011. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  61012. */
  61013. export enum SwitchInput {
  61014. /** B */
  61015. B = 0,
  61016. /** A */
  61017. A = 1,
  61018. /** Y */
  61019. Y = 2,
  61020. /** X */
  61021. X = 3,
  61022. /** L */
  61023. L = 4,
  61024. /** R */
  61025. R = 5,
  61026. /** ZL */
  61027. ZL = 6,
  61028. /** ZR */
  61029. ZR = 7,
  61030. /** Minus */
  61031. Minus = 8,
  61032. /** Plus */
  61033. Plus = 9,
  61034. /** LS */
  61035. LS = 10,
  61036. /** RS */
  61037. RS = 11,
  61038. /** DPadUp */
  61039. DPadUp = 12,
  61040. /** DPadDown */
  61041. DPadDown = 13,
  61042. /** DPadLeft */
  61043. DPadLeft = 14,
  61044. /** DRight */
  61045. DPadRight = 15,
  61046. /** Home */
  61047. Home = 16,
  61048. /** Capture */
  61049. Capture = 17,
  61050. /** LStickXAxis */
  61051. LStickXAxis = 18,
  61052. /** LStickYAxis */
  61053. LStickYAxis = 19,
  61054. /** RStickXAxis */
  61055. RStickXAxis = 20,
  61056. /** RStickYAxis */
  61057. RStickYAxis = 21
  61058. }
  61059. }
  61060. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  61061. import { Engine } from "babylonjs/Engines/engine";
  61062. import { IDisposable } from "babylonjs/scene";
  61063. import { Nullable } from "babylonjs/types";
  61064. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  61065. /**
  61066. * This class will take all inputs from Keyboard, Pointer, and
  61067. * any Gamepads and provide a polling system that all devices
  61068. * will use. This class assumes that there will only be one
  61069. * pointer device and one keyboard.
  61070. */
  61071. export class DeviceInputSystem implements IDisposable {
  61072. /**
  61073. * Returns onDeviceConnected callback property
  61074. * @returns Callback with function to execute when a device is connected
  61075. */
  61076. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  61077. /**
  61078. * Sets callback function when a device is connected and executes against all connected devices
  61079. * @param callback Function to execute when a device is connected
  61080. */
  61081. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  61082. /**
  61083. * Callback to be triggered when a device is disconnected
  61084. */
  61085. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  61086. /**
  61087. * Callback to be triggered when event driven input is updated
  61088. */
  61089. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  61090. private _inputs;
  61091. private _gamepads;
  61092. private _keyboardActive;
  61093. private _pointerActive;
  61094. private _elementToAttachTo;
  61095. private _keyboardDownEvent;
  61096. private _keyboardUpEvent;
  61097. private _pointerMoveEvent;
  61098. private _pointerDownEvent;
  61099. private _pointerUpEvent;
  61100. private _gamepadConnectedEvent;
  61101. private _gamepadDisconnectedEvent;
  61102. private _onDeviceConnected;
  61103. private static _MAX_KEYCODES;
  61104. private static _MAX_POINTER_INPUTS;
  61105. private constructor();
  61106. /**
  61107. * Creates a new DeviceInputSystem instance
  61108. * @param engine Engine to pull input element from
  61109. * @returns The new instance
  61110. */
  61111. static Create(engine: Engine): DeviceInputSystem;
  61112. /**
  61113. * Checks for current device input value, given an id and input index
  61114. * @param deviceName Id of connected device
  61115. * @param inputIndex Index of device input
  61116. * @returns Current value of input
  61117. */
  61118. /**
  61119. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  61120. * @param deviceType Enum specifiying device type
  61121. * @param deviceSlot "Slot" or index that device is referenced in
  61122. * @param inputIndex Id of input to be checked
  61123. * @returns Current value of input
  61124. */
  61125. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  61126. /**
  61127. * Dispose of all the eventlisteners
  61128. */
  61129. dispose(): void;
  61130. /**
  61131. * Checks for existing connections to devices and register them, if necessary
  61132. * Currently handles gamepads and mouse
  61133. */
  61134. private _checkForConnectedDevices;
  61135. /**
  61136. * Add a gamepad to the DeviceInputSystem
  61137. * @param gamepad A single DOM Gamepad object
  61138. */
  61139. private _addGamePad;
  61140. /**
  61141. * Add pointer device to DeviceInputSystem
  61142. * @param deviceType Type of Pointer to add
  61143. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  61144. * @param currentX Current X at point of adding
  61145. * @param currentY Current Y at point of adding
  61146. */
  61147. private _addPointerDevice;
  61148. /**
  61149. * Add device and inputs to device array
  61150. * @param deviceType Enum specifiying device type
  61151. * @param deviceSlot "Slot" or index that device is referenced in
  61152. * @param numberOfInputs Number of input entries to create for given device
  61153. */
  61154. private _registerDevice;
  61155. /**
  61156. * Given a specific device name, remove that device from the device map
  61157. * @param deviceType Enum specifiying device type
  61158. * @param deviceSlot "Slot" or index that device is referenced in
  61159. */
  61160. private _unregisterDevice;
  61161. /**
  61162. * Handle all actions that come from keyboard interaction
  61163. */
  61164. private _handleKeyActions;
  61165. /**
  61166. * Handle all actions that come from pointer interaction
  61167. */
  61168. private _handlePointerActions;
  61169. /**
  61170. * Handle all actions that come from gamepad interaction
  61171. */
  61172. private _handleGamepadActions;
  61173. /**
  61174. * Update all non-event based devices with each frame
  61175. * @param deviceType Enum specifiying device type
  61176. * @param deviceSlot "Slot" or index that device is referenced in
  61177. * @param inputIndex Id of input to be checked
  61178. */
  61179. private _updateDevice;
  61180. /**
  61181. * Gets DeviceType from the device name
  61182. * @param deviceName Name of Device from DeviceInputSystem
  61183. * @returns DeviceType enum value
  61184. */
  61185. private _getGamepadDeviceType;
  61186. }
  61187. }
  61188. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  61189. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  61190. /**
  61191. * Type to handle enforcement of inputs
  61192. */
  61193. 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;
  61194. }
  61195. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  61196. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  61197. import { Engine } from "babylonjs/Engines/engine";
  61198. import { IDisposable } from "babylonjs/scene";
  61199. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  61200. import { Nullable } from "babylonjs/types";
  61201. import { Observable } from "babylonjs/Misc/observable";
  61202. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  61203. /**
  61204. * Class that handles all input for a specific device
  61205. */
  61206. export class DeviceSource<T extends DeviceType> {
  61207. /** Type of device */
  61208. readonly deviceType: DeviceType;
  61209. /** "Slot" or index that device is referenced in */
  61210. readonly deviceSlot: number;
  61211. /**
  61212. * Observable to handle device input changes per device
  61213. */
  61214. readonly onInputChangedObservable: Observable<{
  61215. inputIndex: DeviceInput<T>;
  61216. previousState: Nullable<number>;
  61217. currentState: Nullable<number>;
  61218. }>;
  61219. private readonly _deviceInputSystem;
  61220. /**
  61221. * Default Constructor
  61222. * @param deviceInputSystem Reference to DeviceInputSystem
  61223. * @param deviceType Type of device
  61224. * @param deviceSlot "Slot" or index that device is referenced in
  61225. */
  61226. constructor(deviceInputSystem: DeviceInputSystem,
  61227. /** Type of device */
  61228. deviceType: DeviceType,
  61229. /** "Slot" or index that device is referenced in */
  61230. deviceSlot?: number);
  61231. /**
  61232. * Get input for specific input
  61233. * @param inputIndex index of specific input on device
  61234. * @returns Input value from DeviceInputSystem
  61235. */
  61236. getInput(inputIndex: DeviceInput<T>): number;
  61237. }
  61238. /**
  61239. * Class to keep track of devices
  61240. */
  61241. export class DeviceSourceManager implements IDisposable {
  61242. /**
  61243. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  61244. */
  61245. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  61246. /**
  61247. * Observable to be triggered when after a device is disconnected
  61248. */
  61249. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  61250. private readonly _devices;
  61251. private readonly _firstDevice;
  61252. private readonly _deviceInputSystem;
  61253. /**
  61254. * Default Constructor
  61255. * @param engine engine to pull input element from
  61256. */
  61257. constructor(engine: Engine);
  61258. /**
  61259. * Gets a DeviceSource, given a type and slot
  61260. * @param deviceType Enum specifying device type
  61261. * @param deviceSlot "Slot" or index that device is referenced in
  61262. * @returns DeviceSource object
  61263. */
  61264. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  61265. /**
  61266. * Gets an array of DeviceSource objects for a given device type
  61267. * @param deviceType Enum specifying device type
  61268. * @returns Array of DeviceSource objects
  61269. */
  61270. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  61271. /**
  61272. * Returns a read-only list of all available devices
  61273. * @returns Read-only array with active devices
  61274. */
  61275. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  61276. /**
  61277. * Dispose of DeviceInputSystem and other parts
  61278. */
  61279. dispose(): void;
  61280. /**
  61281. * Function to add device name to device list
  61282. * @param deviceType Enum specifying device type
  61283. * @param deviceSlot "Slot" or index that device is referenced in
  61284. */
  61285. private _addDevice;
  61286. /**
  61287. * Function to remove device name to device list
  61288. * @param deviceType Enum specifying device type
  61289. * @param deviceSlot "Slot" or index that device is referenced in
  61290. */
  61291. private _removeDevice;
  61292. /**
  61293. * Updates array storing first connected device of each type
  61294. * @param type Type of Device
  61295. */
  61296. private _updateFirstDevices;
  61297. }
  61298. }
  61299. declare module "babylonjs/DeviceInput/index" {
  61300. export * from "babylonjs/DeviceInput/deviceInputSystem";
  61301. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  61302. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  61303. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  61304. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  61305. }
  61306. declare module "babylonjs/Engines/nullEngine" {
  61307. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  61308. import { Engine } from "babylonjs/Engines/engine";
  61309. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  61310. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  61311. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61312. import { Effect } from "babylonjs/Materials/effect";
  61313. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  61314. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  61315. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  61316. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  61317. /**
  61318. * Options to create the null engine
  61319. */
  61320. export class NullEngineOptions {
  61321. /**
  61322. * Render width (Default: 512)
  61323. */
  61324. renderWidth: number;
  61325. /**
  61326. * Render height (Default: 256)
  61327. */
  61328. renderHeight: number;
  61329. /**
  61330. * Texture size (Default: 512)
  61331. */
  61332. textureSize: number;
  61333. /**
  61334. * If delta time between frames should be constant
  61335. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  61336. */
  61337. deterministicLockstep: boolean;
  61338. /**
  61339. * Maximum about of steps between frames (Default: 4)
  61340. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  61341. */
  61342. lockstepMaxSteps: number;
  61343. /**
  61344. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  61345. */
  61346. useHighPrecisionMatrix?: boolean;
  61347. }
  61348. /**
  61349. * The null engine class provides support for headless version of babylon.js.
  61350. * This can be used in server side scenario or for testing purposes
  61351. */
  61352. export class NullEngine extends Engine {
  61353. private _options;
  61354. /**
  61355. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  61356. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  61357. * @returns true if engine is in deterministic lock step mode
  61358. */
  61359. isDeterministicLockStep(): boolean;
  61360. /**
  61361. * Gets the max steps when engine is running in deterministic lock step
  61362. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  61363. * @returns the max steps
  61364. */
  61365. getLockstepMaxSteps(): number;
  61366. /**
  61367. * Gets the current hardware scaling level.
  61368. * By default the hardware scaling level is computed from the window device ratio.
  61369. * 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.
  61370. * @returns a number indicating the current hardware scaling level
  61371. */
  61372. getHardwareScalingLevel(): number;
  61373. constructor(options?: NullEngineOptions);
  61374. /**
  61375. * Creates a vertex buffer
  61376. * @param vertices the data for the vertex buffer
  61377. * @returns the new WebGL static buffer
  61378. */
  61379. createVertexBuffer(vertices: FloatArray): DataBuffer;
  61380. /**
  61381. * Creates a new index buffer
  61382. * @param indices defines the content of the index buffer
  61383. * @param updatable defines if the index buffer must be updatable
  61384. * @returns a new webGL buffer
  61385. */
  61386. createIndexBuffer(indices: IndicesArray): DataBuffer;
  61387. /**
  61388. * Clear the current render buffer or the current render target (if any is set up)
  61389. * @param color defines the color to use
  61390. * @param backBuffer defines if the back buffer must be cleared
  61391. * @param depth defines if the depth buffer must be cleared
  61392. * @param stencil defines if the stencil buffer must be cleared
  61393. */
  61394. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  61395. /**
  61396. * Gets the current render width
  61397. * @param useScreen defines if screen size must be used (or the current render target if any)
  61398. * @returns a number defining the current render width
  61399. */
  61400. getRenderWidth(useScreen?: boolean): number;
  61401. /**
  61402. * Gets the current render height
  61403. * @param useScreen defines if screen size must be used (or the current render target if any)
  61404. * @returns a number defining the current render height
  61405. */
  61406. getRenderHeight(useScreen?: boolean): number;
  61407. /**
  61408. * Set the WebGL's viewport
  61409. * @param viewport defines the viewport element to be used
  61410. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  61411. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  61412. */
  61413. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  61414. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  61415. /**
  61416. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  61417. * @param pipelineContext defines the pipeline context to use
  61418. * @param uniformsNames defines the list of uniform names
  61419. * @returns an array of webGL uniform locations
  61420. */
  61421. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  61422. /**
  61423. * Gets the lsit of active attributes for a given webGL program
  61424. * @param pipelineContext defines the pipeline context to use
  61425. * @param attributesNames defines the list of attribute names to get
  61426. * @returns an array of indices indicating the offset of each attribute
  61427. */
  61428. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  61429. /**
  61430. * Binds an effect to the webGL context
  61431. * @param effect defines the effect to bind
  61432. */
  61433. bindSamplers(effect: Effect): void;
  61434. /**
  61435. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  61436. * @param effect defines the effect to activate
  61437. */
  61438. enableEffect(effect: Effect): void;
  61439. /**
  61440. * Set various states to the webGL context
  61441. * @param culling defines backface culling state
  61442. * @param zOffset defines the value to apply to zOffset (0 by default)
  61443. * @param force defines if states must be applied even if cache is up to date
  61444. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  61445. */
  61446. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  61447. /**
  61448. * Set the value of an uniform to an array of int32
  61449. * @param uniform defines the webGL uniform location where to store the value
  61450. * @param array defines the array of int32 to store
  61451. * @returns true if value was set
  61452. */
  61453. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  61454. /**
  61455. * Set the value of an uniform to an array of int32 (stored as vec2)
  61456. * @param uniform defines the webGL uniform location where to store the value
  61457. * @param array defines the array of int32 to store
  61458. * @returns true if value was set
  61459. */
  61460. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  61461. /**
  61462. * Set the value of an uniform to an array of int32 (stored as vec3)
  61463. * @param uniform defines the webGL uniform location where to store the value
  61464. * @param array defines the array of int32 to store
  61465. * @returns true if value was set
  61466. */
  61467. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  61468. /**
  61469. * Set the value of an uniform to an array of int32 (stored as vec4)
  61470. * @param uniform defines the webGL uniform location where to store the value
  61471. * @param array defines the array of int32 to store
  61472. * @returns true if value was set
  61473. */
  61474. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  61475. /**
  61476. * Set the value of an uniform to an array of float32
  61477. * @param uniform defines the webGL uniform location where to store the value
  61478. * @param array defines the array of float32 to store
  61479. * @returns true if value was set
  61480. */
  61481. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  61482. /**
  61483. * Set the value of an uniform to an array of float32 (stored as vec2)
  61484. * @param uniform defines the webGL uniform location where to store the value
  61485. * @param array defines the array of float32 to store
  61486. * @returns true if value was set
  61487. */
  61488. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  61489. /**
  61490. * Set the value of an uniform to an array of float32 (stored as vec3)
  61491. * @param uniform defines the webGL uniform location where to store the value
  61492. * @param array defines the array of float32 to store
  61493. * @returns true if value was set
  61494. */
  61495. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  61496. /**
  61497. * Set the value of an uniform to an array of float32 (stored as vec4)
  61498. * @param uniform defines the webGL uniform location where to store the value
  61499. * @param array defines the array of float32 to store
  61500. * @returns true if value was set
  61501. */
  61502. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  61503. /**
  61504. * Set the value of an uniform to an array of number
  61505. * @param uniform defines the webGL uniform location where to store the value
  61506. * @param array defines the array of number to store
  61507. * @returns true if value was set
  61508. */
  61509. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  61510. /**
  61511. * Set the value of an uniform to an array of number (stored as vec2)
  61512. * @param uniform defines the webGL uniform location where to store the value
  61513. * @param array defines the array of number to store
  61514. * @returns true if value was set
  61515. */
  61516. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  61517. /**
  61518. * Set the value of an uniform to an array of number (stored as vec3)
  61519. * @param uniform defines the webGL uniform location where to store the value
  61520. * @param array defines the array of number to store
  61521. * @returns true if value was set
  61522. */
  61523. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  61524. /**
  61525. * Set the value of an uniform to an array of number (stored as vec4)
  61526. * @param uniform defines the webGL uniform location where to store the value
  61527. * @param array defines the array of number to store
  61528. * @returns true if value was set
  61529. */
  61530. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  61531. /**
  61532. * Set the value of an uniform to an array of float32 (stored as matrices)
  61533. * @param uniform defines the webGL uniform location where to store the value
  61534. * @param matrices defines the array of float32 to store
  61535. * @returns true if value was set
  61536. */
  61537. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  61538. /**
  61539. * Set the value of an uniform to a matrix (3x3)
  61540. * @param uniform defines the webGL uniform location where to store the value
  61541. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  61542. * @returns true if value was set
  61543. */
  61544. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  61545. /**
  61546. * Set the value of an uniform to a matrix (2x2)
  61547. * @param uniform defines the webGL uniform location where to store the value
  61548. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  61549. * @returns true if value was set
  61550. */
  61551. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  61552. /**
  61553. * Set the value of an uniform to a number (float)
  61554. * @param uniform defines the webGL uniform location where to store the value
  61555. * @param value defines the float number to store
  61556. * @returns true if value was set
  61557. */
  61558. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  61559. /**
  61560. * Set the value of an uniform to a vec2
  61561. * @param uniform defines the webGL uniform location where to store the value
  61562. * @param x defines the 1st component of the value
  61563. * @param y defines the 2nd component of the value
  61564. * @returns true if value was set
  61565. */
  61566. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  61567. /**
  61568. * Set the value of an uniform to a vec3
  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. * @returns true if value was set
  61574. */
  61575. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  61576. /**
  61577. * Set the value of an uniform to a boolean
  61578. * @param uniform defines the webGL uniform location where to store the value
  61579. * @param bool defines the boolean to store
  61580. * @returns true if value was set
  61581. */
  61582. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  61583. /**
  61584. * Set the value of an uniform to a vec4
  61585. * @param uniform defines the webGL uniform location where to store the value
  61586. * @param x defines the 1st component of the value
  61587. * @param y defines the 2nd component of the value
  61588. * @param z defines the 3rd component of the value
  61589. * @param w defines the 4th component of the value
  61590. * @returns true if value was set
  61591. */
  61592. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  61593. /**
  61594. * Sets the current alpha mode
  61595. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  61596. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  61597. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  61598. */
  61599. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  61600. /**
  61601. * Bind webGl buffers directly to the webGL context
  61602. * @param vertexBuffers defines the vertex buffer to bind
  61603. * @param indexBuffer defines the index buffer to bind
  61604. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  61605. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  61606. * @param effect defines the effect associated with the vertex buffer
  61607. */
  61608. bindBuffers(vertexBuffers: {
  61609. [key: string]: VertexBuffer;
  61610. }, indexBuffer: DataBuffer, effect: Effect): void;
  61611. /**
  61612. * Force the entire cache to be cleared
  61613. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  61614. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  61615. */
  61616. wipeCaches(bruteForce?: boolean): void;
  61617. /**
  61618. * Send a draw order
  61619. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  61620. * @param indexStart defines the starting index
  61621. * @param indexCount defines the number of index to draw
  61622. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  61623. */
  61624. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  61625. /**
  61626. * Draw a list of indexed primitives
  61627. * @param fillMode defines the primitive to use
  61628. * @param indexStart defines the starting index
  61629. * @param indexCount defines the number of index to draw
  61630. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  61631. */
  61632. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  61633. /**
  61634. * Draw a list of unindexed primitives
  61635. * @param fillMode defines the primitive to use
  61636. * @param verticesStart defines the index of first vertex to draw
  61637. * @param verticesCount defines the count of vertices to draw
  61638. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  61639. */
  61640. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  61641. /** @hidden */
  61642. protected _createTexture(): WebGLTexture;
  61643. /** @hidden */
  61644. _releaseTexture(texture: InternalTexture): void;
  61645. /**
  61646. * Usually called from Texture.ts.
  61647. * Passed information to create a WebGLTexture
  61648. * @param urlArg defines a value which contains one of the following:
  61649. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  61650. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  61651. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  61652. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  61653. * @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)
  61654. * @param scene needed for loading to the correct scene
  61655. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  61656. * @param onLoad optional callback to be called upon successful completion
  61657. * @param onError optional callback to be called upon failure
  61658. * @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
  61659. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  61660. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  61661. * @param forcedExtension defines the extension to use to pick the right loader
  61662. * @param mimeType defines an optional mime type
  61663. * @returns a InternalTexture for assignment back into BABYLON.Texture
  61664. */
  61665. 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;
  61666. /**
  61667. * Creates a new render target texture
  61668. * @param size defines the size of the texture
  61669. * @param options defines the options used to create the texture
  61670. * @returns a new render target texture stored in an InternalTexture
  61671. */
  61672. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  61673. /**
  61674. * Update the sampling mode of a given texture
  61675. * @param samplingMode defines the required sampling mode
  61676. * @param texture defines the texture to update
  61677. */
  61678. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  61679. /**
  61680. * Binds the frame buffer to the specified texture.
  61681. * @param texture The texture to render to or null for the default canvas
  61682. * @param faceIndex The face of the texture to render to in case of cube texture
  61683. * @param requiredWidth The width of the target to render to
  61684. * @param requiredHeight The height of the target to render to
  61685. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  61686. * @param lodLevel defines le lod level to bind to the frame buffer
  61687. */
  61688. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  61689. /**
  61690. * Unbind the current render target texture from the webGL context
  61691. * @param texture defines the render target texture to unbind
  61692. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  61693. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  61694. */
  61695. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  61696. /**
  61697. * Creates a dynamic vertex buffer
  61698. * @param vertices the data for the dynamic vertex buffer
  61699. * @returns the new WebGL dynamic buffer
  61700. */
  61701. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  61702. /**
  61703. * Update the content of a dynamic texture
  61704. * @param texture defines the texture to update
  61705. * @param canvas defines the canvas containing the source
  61706. * @param invertY defines if data must be stored with Y axis inverted
  61707. * @param premulAlpha defines if alpha is stored as premultiplied
  61708. * @param format defines the format of the data
  61709. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  61710. */
  61711. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  61712. /**
  61713. * Gets a boolean indicating if all created effects are ready
  61714. * @returns true if all effects are ready
  61715. */
  61716. areAllEffectsReady(): boolean;
  61717. /**
  61718. * @hidden
  61719. * Get the current error code of the webGL context
  61720. * @returns the error code
  61721. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  61722. */
  61723. getError(): number;
  61724. /** @hidden */
  61725. _getUnpackAlignement(): number;
  61726. /** @hidden */
  61727. _unpackFlipY(value: boolean): void;
  61728. /**
  61729. * Update a dynamic index buffer
  61730. * @param indexBuffer defines the target index buffer
  61731. * @param indices defines the data to update
  61732. * @param offset defines the offset in the target index buffer where update should start
  61733. */
  61734. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  61735. /**
  61736. * Updates a dynamic vertex buffer.
  61737. * @param vertexBuffer the vertex buffer to update
  61738. * @param vertices the data used to update the vertex buffer
  61739. * @param byteOffset the byte offset of the data (optional)
  61740. * @param byteLength the byte length of the data (optional)
  61741. */
  61742. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  61743. /** @hidden */
  61744. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  61745. /** @hidden */
  61746. _bindTexture(channel: number, texture: InternalTexture): void;
  61747. protected _deleteBuffer(buffer: WebGLBuffer): void;
  61748. /**
  61749. * 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
  61750. */
  61751. releaseEffects(): void;
  61752. displayLoadingUI(): void;
  61753. hideLoadingUI(): void;
  61754. /** @hidden */
  61755. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  61756. /** @hidden */
  61757. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  61758. /** @hidden */
  61759. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  61760. /** @hidden */
  61761. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  61762. }
  61763. }
  61764. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  61765. import { Nullable, int } from "babylonjs/types";
  61766. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  61767. /** @hidden */
  61768. export class _OcclusionDataStorage {
  61769. /** @hidden */
  61770. occlusionInternalRetryCounter: number;
  61771. /** @hidden */
  61772. isOcclusionQueryInProgress: boolean;
  61773. /** @hidden */
  61774. isOccluded: boolean;
  61775. /** @hidden */
  61776. occlusionRetryCount: number;
  61777. /** @hidden */
  61778. occlusionType: number;
  61779. /** @hidden */
  61780. occlusionQueryAlgorithmType: number;
  61781. }
  61782. module "babylonjs/Engines/engine" {
  61783. interface Engine {
  61784. /**
  61785. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  61786. * @return the new query
  61787. */
  61788. createQuery(): WebGLQuery;
  61789. /**
  61790. * Delete and release a webGL query
  61791. * @param query defines the query to delete
  61792. * @return the current engine
  61793. */
  61794. deleteQuery(query: WebGLQuery): Engine;
  61795. /**
  61796. * Check if a given query has resolved and got its value
  61797. * @param query defines the query to check
  61798. * @returns true if the query got its value
  61799. */
  61800. isQueryResultAvailable(query: WebGLQuery): boolean;
  61801. /**
  61802. * Gets the value of a given query
  61803. * @param query defines the query to check
  61804. * @returns the value of the query
  61805. */
  61806. getQueryResult(query: WebGLQuery): number;
  61807. /**
  61808. * Initiates an occlusion query
  61809. * @param algorithmType defines the algorithm to use
  61810. * @param query defines the query to use
  61811. * @returns the current engine
  61812. * @see https://doc.babylonjs.com/features/occlusionquery
  61813. */
  61814. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  61815. /**
  61816. * Ends an occlusion query
  61817. * @see https://doc.babylonjs.com/features/occlusionquery
  61818. * @param algorithmType defines the algorithm to use
  61819. * @returns the current engine
  61820. */
  61821. endOcclusionQuery(algorithmType: number): Engine;
  61822. /**
  61823. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  61824. * Please note that only one query can be issued at a time
  61825. * @returns a time token used to track the time span
  61826. */
  61827. startTimeQuery(): Nullable<_TimeToken>;
  61828. /**
  61829. * Ends a time query
  61830. * @param token defines the token used to measure the time span
  61831. * @returns the time spent (in ns)
  61832. */
  61833. endTimeQuery(token: _TimeToken): int;
  61834. /** @hidden */
  61835. _currentNonTimestampToken: Nullable<_TimeToken>;
  61836. /** @hidden */
  61837. _createTimeQuery(): WebGLQuery;
  61838. /** @hidden */
  61839. _deleteTimeQuery(query: WebGLQuery): void;
  61840. /** @hidden */
  61841. _getGlAlgorithmType(algorithmType: number): number;
  61842. /** @hidden */
  61843. _getTimeQueryResult(query: WebGLQuery): any;
  61844. /** @hidden */
  61845. _getTimeQueryAvailability(query: WebGLQuery): any;
  61846. }
  61847. }
  61848. module "babylonjs/Meshes/abstractMesh" {
  61849. interface AbstractMesh {
  61850. /**
  61851. * Backing filed
  61852. * @hidden
  61853. */
  61854. __occlusionDataStorage: _OcclusionDataStorage;
  61855. /**
  61856. * Access property
  61857. * @hidden
  61858. */
  61859. _occlusionDataStorage: _OcclusionDataStorage;
  61860. /**
  61861. * 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.
  61862. * The default value is -1 which means don't break the query and wait till the result
  61863. * @see https://doc.babylonjs.com/features/occlusionquery
  61864. */
  61865. occlusionRetryCount: number;
  61866. /**
  61867. * 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:
  61868. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  61869. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  61870. * * 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.
  61871. * @see https://doc.babylonjs.com/features/occlusionquery
  61872. */
  61873. occlusionType: number;
  61874. /**
  61875. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  61876. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  61877. * * 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.
  61878. * @see https://doc.babylonjs.com/features/occlusionquery
  61879. */
  61880. occlusionQueryAlgorithmType: number;
  61881. /**
  61882. * 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
  61883. * @see https://doc.babylonjs.com/features/occlusionquery
  61884. */
  61885. isOccluded: boolean;
  61886. /**
  61887. * Flag to check the progress status of the query
  61888. * @see https://doc.babylonjs.com/features/occlusionquery
  61889. */
  61890. isOcclusionQueryInProgress: boolean;
  61891. }
  61892. }
  61893. }
  61894. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  61895. import { Nullable } from "babylonjs/types";
  61896. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  61897. /** @hidden */
  61898. export var _forceTransformFeedbackToBundle: boolean;
  61899. module "babylonjs/Engines/engine" {
  61900. interface Engine {
  61901. /**
  61902. * Creates a webGL transform feedback object
  61903. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  61904. * @returns the webGL transform feedback object
  61905. */
  61906. createTransformFeedback(): WebGLTransformFeedback;
  61907. /**
  61908. * Delete a webGL transform feedback object
  61909. * @param value defines the webGL transform feedback object to delete
  61910. */
  61911. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  61912. /**
  61913. * Bind a webGL transform feedback object to the webgl context
  61914. * @param value defines the webGL transform feedback object to bind
  61915. */
  61916. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  61917. /**
  61918. * Begins a transform feedback operation
  61919. * @param usePoints defines if points or triangles must be used
  61920. */
  61921. beginTransformFeedback(usePoints: boolean): void;
  61922. /**
  61923. * Ends a transform feedback operation
  61924. */
  61925. endTransformFeedback(): void;
  61926. /**
  61927. * Specify the varyings to use with transform feedback
  61928. * @param program defines the associated webGL program
  61929. * @param value defines the list of strings representing the varying names
  61930. */
  61931. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  61932. /**
  61933. * Bind a webGL buffer for a transform feedback operation
  61934. * @param value defines the webGL buffer to bind
  61935. */
  61936. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  61937. }
  61938. }
  61939. }
  61940. declare module "babylonjs/Engines/Extensions/engine.views" {
  61941. import { Camera } from "babylonjs/Cameras/camera";
  61942. import { Nullable } from "babylonjs/types";
  61943. /**
  61944. * Class used to define an additional view for the engine
  61945. * @see https://doc.babylonjs.com/how_to/multi_canvases
  61946. */
  61947. export class EngineView {
  61948. /** Defines the canvas where to render the view */
  61949. target: HTMLCanvasElement;
  61950. /** Defines an optional camera used to render the view (will use active camera else) */
  61951. camera?: Camera;
  61952. }
  61953. module "babylonjs/Engines/engine" {
  61954. interface Engine {
  61955. /**
  61956. * Gets or sets the HTML element to use for attaching events
  61957. */
  61958. inputElement: Nullable<HTMLElement>;
  61959. /**
  61960. * Gets the current engine view
  61961. * @see https://doc.babylonjs.com/how_to/multi_canvases
  61962. */
  61963. activeView: Nullable<EngineView>;
  61964. /** Gets or sets the list of views */
  61965. views: EngineView[];
  61966. /**
  61967. * Register a new child canvas
  61968. * @param canvas defines the canvas to register
  61969. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  61970. * @returns the associated view
  61971. */
  61972. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  61973. /**
  61974. * Remove a registered child canvas
  61975. * @param canvas defines the canvas to remove
  61976. * @returns the current engine
  61977. */
  61978. unRegisterView(canvas: HTMLCanvasElement): Engine;
  61979. }
  61980. }
  61981. }
  61982. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  61983. import { Nullable } from "babylonjs/types";
  61984. module "babylonjs/Engines/engine" {
  61985. interface Engine {
  61986. /** @hidden */
  61987. _excludedCompressedTextures: string[];
  61988. /** @hidden */
  61989. _textureFormatInUse: string;
  61990. /**
  61991. * Gets the list of texture formats supported
  61992. */
  61993. readonly texturesSupported: Array<string>;
  61994. /**
  61995. * Gets the texture format in use
  61996. */
  61997. readonly textureFormatInUse: Nullable<string>;
  61998. /**
  61999. * Set the compressed texture extensions or file names to skip.
  62000. *
  62001. * @param skippedFiles defines the list of those texture files you want to skip
  62002. * Example: [".dds", ".env", "myfile.png"]
  62003. */
  62004. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  62005. /**
  62006. * Set the compressed texture format to use, based on the formats you have, and the formats
  62007. * supported by the hardware / browser.
  62008. *
  62009. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  62010. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  62011. * to API arguments needed to compressed textures. This puts the burden on the container
  62012. * generator to house the arcane code for determining these for current & future formats.
  62013. *
  62014. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  62015. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  62016. *
  62017. * Note: The result of this call is not taken into account when a texture is base64.
  62018. *
  62019. * @param formatsAvailable defines the list of those format families you have created
  62020. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  62021. *
  62022. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  62023. * @returns The extension selected.
  62024. */
  62025. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  62026. }
  62027. }
  62028. }
  62029. declare module "babylonjs/Engines/Extensions/index" {
  62030. export * from "babylonjs/Engines/Extensions/engine.alpha";
  62031. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  62032. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  62033. export * from "babylonjs/Engines/Extensions/engine.multiview";
  62034. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  62035. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  62036. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  62037. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  62038. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  62039. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  62040. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  62041. export * from "babylonjs/Engines/Extensions/engine.webVR";
  62042. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  62043. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  62044. export * from "babylonjs/Engines/Extensions/engine.views";
  62045. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  62046. import "babylonjs/Engines/Extensions/engine.textureSelector";
  62047. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  62048. }
  62049. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  62050. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62051. /** @hidden */
  62052. export var rgbdEncodePixelShader: {
  62053. name: string;
  62054. shader: string;
  62055. };
  62056. }
  62057. declare module "babylonjs/Misc/environmentTextureTools" {
  62058. import { Nullable } from "babylonjs/types";
  62059. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  62060. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62061. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62062. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  62063. import "babylonjs/Engines/Extensions/engine.readTexture";
  62064. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  62065. import "babylonjs/Shaders/rgbdEncode.fragment";
  62066. import "babylonjs/Shaders/rgbdDecode.fragment";
  62067. /**
  62068. * Raw texture data and descriptor sufficient for WebGL texture upload
  62069. */
  62070. export interface EnvironmentTextureInfo {
  62071. /**
  62072. * Version of the environment map
  62073. */
  62074. version: number;
  62075. /**
  62076. * Width of image
  62077. */
  62078. width: number;
  62079. /**
  62080. * Irradiance information stored in the file.
  62081. */
  62082. irradiance: any;
  62083. /**
  62084. * Specular information stored in the file.
  62085. */
  62086. specular: any;
  62087. }
  62088. /**
  62089. * Defines One Image in the file. It requires only the position in the file
  62090. * as well as the length.
  62091. */
  62092. interface BufferImageData {
  62093. /**
  62094. * Length of the image data.
  62095. */
  62096. length: number;
  62097. /**
  62098. * Position of the data from the null terminator delimiting the end of the JSON.
  62099. */
  62100. position: number;
  62101. }
  62102. /**
  62103. * Defines the specular data enclosed in the file.
  62104. * This corresponds to the version 1 of the data.
  62105. */
  62106. export interface EnvironmentTextureSpecularInfoV1 {
  62107. /**
  62108. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  62109. */
  62110. specularDataPosition?: number;
  62111. /**
  62112. * This contains all the images data needed to reconstruct the cubemap.
  62113. */
  62114. mipmaps: Array<BufferImageData>;
  62115. /**
  62116. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  62117. */
  62118. lodGenerationScale: number;
  62119. }
  62120. /**
  62121. * Sets of helpers addressing the serialization and deserialization of environment texture
  62122. * stored in a BabylonJS env file.
  62123. * Those files are usually stored as .env files.
  62124. */
  62125. export class EnvironmentTextureTools {
  62126. /**
  62127. * Magic number identifying the env file.
  62128. */
  62129. private static _MagicBytes;
  62130. /**
  62131. * Gets the environment info from an env file.
  62132. * @param data The array buffer containing the .env bytes.
  62133. * @returns the environment file info (the json header) if successfully parsed.
  62134. */
  62135. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  62136. /**
  62137. * Creates an environment texture from a loaded cube texture.
  62138. * @param texture defines the cube texture to convert in env file
  62139. * @return a promise containing the environment data if succesfull.
  62140. */
  62141. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  62142. /**
  62143. * Creates a JSON representation of the spherical data.
  62144. * @param texture defines the texture containing the polynomials
  62145. * @return the JSON representation of the spherical info
  62146. */
  62147. private static _CreateEnvTextureIrradiance;
  62148. /**
  62149. * Creates the ArrayBufferViews used for initializing environment texture image data.
  62150. * @param data the image data
  62151. * @param info parameters that determine what views will be created for accessing the underlying buffer
  62152. * @return the views described by info providing access to the underlying buffer
  62153. */
  62154. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  62155. /**
  62156. * Uploads the texture info contained in the env file to the GPU.
  62157. * @param texture defines the internal texture to upload to
  62158. * @param data defines the data to load
  62159. * @param info defines the texture info retrieved through the GetEnvInfo method
  62160. * @returns a promise
  62161. */
  62162. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  62163. private static _OnImageReadyAsync;
  62164. /**
  62165. * Uploads the levels of image data to the GPU.
  62166. * @param texture defines the internal texture to upload to
  62167. * @param imageData defines the array buffer views of image data [mipmap][face]
  62168. * @returns a promise
  62169. */
  62170. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  62171. /**
  62172. * Uploads spherical polynomials information to the texture.
  62173. * @param texture defines the texture we are trying to upload the information to
  62174. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  62175. */
  62176. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  62177. /** @hidden */
  62178. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  62179. }
  62180. }
  62181. declare module "babylonjs/Engines/nativeEngine" {
  62182. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  62183. import { Engine } from "babylonjs/Engines/engine";
  62184. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  62185. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62186. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62187. import { Effect } from "babylonjs/Materials/effect";
  62188. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  62189. import { Scene } from "babylonjs/scene";
  62190. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  62191. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  62192. import { IMatrixLike, IColor3Like, IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  62193. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  62194. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  62195. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  62196. /**
  62197. * Container for accessors for natively-stored mesh data buffers.
  62198. */
  62199. class NativeDataBuffer extends DataBuffer {
  62200. /**
  62201. * Accessor value used to identify/retrieve a natively-stored index buffer.
  62202. */
  62203. nativeIndexBuffer?: any;
  62204. /**
  62205. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  62206. */
  62207. nativeVertexBuffer?: any;
  62208. }
  62209. /** @hidden */
  62210. class NativeTexture extends InternalTexture {
  62211. getInternalTexture(): InternalTexture;
  62212. getViewCount(): number;
  62213. }
  62214. /** @hidden */
  62215. export class NativeEngine extends Engine {
  62216. private readonly _native;
  62217. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  62218. private readonly INVALID_HANDLE;
  62219. private _boundBuffersVertexArray;
  62220. private _currentDepthTest;
  62221. getHardwareScalingLevel(): number;
  62222. constructor();
  62223. dispose(): void;
  62224. /**
  62225. * Can be used to override the current requestAnimationFrame requester.
  62226. * @hidden
  62227. */
  62228. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  62229. /**
  62230. * Override default engine behavior.
  62231. * @param color
  62232. * @param backBuffer
  62233. * @param depth
  62234. * @param stencil
  62235. */
  62236. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  62237. /**
  62238. * Gets host document
  62239. * @returns the host document object
  62240. */
  62241. getHostDocument(): Nullable<Document>;
  62242. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  62243. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  62244. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  62245. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  62246. [key: string]: VertexBuffer;
  62247. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  62248. bindBuffers(vertexBuffers: {
  62249. [key: string]: VertexBuffer;
  62250. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  62251. recordVertexArrayObject(vertexBuffers: {
  62252. [key: string]: VertexBuffer;
  62253. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  62254. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  62255. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  62256. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  62257. /**
  62258. * Draw a list of indexed primitives
  62259. * @param fillMode defines the primitive to use
  62260. * @param indexStart defines the starting index
  62261. * @param indexCount defines the number of index to draw
  62262. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  62263. */
  62264. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  62265. /**
  62266. * Draw a list of unindexed primitives
  62267. * @param fillMode defines the primitive to use
  62268. * @param verticesStart defines the index of first vertex to draw
  62269. * @param verticesCount defines the count of vertices to draw
  62270. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  62271. */
  62272. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  62273. createPipelineContext(): IPipelineContext;
  62274. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  62275. /** @hidden */
  62276. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  62277. /** @hidden */
  62278. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  62279. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  62280. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  62281. protected _setProgram(program: WebGLProgram): void;
  62282. _releaseEffect(effect: Effect): void;
  62283. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  62284. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  62285. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  62286. bindSamplers(effect: Effect): void;
  62287. setMatrix(uniform: WebGLUniformLocation, matrix: IMatrixLike): void;
  62288. getRenderWidth(useScreen?: boolean): number;
  62289. getRenderHeight(useScreen?: boolean): number;
  62290. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  62291. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  62292. /**
  62293. * Set the z offset to apply to current rendering
  62294. * @param value defines the offset to apply
  62295. */
  62296. setZOffset(value: number): void;
  62297. /**
  62298. * Gets the current value of the zOffset
  62299. * @returns the current zOffset state
  62300. */
  62301. getZOffset(): number;
  62302. /**
  62303. * Enable or disable depth buffering
  62304. * @param enable defines the state to set
  62305. */
  62306. setDepthBuffer(enable: boolean): void;
  62307. /**
  62308. * Gets a boolean indicating if depth writing is enabled
  62309. * @returns the current depth writing state
  62310. */
  62311. getDepthWrite(): boolean;
  62312. setDepthFunctionToGreater(): void;
  62313. setDepthFunctionToGreaterOrEqual(): void;
  62314. setDepthFunctionToLess(): void;
  62315. setDepthFunctionToLessOrEqual(): void;
  62316. /**
  62317. * Enable or disable depth writing
  62318. * @param enable defines the state to set
  62319. */
  62320. setDepthWrite(enable: boolean): void;
  62321. /**
  62322. * Enable or disable color writing
  62323. * @param enable defines the state to set
  62324. */
  62325. setColorWrite(enable: boolean): void;
  62326. /**
  62327. * Gets a boolean indicating if color writing is enabled
  62328. * @returns the current color writing state
  62329. */
  62330. getColorWrite(): boolean;
  62331. /**
  62332. * Sets alpha constants used by some alpha blending modes
  62333. * @param r defines the red component
  62334. * @param g defines the green component
  62335. * @param b defines the blue component
  62336. * @param a defines the alpha component
  62337. */
  62338. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  62339. /**
  62340. * Sets the current alpha mode
  62341. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  62342. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  62343. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  62344. */
  62345. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  62346. /**
  62347. * Gets the current alpha mode
  62348. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  62349. * @returns the current alpha mode
  62350. */
  62351. getAlphaMode(): number;
  62352. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  62353. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  62354. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  62355. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  62356. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  62357. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  62358. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  62359. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  62360. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  62361. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  62362. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  62363. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  62364. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  62365. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  62366. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  62367. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  62368. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  62369. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  62370. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  62371. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  62372. setColor3(uniform: WebGLUniformLocation, color3: IColor3Like): boolean;
  62373. setColor4(uniform: WebGLUniformLocation, color3: IColor3Like, alpha: number): boolean;
  62374. wipeCaches(bruteForce?: boolean): void;
  62375. protected _createTexture(): WebGLTexture;
  62376. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  62377. /**
  62378. * Update the content of a dynamic texture
  62379. * @param texture defines the texture to update
  62380. * @param canvas defines the canvas containing the source
  62381. * @param invertY defines if data must be stored with Y axis inverted
  62382. * @param premulAlpha defines if alpha is stored as premultiplied
  62383. * @param format defines the format of the data
  62384. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  62385. */
  62386. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  62387. /**
  62388. * Usually called from Texture.ts.
  62389. * Passed information to create a WebGLTexture
  62390. * @param url defines a value which contains one of the following:
  62391. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  62392. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  62393. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  62394. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  62395. * @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)
  62396. * @param scene needed for loading to the correct scene
  62397. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  62398. * @param onLoad optional callback to be called upon successful completion
  62399. * @param onError optional callback to be called upon failure
  62400. * @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
  62401. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  62402. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  62403. * @param forcedExtension defines the extension to use to pick the right loader
  62404. * @param mimeType defines an optional mime type
  62405. * @param loaderOptions options to be passed to the loader
  62406. * @returns a InternalTexture for assignment back into BABYLON.Texture
  62407. */
  62408. 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;
  62409. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  62410. _releaseFramebufferObjects(texture: InternalTexture): void;
  62411. /**
  62412. * Creates a cube texture
  62413. * @param rootUrl defines the url where the files to load is located
  62414. * @param scene defines the current scene
  62415. * @param files defines the list of files to load (1 per face)
  62416. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  62417. * @param onLoad defines an optional callback raised when the texture is loaded
  62418. * @param onError defines an optional callback raised if there is an issue to load the texture
  62419. * @param format defines the format of the data
  62420. * @param forcedExtension defines the extension to use to pick the right loader
  62421. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  62422. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  62423. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  62424. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  62425. * @returns the cube texture as an InternalTexture
  62426. */
  62427. 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;
  62428. createRenderTargetTexture(size: number | {
  62429. width: number;
  62430. height: number;
  62431. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  62432. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  62433. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  62434. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  62435. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  62436. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  62437. /**
  62438. * Updates a dynamic vertex buffer.
  62439. * @param vertexBuffer the vertex buffer to update
  62440. * @param data the data used to update the vertex buffer
  62441. * @param byteOffset the byte offset of the data (optional)
  62442. * @param byteLength the byte length of the data (optional)
  62443. */
  62444. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  62445. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  62446. private _updateAnisotropicLevel;
  62447. private _getAddressMode;
  62448. /** @hidden */
  62449. _bindTexture(channel: number, texture: InternalTexture): void;
  62450. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  62451. releaseEffects(): void;
  62452. /** @hidden */
  62453. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  62454. /** @hidden */
  62455. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  62456. /** @hidden */
  62457. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  62458. /** @hidden */
  62459. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  62460. private _getNativeSamplingMode;
  62461. private _getNativeTextureFormat;
  62462. private _getNativeAlphaMode;
  62463. private _getNativeAttribType;
  62464. }
  62465. }
  62466. declare module "babylonjs/Engines/index" {
  62467. export * from "babylonjs/Engines/constants";
  62468. export * from "babylonjs/Engines/engineCapabilities";
  62469. export * from "babylonjs/Engines/instancingAttributeInfo";
  62470. export * from "babylonjs/Engines/thinEngine";
  62471. export * from "babylonjs/Engines/engine";
  62472. export * from "babylonjs/Engines/engineStore";
  62473. export * from "babylonjs/Engines/nullEngine";
  62474. export * from "babylonjs/Engines/Extensions/index";
  62475. export * from "babylonjs/Engines/IPipelineContext";
  62476. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  62477. export * from "babylonjs/Engines/WebGPU/webgpuConstants";
  62478. export * from "babylonjs/Engines/webgpuEngine";
  62479. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  62480. export * from "babylonjs/Engines/nativeEngine";
  62481. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  62482. export * from "babylonjs/Engines/performanceConfigurator";
  62483. export * from "babylonjs/Engines/engineFeatures";
  62484. }
  62485. declare module "babylonjs/Events/clipboardEvents" {
  62486. /**
  62487. * Gather the list of clipboard event types as constants.
  62488. */
  62489. export class ClipboardEventTypes {
  62490. /**
  62491. * The clipboard event is fired when a copy command is active (pressed).
  62492. */
  62493. static readonly COPY: number;
  62494. /**
  62495. * The clipboard event is fired when a cut command is active (pressed).
  62496. */
  62497. static readonly CUT: number;
  62498. /**
  62499. * The clipboard event is fired when a paste command is active (pressed).
  62500. */
  62501. static readonly PASTE: number;
  62502. }
  62503. /**
  62504. * This class is used to store clipboard related info for the onClipboardObservable event.
  62505. */
  62506. export class ClipboardInfo {
  62507. /**
  62508. * Defines the type of event (BABYLON.ClipboardEventTypes)
  62509. */
  62510. type: number;
  62511. /**
  62512. * Defines the related dom event
  62513. */
  62514. event: ClipboardEvent;
  62515. /**
  62516. *Creates an instance of ClipboardInfo.
  62517. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  62518. * @param event Defines the related dom event
  62519. */
  62520. constructor(
  62521. /**
  62522. * Defines the type of event (BABYLON.ClipboardEventTypes)
  62523. */
  62524. type: number,
  62525. /**
  62526. * Defines the related dom event
  62527. */
  62528. event: ClipboardEvent);
  62529. /**
  62530. * Get the clipboard event's type from the keycode.
  62531. * @param keyCode Defines the keyCode for the current keyboard event.
  62532. * @return {number}
  62533. */
  62534. static GetTypeFromCharacter(keyCode: number): number;
  62535. }
  62536. }
  62537. declare module "babylonjs/Events/index" {
  62538. export * from "babylonjs/Events/keyboardEvents";
  62539. export * from "babylonjs/Events/pointerEvents";
  62540. export * from "babylonjs/Events/clipboardEvents";
  62541. }
  62542. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  62543. import { Scene } from "babylonjs/scene";
  62544. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62545. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  62546. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  62547. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  62548. /**
  62549. * Google Daydream controller
  62550. */
  62551. export class DaydreamController extends WebVRController {
  62552. /**
  62553. * Base Url for the controller model.
  62554. */
  62555. static MODEL_BASE_URL: string;
  62556. /**
  62557. * File name for the controller model.
  62558. */
  62559. static MODEL_FILENAME: string;
  62560. /**
  62561. * Gamepad Id prefix used to identify Daydream Controller.
  62562. */
  62563. static readonly GAMEPAD_ID_PREFIX: string;
  62564. /**
  62565. * Creates a new DaydreamController from a gamepad
  62566. * @param vrGamepad the gamepad that the controller should be created from
  62567. */
  62568. constructor(vrGamepad: any);
  62569. /**
  62570. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  62571. * @param scene scene in which to add meshes
  62572. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  62573. */
  62574. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  62575. /**
  62576. * Called once for each button that changed state since the last frame
  62577. * @param buttonIdx Which button index changed
  62578. * @param state New state of the button
  62579. * @param changes Which properties on the state changed since last frame
  62580. */
  62581. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  62582. }
  62583. }
  62584. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  62585. import { Scene } from "babylonjs/scene";
  62586. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62587. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  62588. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  62589. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  62590. /**
  62591. * Gear VR Controller
  62592. */
  62593. export class GearVRController extends WebVRController {
  62594. /**
  62595. * Base Url for the controller model.
  62596. */
  62597. static MODEL_BASE_URL: string;
  62598. /**
  62599. * File name for the controller model.
  62600. */
  62601. static MODEL_FILENAME: string;
  62602. /**
  62603. * Gamepad Id prefix used to identify this controller.
  62604. */
  62605. static readonly GAMEPAD_ID_PREFIX: string;
  62606. private readonly _buttonIndexToObservableNameMap;
  62607. /**
  62608. * Creates a new GearVRController from a gamepad
  62609. * @param vrGamepad the gamepad that the controller should be created from
  62610. */
  62611. constructor(vrGamepad: any);
  62612. /**
  62613. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  62614. * @param scene scene in which to add meshes
  62615. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  62616. */
  62617. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  62618. /**
  62619. * Called once for each button that changed state since the last frame
  62620. * @param buttonIdx Which button index changed
  62621. * @param state New state of the button
  62622. * @param changes Which properties on the state changed since last frame
  62623. */
  62624. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  62625. }
  62626. }
  62627. declare module "babylonjs/Gamepads/Controllers/genericController" {
  62628. import { Scene } from "babylonjs/scene";
  62629. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62630. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  62631. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  62632. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  62633. /**
  62634. * Generic Controller
  62635. */
  62636. export class GenericController extends WebVRController {
  62637. /**
  62638. * Base Url for the controller model.
  62639. */
  62640. static readonly MODEL_BASE_URL: string;
  62641. /**
  62642. * File name for the controller model.
  62643. */
  62644. static readonly MODEL_FILENAME: string;
  62645. /**
  62646. * Creates a new GenericController from a gamepad
  62647. * @param vrGamepad the gamepad that the controller should be created from
  62648. */
  62649. constructor(vrGamepad: any);
  62650. /**
  62651. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  62652. * @param scene scene in which to add meshes
  62653. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  62654. */
  62655. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  62656. /**
  62657. * Called once for each button that changed state since the last frame
  62658. * @param buttonIdx Which button index changed
  62659. * @param state New state of the button
  62660. * @param changes Which properties on the state changed since last frame
  62661. */
  62662. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  62663. }
  62664. }
  62665. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  62666. import { Observable } from "babylonjs/Misc/observable";
  62667. import { Scene } from "babylonjs/scene";
  62668. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62669. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  62670. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  62671. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  62672. /**
  62673. * Oculus Touch Controller
  62674. */
  62675. export class OculusTouchController extends WebVRController {
  62676. /**
  62677. * Base Url for the controller model.
  62678. */
  62679. static MODEL_BASE_URL: string;
  62680. /**
  62681. * File name for the left controller model.
  62682. */
  62683. static MODEL_LEFT_FILENAME: string;
  62684. /**
  62685. * File name for the right controller model.
  62686. */
  62687. static MODEL_RIGHT_FILENAME: string;
  62688. /**
  62689. * Base Url for the Quest controller model.
  62690. */
  62691. static QUEST_MODEL_BASE_URL: string;
  62692. /**
  62693. * @hidden
  62694. * If the controllers are running on a device that needs the updated Quest controller models
  62695. */
  62696. static _IsQuest: boolean;
  62697. /**
  62698. * Fired when the secondary trigger on this controller is modified
  62699. */
  62700. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  62701. /**
  62702. * Fired when the thumb rest on this controller is modified
  62703. */
  62704. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  62705. /**
  62706. * Creates a new OculusTouchController from a gamepad
  62707. * @param vrGamepad the gamepad that the controller should be created from
  62708. */
  62709. constructor(vrGamepad: any);
  62710. /**
  62711. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  62712. * @param scene scene in which to add meshes
  62713. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  62714. */
  62715. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  62716. /**
  62717. * Fired when the A button on this controller is modified
  62718. */
  62719. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  62720. /**
  62721. * Fired when the B button on this controller is modified
  62722. */
  62723. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  62724. /**
  62725. * Fired when the X button on this controller is modified
  62726. */
  62727. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  62728. /**
  62729. * Fired when the Y button on this controller is modified
  62730. */
  62731. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  62732. /**
  62733. * Called once for each button that changed state since the last frame
  62734. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  62735. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  62736. * 2) secondary trigger (same)
  62737. * 3) A (right) X (left), touch, pressed = value
  62738. * 4) B / Y
  62739. * 5) thumb rest
  62740. * @param buttonIdx Which button index changed
  62741. * @param state New state of the button
  62742. * @param changes Which properties on the state changed since last frame
  62743. */
  62744. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  62745. }
  62746. }
  62747. declare module "babylonjs/Gamepads/Controllers/viveController" {
  62748. import { Scene } from "babylonjs/scene";
  62749. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62750. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  62751. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  62752. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  62753. import { Observable } from "babylonjs/Misc/observable";
  62754. /**
  62755. * Vive Controller
  62756. */
  62757. export class ViveController extends WebVRController {
  62758. /**
  62759. * Base Url for the controller model.
  62760. */
  62761. static MODEL_BASE_URL: string;
  62762. /**
  62763. * File name for the controller model.
  62764. */
  62765. static MODEL_FILENAME: string;
  62766. /**
  62767. * Creates a new ViveController from a gamepad
  62768. * @param vrGamepad the gamepad that the controller should be created from
  62769. */
  62770. constructor(vrGamepad: any);
  62771. /**
  62772. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  62773. * @param scene scene in which to add meshes
  62774. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  62775. */
  62776. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  62777. /**
  62778. * Fired when the left button on this controller is modified
  62779. */
  62780. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  62781. /**
  62782. * Fired when the right button on this controller is modified
  62783. */
  62784. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  62785. /**
  62786. * Fired when the menu button on this controller is modified
  62787. */
  62788. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  62789. /**
  62790. * Called once for each button that changed state since the last frame
  62791. * Vive mapping:
  62792. * 0: touchpad
  62793. * 1: trigger
  62794. * 2: left AND right buttons
  62795. * 3: menu button
  62796. * @param buttonIdx Which button index changed
  62797. * @param state New state of the button
  62798. * @param changes Which properties on the state changed since last frame
  62799. */
  62800. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  62801. }
  62802. }
  62803. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  62804. import { Observable } from "babylonjs/Misc/observable";
  62805. import { Scene } from "babylonjs/scene";
  62806. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62807. import { Ray } from "babylonjs/Culling/ray";
  62808. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  62809. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  62810. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  62811. /**
  62812. * Defines the WindowsMotionController object that the state of the windows motion controller
  62813. */
  62814. export class WindowsMotionController extends WebVRController {
  62815. /**
  62816. * The base url used to load the left and right controller models
  62817. */
  62818. static MODEL_BASE_URL: string;
  62819. /**
  62820. * The name of the left controller model file
  62821. */
  62822. static MODEL_LEFT_FILENAME: string;
  62823. /**
  62824. * The name of the right controller model file
  62825. */
  62826. static MODEL_RIGHT_FILENAME: string;
  62827. /**
  62828. * The controller name prefix for this controller type
  62829. */
  62830. static readonly GAMEPAD_ID_PREFIX: string;
  62831. /**
  62832. * The controller id pattern for this controller type
  62833. */
  62834. private static readonly GAMEPAD_ID_PATTERN;
  62835. private _loadedMeshInfo;
  62836. protected readonly _mapping: {
  62837. buttons: string[];
  62838. buttonMeshNames: {
  62839. trigger: string;
  62840. menu: string;
  62841. grip: string;
  62842. thumbstick: string;
  62843. trackpad: string;
  62844. };
  62845. buttonObservableNames: {
  62846. trigger: string;
  62847. menu: string;
  62848. grip: string;
  62849. thumbstick: string;
  62850. trackpad: string;
  62851. };
  62852. axisMeshNames: string[];
  62853. pointingPoseMeshName: string;
  62854. };
  62855. /**
  62856. * Fired when the trackpad on this controller is clicked
  62857. */
  62858. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  62859. /**
  62860. * Fired when the trackpad on this controller is modified
  62861. */
  62862. onTrackpadValuesChangedObservable: Observable<StickValues>;
  62863. /**
  62864. * The current x and y values of this controller's trackpad
  62865. */
  62866. trackpad: StickValues;
  62867. /**
  62868. * Creates a new WindowsMotionController from a gamepad
  62869. * @param vrGamepad the gamepad that the controller should be created from
  62870. */
  62871. constructor(vrGamepad: any);
  62872. /**
  62873. * Fired when the trigger on this controller is modified
  62874. */
  62875. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  62876. /**
  62877. * Fired when the menu button on this controller is modified
  62878. */
  62879. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  62880. /**
  62881. * Fired when the grip button on this controller is modified
  62882. */
  62883. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  62884. /**
  62885. * Fired when the thumbstick button on this controller is modified
  62886. */
  62887. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  62888. /**
  62889. * Fired when the touchpad button on this controller is modified
  62890. */
  62891. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  62892. /**
  62893. * Fired when the touchpad values on this controller are modified
  62894. */
  62895. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  62896. protected _updateTrackpad(): void;
  62897. /**
  62898. * Called once per frame by the engine.
  62899. */
  62900. update(): void;
  62901. /**
  62902. * Called once for each button that changed state since the last frame
  62903. * @param buttonIdx Which button index changed
  62904. * @param state New state of the button
  62905. * @param changes Which properties on the state changed since last frame
  62906. */
  62907. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  62908. /**
  62909. * Moves the buttons on the controller mesh based on their current state
  62910. * @param buttonName the name of the button to move
  62911. * @param buttonValue the value of the button which determines the buttons new position
  62912. */
  62913. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  62914. /**
  62915. * Moves the axis on the controller mesh based on its current state
  62916. * @param axis the index of the axis
  62917. * @param axisValue the value of the axis which determines the meshes new position
  62918. * @hidden
  62919. */
  62920. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  62921. /**
  62922. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  62923. * @param scene scene in which to add meshes
  62924. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  62925. */
  62926. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  62927. /**
  62928. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  62929. * can be transformed by button presses and axes values, based on this._mapping.
  62930. *
  62931. * @param scene scene in which the meshes exist
  62932. * @param meshes list of meshes that make up the controller model to process
  62933. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  62934. */
  62935. private processModel;
  62936. private createMeshInfo;
  62937. /**
  62938. * Gets the ray of the controller in the direction the controller is pointing
  62939. * @param length the length the resulting ray should be
  62940. * @returns a ray in the direction the controller is pointing
  62941. */
  62942. getForwardRay(length?: number): Ray;
  62943. /**
  62944. * Disposes of the controller
  62945. */
  62946. dispose(): void;
  62947. }
  62948. /**
  62949. * This class represents a new windows motion controller in XR.
  62950. */
  62951. export class XRWindowsMotionController extends WindowsMotionController {
  62952. /**
  62953. * Changing the original WIndowsMotionController mapping to fir the new mapping
  62954. */
  62955. protected readonly _mapping: {
  62956. buttons: string[];
  62957. buttonMeshNames: {
  62958. trigger: string;
  62959. menu: string;
  62960. grip: string;
  62961. thumbstick: string;
  62962. trackpad: string;
  62963. };
  62964. buttonObservableNames: {
  62965. trigger: string;
  62966. menu: string;
  62967. grip: string;
  62968. thumbstick: string;
  62969. trackpad: string;
  62970. };
  62971. axisMeshNames: string[];
  62972. pointingPoseMeshName: string;
  62973. };
  62974. /**
  62975. * Construct a new XR-Based windows motion controller
  62976. *
  62977. * @param gamepadInfo the gamepad object from the browser
  62978. */
  62979. constructor(gamepadInfo: any);
  62980. /**
  62981. * holds the thumbstick values (X,Y)
  62982. */
  62983. thumbstickValues: StickValues;
  62984. /**
  62985. * Fired when the thumbstick on this controller is clicked
  62986. */
  62987. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  62988. /**
  62989. * Fired when the thumbstick on this controller is modified
  62990. */
  62991. onThumbstickValuesChangedObservable: Observable<StickValues>;
  62992. /**
  62993. * Fired when the touchpad button on this controller is modified
  62994. */
  62995. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  62996. /**
  62997. * Fired when the touchpad values on this controller are modified
  62998. */
  62999. onTrackpadValuesChangedObservable: Observable<StickValues>;
  63000. /**
  63001. * Fired when the thumbstick button on this controller is modified
  63002. * here to prevent breaking changes
  63003. */
  63004. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  63005. /**
  63006. * updating the thumbstick(!) and not the trackpad.
  63007. * This is named this way due to the difference between WebVR and XR and to avoid
  63008. * changing the parent class.
  63009. */
  63010. protected _updateTrackpad(): void;
  63011. /**
  63012. * Disposes the class with joy
  63013. */
  63014. dispose(): void;
  63015. }
  63016. }
  63017. declare module "babylonjs/Gamepads/Controllers/index" {
  63018. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  63019. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  63020. export * from "babylonjs/Gamepads/Controllers/genericController";
  63021. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  63022. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  63023. export * from "babylonjs/Gamepads/Controllers/viveController";
  63024. export * from "babylonjs/Gamepads/Controllers/webVRController";
  63025. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  63026. }
  63027. declare module "babylonjs/Gamepads/index" {
  63028. export * from "babylonjs/Gamepads/Controllers/index";
  63029. export * from "babylonjs/Gamepads/gamepad";
  63030. export * from "babylonjs/Gamepads/gamepadManager";
  63031. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  63032. export * from "babylonjs/Gamepads/xboxGamepad";
  63033. export * from "babylonjs/Gamepads/dualShockGamepad";
  63034. }
  63035. declare module "babylonjs/Lights/directionalLight" {
  63036. import { Camera } from "babylonjs/Cameras/camera";
  63037. import { Scene } from "babylonjs/scene";
  63038. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63039. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63040. import { Light } from "babylonjs/Lights/light";
  63041. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  63042. import { Effect } from "babylonjs/Materials/effect";
  63043. /**
  63044. * A directional light is defined by a direction (what a surprise!).
  63045. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  63046. * 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.
  63047. * Documentation: https://doc.babylonjs.com/babylon101/lights
  63048. */
  63049. export class DirectionalLight extends ShadowLight {
  63050. private _shadowFrustumSize;
  63051. /**
  63052. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  63053. */
  63054. get shadowFrustumSize(): number;
  63055. /**
  63056. * Specifies a fix frustum size for the shadow generation.
  63057. */
  63058. set shadowFrustumSize(value: number);
  63059. private _shadowOrthoScale;
  63060. /**
  63061. * Gets the shadow projection scale against the optimal computed one.
  63062. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  63063. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  63064. */
  63065. get shadowOrthoScale(): number;
  63066. /**
  63067. * Sets the shadow projection scale against the optimal computed one.
  63068. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  63069. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  63070. */
  63071. set shadowOrthoScale(value: number);
  63072. /**
  63073. * Automatically compute the projection matrix to best fit (including all the casters)
  63074. * on each frame.
  63075. */
  63076. autoUpdateExtends: boolean;
  63077. /**
  63078. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  63079. * on each frame. autoUpdateExtends must be set to true for this to work
  63080. */
  63081. autoCalcShadowZBounds: boolean;
  63082. private _orthoLeft;
  63083. private _orthoRight;
  63084. private _orthoTop;
  63085. private _orthoBottom;
  63086. /**
  63087. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  63088. * The directional light is emitted from everywhere in the given direction.
  63089. * It can cast shadows.
  63090. * Documentation : https://doc.babylonjs.com/babylon101/lights
  63091. * @param name The friendly name of the light
  63092. * @param direction The direction of the light
  63093. * @param scene The scene the light belongs to
  63094. */
  63095. constructor(name: string, direction: Vector3, scene: Scene);
  63096. /**
  63097. * Returns the string "DirectionalLight".
  63098. * @return The class name
  63099. */
  63100. getClassName(): string;
  63101. /**
  63102. * Returns the integer 1.
  63103. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  63104. */
  63105. getTypeID(): number;
  63106. /**
  63107. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  63108. * Returns the DirectionalLight Shadow projection matrix.
  63109. */
  63110. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  63111. /**
  63112. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  63113. * Returns the DirectionalLight Shadow projection matrix.
  63114. */
  63115. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  63116. /**
  63117. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  63118. * Returns the DirectionalLight Shadow projection matrix.
  63119. */
  63120. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  63121. protected _buildUniformLayout(): void;
  63122. /**
  63123. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  63124. * @param effect The effect to update
  63125. * @param lightIndex The index of the light in the effect to update
  63126. * @returns The directional light
  63127. */
  63128. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  63129. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  63130. /**
  63131. * Gets the minZ used for shadow according to both the scene and the light.
  63132. *
  63133. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  63134. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  63135. * @param activeCamera The camera we are returning the min for
  63136. * @returns the depth min z
  63137. */
  63138. getDepthMinZ(activeCamera: Camera): number;
  63139. /**
  63140. * Gets the maxZ used for shadow according to both the scene and the light.
  63141. *
  63142. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  63143. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  63144. * @param activeCamera The camera we are returning the max for
  63145. * @returns the depth max z
  63146. */
  63147. getDepthMaxZ(activeCamera: Camera): number;
  63148. /**
  63149. * Prepares the list of defines specific to the light type.
  63150. * @param defines the list of defines
  63151. * @param lightIndex defines the index of the light for the effect
  63152. */
  63153. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  63154. }
  63155. }
  63156. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  63157. import { Mesh } from "babylonjs/Meshes/mesh";
  63158. /**
  63159. * Class containing static functions to help procedurally build meshes
  63160. */
  63161. export class HemisphereBuilder {
  63162. /**
  63163. * Creates a hemisphere mesh
  63164. * @param name defines the name of the mesh
  63165. * @param options defines the options used to create the mesh
  63166. * @param scene defines the hosting scene
  63167. * @returns the hemisphere mesh
  63168. */
  63169. static CreateHemisphere(name: string, options: {
  63170. segments?: number;
  63171. diameter?: number;
  63172. sideOrientation?: number;
  63173. }, scene: any): Mesh;
  63174. }
  63175. }
  63176. declare module "babylonjs/Lights/spotLight" {
  63177. import { Nullable } from "babylonjs/types";
  63178. import { Scene } from "babylonjs/scene";
  63179. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63180. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63181. import { Effect } from "babylonjs/Materials/effect";
  63182. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63183. import { Light } from "babylonjs/Lights/light";
  63184. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  63185. /**
  63186. * A spot light is defined by a position, a direction, an angle, and an exponent.
  63187. * These values define a cone of light starting from the position, emitting toward the direction.
  63188. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  63189. * and the exponent defines the speed of the decay of the light with distance (reach).
  63190. * Documentation: https://doc.babylonjs.com/babylon101/lights
  63191. */
  63192. export class SpotLight extends ShadowLight {
  63193. private _angle;
  63194. private _innerAngle;
  63195. private _cosHalfAngle;
  63196. private _lightAngleScale;
  63197. private _lightAngleOffset;
  63198. /**
  63199. * Gets the cone angle of the spot light in Radians.
  63200. */
  63201. get angle(): number;
  63202. /**
  63203. * Sets the cone angle of the spot light in Radians.
  63204. */
  63205. set angle(value: number);
  63206. /**
  63207. * Only used in gltf falloff mode, this defines the angle where
  63208. * the directional falloff will start before cutting at angle which could be seen
  63209. * as outer angle.
  63210. */
  63211. get innerAngle(): number;
  63212. /**
  63213. * Only used in gltf falloff mode, this defines the angle where
  63214. * the directional falloff will start before cutting at angle which could be seen
  63215. * as outer angle.
  63216. */
  63217. set innerAngle(value: number);
  63218. private _shadowAngleScale;
  63219. /**
  63220. * Allows scaling the angle of the light for shadow generation only.
  63221. */
  63222. get shadowAngleScale(): number;
  63223. /**
  63224. * Allows scaling the angle of the light for shadow generation only.
  63225. */
  63226. set shadowAngleScale(value: number);
  63227. /**
  63228. * The light decay speed with the distance from the emission spot.
  63229. */
  63230. exponent: number;
  63231. private _projectionTextureMatrix;
  63232. /**
  63233. * Allows reading the projecton texture
  63234. */
  63235. get projectionTextureMatrix(): Matrix;
  63236. protected _projectionTextureLightNear: number;
  63237. /**
  63238. * Gets the near clip of the Spotlight for texture projection.
  63239. */
  63240. get projectionTextureLightNear(): number;
  63241. /**
  63242. * Sets the near clip of the Spotlight for texture projection.
  63243. */
  63244. set projectionTextureLightNear(value: number);
  63245. protected _projectionTextureLightFar: number;
  63246. /**
  63247. * Gets the far clip of the Spotlight for texture projection.
  63248. */
  63249. get projectionTextureLightFar(): number;
  63250. /**
  63251. * Sets the far clip of the Spotlight for texture projection.
  63252. */
  63253. set projectionTextureLightFar(value: number);
  63254. protected _projectionTextureUpDirection: Vector3;
  63255. /**
  63256. * Gets the Up vector of the Spotlight for texture projection.
  63257. */
  63258. get projectionTextureUpDirection(): Vector3;
  63259. /**
  63260. * Sets the Up vector of the Spotlight for texture projection.
  63261. */
  63262. set projectionTextureUpDirection(value: Vector3);
  63263. private _projectionTexture;
  63264. /**
  63265. * Gets the projection texture of the light.
  63266. */
  63267. get projectionTexture(): Nullable<BaseTexture>;
  63268. /**
  63269. * Sets the projection texture of the light.
  63270. */
  63271. set projectionTexture(value: Nullable<BaseTexture>);
  63272. private static _IsProceduralTexture;
  63273. private static _IsTexture;
  63274. private _projectionTextureViewLightDirty;
  63275. private _projectionTextureProjectionLightDirty;
  63276. private _projectionTextureDirty;
  63277. private _projectionTextureViewTargetVector;
  63278. private _projectionTextureViewLightMatrix;
  63279. private _projectionTextureProjectionLightMatrix;
  63280. private _projectionTextureScalingMatrix;
  63281. /**
  63282. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  63283. * It can cast shadows.
  63284. * Documentation : https://doc.babylonjs.com/babylon101/lights
  63285. * @param name The light friendly name
  63286. * @param position The position of the spot light in the scene
  63287. * @param direction The direction of the light in the scene
  63288. * @param angle The cone angle of the light in Radians
  63289. * @param exponent The light decay speed with the distance from the emission spot
  63290. * @param scene The scene the lights belongs to
  63291. */
  63292. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  63293. /**
  63294. * Returns the string "SpotLight".
  63295. * @returns the class name
  63296. */
  63297. getClassName(): string;
  63298. /**
  63299. * Returns the integer 2.
  63300. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  63301. */
  63302. getTypeID(): number;
  63303. /**
  63304. * Overrides the direction setter to recompute the projection texture view light Matrix.
  63305. */
  63306. protected _setDirection(value: Vector3): void;
  63307. /**
  63308. * Overrides the position setter to recompute the projection texture view light Matrix.
  63309. */
  63310. protected _setPosition(value: Vector3): void;
  63311. /**
  63312. * 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.
  63313. * Returns the SpotLight.
  63314. */
  63315. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  63316. protected _computeProjectionTextureViewLightMatrix(): void;
  63317. protected _computeProjectionTextureProjectionLightMatrix(): void;
  63318. /**
  63319. * Main function for light texture projection matrix computing.
  63320. */
  63321. protected _computeProjectionTextureMatrix(): void;
  63322. protected _buildUniformLayout(): void;
  63323. private _computeAngleValues;
  63324. /**
  63325. * Sets the passed Effect "effect" with the Light textures.
  63326. * @param effect The effect to update
  63327. * @param lightIndex The index of the light in the effect to update
  63328. * @returns The light
  63329. */
  63330. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  63331. /**
  63332. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  63333. * @param effect The effect to update
  63334. * @param lightIndex The index of the light in the effect to update
  63335. * @returns The spot light
  63336. */
  63337. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  63338. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  63339. /**
  63340. * Disposes the light and the associated resources.
  63341. */
  63342. dispose(): void;
  63343. /**
  63344. * Prepares the list of defines specific to the light type.
  63345. * @param defines the list of defines
  63346. * @param lightIndex defines the index of the light for the effect
  63347. */
  63348. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  63349. }
  63350. }
  63351. declare module "babylonjs/Gizmos/lightGizmo" {
  63352. import { Nullable } from "babylonjs/types";
  63353. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  63354. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  63355. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  63356. import { Light } from "babylonjs/Lights/light";
  63357. import { Observable } from "babylonjs/Misc/observable";
  63358. /**
  63359. * Gizmo that enables viewing a light
  63360. */
  63361. export class LightGizmo extends Gizmo {
  63362. private _lightMesh;
  63363. private _material;
  63364. private _cachedPosition;
  63365. private _cachedForward;
  63366. private _attachedMeshParent;
  63367. private _pointerObserver;
  63368. /**
  63369. * Event that fires each time the gizmo is clicked
  63370. */
  63371. onClickedObservable: Observable<Light>;
  63372. /**
  63373. * Creates a LightGizmo
  63374. * @param gizmoLayer The utility layer the gizmo will be added to
  63375. */
  63376. constructor(gizmoLayer?: UtilityLayerRenderer);
  63377. private _light;
  63378. /**
  63379. * The light that the gizmo is attached to
  63380. */
  63381. set light(light: Nullable<Light>);
  63382. get light(): Nullable<Light>;
  63383. /**
  63384. * Gets the material used to render the light gizmo
  63385. */
  63386. get material(): StandardMaterial;
  63387. /**
  63388. * @hidden
  63389. * Updates the gizmo to match the attached mesh's position/rotation
  63390. */
  63391. protected _update(): void;
  63392. private static _Scale;
  63393. /**
  63394. * Creates the lines for a light mesh
  63395. */
  63396. private static _CreateLightLines;
  63397. /**
  63398. * Disposes of the light gizmo
  63399. */
  63400. dispose(): void;
  63401. private static _CreateHemisphericLightMesh;
  63402. private static _CreatePointLightMesh;
  63403. private static _CreateSpotLightMesh;
  63404. private static _CreateDirectionalLightMesh;
  63405. }
  63406. }
  63407. declare module "babylonjs/Gizmos/cameraGizmo" {
  63408. import { Nullable } from "babylonjs/types";
  63409. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  63410. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  63411. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  63412. import { Camera } from "babylonjs/Cameras/camera";
  63413. import { Observable } from "babylonjs/Misc/observable";
  63414. /**
  63415. * Gizmo that enables viewing a camera
  63416. */
  63417. export class CameraGizmo extends Gizmo {
  63418. private _cameraMesh;
  63419. private _cameraLinesMesh;
  63420. private _material;
  63421. private _pointerObserver;
  63422. /**
  63423. * Event that fires each time the gizmo is clicked
  63424. */
  63425. onClickedObservable: Observable<Camera>;
  63426. /**
  63427. * Creates a CameraGizmo
  63428. * @param gizmoLayer The utility layer the gizmo will be added to
  63429. */
  63430. constructor(gizmoLayer?: UtilityLayerRenderer);
  63431. private _camera;
  63432. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  63433. get displayFrustum(): boolean;
  63434. set displayFrustum(value: boolean);
  63435. /**
  63436. * The camera that the gizmo is attached to
  63437. */
  63438. set camera(camera: Nullable<Camera>);
  63439. get camera(): Nullable<Camera>;
  63440. /**
  63441. * Gets the material used to render the camera gizmo
  63442. */
  63443. get material(): StandardMaterial;
  63444. /**
  63445. * @hidden
  63446. * Updates the gizmo to match the attached mesh's position/rotation
  63447. */
  63448. protected _update(): void;
  63449. private static _Scale;
  63450. private _invProjection;
  63451. /**
  63452. * Disposes of the camera gizmo
  63453. */
  63454. dispose(): void;
  63455. private static _CreateCameraMesh;
  63456. private static _CreateCameraFrustum;
  63457. }
  63458. }
  63459. declare module "babylonjs/Gizmos/index" {
  63460. export * from "babylonjs/Gizmos/axisDragGizmo";
  63461. export * from "babylonjs/Gizmos/axisScaleGizmo";
  63462. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  63463. export * from "babylonjs/Gizmos/gizmo";
  63464. export * from "babylonjs/Gizmos/gizmoManager";
  63465. export * from "babylonjs/Gizmos/planeRotationGizmo";
  63466. export * from "babylonjs/Gizmos/positionGizmo";
  63467. export * from "babylonjs/Gizmos/rotationGizmo";
  63468. export * from "babylonjs/Gizmos/scaleGizmo";
  63469. export * from "babylonjs/Gizmos/lightGizmo";
  63470. export * from "babylonjs/Gizmos/cameraGizmo";
  63471. export * from "babylonjs/Gizmos/planeDragGizmo";
  63472. }
  63473. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  63474. /** @hidden */
  63475. export var backgroundFragmentDeclaration: {
  63476. name: string;
  63477. shader: string;
  63478. };
  63479. }
  63480. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  63481. /** @hidden */
  63482. export var backgroundUboDeclaration: {
  63483. name: string;
  63484. shader: string;
  63485. };
  63486. }
  63487. declare module "babylonjs/Shaders/background.fragment" {
  63488. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  63489. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  63490. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  63491. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  63492. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  63493. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  63494. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63495. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  63496. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  63497. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  63498. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  63499. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  63500. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  63501. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  63502. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  63503. /** @hidden */
  63504. export var backgroundPixelShader: {
  63505. name: string;
  63506. shader: string;
  63507. };
  63508. }
  63509. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  63510. /** @hidden */
  63511. export var backgroundVertexDeclaration: {
  63512. name: string;
  63513. shader: string;
  63514. };
  63515. }
  63516. declare module "babylonjs/Shaders/background.vertex" {
  63517. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  63518. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  63519. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63520. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63521. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63522. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  63523. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  63524. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  63525. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  63526. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63527. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63528. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  63529. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  63530. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  63531. /** @hidden */
  63532. export var backgroundVertexShader: {
  63533. name: string;
  63534. shader: string;
  63535. };
  63536. }
  63537. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  63538. import { Nullable, int, float } from "babylonjs/types";
  63539. import { Scene } from "babylonjs/scene";
  63540. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63541. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63542. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63543. import { Mesh } from "babylonjs/Meshes/mesh";
  63544. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  63545. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  63546. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  63547. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63548. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  63549. import { Color3 } from "babylonjs/Maths/math.color";
  63550. import "babylonjs/Shaders/background.fragment";
  63551. import "babylonjs/Shaders/background.vertex";
  63552. /**
  63553. * Background material used to create an efficient environement around your scene.
  63554. */
  63555. export class BackgroundMaterial extends PushMaterial {
  63556. /**
  63557. * Standard reflectance value at parallel view angle.
  63558. */
  63559. static StandardReflectance0: number;
  63560. /**
  63561. * Standard reflectance value at grazing angle.
  63562. */
  63563. static StandardReflectance90: number;
  63564. protected _primaryColor: Color3;
  63565. /**
  63566. * Key light Color (multiply against the environement texture)
  63567. */
  63568. primaryColor: Color3;
  63569. protected __perceptualColor: Nullable<Color3>;
  63570. /**
  63571. * Experimental Internal Use Only.
  63572. *
  63573. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  63574. * This acts as a helper to set the primary color to a more "human friendly" value.
  63575. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  63576. * output color as close as possible from the chosen value.
  63577. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  63578. * part of lighting setup.)
  63579. */
  63580. get _perceptualColor(): Nullable<Color3>;
  63581. set _perceptualColor(value: Nullable<Color3>);
  63582. protected _primaryColorShadowLevel: float;
  63583. /**
  63584. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  63585. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  63586. */
  63587. get primaryColorShadowLevel(): float;
  63588. set primaryColorShadowLevel(value: float);
  63589. protected _primaryColorHighlightLevel: float;
  63590. /**
  63591. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  63592. * The primary color is used at the level chosen to define what the white area would look.
  63593. */
  63594. get primaryColorHighlightLevel(): float;
  63595. set primaryColorHighlightLevel(value: float);
  63596. protected _reflectionTexture: Nullable<BaseTexture>;
  63597. /**
  63598. * Reflection Texture used in the material.
  63599. * Should be author in a specific way for the best result (refer to the documentation).
  63600. */
  63601. reflectionTexture: Nullable<BaseTexture>;
  63602. protected _reflectionBlur: float;
  63603. /**
  63604. * Reflection Texture level of blur.
  63605. *
  63606. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  63607. * texture twice.
  63608. */
  63609. reflectionBlur: float;
  63610. protected _diffuseTexture: Nullable<BaseTexture>;
  63611. /**
  63612. * Diffuse Texture used in the material.
  63613. * Should be author in a specific way for the best result (refer to the documentation).
  63614. */
  63615. diffuseTexture: Nullable<BaseTexture>;
  63616. protected _shadowLights: Nullable<IShadowLight[]>;
  63617. /**
  63618. * Specify the list of lights casting shadow on the material.
  63619. * All scene shadow lights will be included if null.
  63620. */
  63621. shadowLights: Nullable<IShadowLight[]>;
  63622. protected _shadowLevel: float;
  63623. /**
  63624. * Helps adjusting the shadow to a softer level if required.
  63625. * 0 means black shadows and 1 means no shadows.
  63626. */
  63627. shadowLevel: float;
  63628. protected _sceneCenter: Vector3;
  63629. /**
  63630. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  63631. * It is usually zero but might be interesting to modify according to your setup.
  63632. */
  63633. sceneCenter: Vector3;
  63634. protected _opacityFresnel: boolean;
  63635. /**
  63636. * This helps specifying that the material is falling off to the sky box at grazing angle.
  63637. * This helps ensuring a nice transition when the camera goes under the ground.
  63638. */
  63639. opacityFresnel: boolean;
  63640. protected _reflectionFresnel: boolean;
  63641. /**
  63642. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  63643. * This helps adding a mirror texture on the ground.
  63644. */
  63645. reflectionFresnel: boolean;
  63646. protected _reflectionFalloffDistance: number;
  63647. /**
  63648. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  63649. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  63650. */
  63651. reflectionFalloffDistance: number;
  63652. protected _reflectionAmount: number;
  63653. /**
  63654. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  63655. */
  63656. reflectionAmount: number;
  63657. protected _reflectionReflectance0: number;
  63658. /**
  63659. * This specifies the weight of the reflection at grazing angle.
  63660. */
  63661. reflectionReflectance0: number;
  63662. protected _reflectionReflectance90: number;
  63663. /**
  63664. * This specifies the weight of the reflection at a perpendicular point of view.
  63665. */
  63666. reflectionReflectance90: number;
  63667. /**
  63668. * Sets the reflection reflectance fresnel values according to the default standard
  63669. * empirically know to work well :-)
  63670. */
  63671. set reflectionStandardFresnelWeight(value: number);
  63672. protected _useRGBColor: boolean;
  63673. /**
  63674. * Helps to directly use the maps channels instead of their level.
  63675. */
  63676. useRGBColor: boolean;
  63677. protected _enableNoise: boolean;
  63678. /**
  63679. * This helps reducing the banding effect that could occur on the background.
  63680. */
  63681. enableNoise: boolean;
  63682. /**
  63683. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  63684. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  63685. * Recommended to be keep at 1.0 except for special cases.
  63686. */
  63687. get fovMultiplier(): number;
  63688. set fovMultiplier(value: number);
  63689. private _fovMultiplier;
  63690. /**
  63691. * Enable the FOV adjustment feature controlled by fovMultiplier.
  63692. */
  63693. useEquirectangularFOV: boolean;
  63694. private _maxSimultaneousLights;
  63695. /**
  63696. * Number of Simultaneous lights allowed on the material.
  63697. */
  63698. maxSimultaneousLights: int;
  63699. private _shadowOnly;
  63700. /**
  63701. * Make the material only render shadows
  63702. */
  63703. shadowOnly: boolean;
  63704. /**
  63705. * Default configuration related to image processing available in the Background Material.
  63706. */
  63707. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  63708. /**
  63709. * Keep track of the image processing observer to allow dispose and replace.
  63710. */
  63711. private _imageProcessingObserver;
  63712. /**
  63713. * Attaches a new image processing configuration to the PBR Material.
  63714. * @param configuration (if null the scene configuration will be use)
  63715. */
  63716. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  63717. /**
  63718. * Gets the image processing configuration used either in this material.
  63719. */
  63720. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  63721. /**
  63722. * Sets the Default image processing configuration used either in the this material.
  63723. *
  63724. * If sets to null, the scene one is in use.
  63725. */
  63726. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  63727. /**
  63728. * Gets wether the color curves effect is enabled.
  63729. */
  63730. get cameraColorCurvesEnabled(): boolean;
  63731. /**
  63732. * Sets wether the color curves effect is enabled.
  63733. */
  63734. set cameraColorCurvesEnabled(value: boolean);
  63735. /**
  63736. * Gets wether the color grading effect is enabled.
  63737. */
  63738. get cameraColorGradingEnabled(): boolean;
  63739. /**
  63740. * Gets wether the color grading effect is enabled.
  63741. */
  63742. set cameraColorGradingEnabled(value: boolean);
  63743. /**
  63744. * Gets wether tonemapping is enabled or not.
  63745. */
  63746. get cameraToneMappingEnabled(): boolean;
  63747. /**
  63748. * Sets wether tonemapping is enabled or not
  63749. */
  63750. set cameraToneMappingEnabled(value: boolean);
  63751. /**
  63752. * The camera exposure used on this material.
  63753. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  63754. * This corresponds to a photographic exposure.
  63755. */
  63756. get cameraExposure(): float;
  63757. /**
  63758. * The camera exposure used on this material.
  63759. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  63760. * This corresponds to a photographic exposure.
  63761. */
  63762. set cameraExposure(value: float);
  63763. /**
  63764. * Gets The camera contrast used on this material.
  63765. */
  63766. get cameraContrast(): float;
  63767. /**
  63768. * Sets The camera contrast used on this material.
  63769. */
  63770. set cameraContrast(value: float);
  63771. /**
  63772. * Gets the Color Grading 2D Lookup Texture.
  63773. */
  63774. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  63775. /**
  63776. * Sets the Color Grading 2D Lookup Texture.
  63777. */
  63778. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  63779. /**
  63780. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  63781. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  63782. * 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;
  63783. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  63784. */
  63785. get cameraColorCurves(): Nullable<ColorCurves>;
  63786. /**
  63787. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  63788. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  63789. * 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;
  63790. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  63791. */
  63792. set cameraColorCurves(value: Nullable<ColorCurves>);
  63793. /**
  63794. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  63795. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  63796. */
  63797. switchToBGR: boolean;
  63798. private _renderTargets;
  63799. private _reflectionControls;
  63800. private _white;
  63801. private _primaryShadowColor;
  63802. private _primaryHighlightColor;
  63803. /**
  63804. * Instantiates a Background Material in the given scene
  63805. * @param name The friendly name of the material
  63806. * @param scene The scene to add the material to
  63807. */
  63808. constructor(name: string, scene: Scene);
  63809. /**
  63810. * Gets a boolean indicating that current material needs to register RTT
  63811. */
  63812. get hasRenderTargetTextures(): boolean;
  63813. /**
  63814. * The entire material has been created in order to prevent overdraw.
  63815. * @returns false
  63816. */
  63817. needAlphaTesting(): boolean;
  63818. /**
  63819. * The entire material has been created in order to prevent overdraw.
  63820. * @returns true if blending is enable
  63821. */
  63822. needAlphaBlending(): boolean;
  63823. /**
  63824. * Checks wether the material is ready to be rendered for a given mesh.
  63825. * @param mesh The mesh to render
  63826. * @param subMesh The submesh to check against
  63827. * @param useInstances Specify wether or not the material is used with instances
  63828. * @returns true if all the dependencies are ready (Textures, Effects...)
  63829. */
  63830. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  63831. /**
  63832. * Compute the primary color according to the chosen perceptual color.
  63833. */
  63834. private _computePrimaryColorFromPerceptualColor;
  63835. /**
  63836. * Compute the highlights and shadow colors according to their chosen levels.
  63837. */
  63838. private _computePrimaryColors;
  63839. /**
  63840. * Build the uniform buffer used in the material.
  63841. */
  63842. buildUniformLayout(): void;
  63843. /**
  63844. * Unbind the material.
  63845. */
  63846. unbind(): void;
  63847. /**
  63848. * Bind only the world matrix to the material.
  63849. * @param world The world matrix to bind.
  63850. */
  63851. bindOnlyWorldMatrix(world: Matrix): void;
  63852. /**
  63853. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  63854. * @param world The world matrix to bind.
  63855. * @param subMesh The submesh to bind for.
  63856. */
  63857. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  63858. /**
  63859. * Checks to see if a texture is used in the material.
  63860. * @param texture - Base texture to use.
  63861. * @returns - Boolean specifying if a texture is used in the material.
  63862. */
  63863. hasTexture(texture: BaseTexture): boolean;
  63864. /**
  63865. * Dispose the material.
  63866. * @param forceDisposeEffect Force disposal of the associated effect.
  63867. * @param forceDisposeTextures Force disposal of the associated textures.
  63868. */
  63869. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  63870. /**
  63871. * Clones the material.
  63872. * @param name The cloned name.
  63873. * @returns The cloned material.
  63874. */
  63875. clone(name: string): BackgroundMaterial;
  63876. /**
  63877. * Serializes the current material to its JSON representation.
  63878. * @returns The JSON representation.
  63879. */
  63880. serialize(): any;
  63881. /**
  63882. * Gets the class name of the material
  63883. * @returns "BackgroundMaterial"
  63884. */
  63885. getClassName(): string;
  63886. /**
  63887. * Parse a JSON input to create back a background material.
  63888. * @param source The JSON data to parse
  63889. * @param scene The scene to create the parsed material in
  63890. * @param rootUrl The root url of the assets the material depends upon
  63891. * @returns the instantiated BackgroundMaterial.
  63892. */
  63893. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  63894. }
  63895. }
  63896. declare module "babylonjs/Helpers/environmentHelper" {
  63897. import { Observable } from "babylonjs/Misc/observable";
  63898. import { Nullable } from "babylonjs/types";
  63899. import { Scene } from "babylonjs/scene";
  63900. import { Vector3 } from "babylonjs/Maths/math.vector";
  63901. import { Color3 } from "babylonjs/Maths/math.color";
  63902. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63903. import { Mesh } from "babylonjs/Meshes/mesh";
  63904. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63905. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  63906. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  63907. import "babylonjs/Meshes/Builders/planeBuilder";
  63908. import "babylonjs/Meshes/Builders/boxBuilder";
  63909. /**
  63910. * Represents the different options available during the creation of
  63911. * a Environment helper.
  63912. *
  63913. * This can control the default ground, skybox and image processing setup of your scene.
  63914. */
  63915. export interface IEnvironmentHelperOptions {
  63916. /**
  63917. * Specifies whether or not to create a ground.
  63918. * True by default.
  63919. */
  63920. createGround: boolean;
  63921. /**
  63922. * Specifies the ground size.
  63923. * 15 by default.
  63924. */
  63925. groundSize: number;
  63926. /**
  63927. * The texture used on the ground for the main color.
  63928. * Comes from the BabylonJS CDN by default.
  63929. *
  63930. * Remarks: Can be either a texture or a url.
  63931. */
  63932. groundTexture: string | BaseTexture;
  63933. /**
  63934. * The color mixed in the ground texture by default.
  63935. * BabylonJS clearColor by default.
  63936. */
  63937. groundColor: Color3;
  63938. /**
  63939. * Specifies the ground opacity.
  63940. * 1 by default.
  63941. */
  63942. groundOpacity: number;
  63943. /**
  63944. * Enables the ground to receive shadows.
  63945. * True by default.
  63946. */
  63947. enableGroundShadow: boolean;
  63948. /**
  63949. * Helps preventing the shadow to be fully black on the ground.
  63950. * 0.5 by default.
  63951. */
  63952. groundShadowLevel: number;
  63953. /**
  63954. * Creates a mirror texture attach to the ground.
  63955. * false by default.
  63956. */
  63957. enableGroundMirror: boolean;
  63958. /**
  63959. * Specifies the ground mirror size ratio.
  63960. * 0.3 by default as the default kernel is 64.
  63961. */
  63962. groundMirrorSizeRatio: number;
  63963. /**
  63964. * Specifies the ground mirror blur kernel size.
  63965. * 64 by default.
  63966. */
  63967. groundMirrorBlurKernel: number;
  63968. /**
  63969. * Specifies the ground mirror visibility amount.
  63970. * 1 by default
  63971. */
  63972. groundMirrorAmount: number;
  63973. /**
  63974. * Specifies the ground mirror reflectance weight.
  63975. * This uses the standard weight of the background material to setup the fresnel effect
  63976. * of the mirror.
  63977. * 1 by default.
  63978. */
  63979. groundMirrorFresnelWeight: number;
  63980. /**
  63981. * Specifies the ground mirror Falloff distance.
  63982. * This can helps reducing the size of the reflection.
  63983. * 0 by Default.
  63984. */
  63985. groundMirrorFallOffDistance: number;
  63986. /**
  63987. * Specifies the ground mirror texture type.
  63988. * Unsigned Int by Default.
  63989. */
  63990. groundMirrorTextureType: number;
  63991. /**
  63992. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  63993. * the shown objects.
  63994. */
  63995. groundYBias: number;
  63996. /**
  63997. * Specifies whether or not to create a skybox.
  63998. * True by default.
  63999. */
  64000. createSkybox: boolean;
  64001. /**
  64002. * Specifies the skybox size.
  64003. * 20 by default.
  64004. */
  64005. skyboxSize: number;
  64006. /**
  64007. * The texture used on the skybox for the main color.
  64008. * Comes from the BabylonJS CDN by default.
  64009. *
  64010. * Remarks: Can be either a texture or a url.
  64011. */
  64012. skyboxTexture: string | BaseTexture;
  64013. /**
  64014. * The color mixed in the skybox texture by default.
  64015. * BabylonJS clearColor by default.
  64016. */
  64017. skyboxColor: Color3;
  64018. /**
  64019. * The background rotation around the Y axis of the scene.
  64020. * This helps aligning the key lights of your scene with the background.
  64021. * 0 by default.
  64022. */
  64023. backgroundYRotation: number;
  64024. /**
  64025. * Compute automatically the size of the elements to best fit with the scene.
  64026. */
  64027. sizeAuto: boolean;
  64028. /**
  64029. * Default position of the rootMesh if autoSize is not true.
  64030. */
  64031. rootPosition: Vector3;
  64032. /**
  64033. * Sets up the image processing in the scene.
  64034. * true by default.
  64035. */
  64036. setupImageProcessing: boolean;
  64037. /**
  64038. * The texture used as your environment texture in the scene.
  64039. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  64040. *
  64041. * Remarks: Can be either a texture or a url.
  64042. */
  64043. environmentTexture: string | BaseTexture;
  64044. /**
  64045. * The value of the exposure to apply to the scene.
  64046. * 0.6 by default if setupImageProcessing is true.
  64047. */
  64048. cameraExposure: number;
  64049. /**
  64050. * The value of the contrast to apply to the scene.
  64051. * 1.6 by default if setupImageProcessing is true.
  64052. */
  64053. cameraContrast: number;
  64054. /**
  64055. * Specifies whether or not tonemapping should be enabled in the scene.
  64056. * true by default if setupImageProcessing is true.
  64057. */
  64058. toneMappingEnabled: boolean;
  64059. }
  64060. /**
  64061. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  64062. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  64063. * It also helps with the default setup of your imageProcessing configuration.
  64064. */
  64065. export class EnvironmentHelper {
  64066. /**
  64067. * Default ground texture URL.
  64068. */
  64069. private static _groundTextureCDNUrl;
  64070. /**
  64071. * Default skybox texture URL.
  64072. */
  64073. private static _skyboxTextureCDNUrl;
  64074. /**
  64075. * Default environment texture URL.
  64076. */
  64077. private static _environmentTextureCDNUrl;
  64078. /**
  64079. * Creates the default options for the helper.
  64080. */
  64081. private static _getDefaultOptions;
  64082. private _rootMesh;
  64083. /**
  64084. * Gets the root mesh created by the helper.
  64085. */
  64086. get rootMesh(): Mesh;
  64087. private _skybox;
  64088. /**
  64089. * Gets the skybox created by the helper.
  64090. */
  64091. get skybox(): Nullable<Mesh>;
  64092. private _skyboxTexture;
  64093. /**
  64094. * Gets the skybox texture created by the helper.
  64095. */
  64096. get skyboxTexture(): Nullable<BaseTexture>;
  64097. private _skyboxMaterial;
  64098. /**
  64099. * Gets the skybox material created by the helper.
  64100. */
  64101. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  64102. private _ground;
  64103. /**
  64104. * Gets the ground mesh created by the helper.
  64105. */
  64106. get ground(): Nullable<Mesh>;
  64107. private _groundTexture;
  64108. /**
  64109. * Gets the ground texture created by the helper.
  64110. */
  64111. get groundTexture(): Nullable<BaseTexture>;
  64112. private _groundMirror;
  64113. /**
  64114. * Gets the ground mirror created by the helper.
  64115. */
  64116. get groundMirror(): Nullable<MirrorTexture>;
  64117. /**
  64118. * Gets the ground mirror render list to helps pushing the meshes
  64119. * you wish in the ground reflection.
  64120. */
  64121. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  64122. private _groundMaterial;
  64123. /**
  64124. * Gets the ground material created by the helper.
  64125. */
  64126. get groundMaterial(): Nullable<BackgroundMaterial>;
  64127. /**
  64128. * Stores the creation options.
  64129. */
  64130. private readonly _scene;
  64131. private _options;
  64132. /**
  64133. * This observable will be notified with any error during the creation of the environment,
  64134. * mainly texture creation errors.
  64135. */
  64136. onErrorObservable: Observable<{
  64137. message?: string;
  64138. exception?: any;
  64139. }>;
  64140. /**
  64141. * constructor
  64142. * @param options Defines the options we want to customize the helper
  64143. * @param scene The scene to add the material to
  64144. */
  64145. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  64146. /**
  64147. * Updates the background according to the new options
  64148. * @param options
  64149. */
  64150. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  64151. /**
  64152. * Sets the primary color of all the available elements.
  64153. * @param color the main color to affect to the ground and the background
  64154. */
  64155. setMainColor(color: Color3): void;
  64156. /**
  64157. * Setup the image processing according to the specified options.
  64158. */
  64159. private _setupImageProcessing;
  64160. /**
  64161. * Setup the environment texture according to the specified options.
  64162. */
  64163. private _setupEnvironmentTexture;
  64164. /**
  64165. * Setup the background according to the specified options.
  64166. */
  64167. private _setupBackground;
  64168. /**
  64169. * Get the scene sizes according to the setup.
  64170. */
  64171. private _getSceneSize;
  64172. /**
  64173. * Setup the ground according to the specified options.
  64174. */
  64175. private _setupGround;
  64176. /**
  64177. * Setup the ground material according to the specified options.
  64178. */
  64179. private _setupGroundMaterial;
  64180. /**
  64181. * Setup the ground diffuse texture according to the specified options.
  64182. */
  64183. private _setupGroundDiffuseTexture;
  64184. /**
  64185. * Setup the ground mirror texture according to the specified options.
  64186. */
  64187. private _setupGroundMirrorTexture;
  64188. /**
  64189. * Setup the ground to receive the mirror texture.
  64190. */
  64191. private _setupMirrorInGroundMaterial;
  64192. /**
  64193. * Setup the skybox according to the specified options.
  64194. */
  64195. private _setupSkybox;
  64196. /**
  64197. * Setup the skybox material according to the specified options.
  64198. */
  64199. private _setupSkyboxMaterial;
  64200. /**
  64201. * Setup the skybox reflection texture according to the specified options.
  64202. */
  64203. private _setupSkyboxReflectionTexture;
  64204. private _errorHandler;
  64205. /**
  64206. * Dispose all the elements created by the Helper.
  64207. */
  64208. dispose(): void;
  64209. }
  64210. }
  64211. declare module "babylonjs/Helpers/textureDome" {
  64212. import { Scene } from "babylonjs/scene";
  64213. import { TransformNode } from "babylonjs/Meshes/transformNode";
  64214. import { Mesh } from "babylonjs/Meshes/mesh";
  64215. import { Texture } from "babylonjs/Materials/Textures/texture";
  64216. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  64217. import "babylonjs/Meshes/Builders/sphereBuilder";
  64218. import { Nullable } from "babylonjs/types";
  64219. import { Observable } from "babylonjs/Misc/observable";
  64220. /**
  64221. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  64222. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  64223. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  64224. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  64225. */
  64226. export abstract class TextureDome<T extends Texture> extends TransformNode {
  64227. protected onError: Nullable<(message?: string, exception?: any) => void>;
  64228. /**
  64229. * Define the source as a Monoscopic panoramic 360/180.
  64230. */
  64231. static readonly MODE_MONOSCOPIC: number;
  64232. /**
  64233. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  64234. */
  64235. static readonly MODE_TOPBOTTOM: number;
  64236. /**
  64237. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  64238. */
  64239. static readonly MODE_SIDEBYSIDE: number;
  64240. private _halfDome;
  64241. private _crossEye;
  64242. protected _useDirectMapping: boolean;
  64243. /**
  64244. * The texture being displayed on the sphere
  64245. */
  64246. protected _texture: T;
  64247. /**
  64248. * Gets the texture being displayed on the sphere
  64249. */
  64250. get texture(): T;
  64251. /**
  64252. * Sets the texture being displayed on the sphere
  64253. */
  64254. set texture(newTexture: T);
  64255. /**
  64256. * The skybox material
  64257. */
  64258. protected _material: BackgroundMaterial;
  64259. /**
  64260. * The surface used for the dome
  64261. */
  64262. protected _mesh: Mesh;
  64263. /**
  64264. * Gets the mesh used for the dome.
  64265. */
  64266. get mesh(): Mesh;
  64267. /**
  64268. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  64269. */
  64270. private _halfDomeMask;
  64271. /**
  64272. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  64273. * Also see the options.resolution property.
  64274. */
  64275. get fovMultiplier(): number;
  64276. set fovMultiplier(value: number);
  64277. protected _textureMode: number;
  64278. /**
  64279. * Gets or set the current texture mode for the texture. It can be:
  64280. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  64281. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  64282. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  64283. */
  64284. get textureMode(): number;
  64285. /**
  64286. * Sets the current texture mode for the texture. It can be:
  64287. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  64288. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  64289. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  64290. */
  64291. set textureMode(value: number);
  64292. /**
  64293. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  64294. */
  64295. get halfDome(): boolean;
  64296. /**
  64297. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  64298. */
  64299. set halfDome(enabled: boolean);
  64300. /**
  64301. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  64302. */
  64303. set crossEye(enabled: boolean);
  64304. /**
  64305. * Is it a cross-eye texture?
  64306. */
  64307. get crossEye(): boolean;
  64308. /**
  64309. * The background material of this dome.
  64310. */
  64311. get material(): BackgroundMaterial;
  64312. /**
  64313. * Oberserver used in Stereoscopic VR Mode.
  64314. */
  64315. private _onBeforeCameraRenderObserver;
  64316. /**
  64317. * Observable raised when an error occured while loading the 360 image
  64318. */
  64319. onLoadErrorObservable: Observable<string>;
  64320. /**
  64321. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  64322. * @param name Element's name, child elements will append suffixes for their own names.
  64323. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  64324. * @param options An object containing optional or exposed sub element properties
  64325. */
  64326. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  64327. resolution?: number;
  64328. clickToPlay?: boolean;
  64329. autoPlay?: boolean;
  64330. loop?: boolean;
  64331. size?: number;
  64332. poster?: string;
  64333. faceForward?: boolean;
  64334. useDirectMapping?: boolean;
  64335. halfDomeMode?: boolean;
  64336. crossEyeMode?: boolean;
  64337. generateMipMaps?: boolean;
  64338. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  64339. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  64340. protected _changeTextureMode(value: number): void;
  64341. /**
  64342. * Releases resources associated with this node.
  64343. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  64344. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  64345. */
  64346. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  64347. }
  64348. }
  64349. declare module "babylonjs/Helpers/photoDome" {
  64350. import { Scene } from "babylonjs/scene";
  64351. import { Texture } from "babylonjs/Materials/Textures/texture";
  64352. import { TextureDome } from "babylonjs/Helpers/textureDome";
  64353. /**
  64354. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  64355. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  64356. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  64357. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  64358. */
  64359. export class PhotoDome extends TextureDome<Texture> {
  64360. /**
  64361. * Define the image as a Monoscopic panoramic 360 image.
  64362. */
  64363. static readonly MODE_MONOSCOPIC: number;
  64364. /**
  64365. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  64366. */
  64367. static readonly MODE_TOPBOTTOM: number;
  64368. /**
  64369. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  64370. */
  64371. static readonly MODE_SIDEBYSIDE: number;
  64372. /**
  64373. * Gets or sets the texture being displayed on the sphere
  64374. */
  64375. get photoTexture(): Texture;
  64376. /**
  64377. * sets the texture being displayed on the sphere
  64378. */
  64379. set photoTexture(value: Texture);
  64380. /**
  64381. * Gets the current video mode for the video. It can be:
  64382. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  64383. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  64384. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  64385. */
  64386. get imageMode(): number;
  64387. /**
  64388. * Sets the current video mode for the video. It can be:
  64389. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  64390. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  64391. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  64392. */
  64393. set imageMode(value: number);
  64394. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  64395. }
  64396. }
  64397. declare module "babylonjs/Misc/dds" {
  64398. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  64399. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64400. import { Nullable } from "babylonjs/types";
  64401. import { Scene } from "babylonjs/scene";
  64402. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  64403. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64404. /**
  64405. * Direct draw surface info
  64406. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  64407. */
  64408. export interface DDSInfo {
  64409. /**
  64410. * Width of the texture
  64411. */
  64412. width: number;
  64413. /**
  64414. * Width of the texture
  64415. */
  64416. height: number;
  64417. /**
  64418. * Number of Mipmaps for the texture
  64419. * @see https://en.wikipedia.org/wiki/Mipmap
  64420. */
  64421. mipmapCount: number;
  64422. /**
  64423. * If the textures format is a known fourCC format
  64424. * @see https://www.fourcc.org/
  64425. */
  64426. isFourCC: boolean;
  64427. /**
  64428. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  64429. */
  64430. isRGB: boolean;
  64431. /**
  64432. * If the texture is a lumincance format
  64433. */
  64434. isLuminance: boolean;
  64435. /**
  64436. * If this is a cube texture
  64437. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  64438. */
  64439. isCube: boolean;
  64440. /**
  64441. * If the texture is a compressed format eg. FOURCC_DXT1
  64442. */
  64443. isCompressed: boolean;
  64444. /**
  64445. * The dxgiFormat of the texture
  64446. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  64447. */
  64448. dxgiFormat: number;
  64449. /**
  64450. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  64451. */
  64452. textureType: number;
  64453. /**
  64454. * Sphericle polynomial created for the dds texture
  64455. */
  64456. sphericalPolynomial?: SphericalPolynomial;
  64457. }
  64458. /**
  64459. * Class used to provide DDS decompression tools
  64460. */
  64461. export class DDSTools {
  64462. /**
  64463. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  64464. */
  64465. static StoreLODInAlphaChannel: boolean;
  64466. /**
  64467. * Gets DDS information from an array buffer
  64468. * @param data defines the array buffer view to read data from
  64469. * @returns the DDS information
  64470. */
  64471. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  64472. private static _FloatView;
  64473. private static _Int32View;
  64474. private static _ToHalfFloat;
  64475. private static _FromHalfFloat;
  64476. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  64477. private static _GetHalfFloatRGBAArrayBuffer;
  64478. private static _GetFloatRGBAArrayBuffer;
  64479. private static _GetFloatAsUIntRGBAArrayBuffer;
  64480. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  64481. private static _GetRGBAArrayBuffer;
  64482. private static _ExtractLongWordOrder;
  64483. private static _GetRGBArrayBuffer;
  64484. private static _GetLuminanceArrayBuffer;
  64485. /**
  64486. * Uploads DDS Levels to a Babylon Texture
  64487. * @hidden
  64488. */
  64489. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  64490. }
  64491. module "babylonjs/Engines/thinEngine" {
  64492. interface ThinEngine {
  64493. /**
  64494. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  64495. * @param rootUrl defines the url where the file to load is located
  64496. * @param scene defines the current scene
  64497. * @param lodScale defines scale to apply to the mip map selection
  64498. * @param lodOffset defines offset to apply to the mip map selection
  64499. * @param onLoad defines an optional callback raised when the texture is loaded
  64500. * @param onError defines an optional callback raised if there is an issue to load the texture
  64501. * @param format defines the format of the data
  64502. * @param forcedExtension defines the extension to use to pick the right loader
  64503. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  64504. * @returns the cube texture as an InternalTexture
  64505. */
  64506. 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;
  64507. }
  64508. }
  64509. }
  64510. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  64511. import { Nullable } from "babylonjs/types";
  64512. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64513. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64514. /**
  64515. * Implementation of the DDS Texture Loader.
  64516. * @hidden
  64517. */
  64518. export class _DDSTextureLoader implements IInternalTextureLoader {
  64519. /**
  64520. * Defines wether the loader supports cascade loading the different faces.
  64521. */
  64522. readonly supportCascades: boolean;
  64523. /**
  64524. * This returns if the loader support the current file information.
  64525. * @param extension defines the file extension of the file being loaded
  64526. * @returns true if the loader can load the specified file
  64527. */
  64528. canLoad(extension: string): boolean;
  64529. /**
  64530. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64531. * @param data contains the texture data
  64532. * @param texture defines the BabylonJS internal texture
  64533. * @param createPolynomials will be true if polynomials have been requested
  64534. * @param onLoad defines the callback to trigger once the texture is ready
  64535. * @param onError defines the callback to trigger in case of error
  64536. */
  64537. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64538. /**
  64539. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64540. * @param data contains the texture data
  64541. * @param texture defines the BabylonJS internal texture
  64542. * @param callback defines the method to call once ready to upload
  64543. */
  64544. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64545. }
  64546. }
  64547. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  64548. import { Nullable } from "babylonjs/types";
  64549. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64550. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64551. /**
  64552. * Implementation of the ENV Texture Loader.
  64553. * @hidden
  64554. */
  64555. export class _ENVTextureLoader implements IInternalTextureLoader {
  64556. /**
  64557. * Defines wether the loader supports cascade loading the different faces.
  64558. */
  64559. readonly supportCascades: boolean;
  64560. /**
  64561. * This returns if the loader support the current file information.
  64562. * @param extension defines the file extension of the file being loaded
  64563. * @returns true if the loader can load the specified file
  64564. */
  64565. canLoad(extension: string): boolean;
  64566. /**
  64567. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64568. * @param data contains the texture data
  64569. * @param texture defines the BabylonJS internal texture
  64570. * @param createPolynomials will be true if polynomials have been requested
  64571. * @param onLoad defines the callback to trigger once the texture is ready
  64572. * @param onError defines the callback to trigger in case of error
  64573. */
  64574. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64575. /**
  64576. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64577. * @param data contains the texture data
  64578. * @param texture defines the BabylonJS internal texture
  64579. * @param callback defines the method to call once ready to upload
  64580. */
  64581. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64582. }
  64583. }
  64584. declare module "babylonjs/Misc/khronosTextureContainer" {
  64585. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64586. /**
  64587. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  64588. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  64589. */
  64590. export class KhronosTextureContainer {
  64591. /** contents of the KTX container file */
  64592. data: ArrayBufferView;
  64593. private static HEADER_LEN;
  64594. private static COMPRESSED_2D;
  64595. private static COMPRESSED_3D;
  64596. private static TEX_2D;
  64597. private static TEX_3D;
  64598. /**
  64599. * Gets the openGL type
  64600. */
  64601. glType: number;
  64602. /**
  64603. * Gets the openGL type size
  64604. */
  64605. glTypeSize: number;
  64606. /**
  64607. * Gets the openGL format
  64608. */
  64609. glFormat: number;
  64610. /**
  64611. * Gets the openGL internal format
  64612. */
  64613. glInternalFormat: number;
  64614. /**
  64615. * Gets the base internal format
  64616. */
  64617. glBaseInternalFormat: number;
  64618. /**
  64619. * Gets image width in pixel
  64620. */
  64621. pixelWidth: number;
  64622. /**
  64623. * Gets image height in pixel
  64624. */
  64625. pixelHeight: number;
  64626. /**
  64627. * Gets image depth in pixels
  64628. */
  64629. pixelDepth: number;
  64630. /**
  64631. * Gets the number of array elements
  64632. */
  64633. numberOfArrayElements: number;
  64634. /**
  64635. * Gets the number of faces
  64636. */
  64637. numberOfFaces: number;
  64638. /**
  64639. * Gets the number of mipmap levels
  64640. */
  64641. numberOfMipmapLevels: number;
  64642. /**
  64643. * Gets the bytes of key value data
  64644. */
  64645. bytesOfKeyValueData: number;
  64646. /**
  64647. * Gets the load type
  64648. */
  64649. loadType: number;
  64650. /**
  64651. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  64652. */
  64653. isInvalid: boolean;
  64654. /**
  64655. * Creates a new KhronosTextureContainer
  64656. * @param data contents of the KTX container file
  64657. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  64658. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  64659. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  64660. */
  64661. constructor(
  64662. /** contents of the KTX container file */
  64663. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  64664. /**
  64665. * Uploads KTX content to a Babylon Texture.
  64666. * It is assumed that the texture has already been created & is currently bound
  64667. * @hidden
  64668. */
  64669. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  64670. private _upload2DCompressedLevels;
  64671. /**
  64672. * Checks if the given data starts with a KTX file identifier.
  64673. * @param data the data to check
  64674. * @returns true if the data is a KTX file or false otherwise
  64675. */
  64676. static IsValid(data: ArrayBufferView): boolean;
  64677. }
  64678. }
  64679. declare module "babylonjs/Misc/workerPool" {
  64680. import { IDisposable } from "babylonjs/scene";
  64681. /**
  64682. * Helper class to push actions to a pool of workers.
  64683. */
  64684. export class WorkerPool implements IDisposable {
  64685. private _workerInfos;
  64686. private _pendingActions;
  64687. /**
  64688. * Constructor
  64689. * @param workers Array of workers to use for actions
  64690. */
  64691. constructor(workers: Array<Worker>);
  64692. /**
  64693. * Terminates all workers and clears any pending actions.
  64694. */
  64695. dispose(): void;
  64696. /**
  64697. * Pushes an action to the worker pool. If all the workers are active, the action will be
  64698. * pended until a worker has completed its action.
  64699. * @param action The action to perform. Call onComplete when the action is complete.
  64700. */
  64701. push(action: (worker: Worker, onComplete: () => void) => void): void;
  64702. private _execute;
  64703. }
  64704. }
  64705. declare module "babylonjs/Misc/khronosTextureContainer2" {
  64706. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64707. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64708. /**
  64709. * Class for loading KTX2 files
  64710. */
  64711. export class KhronosTextureContainer2 {
  64712. private static _WorkerPoolPromise?;
  64713. private static _Initialized;
  64714. private static _Ktx2Decoder;
  64715. /**
  64716. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  64717. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  64718. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  64719. * Urls you can change:
  64720. * URLConfig.jsDecoderModule
  64721. * URLConfig.wasmUASTCToASTC
  64722. * URLConfig.wasmUASTCToBC7
  64723. * URLConfig.wasmUASTCToRGBA_UNORM
  64724. * URLConfig.wasmUASTCToRGBA_SRGB
  64725. * URLConfig.jsMSCTranscoder
  64726. * URLConfig.wasmMSCTranscoder
  64727. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#22
  64728. */
  64729. static URLConfig: {
  64730. jsDecoderModule: string;
  64731. wasmUASTCToASTC: null;
  64732. wasmUASTCToBC7: null;
  64733. wasmUASTCToRGBA_UNORM: null;
  64734. wasmUASTCToRGBA_SRGB: null;
  64735. jsMSCTranscoder: null;
  64736. wasmMSCTranscoder: null;
  64737. };
  64738. /**
  64739. * Default number of workers used to handle data decoding
  64740. */
  64741. static DefaultNumWorkers: number;
  64742. private static GetDefaultNumWorkers;
  64743. private _engine;
  64744. private static _CreateWorkerPool;
  64745. /**
  64746. * Constructor
  64747. * @param engine The engine to use
  64748. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  64749. */
  64750. constructor(engine: ThinEngine, numWorkers?: number);
  64751. /** @hidden */
  64752. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  64753. /**
  64754. * Stop all async operations and release resources.
  64755. */
  64756. dispose(): void;
  64757. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  64758. /**
  64759. * Checks if the given data starts with a KTX2 file identifier.
  64760. * @param data the data to check
  64761. * @returns true if the data is a KTX2 file or false otherwise
  64762. */
  64763. static IsValid(data: ArrayBufferView): boolean;
  64764. }
  64765. }
  64766. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  64767. import { Nullable } from "babylonjs/types";
  64768. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64769. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64770. /**
  64771. * Implementation of the KTX Texture Loader.
  64772. * @hidden
  64773. */
  64774. export class _KTXTextureLoader implements IInternalTextureLoader {
  64775. /**
  64776. * Defines wether the loader supports cascade loading the different faces.
  64777. */
  64778. readonly supportCascades: boolean;
  64779. /**
  64780. * This returns if the loader support the current file information.
  64781. * @param extension defines the file extension of the file being loaded
  64782. * @param mimeType defines the optional mime type of the file being loaded
  64783. * @returns true if the loader can load the specified file
  64784. */
  64785. canLoad(extension: string, mimeType?: string): boolean;
  64786. /**
  64787. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64788. * @param data contains the texture data
  64789. * @param texture defines the BabylonJS internal texture
  64790. * @param createPolynomials will be true if polynomials have been requested
  64791. * @param onLoad defines the callback to trigger once the texture is ready
  64792. * @param onError defines the callback to trigger in case of error
  64793. */
  64794. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64795. /**
  64796. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64797. * @param data contains the texture data
  64798. * @param texture defines the BabylonJS internal texture
  64799. * @param callback defines the method to call once ready to upload
  64800. */
  64801. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  64802. }
  64803. }
  64804. declare module "babylonjs/Helpers/sceneHelpers" {
  64805. import { Nullable } from "babylonjs/types";
  64806. import { Mesh } from "babylonjs/Meshes/mesh";
  64807. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64808. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  64809. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  64810. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  64811. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  64812. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  64813. import "babylonjs/Meshes/Builders/boxBuilder";
  64814. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  64815. /** @hidden */
  64816. export var _forceSceneHelpersToBundle: boolean;
  64817. module "babylonjs/scene" {
  64818. interface Scene {
  64819. /**
  64820. * Creates a default light for the scene.
  64821. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  64822. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  64823. */
  64824. createDefaultLight(replace?: boolean): void;
  64825. /**
  64826. * Creates a default camera for the scene.
  64827. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  64828. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  64829. * @param replace has default false, when true replaces the active camera in the scene
  64830. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  64831. */
  64832. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  64833. /**
  64834. * Creates a default camera and a default light.
  64835. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  64836. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  64837. * @param replace has the default false, when true replaces the active camera/light in the scene
  64838. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  64839. */
  64840. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  64841. /**
  64842. * Creates a new sky box
  64843. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  64844. * @param environmentTexture defines the texture to use as environment texture
  64845. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  64846. * @param scale defines the overall scale of the skybox
  64847. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  64848. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  64849. * @returns a new mesh holding the sky box
  64850. */
  64851. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  64852. /**
  64853. * Creates a new environment
  64854. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  64855. * @param options defines the options you can use to configure the environment
  64856. * @returns the new EnvironmentHelper
  64857. */
  64858. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  64859. /**
  64860. * Creates a new VREXperienceHelper
  64861. * @see https://doc.babylonjs.com/how_to/webvr_helper
  64862. * @param webVROptions defines the options used to create the new VREXperienceHelper
  64863. * @returns a new VREXperienceHelper
  64864. */
  64865. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  64866. /**
  64867. * Creates a new WebXRDefaultExperience
  64868. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  64869. * @param options experience options
  64870. * @returns a promise for a new WebXRDefaultExperience
  64871. */
  64872. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  64873. }
  64874. }
  64875. }
  64876. declare module "babylonjs/Helpers/videoDome" {
  64877. import { Scene } from "babylonjs/scene";
  64878. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  64879. import { TextureDome } from "babylonjs/Helpers/textureDome";
  64880. /**
  64881. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  64882. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  64883. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  64884. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  64885. */
  64886. export class VideoDome extends TextureDome<VideoTexture> {
  64887. /**
  64888. * Define the video source as a Monoscopic panoramic 360 video.
  64889. */
  64890. static readonly MODE_MONOSCOPIC: number;
  64891. /**
  64892. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  64893. */
  64894. static readonly MODE_TOPBOTTOM: number;
  64895. /**
  64896. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  64897. */
  64898. static readonly MODE_SIDEBYSIDE: number;
  64899. /**
  64900. * Get the video texture associated with this video dome
  64901. */
  64902. get videoTexture(): VideoTexture;
  64903. /**
  64904. * Get the video mode of this dome
  64905. */
  64906. get videoMode(): number;
  64907. /**
  64908. * Set the video mode of this dome.
  64909. * @see textureMode
  64910. */
  64911. set videoMode(value: number);
  64912. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  64913. }
  64914. }
  64915. declare module "babylonjs/Helpers/index" {
  64916. export * from "babylonjs/Helpers/environmentHelper";
  64917. export * from "babylonjs/Helpers/photoDome";
  64918. export * from "babylonjs/Helpers/sceneHelpers";
  64919. export * from "babylonjs/Helpers/videoDome";
  64920. }
  64921. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  64922. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  64923. import { IDisposable } from "babylonjs/scene";
  64924. import { Engine } from "babylonjs/Engines/engine";
  64925. /**
  64926. * This class can be used to get instrumentation data from a Babylon engine
  64927. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  64928. */
  64929. export class EngineInstrumentation implements IDisposable {
  64930. /**
  64931. * Define the instrumented engine.
  64932. */
  64933. engine: Engine;
  64934. private _captureGPUFrameTime;
  64935. private _gpuFrameTimeToken;
  64936. private _gpuFrameTime;
  64937. private _captureShaderCompilationTime;
  64938. private _shaderCompilationTime;
  64939. private _onBeginFrameObserver;
  64940. private _onEndFrameObserver;
  64941. private _onBeforeShaderCompilationObserver;
  64942. private _onAfterShaderCompilationObserver;
  64943. /**
  64944. * Gets the perf counter used for GPU frame time
  64945. */
  64946. get gpuFrameTimeCounter(): PerfCounter;
  64947. /**
  64948. * Gets the GPU frame time capture status
  64949. */
  64950. get captureGPUFrameTime(): boolean;
  64951. /**
  64952. * Enable or disable the GPU frame time capture
  64953. */
  64954. set captureGPUFrameTime(value: boolean);
  64955. /**
  64956. * Gets the perf counter used for shader compilation time
  64957. */
  64958. get shaderCompilationTimeCounter(): PerfCounter;
  64959. /**
  64960. * Gets the shader compilation time capture status
  64961. */
  64962. get captureShaderCompilationTime(): boolean;
  64963. /**
  64964. * Enable or disable the shader compilation time capture
  64965. */
  64966. set captureShaderCompilationTime(value: boolean);
  64967. /**
  64968. * Instantiates a new engine instrumentation.
  64969. * This class can be used to get instrumentation data from a Babylon engine
  64970. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  64971. * @param engine Defines the engine to instrument
  64972. */
  64973. constructor(
  64974. /**
  64975. * Define the instrumented engine.
  64976. */
  64977. engine: Engine);
  64978. /**
  64979. * Dispose and release associated resources.
  64980. */
  64981. dispose(): void;
  64982. }
  64983. }
  64984. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  64985. import { Scene, IDisposable } from "babylonjs/scene";
  64986. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  64987. /**
  64988. * This class can be used to get instrumentation data from a Babylon engine
  64989. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  64990. */
  64991. export class SceneInstrumentation implements IDisposable {
  64992. /**
  64993. * Defines the scene to instrument
  64994. */
  64995. scene: Scene;
  64996. private _captureActiveMeshesEvaluationTime;
  64997. private _activeMeshesEvaluationTime;
  64998. private _captureRenderTargetsRenderTime;
  64999. private _renderTargetsRenderTime;
  65000. private _captureFrameTime;
  65001. private _frameTime;
  65002. private _captureRenderTime;
  65003. private _renderTime;
  65004. private _captureInterFrameTime;
  65005. private _interFrameTime;
  65006. private _captureParticlesRenderTime;
  65007. private _particlesRenderTime;
  65008. private _captureSpritesRenderTime;
  65009. private _spritesRenderTime;
  65010. private _capturePhysicsTime;
  65011. private _physicsTime;
  65012. private _captureAnimationsTime;
  65013. private _animationsTime;
  65014. private _captureCameraRenderTime;
  65015. private _cameraRenderTime;
  65016. private _onBeforeActiveMeshesEvaluationObserver;
  65017. private _onAfterActiveMeshesEvaluationObserver;
  65018. private _onBeforeRenderTargetsRenderObserver;
  65019. private _onAfterRenderTargetsRenderObserver;
  65020. private _onAfterRenderObserver;
  65021. private _onBeforeDrawPhaseObserver;
  65022. private _onAfterDrawPhaseObserver;
  65023. private _onBeforeAnimationsObserver;
  65024. private _onBeforeParticlesRenderingObserver;
  65025. private _onAfterParticlesRenderingObserver;
  65026. private _onBeforeSpritesRenderingObserver;
  65027. private _onAfterSpritesRenderingObserver;
  65028. private _onBeforePhysicsObserver;
  65029. private _onAfterPhysicsObserver;
  65030. private _onAfterAnimationsObserver;
  65031. private _onBeforeCameraRenderObserver;
  65032. private _onAfterCameraRenderObserver;
  65033. /**
  65034. * Gets the perf counter used for active meshes evaluation time
  65035. */
  65036. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  65037. /**
  65038. * Gets the active meshes evaluation time capture status
  65039. */
  65040. get captureActiveMeshesEvaluationTime(): boolean;
  65041. /**
  65042. * Enable or disable the active meshes evaluation time capture
  65043. */
  65044. set captureActiveMeshesEvaluationTime(value: boolean);
  65045. /**
  65046. * Gets the perf counter used for render targets render time
  65047. */
  65048. get renderTargetsRenderTimeCounter(): PerfCounter;
  65049. /**
  65050. * Gets the render targets render time capture status
  65051. */
  65052. get captureRenderTargetsRenderTime(): boolean;
  65053. /**
  65054. * Enable or disable the render targets render time capture
  65055. */
  65056. set captureRenderTargetsRenderTime(value: boolean);
  65057. /**
  65058. * Gets the perf counter used for particles render time
  65059. */
  65060. get particlesRenderTimeCounter(): PerfCounter;
  65061. /**
  65062. * Gets the particles render time capture status
  65063. */
  65064. get captureParticlesRenderTime(): boolean;
  65065. /**
  65066. * Enable or disable the particles render time capture
  65067. */
  65068. set captureParticlesRenderTime(value: boolean);
  65069. /**
  65070. * Gets the perf counter used for sprites render time
  65071. */
  65072. get spritesRenderTimeCounter(): PerfCounter;
  65073. /**
  65074. * Gets the sprites render time capture status
  65075. */
  65076. get captureSpritesRenderTime(): boolean;
  65077. /**
  65078. * Enable or disable the sprites render time capture
  65079. */
  65080. set captureSpritesRenderTime(value: boolean);
  65081. /**
  65082. * Gets the perf counter used for physics time
  65083. */
  65084. get physicsTimeCounter(): PerfCounter;
  65085. /**
  65086. * Gets the physics time capture status
  65087. */
  65088. get capturePhysicsTime(): boolean;
  65089. /**
  65090. * Enable or disable the physics time capture
  65091. */
  65092. set capturePhysicsTime(value: boolean);
  65093. /**
  65094. * Gets the perf counter used for animations time
  65095. */
  65096. get animationsTimeCounter(): PerfCounter;
  65097. /**
  65098. * Gets the animations time capture status
  65099. */
  65100. get captureAnimationsTime(): boolean;
  65101. /**
  65102. * Enable or disable the animations time capture
  65103. */
  65104. set captureAnimationsTime(value: boolean);
  65105. /**
  65106. * Gets the perf counter used for frame time capture
  65107. */
  65108. get frameTimeCounter(): PerfCounter;
  65109. /**
  65110. * Gets the frame time capture status
  65111. */
  65112. get captureFrameTime(): boolean;
  65113. /**
  65114. * Enable or disable the frame time capture
  65115. */
  65116. set captureFrameTime(value: boolean);
  65117. /**
  65118. * Gets the perf counter used for inter-frames time capture
  65119. */
  65120. get interFrameTimeCounter(): PerfCounter;
  65121. /**
  65122. * Gets the inter-frames time capture status
  65123. */
  65124. get captureInterFrameTime(): boolean;
  65125. /**
  65126. * Enable or disable the inter-frames time capture
  65127. */
  65128. set captureInterFrameTime(value: boolean);
  65129. /**
  65130. * Gets the perf counter used for render time capture
  65131. */
  65132. get renderTimeCounter(): PerfCounter;
  65133. /**
  65134. * Gets the render time capture status
  65135. */
  65136. get captureRenderTime(): boolean;
  65137. /**
  65138. * Enable or disable the render time capture
  65139. */
  65140. set captureRenderTime(value: boolean);
  65141. /**
  65142. * Gets the perf counter used for camera render time capture
  65143. */
  65144. get cameraRenderTimeCounter(): PerfCounter;
  65145. /**
  65146. * Gets the camera render time capture status
  65147. */
  65148. get captureCameraRenderTime(): boolean;
  65149. /**
  65150. * Enable or disable the camera render time capture
  65151. */
  65152. set captureCameraRenderTime(value: boolean);
  65153. /**
  65154. * Gets the perf counter used for draw calls
  65155. */
  65156. get drawCallsCounter(): PerfCounter;
  65157. /**
  65158. * Instantiates a new scene instrumentation.
  65159. * This class can be used to get instrumentation data from a Babylon engine
  65160. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  65161. * @param scene Defines the scene to instrument
  65162. */
  65163. constructor(
  65164. /**
  65165. * Defines the scene to instrument
  65166. */
  65167. scene: Scene);
  65168. /**
  65169. * Dispose and release associated resources.
  65170. */
  65171. dispose(): void;
  65172. }
  65173. }
  65174. declare module "babylonjs/Instrumentation/index" {
  65175. export * from "babylonjs/Instrumentation/engineInstrumentation";
  65176. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  65177. export * from "babylonjs/Instrumentation/timeToken";
  65178. }
  65179. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  65180. /** @hidden */
  65181. export var glowMapGenerationPixelShader: {
  65182. name: string;
  65183. shader: string;
  65184. };
  65185. }
  65186. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  65187. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65188. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65189. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65190. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65191. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65192. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65193. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65194. /** @hidden */
  65195. export var glowMapGenerationVertexShader: {
  65196. name: string;
  65197. shader: string;
  65198. };
  65199. }
  65200. declare module "babylonjs/Layers/effectLayer" {
  65201. import { Observable } from "babylonjs/Misc/observable";
  65202. import { Nullable } from "babylonjs/types";
  65203. import { Camera } from "babylonjs/Cameras/camera";
  65204. import { Scene } from "babylonjs/scene";
  65205. import { ISize } from "babylonjs/Maths/math.size";
  65206. import { Color4 } from "babylonjs/Maths/math.color";
  65207. import { Engine } from "babylonjs/Engines/engine";
  65208. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65209. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65210. import { Mesh } from "babylonjs/Meshes/mesh";
  65211. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65212. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65213. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65214. import { Effect } from "babylonjs/Materials/effect";
  65215. import { Material } from "babylonjs/Materials/material";
  65216. import "babylonjs/Shaders/glowMapGeneration.fragment";
  65217. import "babylonjs/Shaders/glowMapGeneration.vertex";
  65218. /**
  65219. * Effect layer options. This helps customizing the behaviour
  65220. * of the effect layer.
  65221. */
  65222. export interface IEffectLayerOptions {
  65223. /**
  65224. * Multiplication factor apply to the canvas size to compute the render target size
  65225. * used to generated the objects (the smaller the faster).
  65226. */
  65227. mainTextureRatio: number;
  65228. /**
  65229. * Enforces a fixed size texture to ensure effect stability across devices.
  65230. */
  65231. mainTextureFixedSize?: number;
  65232. /**
  65233. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  65234. */
  65235. alphaBlendingMode: number;
  65236. /**
  65237. * The camera attached to the layer.
  65238. */
  65239. camera: Nullable<Camera>;
  65240. /**
  65241. * The rendering group to draw the layer in.
  65242. */
  65243. renderingGroupId: number;
  65244. }
  65245. /**
  65246. * The effect layer Helps adding post process effect blended with the main pass.
  65247. *
  65248. * This can be for instance use to generate glow or higlight effects on the scene.
  65249. *
  65250. * The effect layer class can not be used directly and is intented to inherited from to be
  65251. * customized per effects.
  65252. */
  65253. export abstract class EffectLayer {
  65254. private _vertexBuffers;
  65255. private _indexBuffer;
  65256. private _cachedDefines;
  65257. private _effectLayerMapGenerationEffect;
  65258. private _effectLayerOptions;
  65259. private _mergeEffect;
  65260. protected _scene: Scene;
  65261. protected _engine: Engine;
  65262. protected _maxSize: number;
  65263. protected _mainTextureDesiredSize: ISize;
  65264. protected _mainTexture: RenderTargetTexture;
  65265. protected _shouldRender: boolean;
  65266. protected _postProcesses: PostProcess[];
  65267. protected _textures: BaseTexture[];
  65268. protected _emissiveTextureAndColor: {
  65269. texture: Nullable<BaseTexture>;
  65270. color: Color4;
  65271. };
  65272. /**
  65273. * The name of the layer
  65274. */
  65275. name: string;
  65276. /**
  65277. * The clear color of the texture used to generate the glow map.
  65278. */
  65279. neutralColor: Color4;
  65280. /**
  65281. * Specifies whether the highlight layer is enabled or not.
  65282. */
  65283. isEnabled: boolean;
  65284. /**
  65285. * Gets the camera attached to the layer.
  65286. */
  65287. get camera(): Nullable<Camera>;
  65288. /**
  65289. * Gets the rendering group id the layer should render in.
  65290. */
  65291. get renderingGroupId(): number;
  65292. set renderingGroupId(renderingGroupId: number);
  65293. /**
  65294. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  65295. */
  65296. disableBoundingBoxesFromEffectLayer: boolean;
  65297. /**
  65298. * An event triggered when the effect layer has been disposed.
  65299. */
  65300. onDisposeObservable: Observable<EffectLayer>;
  65301. /**
  65302. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  65303. */
  65304. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  65305. /**
  65306. * An event triggered when the generated texture is being merged in the scene.
  65307. */
  65308. onBeforeComposeObservable: Observable<EffectLayer>;
  65309. /**
  65310. * An event triggered when the mesh is rendered into the effect render target.
  65311. */
  65312. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  65313. /**
  65314. * An event triggered after the mesh has been rendered into the effect render target.
  65315. */
  65316. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  65317. /**
  65318. * An event triggered when the generated texture has been merged in the scene.
  65319. */
  65320. onAfterComposeObservable: Observable<EffectLayer>;
  65321. /**
  65322. * An event triggered when the efffect layer changes its size.
  65323. */
  65324. onSizeChangedObservable: Observable<EffectLayer>;
  65325. /** @hidden */
  65326. static _SceneComponentInitialization: (scene: Scene) => void;
  65327. /**
  65328. * Instantiates a new effect Layer and references it in the scene.
  65329. * @param name The name of the layer
  65330. * @param scene The scene to use the layer in
  65331. */
  65332. constructor(
  65333. /** The Friendly of the effect in the scene */
  65334. name: string, scene: Scene);
  65335. /**
  65336. * Get the effect name of the layer.
  65337. * @return The effect name
  65338. */
  65339. abstract getEffectName(): string;
  65340. /**
  65341. * Checks for the readiness of the element composing the layer.
  65342. * @param subMesh the mesh to check for
  65343. * @param useInstances specify whether or not to use instances to render the mesh
  65344. * @return true if ready otherwise, false
  65345. */
  65346. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65347. /**
  65348. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  65349. * @returns true if the effect requires stencil during the main canvas render pass.
  65350. */
  65351. abstract needStencil(): boolean;
  65352. /**
  65353. * Create the merge effect. This is the shader use to blit the information back
  65354. * to the main canvas at the end of the scene rendering.
  65355. * @returns The effect containing the shader used to merge the effect on the main canvas
  65356. */
  65357. protected abstract _createMergeEffect(): Effect;
  65358. /**
  65359. * Creates the render target textures and post processes used in the effect layer.
  65360. */
  65361. protected abstract _createTextureAndPostProcesses(): void;
  65362. /**
  65363. * Implementation specific of rendering the generating effect on the main canvas.
  65364. * @param effect The effect used to render through
  65365. */
  65366. protected abstract _internalRender(effect: Effect): void;
  65367. /**
  65368. * Sets the required values for both the emissive texture and and the main color.
  65369. */
  65370. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  65371. /**
  65372. * Free any resources and references associated to a mesh.
  65373. * Internal use
  65374. * @param mesh The mesh to free.
  65375. */
  65376. abstract _disposeMesh(mesh: Mesh): void;
  65377. /**
  65378. * Serializes this layer (Glow or Highlight for example)
  65379. * @returns a serialized layer object
  65380. */
  65381. abstract serialize?(): any;
  65382. /**
  65383. * Initializes the effect layer with the required options.
  65384. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  65385. */
  65386. protected _init(options: Partial<IEffectLayerOptions>): void;
  65387. /**
  65388. * Generates the index buffer of the full screen quad blending to the main canvas.
  65389. */
  65390. private _generateIndexBuffer;
  65391. /**
  65392. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  65393. */
  65394. private _generateVertexBuffer;
  65395. /**
  65396. * Sets the main texture desired size which is the closest power of two
  65397. * of the engine canvas size.
  65398. */
  65399. private _setMainTextureSize;
  65400. /**
  65401. * Creates the main texture for the effect layer.
  65402. */
  65403. protected _createMainTexture(): void;
  65404. /**
  65405. * Adds specific effects defines.
  65406. * @param defines The defines to add specifics to.
  65407. */
  65408. protected _addCustomEffectDefines(defines: string[]): void;
  65409. /**
  65410. * Checks for the readiness of the element composing the layer.
  65411. * @param subMesh the mesh to check for
  65412. * @param useInstances specify whether or not to use instances to render the mesh
  65413. * @param emissiveTexture the associated emissive texture used to generate the glow
  65414. * @return true if ready otherwise, false
  65415. */
  65416. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  65417. /**
  65418. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  65419. */
  65420. render(): void;
  65421. /**
  65422. * Determine if a given mesh will be used in the current effect.
  65423. * @param mesh mesh to test
  65424. * @returns true if the mesh will be used
  65425. */
  65426. hasMesh(mesh: AbstractMesh): boolean;
  65427. /**
  65428. * Returns true if the layer contains information to display, otherwise false.
  65429. * @returns true if the glow layer should be rendered
  65430. */
  65431. shouldRender(): boolean;
  65432. /**
  65433. * Returns true if the mesh should render, otherwise false.
  65434. * @param mesh The mesh to render
  65435. * @returns true if it should render otherwise false
  65436. */
  65437. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  65438. /**
  65439. * Returns true if the mesh can be rendered, otherwise false.
  65440. * @param mesh The mesh to render
  65441. * @param material The material used on the mesh
  65442. * @returns true if it can be rendered otherwise false
  65443. */
  65444. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  65445. /**
  65446. * Returns true if the mesh should render, otherwise false.
  65447. * @param mesh The mesh to render
  65448. * @returns true if it should render otherwise false
  65449. */
  65450. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  65451. /**
  65452. * Renders the submesh passed in parameter to the generation map.
  65453. */
  65454. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  65455. /**
  65456. * Defines whether the current material of the mesh should be use to render the effect.
  65457. * @param mesh defines the current mesh to render
  65458. */
  65459. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  65460. /**
  65461. * Rebuild the required buffers.
  65462. * @hidden Internal use only.
  65463. */
  65464. _rebuild(): void;
  65465. /**
  65466. * Dispose only the render target textures and post process.
  65467. */
  65468. private _disposeTextureAndPostProcesses;
  65469. /**
  65470. * Dispose the highlight layer and free resources.
  65471. */
  65472. dispose(): void;
  65473. /**
  65474. * Gets the class name of the effect layer
  65475. * @returns the string with the class name of the effect layer
  65476. */
  65477. getClassName(): string;
  65478. /**
  65479. * Creates an effect layer from parsed effect layer data
  65480. * @param parsedEffectLayer defines effect layer data
  65481. * @param scene defines the current scene
  65482. * @param rootUrl defines the root URL containing the effect layer information
  65483. * @returns a parsed effect Layer
  65484. */
  65485. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  65486. }
  65487. }
  65488. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  65489. import { Scene } from "babylonjs/scene";
  65490. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  65491. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  65492. import { AbstractScene } from "babylonjs/abstractScene";
  65493. module "babylonjs/abstractScene" {
  65494. interface AbstractScene {
  65495. /**
  65496. * The list of effect layers (highlights/glow) added to the scene
  65497. * @see https://doc.babylonjs.com/how_to/highlight_layer
  65498. * @see https://doc.babylonjs.com/how_to/glow_layer
  65499. */
  65500. effectLayers: Array<EffectLayer>;
  65501. /**
  65502. * Removes the given effect layer from this scene.
  65503. * @param toRemove defines the effect layer to remove
  65504. * @returns the index of the removed effect layer
  65505. */
  65506. removeEffectLayer(toRemove: EffectLayer): number;
  65507. /**
  65508. * Adds the given effect layer to this scene
  65509. * @param newEffectLayer defines the effect layer to add
  65510. */
  65511. addEffectLayer(newEffectLayer: EffectLayer): void;
  65512. }
  65513. }
  65514. /**
  65515. * Defines the layer scene component responsible to manage any effect layers
  65516. * in a given scene.
  65517. */
  65518. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  65519. /**
  65520. * The component name helpfull to identify the component in the list of scene components.
  65521. */
  65522. readonly name: string;
  65523. /**
  65524. * The scene the component belongs to.
  65525. */
  65526. scene: Scene;
  65527. private _engine;
  65528. private _renderEffects;
  65529. private _needStencil;
  65530. private _previousStencilState;
  65531. /**
  65532. * Creates a new instance of the component for the given scene
  65533. * @param scene Defines the scene to register the component in
  65534. */
  65535. constructor(scene: Scene);
  65536. /**
  65537. * Registers the component in a given scene
  65538. */
  65539. register(): void;
  65540. /**
  65541. * Rebuilds the elements related to this component in case of
  65542. * context lost for instance.
  65543. */
  65544. rebuild(): void;
  65545. /**
  65546. * Serializes the component data to the specified json object
  65547. * @param serializationObject The object to serialize to
  65548. */
  65549. serialize(serializationObject: any): void;
  65550. /**
  65551. * Adds all the elements from the container to the scene
  65552. * @param container the container holding the elements
  65553. */
  65554. addFromContainer(container: AbstractScene): void;
  65555. /**
  65556. * Removes all the elements in the container from the scene
  65557. * @param container contains the elements to remove
  65558. * @param dispose if the removed element should be disposed (default: false)
  65559. */
  65560. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  65561. /**
  65562. * Disposes the component and the associated ressources.
  65563. */
  65564. dispose(): void;
  65565. private _isReadyForMesh;
  65566. private _renderMainTexture;
  65567. private _setStencil;
  65568. private _setStencilBack;
  65569. private _draw;
  65570. private _drawCamera;
  65571. private _drawRenderingGroup;
  65572. }
  65573. }
  65574. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  65575. /** @hidden */
  65576. export var glowMapMergePixelShader: {
  65577. name: string;
  65578. shader: string;
  65579. };
  65580. }
  65581. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  65582. /** @hidden */
  65583. export var glowMapMergeVertexShader: {
  65584. name: string;
  65585. shader: string;
  65586. };
  65587. }
  65588. declare module "babylonjs/Layers/glowLayer" {
  65589. import { Nullable } from "babylonjs/types";
  65590. import { Camera } from "babylonjs/Cameras/camera";
  65591. import { Scene } from "babylonjs/scene";
  65592. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65593. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65594. import { Mesh } from "babylonjs/Meshes/mesh";
  65595. import { Texture } from "babylonjs/Materials/Textures/texture";
  65596. import { Effect } from "babylonjs/Materials/effect";
  65597. import { Material } from "babylonjs/Materials/material";
  65598. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  65599. import { Color4 } from "babylonjs/Maths/math.color";
  65600. import "babylonjs/Shaders/glowMapMerge.fragment";
  65601. import "babylonjs/Shaders/glowMapMerge.vertex";
  65602. import "babylonjs/Layers/effectLayerSceneComponent";
  65603. module "babylonjs/abstractScene" {
  65604. interface AbstractScene {
  65605. /**
  65606. * Return a the first highlight layer of the scene with a given name.
  65607. * @param name The name of the highlight layer to look for.
  65608. * @return The highlight layer if found otherwise null.
  65609. */
  65610. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  65611. }
  65612. }
  65613. /**
  65614. * Glow layer options. This helps customizing the behaviour
  65615. * of the glow layer.
  65616. */
  65617. export interface IGlowLayerOptions {
  65618. /**
  65619. * Multiplication factor apply to the canvas size to compute the render target size
  65620. * used to generated the glowing objects (the smaller the faster).
  65621. */
  65622. mainTextureRatio: number;
  65623. /**
  65624. * Enforces a fixed size texture to ensure resize independant blur.
  65625. */
  65626. mainTextureFixedSize?: number;
  65627. /**
  65628. * How big is the kernel of the blur texture.
  65629. */
  65630. blurKernelSize: number;
  65631. /**
  65632. * The camera attached to the layer.
  65633. */
  65634. camera: Nullable<Camera>;
  65635. /**
  65636. * Enable MSAA by chosing the number of samples.
  65637. */
  65638. mainTextureSamples?: number;
  65639. /**
  65640. * The rendering group to draw the layer in.
  65641. */
  65642. renderingGroupId: number;
  65643. }
  65644. /**
  65645. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  65646. *
  65647. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  65648. *
  65649. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  65650. */
  65651. export class GlowLayer extends EffectLayer {
  65652. /**
  65653. * Effect Name of the layer.
  65654. */
  65655. static readonly EffectName: string;
  65656. /**
  65657. * The default blur kernel size used for the glow.
  65658. */
  65659. static DefaultBlurKernelSize: number;
  65660. /**
  65661. * The default texture size ratio used for the glow.
  65662. */
  65663. static DefaultTextureRatio: number;
  65664. /**
  65665. * Sets the kernel size of the blur.
  65666. */
  65667. set blurKernelSize(value: number);
  65668. /**
  65669. * Gets the kernel size of the blur.
  65670. */
  65671. get blurKernelSize(): number;
  65672. /**
  65673. * Sets the glow intensity.
  65674. */
  65675. set intensity(value: number);
  65676. /**
  65677. * Gets the glow intensity.
  65678. */
  65679. get intensity(): number;
  65680. private _options;
  65681. private _intensity;
  65682. private _horizontalBlurPostprocess1;
  65683. private _verticalBlurPostprocess1;
  65684. private _horizontalBlurPostprocess2;
  65685. private _verticalBlurPostprocess2;
  65686. private _blurTexture1;
  65687. private _blurTexture2;
  65688. private _postProcesses1;
  65689. private _postProcesses2;
  65690. private _includedOnlyMeshes;
  65691. private _excludedMeshes;
  65692. private _meshesUsingTheirOwnMaterials;
  65693. /**
  65694. * Callback used to let the user override the color selection on a per mesh basis
  65695. */
  65696. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  65697. /**
  65698. * Callback used to let the user override the texture selection on a per mesh basis
  65699. */
  65700. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  65701. /**
  65702. * Instantiates a new glow Layer and references it to the scene.
  65703. * @param name The name of the layer
  65704. * @param scene The scene to use the layer in
  65705. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  65706. */
  65707. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  65708. /**
  65709. * Get the effect name of the layer.
  65710. * @return The effect name
  65711. */
  65712. getEffectName(): string;
  65713. /**
  65714. * Create the merge effect. This is the shader use to blit the information back
  65715. * to the main canvas at the end of the scene rendering.
  65716. */
  65717. protected _createMergeEffect(): Effect;
  65718. /**
  65719. * Creates the render target textures and post processes used in the glow layer.
  65720. */
  65721. protected _createTextureAndPostProcesses(): void;
  65722. /**
  65723. * Checks for the readiness of the element composing the layer.
  65724. * @param subMesh the mesh to check for
  65725. * @param useInstances specify wether or not to use instances to render the mesh
  65726. * @param emissiveTexture the associated emissive texture used to generate the glow
  65727. * @return true if ready otherwise, false
  65728. */
  65729. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65730. /**
  65731. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  65732. */
  65733. needStencil(): boolean;
  65734. /**
  65735. * Returns true if the mesh can be rendered, otherwise false.
  65736. * @param mesh The mesh to render
  65737. * @param material The material used on the mesh
  65738. * @returns true if it can be rendered otherwise false
  65739. */
  65740. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  65741. /**
  65742. * Implementation specific of rendering the generating effect on the main canvas.
  65743. * @param effect The effect used to render through
  65744. */
  65745. protected _internalRender(effect: Effect): void;
  65746. /**
  65747. * Sets the required values for both the emissive texture and and the main color.
  65748. */
  65749. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  65750. /**
  65751. * Returns true if the mesh should render, otherwise false.
  65752. * @param mesh The mesh to render
  65753. * @returns true if it should render otherwise false
  65754. */
  65755. protected _shouldRenderMesh(mesh: Mesh): boolean;
  65756. /**
  65757. * Adds specific effects defines.
  65758. * @param defines The defines to add specifics to.
  65759. */
  65760. protected _addCustomEffectDefines(defines: string[]): void;
  65761. /**
  65762. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  65763. * @param mesh The mesh to exclude from the glow layer
  65764. */
  65765. addExcludedMesh(mesh: Mesh): void;
  65766. /**
  65767. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  65768. * @param mesh The mesh to remove
  65769. */
  65770. removeExcludedMesh(mesh: Mesh): void;
  65771. /**
  65772. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  65773. * @param mesh The mesh to include in the glow layer
  65774. */
  65775. addIncludedOnlyMesh(mesh: Mesh): void;
  65776. /**
  65777. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  65778. * @param mesh The mesh to remove
  65779. */
  65780. removeIncludedOnlyMesh(mesh: Mesh): void;
  65781. /**
  65782. * Determine if a given mesh will be used in the glow layer
  65783. * @param mesh The mesh to test
  65784. * @returns true if the mesh will be highlighted by the current glow layer
  65785. */
  65786. hasMesh(mesh: AbstractMesh): boolean;
  65787. /**
  65788. * Defines whether the current material of the mesh should be use to render the effect.
  65789. * @param mesh defines the current mesh to render
  65790. */
  65791. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  65792. /**
  65793. * Add a mesh to be rendered through its own material and not with emissive only.
  65794. * @param mesh The mesh for which we need to use its material
  65795. */
  65796. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  65797. /**
  65798. * Remove a mesh from being rendered through its own material and not with emissive only.
  65799. * @param mesh The mesh for which we need to not use its material
  65800. */
  65801. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  65802. /**
  65803. * Free any resources and references associated to a mesh.
  65804. * Internal use
  65805. * @param mesh The mesh to free.
  65806. * @hidden
  65807. */
  65808. _disposeMesh(mesh: Mesh): void;
  65809. /**
  65810. * Gets the class name of the effect layer
  65811. * @returns the string with the class name of the effect layer
  65812. */
  65813. getClassName(): string;
  65814. /**
  65815. * Serializes this glow layer
  65816. * @returns a serialized glow layer object
  65817. */
  65818. serialize(): any;
  65819. /**
  65820. * Creates a Glow Layer from parsed glow layer data
  65821. * @param parsedGlowLayer defines glow layer data
  65822. * @param scene defines the current scene
  65823. * @param rootUrl defines the root URL containing the glow layer information
  65824. * @returns a parsed Glow Layer
  65825. */
  65826. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  65827. }
  65828. }
  65829. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  65830. /** @hidden */
  65831. export var glowBlurPostProcessPixelShader: {
  65832. name: string;
  65833. shader: string;
  65834. };
  65835. }
  65836. declare module "babylonjs/Layers/highlightLayer" {
  65837. import { Observable } from "babylonjs/Misc/observable";
  65838. import { Nullable } from "babylonjs/types";
  65839. import { Camera } from "babylonjs/Cameras/camera";
  65840. import { Scene } from "babylonjs/scene";
  65841. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65842. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65843. import { Mesh } from "babylonjs/Meshes/mesh";
  65844. import { Effect } from "babylonjs/Materials/effect";
  65845. import { Material } from "babylonjs/Materials/material";
  65846. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  65847. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  65848. import "babylonjs/Shaders/glowMapMerge.fragment";
  65849. import "babylonjs/Shaders/glowMapMerge.vertex";
  65850. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  65851. module "babylonjs/abstractScene" {
  65852. interface AbstractScene {
  65853. /**
  65854. * Return a the first highlight layer of the scene with a given name.
  65855. * @param name The name of the highlight layer to look for.
  65856. * @return The highlight layer if found otherwise null.
  65857. */
  65858. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  65859. }
  65860. }
  65861. /**
  65862. * Highlight layer options. This helps customizing the behaviour
  65863. * of the highlight layer.
  65864. */
  65865. export interface IHighlightLayerOptions {
  65866. /**
  65867. * Multiplication factor apply to the canvas size to compute the render target size
  65868. * used to generated the glowing objects (the smaller the faster).
  65869. */
  65870. mainTextureRatio: number;
  65871. /**
  65872. * Enforces a fixed size texture to ensure resize independant blur.
  65873. */
  65874. mainTextureFixedSize?: number;
  65875. /**
  65876. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  65877. * of the picture to blur (the smaller the faster).
  65878. */
  65879. blurTextureSizeRatio: number;
  65880. /**
  65881. * How big in texel of the blur texture is the vertical blur.
  65882. */
  65883. blurVerticalSize: number;
  65884. /**
  65885. * How big in texel of the blur texture is the horizontal blur.
  65886. */
  65887. blurHorizontalSize: number;
  65888. /**
  65889. * Alpha blending mode used to apply the blur. Default is combine.
  65890. */
  65891. alphaBlendingMode: number;
  65892. /**
  65893. * The camera attached to the layer.
  65894. */
  65895. camera: Nullable<Camera>;
  65896. /**
  65897. * Should we display highlight as a solid stroke?
  65898. */
  65899. isStroke?: boolean;
  65900. /**
  65901. * The rendering group to draw the layer in.
  65902. */
  65903. renderingGroupId: number;
  65904. }
  65905. /**
  65906. * The highlight layer Helps adding a glow effect around a mesh.
  65907. *
  65908. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  65909. * glowy meshes to your scene.
  65910. *
  65911. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  65912. */
  65913. export class HighlightLayer extends EffectLayer {
  65914. name: string;
  65915. /**
  65916. * Effect Name of the highlight layer.
  65917. */
  65918. static readonly EffectName: string;
  65919. /**
  65920. * The neutral color used during the preparation of the glow effect.
  65921. * This is black by default as the blend operation is a blend operation.
  65922. */
  65923. static NeutralColor: Color4;
  65924. /**
  65925. * Stencil value used for glowing meshes.
  65926. */
  65927. static GlowingMeshStencilReference: number;
  65928. /**
  65929. * Stencil value used for the other meshes in the scene.
  65930. */
  65931. static NormalMeshStencilReference: number;
  65932. /**
  65933. * Specifies whether or not the inner glow is ACTIVE in the layer.
  65934. */
  65935. innerGlow: boolean;
  65936. /**
  65937. * Specifies whether or not the outer glow is ACTIVE in the layer.
  65938. */
  65939. outerGlow: boolean;
  65940. /**
  65941. * Specifies the horizontal size of the blur.
  65942. */
  65943. set blurHorizontalSize(value: number);
  65944. /**
  65945. * Specifies the vertical size of the blur.
  65946. */
  65947. set blurVerticalSize(value: number);
  65948. /**
  65949. * Gets the horizontal size of the blur.
  65950. */
  65951. get blurHorizontalSize(): number;
  65952. /**
  65953. * Gets the vertical size of the blur.
  65954. */
  65955. get blurVerticalSize(): number;
  65956. /**
  65957. * An event triggered when the highlight layer is being blurred.
  65958. */
  65959. onBeforeBlurObservable: Observable<HighlightLayer>;
  65960. /**
  65961. * An event triggered when the highlight layer has been blurred.
  65962. */
  65963. onAfterBlurObservable: Observable<HighlightLayer>;
  65964. private _instanceGlowingMeshStencilReference;
  65965. private _options;
  65966. private _downSamplePostprocess;
  65967. private _horizontalBlurPostprocess;
  65968. private _verticalBlurPostprocess;
  65969. private _blurTexture;
  65970. private _meshes;
  65971. private _excludedMeshes;
  65972. /**
  65973. * Instantiates a new highlight Layer and references it to the scene..
  65974. * @param name The name of the layer
  65975. * @param scene The scene to use the layer in
  65976. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  65977. */
  65978. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  65979. /**
  65980. * Get the effect name of the layer.
  65981. * @return The effect name
  65982. */
  65983. getEffectName(): string;
  65984. /**
  65985. * Create the merge effect. This is the shader use to blit the information back
  65986. * to the main canvas at the end of the scene rendering.
  65987. */
  65988. protected _createMergeEffect(): Effect;
  65989. /**
  65990. * Creates the render target textures and post processes used in the highlight layer.
  65991. */
  65992. protected _createTextureAndPostProcesses(): void;
  65993. /**
  65994. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  65995. */
  65996. needStencil(): boolean;
  65997. /**
  65998. * Checks for the readiness of the element composing the layer.
  65999. * @param subMesh the mesh to check for
  66000. * @param useInstances specify wether or not to use instances to render the mesh
  66001. * @param emissiveTexture the associated emissive texture used to generate the glow
  66002. * @return true if ready otherwise, false
  66003. */
  66004. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66005. /**
  66006. * Implementation specific of rendering the generating effect on the main canvas.
  66007. * @param effect The effect used to render through
  66008. */
  66009. protected _internalRender(effect: Effect): void;
  66010. /**
  66011. * Returns true if the layer contains information to display, otherwise false.
  66012. */
  66013. shouldRender(): boolean;
  66014. /**
  66015. * Returns true if the mesh should render, otherwise false.
  66016. * @param mesh The mesh to render
  66017. * @returns true if it should render otherwise false
  66018. */
  66019. protected _shouldRenderMesh(mesh: Mesh): boolean;
  66020. /**
  66021. * Returns true if the mesh can be rendered, otherwise false.
  66022. * @param mesh The mesh to render
  66023. * @param material The material used on the mesh
  66024. * @returns true if it can be rendered otherwise false
  66025. */
  66026. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  66027. /**
  66028. * Adds specific effects defines.
  66029. * @param defines The defines to add specifics to.
  66030. */
  66031. protected _addCustomEffectDefines(defines: string[]): void;
  66032. /**
  66033. * Sets the required values for both the emissive texture and and the main color.
  66034. */
  66035. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  66036. /**
  66037. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  66038. * @param mesh The mesh to exclude from the highlight layer
  66039. */
  66040. addExcludedMesh(mesh: Mesh): void;
  66041. /**
  66042. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  66043. * @param mesh The mesh to highlight
  66044. */
  66045. removeExcludedMesh(mesh: Mesh): void;
  66046. /**
  66047. * Determine if a given mesh will be highlighted by the current HighlightLayer
  66048. * @param mesh mesh to test
  66049. * @returns true if the mesh will be highlighted by the current HighlightLayer
  66050. */
  66051. hasMesh(mesh: AbstractMesh): boolean;
  66052. /**
  66053. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  66054. * @param mesh The mesh to highlight
  66055. * @param color The color of the highlight
  66056. * @param glowEmissiveOnly Extract the glow from the emissive texture
  66057. */
  66058. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  66059. /**
  66060. * Remove a mesh from the highlight layer in order to make it stop glowing.
  66061. * @param mesh The mesh to highlight
  66062. */
  66063. removeMesh(mesh: Mesh): void;
  66064. /**
  66065. * Remove all the meshes currently referenced in the highlight layer
  66066. */
  66067. removeAllMeshes(): void;
  66068. /**
  66069. * Force the stencil to the normal expected value for none glowing parts
  66070. */
  66071. private _defaultStencilReference;
  66072. /**
  66073. * Free any resources and references associated to a mesh.
  66074. * Internal use
  66075. * @param mesh The mesh to free.
  66076. * @hidden
  66077. */
  66078. _disposeMesh(mesh: Mesh): void;
  66079. /**
  66080. * Dispose the highlight layer and free resources.
  66081. */
  66082. dispose(): void;
  66083. /**
  66084. * Gets the class name of the effect layer
  66085. * @returns the string with the class name of the effect layer
  66086. */
  66087. getClassName(): string;
  66088. /**
  66089. * Serializes this Highlight layer
  66090. * @returns a serialized Highlight layer object
  66091. */
  66092. serialize(): any;
  66093. /**
  66094. * Creates a Highlight layer from parsed Highlight layer data
  66095. * @param parsedHightlightLayer defines the Highlight layer data
  66096. * @param scene defines the current scene
  66097. * @param rootUrl defines the root URL containing the Highlight layer information
  66098. * @returns a parsed Highlight layer
  66099. */
  66100. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  66101. }
  66102. }
  66103. declare module "babylonjs/Layers/layerSceneComponent" {
  66104. import { Scene } from "babylonjs/scene";
  66105. import { ISceneComponent } from "babylonjs/sceneComponent";
  66106. import { Layer } from "babylonjs/Layers/layer";
  66107. import { AbstractScene } from "babylonjs/abstractScene";
  66108. module "babylonjs/abstractScene" {
  66109. interface AbstractScene {
  66110. /**
  66111. * The list of layers (background and foreground) of the scene
  66112. */
  66113. layers: Array<Layer>;
  66114. }
  66115. }
  66116. /**
  66117. * Defines the layer scene component responsible to manage any layers
  66118. * in a given scene.
  66119. */
  66120. export class LayerSceneComponent implements ISceneComponent {
  66121. /**
  66122. * The component name helpfull to identify the component in the list of scene components.
  66123. */
  66124. readonly name: string;
  66125. /**
  66126. * The scene the component belongs to.
  66127. */
  66128. scene: Scene;
  66129. private _engine;
  66130. /**
  66131. * Creates a new instance of the component for the given scene
  66132. * @param scene Defines the scene to register the component in
  66133. */
  66134. constructor(scene: Scene);
  66135. /**
  66136. * Registers the component in a given scene
  66137. */
  66138. register(): void;
  66139. /**
  66140. * Rebuilds the elements related to this component in case of
  66141. * context lost for instance.
  66142. */
  66143. rebuild(): void;
  66144. /**
  66145. * Disposes the component and the associated ressources.
  66146. */
  66147. dispose(): void;
  66148. private _draw;
  66149. private _drawCameraPredicate;
  66150. private _drawCameraBackground;
  66151. private _drawCameraForeground;
  66152. private _drawRenderTargetPredicate;
  66153. private _drawRenderTargetBackground;
  66154. private _drawRenderTargetForeground;
  66155. /**
  66156. * Adds all the elements from the container to the scene
  66157. * @param container the container holding the elements
  66158. */
  66159. addFromContainer(container: AbstractScene): void;
  66160. /**
  66161. * Removes all the elements in the container from the scene
  66162. * @param container contains the elements to remove
  66163. * @param dispose if the removed element should be disposed (default: false)
  66164. */
  66165. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  66166. }
  66167. }
  66168. declare module "babylonjs/Shaders/layer.fragment" {
  66169. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66170. /** @hidden */
  66171. export var layerPixelShader: {
  66172. name: string;
  66173. shader: string;
  66174. };
  66175. }
  66176. declare module "babylonjs/Shaders/layer.vertex" {
  66177. /** @hidden */
  66178. export var layerVertexShader: {
  66179. name: string;
  66180. shader: string;
  66181. };
  66182. }
  66183. declare module "babylonjs/Layers/layer" {
  66184. import { Observable } from "babylonjs/Misc/observable";
  66185. import { Nullable } from "babylonjs/types";
  66186. import { Scene } from "babylonjs/scene";
  66187. import { Vector2 } from "babylonjs/Maths/math.vector";
  66188. import { Color4 } from "babylonjs/Maths/math.color";
  66189. import { Texture } from "babylonjs/Materials/Textures/texture";
  66190. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66191. import "babylonjs/Shaders/layer.fragment";
  66192. import "babylonjs/Shaders/layer.vertex";
  66193. /**
  66194. * This represents a full screen 2d layer.
  66195. * This can be useful to display a picture in the background of your scene for instance.
  66196. * @see https://www.babylonjs-playground.com/#08A2BS#1
  66197. */
  66198. export class Layer {
  66199. /**
  66200. * Define the name of the layer.
  66201. */
  66202. name: string;
  66203. /**
  66204. * Define the texture the layer should display.
  66205. */
  66206. texture: Nullable<Texture>;
  66207. /**
  66208. * Is the layer in background or foreground.
  66209. */
  66210. isBackground: boolean;
  66211. /**
  66212. * Define the color of the layer (instead of texture).
  66213. */
  66214. color: Color4;
  66215. /**
  66216. * Define the scale of the layer in order to zoom in out of the texture.
  66217. */
  66218. scale: Vector2;
  66219. /**
  66220. * Define an offset for the layer in order to shift the texture.
  66221. */
  66222. offset: Vector2;
  66223. /**
  66224. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  66225. */
  66226. alphaBlendingMode: number;
  66227. /**
  66228. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  66229. * Alpha test will not mix with the background color in case of transparency.
  66230. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  66231. */
  66232. alphaTest: boolean;
  66233. /**
  66234. * Define a mask to restrict the layer to only some of the scene cameras.
  66235. */
  66236. layerMask: number;
  66237. /**
  66238. * Define the list of render target the layer is visible into.
  66239. */
  66240. renderTargetTextures: RenderTargetTexture[];
  66241. /**
  66242. * Define if the layer is only used in renderTarget or if it also
  66243. * renders in the main frame buffer of the canvas.
  66244. */
  66245. renderOnlyInRenderTargetTextures: boolean;
  66246. private _scene;
  66247. private _vertexBuffers;
  66248. private _indexBuffer;
  66249. private _effect;
  66250. private _previousDefines;
  66251. /**
  66252. * An event triggered when the layer is disposed.
  66253. */
  66254. onDisposeObservable: Observable<Layer>;
  66255. private _onDisposeObserver;
  66256. /**
  66257. * Back compatibility with callback before the onDisposeObservable existed.
  66258. * The set callback will be triggered when the layer has been disposed.
  66259. */
  66260. set onDispose(callback: () => void);
  66261. /**
  66262. * An event triggered before rendering the scene
  66263. */
  66264. onBeforeRenderObservable: Observable<Layer>;
  66265. private _onBeforeRenderObserver;
  66266. /**
  66267. * Back compatibility with callback before the onBeforeRenderObservable existed.
  66268. * The set callback will be triggered just before rendering the layer.
  66269. */
  66270. set onBeforeRender(callback: () => void);
  66271. /**
  66272. * An event triggered after rendering the scene
  66273. */
  66274. onAfterRenderObservable: Observable<Layer>;
  66275. private _onAfterRenderObserver;
  66276. /**
  66277. * Back compatibility with callback before the onAfterRenderObservable existed.
  66278. * The set callback will be triggered just after rendering the layer.
  66279. */
  66280. set onAfterRender(callback: () => void);
  66281. /**
  66282. * Instantiates a new layer.
  66283. * This represents a full screen 2d layer.
  66284. * This can be useful to display a picture in the background of your scene for instance.
  66285. * @see https://www.babylonjs-playground.com/#08A2BS#1
  66286. * @param name Define the name of the layer in the scene
  66287. * @param imgUrl Define the url of the texture to display in the layer
  66288. * @param scene Define the scene the layer belongs to
  66289. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  66290. * @param color Defines a color for the layer
  66291. */
  66292. constructor(
  66293. /**
  66294. * Define the name of the layer.
  66295. */
  66296. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  66297. private _createIndexBuffer;
  66298. /** @hidden */
  66299. _rebuild(): void;
  66300. /**
  66301. * Renders the layer in the scene.
  66302. */
  66303. render(): void;
  66304. /**
  66305. * Disposes and releases the associated ressources.
  66306. */
  66307. dispose(): void;
  66308. }
  66309. }
  66310. declare module "babylonjs/Layers/index" {
  66311. export * from "babylonjs/Layers/effectLayer";
  66312. export * from "babylonjs/Layers/effectLayerSceneComponent";
  66313. export * from "babylonjs/Layers/glowLayer";
  66314. export * from "babylonjs/Layers/highlightLayer";
  66315. export * from "babylonjs/Layers/layer";
  66316. export * from "babylonjs/Layers/layerSceneComponent";
  66317. }
  66318. declare module "babylonjs/Shaders/lensFlare.fragment" {
  66319. /** @hidden */
  66320. export var lensFlarePixelShader: {
  66321. name: string;
  66322. shader: string;
  66323. };
  66324. }
  66325. declare module "babylonjs/Shaders/lensFlare.vertex" {
  66326. /** @hidden */
  66327. export var lensFlareVertexShader: {
  66328. name: string;
  66329. shader: string;
  66330. };
  66331. }
  66332. declare module "babylonjs/LensFlares/lensFlareSystem" {
  66333. import { Scene } from "babylonjs/scene";
  66334. import { Vector3 } from "babylonjs/Maths/math.vector";
  66335. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66336. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  66337. import "babylonjs/Shaders/lensFlare.fragment";
  66338. import "babylonjs/Shaders/lensFlare.vertex";
  66339. import { Viewport } from "babylonjs/Maths/math.viewport";
  66340. /**
  66341. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  66342. * It is usually composed of several `lensFlare`.
  66343. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  66344. */
  66345. export class LensFlareSystem {
  66346. /**
  66347. * Define the name of the lens flare system
  66348. */
  66349. name: string;
  66350. /**
  66351. * List of lens flares used in this system.
  66352. */
  66353. lensFlares: LensFlare[];
  66354. /**
  66355. * Define a limit from the border the lens flare can be visible.
  66356. */
  66357. borderLimit: number;
  66358. /**
  66359. * Define a viewport border we do not want to see the lens flare in.
  66360. */
  66361. viewportBorder: number;
  66362. /**
  66363. * Define a predicate which could limit the list of meshes able to occlude the effect.
  66364. */
  66365. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  66366. /**
  66367. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  66368. */
  66369. layerMask: number;
  66370. /**
  66371. * Define the id of the lens flare system in the scene.
  66372. * (equal to name by default)
  66373. */
  66374. id: string;
  66375. private _scene;
  66376. private _emitter;
  66377. private _vertexBuffers;
  66378. private _indexBuffer;
  66379. private _effect;
  66380. private _positionX;
  66381. private _positionY;
  66382. private _isEnabled;
  66383. /** @hidden */
  66384. static _SceneComponentInitialization: (scene: Scene) => void;
  66385. /**
  66386. * Instantiates a lens flare system.
  66387. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  66388. * It is usually composed of several `lensFlare`.
  66389. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  66390. * @param name Define the name of the lens flare system in the scene
  66391. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  66392. * @param scene Define the scene the lens flare system belongs to
  66393. */
  66394. constructor(
  66395. /**
  66396. * Define the name of the lens flare system
  66397. */
  66398. name: string, emitter: any, scene: Scene);
  66399. /**
  66400. * Define if the lens flare system is enabled.
  66401. */
  66402. get isEnabled(): boolean;
  66403. set isEnabled(value: boolean);
  66404. /**
  66405. * Get the scene the effects belongs to.
  66406. * @returns the scene holding the lens flare system
  66407. */
  66408. getScene(): Scene;
  66409. /**
  66410. * Get the emitter of the lens flare system.
  66411. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  66412. * @returns the emitter of the lens flare system
  66413. */
  66414. getEmitter(): any;
  66415. /**
  66416. * Set the emitter of the lens flare system.
  66417. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  66418. * @param newEmitter Define the new emitter of the system
  66419. */
  66420. setEmitter(newEmitter: any): void;
  66421. /**
  66422. * Get the lens flare system emitter position.
  66423. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  66424. * @returns the position
  66425. */
  66426. getEmitterPosition(): Vector3;
  66427. /**
  66428. * @hidden
  66429. */
  66430. computeEffectivePosition(globalViewport: Viewport): boolean;
  66431. /** @hidden */
  66432. _isVisible(): boolean;
  66433. /**
  66434. * @hidden
  66435. */
  66436. render(): boolean;
  66437. /**
  66438. * Dispose and release the lens flare with its associated resources.
  66439. */
  66440. dispose(): void;
  66441. /**
  66442. * Parse a lens flare system from a JSON repressentation
  66443. * @param parsedLensFlareSystem Define the JSON to parse
  66444. * @param scene Define the scene the parsed system should be instantiated in
  66445. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  66446. * @returns the parsed system
  66447. */
  66448. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  66449. /**
  66450. * Serialize the current Lens Flare System into a JSON representation.
  66451. * @returns the serialized JSON
  66452. */
  66453. serialize(): any;
  66454. }
  66455. }
  66456. declare module "babylonjs/LensFlares/lensFlare" {
  66457. import { Nullable } from "babylonjs/types";
  66458. import { Color3 } from "babylonjs/Maths/math.color";
  66459. import { Texture } from "babylonjs/Materials/Textures/texture";
  66460. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  66461. /**
  66462. * This represents one of the lens effect in a `lensFlareSystem`.
  66463. * It controls one of the indiviual texture used in the effect.
  66464. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  66465. */
  66466. export class LensFlare {
  66467. /**
  66468. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  66469. */
  66470. size: number;
  66471. /**
  66472. * 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.
  66473. */
  66474. position: number;
  66475. /**
  66476. * Define the lens color.
  66477. */
  66478. color: Color3;
  66479. /**
  66480. * Define the lens texture.
  66481. */
  66482. texture: Nullable<Texture>;
  66483. /**
  66484. * Define the alpha mode to render this particular lens.
  66485. */
  66486. alphaMode: number;
  66487. private _system;
  66488. /**
  66489. * Creates a new Lens Flare.
  66490. * This represents one of the lens effect in a `lensFlareSystem`.
  66491. * It controls one of the indiviual texture used in the effect.
  66492. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  66493. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  66494. * @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.
  66495. * @param color Define the lens color
  66496. * @param imgUrl Define the lens texture url
  66497. * @param system Define the `lensFlareSystem` this flare is part of
  66498. * @returns The newly created Lens Flare
  66499. */
  66500. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  66501. /**
  66502. * Instantiates a new Lens Flare.
  66503. * This represents one of the lens effect in a `lensFlareSystem`.
  66504. * It controls one of the indiviual texture used in the effect.
  66505. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  66506. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  66507. * @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.
  66508. * @param color Define the lens color
  66509. * @param imgUrl Define the lens texture url
  66510. * @param system Define the `lensFlareSystem` this flare is part of
  66511. */
  66512. constructor(
  66513. /**
  66514. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  66515. */
  66516. size: number,
  66517. /**
  66518. * 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.
  66519. */
  66520. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  66521. /**
  66522. * Dispose and release the lens flare with its associated resources.
  66523. */
  66524. dispose(): void;
  66525. }
  66526. }
  66527. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  66528. import { Nullable } from "babylonjs/types";
  66529. import { Scene } from "babylonjs/scene";
  66530. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  66531. import { AbstractScene } from "babylonjs/abstractScene";
  66532. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  66533. module "babylonjs/abstractScene" {
  66534. interface AbstractScene {
  66535. /**
  66536. * The list of lens flare system added to the scene
  66537. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  66538. */
  66539. lensFlareSystems: Array<LensFlareSystem>;
  66540. /**
  66541. * Removes the given lens flare system from this scene.
  66542. * @param toRemove The lens flare system to remove
  66543. * @returns The index of the removed lens flare system
  66544. */
  66545. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  66546. /**
  66547. * Adds the given lens flare system to this scene
  66548. * @param newLensFlareSystem The lens flare system to add
  66549. */
  66550. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  66551. /**
  66552. * Gets a lens flare system using its name
  66553. * @param name defines the name to look for
  66554. * @returns the lens flare system or null if not found
  66555. */
  66556. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  66557. /**
  66558. * Gets a lens flare system using its id
  66559. * @param id defines the id to look for
  66560. * @returns the lens flare system or null if not found
  66561. */
  66562. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  66563. }
  66564. }
  66565. /**
  66566. * Defines the lens flare scene component responsible to manage any lens flares
  66567. * in a given scene.
  66568. */
  66569. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  66570. /**
  66571. * The component name helpfull to identify the component in the list of scene components.
  66572. */
  66573. readonly name: string;
  66574. /**
  66575. * The scene the component belongs to.
  66576. */
  66577. scene: Scene;
  66578. /**
  66579. * Creates a new instance of the component for the given scene
  66580. * @param scene Defines the scene to register the component in
  66581. */
  66582. constructor(scene: Scene);
  66583. /**
  66584. * Registers the component in a given scene
  66585. */
  66586. register(): void;
  66587. /**
  66588. * Rebuilds the elements related to this component in case of
  66589. * context lost for instance.
  66590. */
  66591. rebuild(): void;
  66592. /**
  66593. * Adds all the elements from the container to the scene
  66594. * @param container the container holding the elements
  66595. */
  66596. addFromContainer(container: AbstractScene): void;
  66597. /**
  66598. * Removes all the elements in the container from the scene
  66599. * @param container contains the elements to remove
  66600. * @param dispose if the removed element should be disposed (default: false)
  66601. */
  66602. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  66603. /**
  66604. * Serializes the component data to the specified json object
  66605. * @param serializationObject The object to serialize to
  66606. */
  66607. serialize(serializationObject: any): void;
  66608. /**
  66609. * Disposes the component and the associated ressources.
  66610. */
  66611. dispose(): void;
  66612. private _draw;
  66613. }
  66614. }
  66615. declare module "babylonjs/LensFlares/index" {
  66616. export * from "babylonjs/LensFlares/lensFlare";
  66617. export * from "babylonjs/LensFlares/lensFlareSystem";
  66618. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  66619. }
  66620. declare module "babylonjs/Shaders/depth.fragment" {
  66621. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  66622. /** @hidden */
  66623. export var depthPixelShader: {
  66624. name: string;
  66625. shader: string;
  66626. };
  66627. }
  66628. declare module "babylonjs/Shaders/depth.vertex" {
  66629. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66630. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66631. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66632. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66633. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66634. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66635. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66636. /** @hidden */
  66637. export var depthVertexShader: {
  66638. name: string;
  66639. shader: string;
  66640. };
  66641. }
  66642. declare module "babylonjs/Rendering/depthRenderer" {
  66643. import { Nullable } from "babylonjs/types";
  66644. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66645. import { Scene } from "babylonjs/scene";
  66646. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66647. import { Camera } from "babylonjs/Cameras/camera";
  66648. import "babylonjs/Shaders/depth.fragment";
  66649. import "babylonjs/Shaders/depth.vertex";
  66650. /**
  66651. * This represents a depth renderer in Babylon.
  66652. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  66653. */
  66654. export class DepthRenderer {
  66655. private _scene;
  66656. private _depthMap;
  66657. private _effect;
  66658. private readonly _storeNonLinearDepth;
  66659. private readonly _clearColor;
  66660. /** Get if the depth renderer is using packed depth or not */
  66661. readonly isPacked: boolean;
  66662. private _cachedDefines;
  66663. private _camera;
  66664. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  66665. enabled: boolean;
  66666. /**
  66667. * Specifiess that the depth renderer will only be used within
  66668. * the camera it is created for.
  66669. * This can help forcing its rendering during the camera processing.
  66670. */
  66671. useOnlyInActiveCamera: boolean;
  66672. /** @hidden */
  66673. static _SceneComponentInitialization: (scene: Scene) => void;
  66674. /**
  66675. * Instantiates a depth renderer
  66676. * @param scene The scene the renderer belongs to
  66677. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  66678. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  66679. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66680. */
  66681. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  66682. /**
  66683. * Creates the depth rendering effect and checks if the effect is ready.
  66684. * @param subMesh The submesh to be used to render the depth map of
  66685. * @param useInstances If multiple world instances should be used
  66686. * @returns if the depth renderer is ready to render the depth map
  66687. */
  66688. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66689. /**
  66690. * Gets the texture which the depth map will be written to.
  66691. * @returns The depth map texture
  66692. */
  66693. getDepthMap(): RenderTargetTexture;
  66694. /**
  66695. * Disposes of the depth renderer.
  66696. */
  66697. dispose(): void;
  66698. }
  66699. }
  66700. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  66701. /** @hidden */
  66702. export var minmaxReduxPixelShader: {
  66703. name: string;
  66704. shader: string;
  66705. };
  66706. }
  66707. declare module "babylonjs/Misc/minMaxReducer" {
  66708. import { Nullable } from "babylonjs/types";
  66709. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66710. import { Camera } from "babylonjs/Cameras/camera";
  66711. import { Observer } from "babylonjs/Misc/observable";
  66712. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66713. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  66714. import { Observable } from "babylonjs/Misc/observable";
  66715. import "babylonjs/Shaders/minmaxRedux.fragment";
  66716. /**
  66717. * This class computes a min/max reduction from a texture: it means it computes the minimum
  66718. * and maximum values from all values of the texture.
  66719. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  66720. * The source values are read from the red channel of the texture.
  66721. */
  66722. export class MinMaxReducer {
  66723. /**
  66724. * Observable triggered when the computation has been performed
  66725. */
  66726. onAfterReductionPerformed: Observable<{
  66727. min: number;
  66728. max: number;
  66729. }>;
  66730. protected _camera: Camera;
  66731. protected _sourceTexture: Nullable<RenderTargetTexture>;
  66732. protected _reductionSteps: Nullable<Array<PostProcess>>;
  66733. protected _postProcessManager: PostProcessManager;
  66734. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  66735. protected _forceFullscreenViewport: boolean;
  66736. /**
  66737. * Creates a min/max reducer
  66738. * @param camera The camera to use for the post processes
  66739. */
  66740. constructor(camera: Camera);
  66741. /**
  66742. * Gets the texture used to read the values from.
  66743. */
  66744. get sourceTexture(): Nullable<RenderTargetTexture>;
  66745. /**
  66746. * Sets the source texture to read the values from.
  66747. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  66748. * because in such textures '1' value must not be taken into account to compute the maximum
  66749. * as this value is used to clear the texture.
  66750. * Note that the computation is not activated by calling this function, you must call activate() for that!
  66751. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  66752. * @param depthRedux Indicates if the texture is a depth texture or not
  66753. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  66754. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  66755. */
  66756. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  66757. /**
  66758. * Defines the refresh rate of the computation.
  66759. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  66760. */
  66761. get refreshRate(): number;
  66762. set refreshRate(value: number);
  66763. protected _activated: boolean;
  66764. /**
  66765. * Gets the activation status of the reducer
  66766. */
  66767. get activated(): boolean;
  66768. /**
  66769. * Activates the reduction computation.
  66770. * When activated, the observers registered in onAfterReductionPerformed are
  66771. * called after the compuation is performed
  66772. */
  66773. activate(): void;
  66774. /**
  66775. * Deactivates the reduction computation.
  66776. */
  66777. deactivate(): void;
  66778. /**
  66779. * Disposes the min/max reducer
  66780. * @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.
  66781. */
  66782. dispose(disposeAll?: boolean): void;
  66783. }
  66784. }
  66785. declare module "babylonjs/Misc/depthReducer" {
  66786. import { Nullable } from "babylonjs/types";
  66787. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66788. import { Camera } from "babylonjs/Cameras/camera";
  66789. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  66790. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  66791. /**
  66792. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  66793. */
  66794. export class DepthReducer extends MinMaxReducer {
  66795. private _depthRenderer;
  66796. private _depthRendererId;
  66797. /**
  66798. * Gets the depth renderer used for the computation.
  66799. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  66800. */
  66801. get depthRenderer(): Nullable<DepthRenderer>;
  66802. /**
  66803. * Creates a depth reducer
  66804. * @param camera The camera used to render the depth texture
  66805. */
  66806. constructor(camera: Camera);
  66807. /**
  66808. * Sets the depth renderer to use to generate the depth map
  66809. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  66810. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  66811. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  66812. */
  66813. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  66814. /** @hidden */
  66815. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  66816. /**
  66817. * Activates the reduction computation.
  66818. * When activated, the observers registered in onAfterReductionPerformed are
  66819. * called after the compuation is performed
  66820. */
  66821. activate(): void;
  66822. /**
  66823. * Deactivates the reduction computation.
  66824. */
  66825. deactivate(): void;
  66826. /**
  66827. * Disposes the depth reducer
  66828. * @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.
  66829. */
  66830. dispose(disposeAll?: boolean): void;
  66831. }
  66832. }
  66833. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  66834. import { Nullable } from "babylonjs/types";
  66835. import { Scene } from "babylonjs/scene";
  66836. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  66837. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66838. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66839. import { Effect } from "babylonjs/Materials/effect";
  66840. import "babylonjs/Shaders/shadowMap.fragment";
  66841. import "babylonjs/Shaders/shadowMap.vertex";
  66842. import "babylonjs/Shaders/depthBoxBlur.fragment";
  66843. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  66844. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  66845. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  66846. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  66847. /**
  66848. * A CSM implementation allowing casting shadows on large scenes.
  66849. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  66850. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  66851. */
  66852. export class CascadedShadowGenerator extends ShadowGenerator {
  66853. private static readonly frustumCornersNDCSpace;
  66854. /**
  66855. * Name of the CSM class
  66856. */
  66857. static CLASSNAME: string;
  66858. /**
  66859. * Defines the default number of cascades used by the CSM.
  66860. */
  66861. static readonly DEFAULT_CASCADES_COUNT: number;
  66862. /**
  66863. * Defines the minimum number of cascades used by the CSM.
  66864. */
  66865. static readonly MIN_CASCADES_COUNT: number;
  66866. /**
  66867. * Defines the maximum number of cascades used by the CSM.
  66868. */
  66869. static readonly MAX_CASCADES_COUNT: number;
  66870. protected _validateFilter(filter: number): number;
  66871. /**
  66872. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  66873. */
  66874. penumbraDarkness: number;
  66875. private _numCascades;
  66876. /**
  66877. * Gets or set the number of cascades used by the CSM.
  66878. */
  66879. get numCascades(): number;
  66880. set numCascades(value: number);
  66881. /**
  66882. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  66883. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  66884. */
  66885. stabilizeCascades: boolean;
  66886. private _freezeShadowCastersBoundingInfo;
  66887. private _freezeShadowCastersBoundingInfoObservable;
  66888. /**
  66889. * Enables or disables the shadow casters bounding info computation.
  66890. * If your shadow casters don't move, you can disable this feature.
  66891. * If it is enabled, the bounding box computation is done every frame.
  66892. */
  66893. get freezeShadowCastersBoundingInfo(): boolean;
  66894. set freezeShadowCastersBoundingInfo(freeze: boolean);
  66895. private _scbiMin;
  66896. private _scbiMax;
  66897. protected _computeShadowCastersBoundingInfo(): void;
  66898. protected _shadowCastersBoundingInfo: BoundingInfo;
  66899. /**
  66900. * Gets or sets the shadow casters bounding info.
  66901. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  66902. * so that the system won't overwrite the bounds you provide
  66903. */
  66904. get shadowCastersBoundingInfo(): BoundingInfo;
  66905. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  66906. protected _breaksAreDirty: boolean;
  66907. protected _minDistance: number;
  66908. protected _maxDistance: number;
  66909. /**
  66910. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  66911. *
  66912. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  66913. * If you don't know these values, simply leave them to their defaults and don't call this function.
  66914. * @param min minimal distance for the breaks (default to 0.)
  66915. * @param max maximal distance for the breaks (default to 1.)
  66916. */
  66917. setMinMaxDistance(min: number, max: number): void;
  66918. /** Gets the minimal distance used in the cascade break computation */
  66919. get minDistance(): number;
  66920. /** Gets the maximal distance used in the cascade break computation */
  66921. get maxDistance(): number;
  66922. /**
  66923. * Gets the class name of that object
  66924. * @returns "CascadedShadowGenerator"
  66925. */
  66926. getClassName(): string;
  66927. private _cascadeMinExtents;
  66928. private _cascadeMaxExtents;
  66929. /**
  66930. * Gets a cascade minimum extents
  66931. * @param cascadeIndex index of the cascade
  66932. * @returns the minimum cascade extents
  66933. */
  66934. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  66935. /**
  66936. * Gets a cascade maximum extents
  66937. * @param cascadeIndex index of the cascade
  66938. * @returns the maximum cascade extents
  66939. */
  66940. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  66941. private _cascades;
  66942. private _currentLayer;
  66943. private _viewSpaceFrustumsZ;
  66944. private _viewMatrices;
  66945. private _projectionMatrices;
  66946. private _transformMatrices;
  66947. private _transformMatricesAsArray;
  66948. private _frustumLengths;
  66949. private _lightSizeUVCorrection;
  66950. private _depthCorrection;
  66951. private _frustumCornersWorldSpace;
  66952. private _frustumCenter;
  66953. private _shadowCameraPos;
  66954. private _shadowMaxZ;
  66955. /**
  66956. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  66957. * It defaults to camera.maxZ
  66958. */
  66959. get shadowMaxZ(): number;
  66960. /**
  66961. * Sets the shadow max z distance.
  66962. */
  66963. set shadowMaxZ(value: number);
  66964. protected _debug: boolean;
  66965. /**
  66966. * Gets or sets the debug flag.
  66967. * When enabled, the cascades are materialized by different colors on the screen.
  66968. */
  66969. get debug(): boolean;
  66970. set debug(dbg: boolean);
  66971. private _depthClamp;
  66972. /**
  66973. * Gets or sets the depth clamping value.
  66974. *
  66975. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  66976. * to account for the shadow casters far away.
  66977. *
  66978. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  66979. */
  66980. get depthClamp(): boolean;
  66981. set depthClamp(value: boolean);
  66982. private _cascadeBlendPercentage;
  66983. /**
  66984. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  66985. * It defaults to 0.1 (10% blending).
  66986. */
  66987. get cascadeBlendPercentage(): number;
  66988. set cascadeBlendPercentage(value: number);
  66989. private _lambda;
  66990. /**
  66991. * Gets or set the lambda parameter.
  66992. * This parameter is used to split the camera frustum and create the cascades.
  66993. * 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.
  66994. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  66995. */
  66996. get lambda(): number;
  66997. set lambda(value: number);
  66998. /**
  66999. * Gets the view matrix corresponding to a given cascade
  67000. * @param cascadeNum cascade to retrieve the view matrix from
  67001. * @returns the cascade view matrix
  67002. */
  67003. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  67004. /**
  67005. * Gets the projection matrix corresponding to a given cascade
  67006. * @param cascadeNum cascade to retrieve the projection matrix from
  67007. * @returns the cascade projection matrix
  67008. */
  67009. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  67010. /**
  67011. * Gets the transformation matrix corresponding to a given cascade
  67012. * @param cascadeNum cascade to retrieve the transformation matrix from
  67013. * @returns the cascade transformation matrix
  67014. */
  67015. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  67016. private _depthRenderer;
  67017. /**
  67018. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  67019. *
  67020. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  67021. *
  67022. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  67023. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  67024. * @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
  67025. */
  67026. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  67027. private _depthReducer;
  67028. private _autoCalcDepthBounds;
  67029. /**
  67030. * Gets or sets the autoCalcDepthBounds property.
  67031. *
  67032. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  67033. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  67034. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  67035. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  67036. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  67037. */
  67038. get autoCalcDepthBounds(): boolean;
  67039. set autoCalcDepthBounds(value: boolean);
  67040. /**
  67041. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  67042. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  67043. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  67044. * for setting the refresh rate on the renderer yourself!
  67045. */
  67046. get autoCalcDepthBoundsRefreshRate(): number;
  67047. set autoCalcDepthBoundsRefreshRate(value: number);
  67048. /**
  67049. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  67050. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  67051. * you change the camera near/far planes!
  67052. */
  67053. splitFrustum(): void;
  67054. private _splitFrustum;
  67055. private _computeMatrices;
  67056. private _computeFrustumInWorldSpace;
  67057. private _computeCascadeFrustum;
  67058. /**
  67059. * Support test.
  67060. */
  67061. static get IsSupported(): boolean;
  67062. /** @hidden */
  67063. static _SceneComponentInitialization: (scene: Scene) => void;
  67064. /**
  67065. * Creates a Cascaded Shadow Generator object.
  67066. * A ShadowGenerator is the required tool to use the shadows.
  67067. * Each directional light casting shadows needs to use its own ShadowGenerator.
  67068. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  67069. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  67070. * @param light The directional light object generating the shadows.
  67071. * @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.
  67072. */
  67073. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  67074. protected _initializeGenerator(): void;
  67075. protected _createTargetRenderTexture(): void;
  67076. protected _initializeShadowMap(): void;
  67077. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  67078. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  67079. /**
  67080. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  67081. * @param defines Defines of the material we want to update
  67082. * @param lightIndex Index of the light in the enabled light list of the material
  67083. */
  67084. prepareDefines(defines: any, lightIndex: number): void;
  67085. /**
  67086. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  67087. * defined in the generator but impacting the effect).
  67088. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  67089. * @param effect The effect we are binfing the information for
  67090. */
  67091. bindShadowLight(lightIndex: string, effect: Effect): void;
  67092. /**
  67093. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  67094. * (eq to view projection * shadow projection matrices)
  67095. * @returns The transform matrix used to create the shadow map
  67096. */
  67097. getTransformMatrix(): Matrix;
  67098. /**
  67099. * Disposes the ShadowGenerator.
  67100. * Returns nothing.
  67101. */
  67102. dispose(): void;
  67103. /**
  67104. * Serializes the shadow generator setup to a json object.
  67105. * @returns The serialized JSON object
  67106. */
  67107. serialize(): any;
  67108. /**
  67109. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  67110. * @param parsedShadowGenerator The JSON object to parse
  67111. * @param scene The scene to create the shadow map for
  67112. * @returns The parsed shadow generator
  67113. */
  67114. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  67115. }
  67116. }
  67117. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  67118. import { Scene } from "babylonjs/scene";
  67119. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  67120. import { AbstractScene } from "babylonjs/abstractScene";
  67121. /**
  67122. * Defines the shadow generator component responsible to manage any shadow generators
  67123. * in a given scene.
  67124. */
  67125. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  67126. /**
  67127. * The component name helpfull to identify the component in the list of scene components.
  67128. */
  67129. readonly name: string;
  67130. /**
  67131. * The scene the component belongs to.
  67132. */
  67133. scene: Scene;
  67134. /**
  67135. * Creates a new instance of the component for the given scene
  67136. * @param scene Defines the scene to register the component in
  67137. */
  67138. constructor(scene: Scene);
  67139. /**
  67140. * Registers the component in a given scene
  67141. */
  67142. register(): void;
  67143. /**
  67144. * Rebuilds the elements related to this component in case of
  67145. * context lost for instance.
  67146. */
  67147. rebuild(): void;
  67148. /**
  67149. * Serializes the component data to the specified json object
  67150. * @param serializationObject The object to serialize to
  67151. */
  67152. serialize(serializationObject: any): void;
  67153. /**
  67154. * Adds all the elements from the container to the scene
  67155. * @param container the container holding the elements
  67156. */
  67157. addFromContainer(container: AbstractScene): void;
  67158. /**
  67159. * Removes all the elements in the container from the scene
  67160. * @param container contains the elements to remove
  67161. * @param dispose if the removed element should be disposed (default: false)
  67162. */
  67163. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  67164. /**
  67165. * Rebuilds the elements related to this component in case of
  67166. * context lost for instance.
  67167. */
  67168. dispose(): void;
  67169. private _gatherRenderTargets;
  67170. }
  67171. }
  67172. declare module "babylonjs/Lights/Shadows/index" {
  67173. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  67174. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  67175. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  67176. }
  67177. declare module "babylonjs/Lights/pointLight" {
  67178. import { Scene } from "babylonjs/scene";
  67179. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  67180. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67181. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  67182. import { Effect } from "babylonjs/Materials/effect";
  67183. /**
  67184. * A point light is a light defined by an unique point in world space.
  67185. * The light is emitted in every direction from this point.
  67186. * A good example of a point light is a standard light bulb.
  67187. * Documentation: https://doc.babylonjs.com/babylon101/lights
  67188. */
  67189. export class PointLight extends ShadowLight {
  67190. private _shadowAngle;
  67191. /**
  67192. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  67193. * This specifies what angle the shadow will use to be created.
  67194. *
  67195. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  67196. */
  67197. get shadowAngle(): number;
  67198. /**
  67199. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  67200. * This specifies what angle the shadow will use to be created.
  67201. *
  67202. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  67203. */
  67204. set shadowAngle(value: number);
  67205. /**
  67206. * Gets the direction if it has been set.
  67207. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  67208. */
  67209. get direction(): Vector3;
  67210. /**
  67211. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  67212. */
  67213. set direction(value: Vector3);
  67214. /**
  67215. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  67216. * A PointLight emits the light in every direction.
  67217. * It can cast shadows.
  67218. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  67219. * ```javascript
  67220. * var pointLight = new PointLight("pl", camera.position, scene);
  67221. * ```
  67222. * Documentation : https://doc.babylonjs.com/babylon101/lights
  67223. * @param name The light friendly name
  67224. * @param position The position of the point light in the scene
  67225. * @param scene The scene the lights belongs to
  67226. */
  67227. constructor(name: string, position: Vector3, scene: Scene);
  67228. /**
  67229. * Returns the string "PointLight"
  67230. * @returns the class name
  67231. */
  67232. getClassName(): string;
  67233. /**
  67234. * Returns the integer 0.
  67235. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  67236. */
  67237. getTypeID(): number;
  67238. /**
  67239. * Specifies wether or not the shadowmap should be a cube texture.
  67240. * @returns true if the shadowmap needs to be a cube texture.
  67241. */
  67242. needCube(): boolean;
  67243. /**
  67244. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  67245. * @param faceIndex The index of the face we are computed the direction to generate shadow
  67246. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  67247. */
  67248. getShadowDirection(faceIndex?: number): Vector3;
  67249. /**
  67250. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  67251. * - fov = PI / 2
  67252. * - aspect ratio : 1.0
  67253. * - z-near and far equal to the active camera minZ and maxZ.
  67254. * Returns the PointLight.
  67255. */
  67256. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  67257. protected _buildUniformLayout(): void;
  67258. /**
  67259. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  67260. * @param effect The effect to update
  67261. * @param lightIndex The index of the light in the effect to update
  67262. * @returns The point light
  67263. */
  67264. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  67265. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  67266. /**
  67267. * Prepares the list of defines specific to the light type.
  67268. * @param defines the list of defines
  67269. * @param lightIndex defines the index of the light for the effect
  67270. */
  67271. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  67272. }
  67273. }
  67274. declare module "babylonjs/Lights/index" {
  67275. export * from "babylonjs/Lights/light";
  67276. export * from "babylonjs/Lights/shadowLight";
  67277. export * from "babylonjs/Lights/Shadows/index";
  67278. export * from "babylonjs/Lights/directionalLight";
  67279. export * from "babylonjs/Lights/hemisphericLight";
  67280. export * from "babylonjs/Lights/pointLight";
  67281. export * from "babylonjs/Lights/spotLight";
  67282. }
  67283. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  67284. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  67285. /**
  67286. * Header information of HDR texture files.
  67287. */
  67288. export interface HDRInfo {
  67289. /**
  67290. * The height of the texture in pixels.
  67291. */
  67292. height: number;
  67293. /**
  67294. * The width of the texture in pixels.
  67295. */
  67296. width: number;
  67297. /**
  67298. * The index of the beginning of the data in the binary file.
  67299. */
  67300. dataPosition: number;
  67301. }
  67302. /**
  67303. * This groups tools to convert HDR texture to native colors array.
  67304. */
  67305. export class HDRTools {
  67306. private static Ldexp;
  67307. private static Rgbe2float;
  67308. private static readStringLine;
  67309. /**
  67310. * Reads header information from an RGBE texture stored in a native array.
  67311. * More information on this format are available here:
  67312. * https://en.wikipedia.org/wiki/RGBE_image_format
  67313. *
  67314. * @param uint8array The binary file stored in native array.
  67315. * @return The header information.
  67316. */
  67317. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  67318. /**
  67319. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  67320. * This RGBE texture needs to store the information as a panorama.
  67321. *
  67322. * More information on this format are available here:
  67323. * https://en.wikipedia.org/wiki/RGBE_image_format
  67324. *
  67325. * @param buffer The binary file stored in an array buffer.
  67326. * @param size The expected size of the extracted cubemap.
  67327. * @return The Cube Map information.
  67328. */
  67329. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  67330. /**
  67331. * Returns the pixels data extracted from an RGBE texture.
  67332. * This pixels will be stored left to right up to down in the R G B order in one array.
  67333. *
  67334. * More information on this format are available here:
  67335. * https://en.wikipedia.org/wiki/RGBE_image_format
  67336. *
  67337. * @param uint8array The binary file stored in an array buffer.
  67338. * @param hdrInfo The header information of the file.
  67339. * @return The pixels data in RGB right to left up to down order.
  67340. */
  67341. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  67342. private static RGBE_ReadPixels_RLE;
  67343. private static RGBE_ReadPixels_NOT_RLE;
  67344. }
  67345. }
  67346. declare module "babylonjs/Materials/effectRenderer" {
  67347. import { Nullable } from "babylonjs/types";
  67348. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  67349. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67350. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  67351. import { Viewport } from "babylonjs/Maths/math.viewport";
  67352. import { Observable } from "babylonjs/Misc/observable";
  67353. import { Effect } from "babylonjs/Materials/effect";
  67354. import "babylonjs/Shaders/postprocess.vertex";
  67355. /**
  67356. * Effect Render Options
  67357. */
  67358. export interface IEffectRendererOptions {
  67359. /**
  67360. * Defines the vertices positions.
  67361. */
  67362. positions?: number[];
  67363. /**
  67364. * Defines the indices.
  67365. */
  67366. indices?: number[];
  67367. }
  67368. /**
  67369. * Helper class to render one or more effects.
  67370. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  67371. */
  67372. export class EffectRenderer {
  67373. private engine;
  67374. private static _DefaultOptions;
  67375. private _vertexBuffers;
  67376. private _indexBuffer;
  67377. private _fullscreenViewport;
  67378. /**
  67379. * Creates an effect renderer
  67380. * @param engine the engine to use for rendering
  67381. * @param options defines the options of the effect renderer
  67382. */
  67383. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  67384. /**
  67385. * Sets the current viewport in normalized coordinates 0-1
  67386. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  67387. */
  67388. setViewport(viewport?: Viewport): void;
  67389. /**
  67390. * Binds the embedded attributes buffer to the effect.
  67391. * @param effect Defines the effect to bind the attributes for
  67392. */
  67393. bindBuffers(effect: Effect): void;
  67394. /**
  67395. * Sets the current effect wrapper to use during draw.
  67396. * The effect needs to be ready before calling this api.
  67397. * This also sets the default full screen position attribute.
  67398. * @param effectWrapper Defines the effect to draw with
  67399. */
  67400. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  67401. /**
  67402. * Restores engine states
  67403. */
  67404. restoreStates(): void;
  67405. /**
  67406. * Draws a full screen quad.
  67407. */
  67408. draw(): void;
  67409. private isRenderTargetTexture;
  67410. /**
  67411. * renders one or more effects to a specified texture
  67412. * @param effectWrapper the effect to renderer
  67413. * @param outputTexture texture to draw to, if null it will render to the screen.
  67414. */
  67415. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  67416. /**
  67417. * Disposes of the effect renderer
  67418. */
  67419. dispose(): void;
  67420. }
  67421. /**
  67422. * Options to create an EffectWrapper
  67423. */
  67424. interface EffectWrapperCreationOptions {
  67425. /**
  67426. * Engine to use to create the effect
  67427. */
  67428. engine: ThinEngine;
  67429. /**
  67430. * Fragment shader for the effect
  67431. */
  67432. fragmentShader: string;
  67433. /**
  67434. * Use the shader store instead of direct source code
  67435. */
  67436. useShaderStore?: boolean;
  67437. /**
  67438. * Vertex shader for the effect
  67439. */
  67440. vertexShader?: string;
  67441. /**
  67442. * Attributes to use in the shader
  67443. */
  67444. attributeNames?: Array<string>;
  67445. /**
  67446. * Uniforms to use in the shader
  67447. */
  67448. uniformNames?: Array<string>;
  67449. /**
  67450. * Texture sampler names to use in the shader
  67451. */
  67452. samplerNames?: Array<string>;
  67453. /**
  67454. * Defines to use in the shader
  67455. */
  67456. defines?: Array<string>;
  67457. /**
  67458. * Callback when effect is compiled
  67459. */
  67460. onCompiled?: Nullable<(effect: Effect) => void>;
  67461. /**
  67462. * The friendly name of the effect displayed in Spector.
  67463. */
  67464. name?: string;
  67465. }
  67466. /**
  67467. * Wraps an effect to be used for rendering
  67468. */
  67469. export class EffectWrapper {
  67470. /**
  67471. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  67472. */
  67473. onApplyObservable: Observable<{}>;
  67474. /**
  67475. * The underlying effect
  67476. */
  67477. effect: Effect;
  67478. /**
  67479. * Creates an effect to be renderer
  67480. * @param creationOptions options to create the effect
  67481. */
  67482. constructor(creationOptions: EffectWrapperCreationOptions);
  67483. /**
  67484. * Disposes of the effect wrapper
  67485. */
  67486. dispose(): void;
  67487. }
  67488. }
  67489. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  67490. /** @hidden */
  67491. export var hdrFilteringVertexShader: {
  67492. name: string;
  67493. shader: string;
  67494. };
  67495. }
  67496. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  67497. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67498. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  67499. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  67500. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  67501. /** @hidden */
  67502. export var hdrFilteringPixelShader: {
  67503. name: string;
  67504. shader: string;
  67505. };
  67506. }
  67507. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  67508. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  67509. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  67510. import { Nullable } from "babylonjs/types";
  67511. import "babylonjs/Shaders/hdrFiltering.vertex";
  67512. import "babylonjs/Shaders/hdrFiltering.fragment";
  67513. /**
  67514. * Options for texture filtering
  67515. */
  67516. interface IHDRFilteringOptions {
  67517. /**
  67518. * Scales pixel intensity for the input HDR map.
  67519. */
  67520. hdrScale?: number;
  67521. /**
  67522. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  67523. */
  67524. quality?: number;
  67525. }
  67526. /**
  67527. * Filters HDR maps to get correct renderings of PBR reflections
  67528. */
  67529. export class HDRFiltering {
  67530. private _engine;
  67531. private _effectRenderer;
  67532. private _effectWrapper;
  67533. private _lodGenerationOffset;
  67534. private _lodGenerationScale;
  67535. /**
  67536. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  67537. * you care about baking speed.
  67538. */
  67539. quality: number;
  67540. /**
  67541. * Scales pixel intensity for the input HDR map.
  67542. */
  67543. hdrScale: number;
  67544. /**
  67545. * Instantiates HDR filter for reflection maps
  67546. *
  67547. * @param engine Thin engine
  67548. * @param options Options
  67549. */
  67550. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  67551. private _createRenderTarget;
  67552. private _prefilterInternal;
  67553. private _createEffect;
  67554. /**
  67555. * Get a value indicating if the filter is ready to be used
  67556. * @param texture Texture to filter
  67557. * @returns true if the filter is ready
  67558. */
  67559. isReady(texture: BaseTexture): boolean;
  67560. /**
  67561. * Prefilters a cube texture to have mipmap levels representing roughness values.
  67562. * Prefiltering will be invoked at the end of next rendering pass.
  67563. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  67564. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  67565. * @param texture Texture to filter
  67566. * @param onFinished Callback when filtering is done
  67567. * @return Promise called when prefiltering is done
  67568. */
  67569. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<void>;
  67570. }
  67571. }
  67572. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  67573. import { Nullable } from "babylonjs/types";
  67574. import { Scene } from "babylonjs/scene";
  67575. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  67576. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  67577. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  67578. import "babylonjs/Engines/Extensions/engine.rawTexture";
  67579. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  67580. /**
  67581. * This represents a texture coming from an HDR input.
  67582. *
  67583. * The only supported format is currently panorama picture stored in RGBE format.
  67584. * Example of such files can be found on HDRLib: http://hdrlib.com/
  67585. */
  67586. export class HDRCubeTexture extends BaseTexture {
  67587. private static _facesMapping;
  67588. private _generateHarmonics;
  67589. private _noMipmap;
  67590. private _prefilterOnLoad;
  67591. private _textureMatrix;
  67592. private _size;
  67593. private _onLoad;
  67594. private _onError;
  67595. /**
  67596. * The texture URL.
  67597. */
  67598. url: string;
  67599. protected _isBlocking: boolean;
  67600. /**
  67601. * Sets wether or not the texture is blocking during loading.
  67602. */
  67603. set isBlocking(value: boolean);
  67604. /**
  67605. * Gets wether or not the texture is blocking during loading.
  67606. */
  67607. get isBlocking(): boolean;
  67608. protected _rotationY: number;
  67609. /**
  67610. * Sets texture matrix rotation angle around Y axis in radians.
  67611. */
  67612. set rotationY(value: number);
  67613. /**
  67614. * Gets texture matrix rotation angle around Y axis radians.
  67615. */
  67616. get rotationY(): number;
  67617. /**
  67618. * Gets or sets the center of the bounding box associated with the cube texture
  67619. * It must define where the camera used to render the texture was set
  67620. */
  67621. boundingBoxPosition: Vector3;
  67622. private _boundingBoxSize;
  67623. /**
  67624. * Gets or sets the size of the bounding box associated with the cube texture
  67625. * When defined, the cubemap will switch to local mode
  67626. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  67627. * @example https://www.babylonjs-playground.com/#RNASML
  67628. */
  67629. set boundingBoxSize(value: Vector3);
  67630. get boundingBoxSize(): Vector3;
  67631. /**
  67632. * Instantiates an HDRTexture from the following parameters.
  67633. *
  67634. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  67635. * @param sceneOrEngine The scene or engine the texture will be used in
  67636. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  67637. * @param noMipmap Forces to not generate the mipmap if true
  67638. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  67639. * @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)
  67640. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  67641. */
  67642. 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>);
  67643. /**
  67644. * Get the current class name of the texture useful for serialization or dynamic coding.
  67645. * @returns "HDRCubeTexture"
  67646. */
  67647. getClassName(): string;
  67648. /**
  67649. * Occurs when the file is raw .hdr file.
  67650. */
  67651. private loadTexture;
  67652. clone(): HDRCubeTexture;
  67653. delayLoad(): void;
  67654. /**
  67655. * Get the texture reflection matrix used to rotate/transform the reflection.
  67656. * @returns the reflection matrix
  67657. */
  67658. getReflectionTextureMatrix(): Matrix;
  67659. /**
  67660. * Set the texture reflection matrix used to rotate/transform the reflection.
  67661. * @param value Define the reflection matrix to set
  67662. */
  67663. setReflectionTextureMatrix(value: Matrix): void;
  67664. /**
  67665. * Parses a JSON representation of an HDR Texture in order to create the texture
  67666. * @param parsedTexture Define the JSON representation
  67667. * @param scene Define the scene the texture should be created in
  67668. * @param rootUrl Define the root url in case we need to load relative dependencies
  67669. * @returns the newly created texture after parsing
  67670. */
  67671. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  67672. serialize(): any;
  67673. }
  67674. }
  67675. declare module "babylonjs/Physics/physicsEngine" {
  67676. import { Nullable } from "babylonjs/types";
  67677. import { Vector3 } from "babylonjs/Maths/math.vector";
  67678. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  67679. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  67680. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  67681. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  67682. /**
  67683. * Class used to control physics engine
  67684. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  67685. */
  67686. export class PhysicsEngine implements IPhysicsEngine {
  67687. private _physicsPlugin;
  67688. /**
  67689. * Global value used to control the smallest number supported by the simulation
  67690. */
  67691. static Epsilon: number;
  67692. private _impostors;
  67693. private _joints;
  67694. private _subTimeStep;
  67695. /**
  67696. * Gets the gravity vector used by the simulation
  67697. */
  67698. gravity: Vector3;
  67699. /**
  67700. * Factory used to create the default physics plugin.
  67701. * @returns The default physics plugin
  67702. */
  67703. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  67704. /**
  67705. * Creates a new Physics Engine
  67706. * @param gravity defines the gravity vector used by the simulation
  67707. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  67708. */
  67709. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  67710. /**
  67711. * Sets the gravity vector used by the simulation
  67712. * @param gravity defines the gravity vector to use
  67713. */
  67714. setGravity(gravity: Vector3): void;
  67715. /**
  67716. * Set the time step of the physics engine.
  67717. * Default is 1/60.
  67718. * To slow it down, enter 1/600 for example.
  67719. * To speed it up, 1/30
  67720. * @param newTimeStep defines the new timestep to apply to this world.
  67721. */
  67722. setTimeStep(newTimeStep?: number): void;
  67723. /**
  67724. * Get the time step of the physics engine.
  67725. * @returns the current time step
  67726. */
  67727. getTimeStep(): number;
  67728. /**
  67729. * Set the sub time step of the physics engine.
  67730. * Default is 0 meaning there is no sub steps
  67731. * To increase physics resolution precision, set a small value (like 1 ms)
  67732. * @param subTimeStep defines the new sub timestep used for physics resolution.
  67733. */
  67734. setSubTimeStep(subTimeStep?: number): void;
  67735. /**
  67736. * Get the sub time step of the physics engine.
  67737. * @returns the current sub time step
  67738. */
  67739. getSubTimeStep(): number;
  67740. /**
  67741. * Release all resources
  67742. */
  67743. dispose(): void;
  67744. /**
  67745. * Gets the name of the current physics plugin
  67746. * @returns the name of the plugin
  67747. */
  67748. getPhysicsPluginName(): string;
  67749. /**
  67750. * Adding a new impostor for the impostor tracking.
  67751. * This will be done by the impostor itself.
  67752. * @param impostor the impostor to add
  67753. */
  67754. addImpostor(impostor: PhysicsImpostor): void;
  67755. /**
  67756. * Remove an impostor from the engine.
  67757. * This impostor and its mesh will not longer be updated by the physics engine.
  67758. * @param impostor the impostor to remove
  67759. */
  67760. removeImpostor(impostor: PhysicsImpostor): void;
  67761. /**
  67762. * Add a joint to the physics engine
  67763. * @param mainImpostor defines the main impostor to which the joint is added.
  67764. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  67765. * @param joint defines the joint that will connect both impostors.
  67766. */
  67767. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  67768. /**
  67769. * Removes a joint from the simulation
  67770. * @param mainImpostor defines the impostor used with the joint
  67771. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  67772. * @param joint defines the joint to remove
  67773. */
  67774. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  67775. /**
  67776. * Called by the scene. No need to call it.
  67777. * @param delta defines the timespam between frames
  67778. */
  67779. _step(delta: number): void;
  67780. /**
  67781. * Gets the current plugin used to run the simulation
  67782. * @returns current plugin
  67783. */
  67784. getPhysicsPlugin(): IPhysicsEnginePlugin;
  67785. /**
  67786. * Gets the list of physic impostors
  67787. * @returns an array of PhysicsImpostor
  67788. */
  67789. getImpostors(): Array<PhysicsImpostor>;
  67790. /**
  67791. * Gets the impostor for a physics enabled object
  67792. * @param object defines the object impersonated by the impostor
  67793. * @returns the PhysicsImpostor or null if not found
  67794. */
  67795. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  67796. /**
  67797. * Gets the impostor for a physics body object
  67798. * @param body defines physics body used by the impostor
  67799. * @returns the PhysicsImpostor or null if not found
  67800. */
  67801. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  67802. /**
  67803. * Does a raycast in the physics world
  67804. * @param from when should the ray start?
  67805. * @param to when should the ray end?
  67806. * @returns PhysicsRaycastResult
  67807. */
  67808. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  67809. }
  67810. }
  67811. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  67812. import { Nullable } from "babylonjs/types";
  67813. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  67814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67815. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  67816. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  67817. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  67818. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  67819. /** @hidden */
  67820. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  67821. private _useDeltaForWorldStep;
  67822. world: any;
  67823. name: string;
  67824. private _physicsMaterials;
  67825. private _fixedTimeStep;
  67826. private _cannonRaycastResult;
  67827. private _raycastResult;
  67828. private _physicsBodysToRemoveAfterStep;
  67829. private _firstFrame;
  67830. BJSCANNON: any;
  67831. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  67832. setGravity(gravity: Vector3): void;
  67833. setTimeStep(timeStep: number): void;
  67834. getTimeStep(): number;
  67835. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  67836. private _removeMarkedPhysicsBodiesFromWorld;
  67837. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  67838. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  67839. generatePhysicsBody(impostor: PhysicsImpostor): void;
  67840. private _processChildMeshes;
  67841. removePhysicsBody(impostor: PhysicsImpostor): void;
  67842. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  67843. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  67844. private _addMaterial;
  67845. private _checkWithEpsilon;
  67846. private _createShape;
  67847. private _createHeightmap;
  67848. private _minus90X;
  67849. private _plus90X;
  67850. private _tmpPosition;
  67851. private _tmpDeltaPosition;
  67852. private _tmpUnityRotation;
  67853. private _updatePhysicsBodyTransformation;
  67854. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  67855. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  67856. isSupported(): boolean;
  67857. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  67858. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  67859. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  67860. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  67861. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  67862. getBodyMass(impostor: PhysicsImpostor): number;
  67863. getBodyFriction(impostor: PhysicsImpostor): number;
  67864. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  67865. getBodyRestitution(impostor: PhysicsImpostor): number;
  67866. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  67867. sleepBody(impostor: PhysicsImpostor): void;
  67868. wakeUpBody(impostor: PhysicsImpostor): void;
  67869. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  67870. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  67871. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  67872. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  67873. getRadius(impostor: PhysicsImpostor): number;
  67874. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  67875. dispose(): void;
  67876. private _extendNamespace;
  67877. /**
  67878. * Does a raycast in the physics world
  67879. * @param from when should the ray start?
  67880. * @param to when should the ray end?
  67881. * @returns PhysicsRaycastResult
  67882. */
  67883. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  67884. }
  67885. }
  67886. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  67887. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  67888. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  67889. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  67890. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67891. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  67892. import { Nullable } from "babylonjs/types";
  67893. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  67894. /** @hidden */
  67895. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  67896. private _useDeltaForWorldStep;
  67897. world: any;
  67898. name: string;
  67899. BJSOIMO: any;
  67900. private _raycastResult;
  67901. private _fixedTimeStep;
  67902. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  67903. setGravity(gravity: Vector3): void;
  67904. setTimeStep(timeStep: number): void;
  67905. getTimeStep(): number;
  67906. private _tmpImpostorsArray;
  67907. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  67908. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  67909. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  67910. generatePhysicsBody(impostor: PhysicsImpostor): void;
  67911. private _tmpPositionVector;
  67912. removePhysicsBody(impostor: PhysicsImpostor): void;
  67913. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  67914. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  67915. isSupported(): boolean;
  67916. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  67917. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  67918. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  67919. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  67920. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  67921. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  67922. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  67923. getBodyMass(impostor: PhysicsImpostor): number;
  67924. getBodyFriction(impostor: PhysicsImpostor): number;
  67925. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  67926. getBodyRestitution(impostor: PhysicsImpostor): number;
  67927. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  67928. sleepBody(impostor: PhysicsImpostor): void;
  67929. wakeUpBody(impostor: PhysicsImpostor): void;
  67930. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  67931. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  67932. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  67933. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  67934. getRadius(impostor: PhysicsImpostor): number;
  67935. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  67936. dispose(): void;
  67937. /**
  67938. * Does a raycast in the physics world
  67939. * @param from when should the ray start?
  67940. * @param to when should the ray end?
  67941. * @returns PhysicsRaycastResult
  67942. */
  67943. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  67944. }
  67945. }
  67946. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  67947. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  67948. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  67949. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  67950. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  67951. import { Nullable } from "babylonjs/types";
  67952. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67953. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  67954. /**
  67955. * AmmoJS Physics plugin
  67956. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  67957. * @see https://github.com/kripken/ammo.js/
  67958. */
  67959. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  67960. private _useDeltaForWorldStep;
  67961. /**
  67962. * Reference to the Ammo library
  67963. */
  67964. bjsAMMO: any;
  67965. /**
  67966. * Created ammoJS world which physics bodies are added to
  67967. */
  67968. world: any;
  67969. /**
  67970. * Name of the plugin
  67971. */
  67972. name: string;
  67973. private _timeStep;
  67974. private _fixedTimeStep;
  67975. private _maxSteps;
  67976. private _tmpQuaternion;
  67977. private _tmpAmmoTransform;
  67978. private _tmpAmmoQuaternion;
  67979. private _tmpAmmoConcreteContactResultCallback;
  67980. private _collisionConfiguration;
  67981. private _dispatcher;
  67982. private _overlappingPairCache;
  67983. private _solver;
  67984. private _softBodySolver;
  67985. private _tmpAmmoVectorA;
  67986. private _tmpAmmoVectorB;
  67987. private _tmpAmmoVectorC;
  67988. private _tmpAmmoVectorD;
  67989. private _tmpContactCallbackResult;
  67990. private _tmpAmmoVectorRCA;
  67991. private _tmpAmmoVectorRCB;
  67992. private _raycastResult;
  67993. private _tmpContactPoint;
  67994. private static readonly DISABLE_COLLISION_FLAG;
  67995. private static readonly KINEMATIC_FLAG;
  67996. private static readonly DISABLE_DEACTIVATION_FLAG;
  67997. /**
  67998. * Initializes the ammoJS plugin
  67999. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  68000. * @param ammoInjection can be used to inject your own ammo reference
  68001. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  68002. */
  68003. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  68004. /**
  68005. * Sets the gravity of the physics world (m/(s^2))
  68006. * @param gravity Gravity to set
  68007. */
  68008. setGravity(gravity: Vector3): void;
  68009. /**
  68010. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  68011. * @param timeStep timestep to use in seconds
  68012. */
  68013. setTimeStep(timeStep: number): void;
  68014. /**
  68015. * 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)
  68016. * @param fixedTimeStep fixedTimeStep to use in seconds
  68017. */
  68018. setFixedTimeStep(fixedTimeStep: number): void;
  68019. /**
  68020. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  68021. * @param maxSteps the maximum number of steps by the physics engine per frame
  68022. */
  68023. setMaxSteps(maxSteps: number): void;
  68024. /**
  68025. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  68026. * @returns the current timestep in seconds
  68027. */
  68028. getTimeStep(): number;
  68029. /**
  68030. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  68031. */
  68032. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  68033. private _isImpostorInContact;
  68034. private _isImpostorPairInContact;
  68035. private _stepSimulation;
  68036. /**
  68037. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  68038. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  68039. * After the step the babylon meshes are set to the position of the physics imposters
  68040. * @param delta amount of time to step forward
  68041. * @param impostors array of imposters to update before/after the step
  68042. */
  68043. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  68044. /**
  68045. * Update babylon mesh to match physics world object
  68046. * @param impostor imposter to match
  68047. */
  68048. private _afterSoftStep;
  68049. /**
  68050. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  68051. * @param impostor imposter to match
  68052. */
  68053. private _ropeStep;
  68054. /**
  68055. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  68056. * @param impostor imposter to match
  68057. */
  68058. private _softbodyOrClothStep;
  68059. private _tmpMatrix;
  68060. /**
  68061. * Applies an impulse on the imposter
  68062. * @param impostor imposter to apply impulse to
  68063. * @param force amount of force to be applied to the imposter
  68064. * @param contactPoint the location to apply the impulse on the imposter
  68065. */
  68066. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  68067. /**
  68068. * Applies a force on the imposter
  68069. * @param impostor imposter to apply force
  68070. * @param force amount of force to be applied to the imposter
  68071. * @param contactPoint the location to apply the force on the imposter
  68072. */
  68073. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  68074. /**
  68075. * Creates a physics body using the plugin
  68076. * @param impostor the imposter to create the physics body on
  68077. */
  68078. generatePhysicsBody(impostor: PhysicsImpostor): void;
  68079. /**
  68080. * Removes the physics body from the imposter and disposes of the body's memory
  68081. * @param impostor imposter to remove the physics body from
  68082. */
  68083. removePhysicsBody(impostor: PhysicsImpostor): void;
  68084. /**
  68085. * Generates a joint
  68086. * @param impostorJoint the imposter joint to create the joint with
  68087. */
  68088. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  68089. /**
  68090. * Removes a joint
  68091. * @param impostorJoint the imposter joint to remove the joint from
  68092. */
  68093. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  68094. private _addMeshVerts;
  68095. /**
  68096. * Initialise the soft body vertices to match its object's (mesh) vertices
  68097. * Softbody vertices (nodes) are in world space and to match this
  68098. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  68099. * @param impostor to create the softbody for
  68100. */
  68101. private _softVertexData;
  68102. /**
  68103. * Create an impostor's soft body
  68104. * @param impostor to create the softbody for
  68105. */
  68106. private _createSoftbody;
  68107. /**
  68108. * Create cloth for an impostor
  68109. * @param impostor to create the softbody for
  68110. */
  68111. private _createCloth;
  68112. /**
  68113. * Create rope for an impostor
  68114. * @param impostor to create the softbody for
  68115. */
  68116. private _createRope;
  68117. /**
  68118. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  68119. * @param impostor to create the custom physics shape for
  68120. */
  68121. private _createCustom;
  68122. private _addHullVerts;
  68123. private _createShape;
  68124. /**
  68125. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  68126. * @param impostor imposter containing the physics body and babylon object
  68127. */
  68128. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  68129. /**
  68130. * Sets the babylon object's position/rotation from the physics body's position/rotation
  68131. * @param impostor imposter containing the physics body and babylon object
  68132. * @param newPosition new position
  68133. * @param newRotation new rotation
  68134. */
  68135. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  68136. /**
  68137. * If this plugin is supported
  68138. * @returns true if its supported
  68139. */
  68140. isSupported(): boolean;
  68141. /**
  68142. * Sets the linear velocity of the physics body
  68143. * @param impostor imposter to set the velocity on
  68144. * @param velocity velocity to set
  68145. */
  68146. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  68147. /**
  68148. * Sets the angular velocity of the physics body
  68149. * @param impostor imposter to set the velocity on
  68150. * @param velocity velocity to set
  68151. */
  68152. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  68153. /**
  68154. * gets the linear velocity
  68155. * @param impostor imposter to get linear velocity from
  68156. * @returns linear velocity
  68157. */
  68158. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  68159. /**
  68160. * gets the angular velocity
  68161. * @param impostor imposter to get angular velocity from
  68162. * @returns angular velocity
  68163. */
  68164. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  68165. /**
  68166. * Sets the mass of physics body
  68167. * @param impostor imposter to set the mass on
  68168. * @param mass mass to set
  68169. */
  68170. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  68171. /**
  68172. * Gets the mass of the physics body
  68173. * @param impostor imposter to get the mass from
  68174. * @returns mass
  68175. */
  68176. getBodyMass(impostor: PhysicsImpostor): number;
  68177. /**
  68178. * Gets friction of the impostor
  68179. * @param impostor impostor to get friction from
  68180. * @returns friction value
  68181. */
  68182. getBodyFriction(impostor: PhysicsImpostor): number;
  68183. /**
  68184. * Sets friction of the impostor
  68185. * @param impostor impostor to set friction on
  68186. * @param friction friction value
  68187. */
  68188. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  68189. /**
  68190. * Gets restitution of the impostor
  68191. * @param impostor impostor to get restitution from
  68192. * @returns restitution value
  68193. */
  68194. getBodyRestitution(impostor: PhysicsImpostor): number;
  68195. /**
  68196. * Sets resitution of the impostor
  68197. * @param impostor impostor to set resitution on
  68198. * @param restitution resitution value
  68199. */
  68200. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  68201. /**
  68202. * Gets pressure inside the impostor
  68203. * @param impostor impostor to get pressure from
  68204. * @returns pressure value
  68205. */
  68206. getBodyPressure(impostor: PhysicsImpostor): number;
  68207. /**
  68208. * Sets pressure inside a soft body impostor
  68209. * Cloth and rope must remain 0 pressure
  68210. * @param impostor impostor to set pressure on
  68211. * @param pressure pressure value
  68212. */
  68213. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  68214. /**
  68215. * Gets stiffness of the impostor
  68216. * @param impostor impostor to get stiffness from
  68217. * @returns pressure value
  68218. */
  68219. getBodyStiffness(impostor: PhysicsImpostor): number;
  68220. /**
  68221. * Sets stiffness of the impostor
  68222. * @param impostor impostor to set stiffness on
  68223. * @param stiffness stiffness value from 0 to 1
  68224. */
  68225. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  68226. /**
  68227. * Gets velocityIterations of the impostor
  68228. * @param impostor impostor to get velocity iterations from
  68229. * @returns velocityIterations value
  68230. */
  68231. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  68232. /**
  68233. * Sets velocityIterations of the impostor
  68234. * @param impostor impostor to set velocity iterations on
  68235. * @param velocityIterations velocityIterations value
  68236. */
  68237. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  68238. /**
  68239. * Gets positionIterations of the impostor
  68240. * @param impostor impostor to get position iterations from
  68241. * @returns positionIterations value
  68242. */
  68243. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  68244. /**
  68245. * Sets positionIterations of the impostor
  68246. * @param impostor impostor to set position on
  68247. * @param positionIterations positionIterations value
  68248. */
  68249. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  68250. /**
  68251. * Append an anchor to a cloth object
  68252. * @param impostor is the cloth impostor to add anchor to
  68253. * @param otherImpostor is the rigid impostor to anchor to
  68254. * @param width ratio across width from 0 to 1
  68255. * @param height ratio up height from 0 to 1
  68256. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  68257. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  68258. */
  68259. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  68260. /**
  68261. * Append an hook to a rope object
  68262. * @param impostor is the rope impostor to add hook to
  68263. * @param otherImpostor is the rigid impostor to hook to
  68264. * @param length ratio along the rope from 0 to 1
  68265. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  68266. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  68267. */
  68268. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  68269. /**
  68270. * Sleeps the physics body and stops it from being active
  68271. * @param impostor impostor to sleep
  68272. */
  68273. sleepBody(impostor: PhysicsImpostor): void;
  68274. /**
  68275. * Activates the physics body
  68276. * @param impostor impostor to activate
  68277. */
  68278. wakeUpBody(impostor: PhysicsImpostor): void;
  68279. /**
  68280. * Updates the distance parameters of the joint
  68281. * @param joint joint to update
  68282. * @param maxDistance maximum distance of the joint
  68283. * @param minDistance minimum distance of the joint
  68284. */
  68285. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  68286. /**
  68287. * Sets a motor on the joint
  68288. * @param joint joint to set motor on
  68289. * @param speed speed of the motor
  68290. * @param maxForce maximum force of the motor
  68291. * @param motorIndex index of the motor
  68292. */
  68293. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  68294. /**
  68295. * Sets the motors limit
  68296. * @param joint joint to set limit on
  68297. * @param upperLimit upper limit
  68298. * @param lowerLimit lower limit
  68299. */
  68300. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  68301. /**
  68302. * Syncs the position and rotation of a mesh with the impostor
  68303. * @param mesh mesh to sync
  68304. * @param impostor impostor to update the mesh with
  68305. */
  68306. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  68307. /**
  68308. * Gets the radius of the impostor
  68309. * @param impostor impostor to get radius from
  68310. * @returns the radius
  68311. */
  68312. getRadius(impostor: PhysicsImpostor): number;
  68313. /**
  68314. * Gets the box size of the impostor
  68315. * @param impostor impostor to get box size from
  68316. * @param result the resulting box size
  68317. */
  68318. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  68319. /**
  68320. * Disposes of the impostor
  68321. */
  68322. dispose(): void;
  68323. /**
  68324. * Does a raycast in the physics world
  68325. * @param from when should the ray start?
  68326. * @param to when should the ray end?
  68327. * @returns PhysicsRaycastResult
  68328. */
  68329. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  68330. }
  68331. }
  68332. declare module "babylonjs/Probes/reflectionProbe" {
  68333. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  68334. import { Vector3 } from "babylonjs/Maths/math.vector";
  68335. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68336. import { Nullable } from "babylonjs/types";
  68337. import { Scene } from "babylonjs/scene";
  68338. module "babylonjs/abstractScene" {
  68339. interface AbstractScene {
  68340. /**
  68341. * The list of reflection probes added to the scene
  68342. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  68343. */
  68344. reflectionProbes: Array<ReflectionProbe>;
  68345. /**
  68346. * Removes the given reflection probe from this scene.
  68347. * @param toRemove The reflection probe to remove
  68348. * @returns The index of the removed reflection probe
  68349. */
  68350. removeReflectionProbe(toRemove: ReflectionProbe): number;
  68351. /**
  68352. * Adds the given reflection probe to this scene.
  68353. * @param newReflectionProbe The reflection probe to add
  68354. */
  68355. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  68356. }
  68357. }
  68358. /**
  68359. * Class used to generate realtime reflection / refraction cube textures
  68360. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  68361. */
  68362. export class ReflectionProbe {
  68363. /** defines the name of the probe */
  68364. name: string;
  68365. private _scene;
  68366. private _renderTargetTexture;
  68367. private _projectionMatrix;
  68368. private _viewMatrix;
  68369. private _target;
  68370. private _add;
  68371. private _attachedMesh;
  68372. private _invertYAxis;
  68373. /** Gets or sets probe position (center of the cube map) */
  68374. position: Vector3;
  68375. /**
  68376. * Creates a new reflection probe
  68377. * @param name defines the name of the probe
  68378. * @param size defines the texture resolution (for each face)
  68379. * @param scene defines the hosting scene
  68380. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  68381. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  68382. */
  68383. constructor(
  68384. /** defines the name of the probe */
  68385. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  68386. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  68387. get samples(): number;
  68388. set samples(value: number);
  68389. /** Gets or sets the refresh rate to use (on every frame by default) */
  68390. get refreshRate(): number;
  68391. set refreshRate(value: number);
  68392. /**
  68393. * Gets the hosting scene
  68394. * @returns a Scene
  68395. */
  68396. getScene(): Scene;
  68397. /** Gets the internal CubeTexture used to render to */
  68398. get cubeTexture(): RenderTargetTexture;
  68399. /** Gets the list of meshes to render */
  68400. get renderList(): Nullable<AbstractMesh[]>;
  68401. /**
  68402. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  68403. * @param mesh defines the mesh to attach to
  68404. */
  68405. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  68406. /**
  68407. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  68408. * @param renderingGroupId The rendering group id corresponding to its index
  68409. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  68410. */
  68411. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  68412. /**
  68413. * Clean all associated resources
  68414. */
  68415. dispose(): void;
  68416. /**
  68417. * Converts the reflection probe information to a readable string for debug purpose.
  68418. * @param fullDetails Supports for multiple levels of logging within scene loading
  68419. * @returns the human readable reflection probe info
  68420. */
  68421. toString(fullDetails?: boolean): string;
  68422. /**
  68423. * Get the class name of the relfection probe.
  68424. * @returns "ReflectionProbe"
  68425. */
  68426. getClassName(): string;
  68427. /**
  68428. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  68429. * @returns The JSON representation of the texture
  68430. */
  68431. serialize(): any;
  68432. /**
  68433. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  68434. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  68435. * @param scene Define the scene the parsed reflection probe should be instantiated in
  68436. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  68437. * @returns The parsed reflection probe if successful
  68438. */
  68439. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  68440. }
  68441. }
  68442. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  68443. /** @hidden */
  68444. export var _BabylonLoaderRegistered: boolean;
  68445. /**
  68446. * Helps setting up some configuration for the babylon file loader.
  68447. */
  68448. export class BabylonFileLoaderConfiguration {
  68449. /**
  68450. * The loader does not allow injecting custom physix engine into the plugins.
  68451. * Unfortunately in ES6, we need to manually inject them into the plugin.
  68452. * So you could set this variable to your engine import to make it work.
  68453. */
  68454. static LoaderInjectedPhysicsEngine: any;
  68455. }
  68456. }
  68457. declare module "babylonjs/Loading/Plugins/index" {
  68458. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  68459. }
  68460. declare module "babylonjs/Loading/index" {
  68461. export * from "babylonjs/Loading/loadingScreen";
  68462. export * from "babylonjs/Loading/Plugins/index";
  68463. export * from "babylonjs/Loading/sceneLoader";
  68464. export * from "babylonjs/Loading/sceneLoaderFlags";
  68465. }
  68466. declare module "babylonjs/Materials/Background/index" {
  68467. export * from "babylonjs/Materials/Background/backgroundMaterial";
  68468. }
  68469. declare module "babylonjs/Materials/Occlusion/occlusionMaterial" {
  68470. import { Scene } from "babylonjs/scene";
  68471. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  68472. import "babylonjs/Shaders/color.fragment";
  68473. import "babylonjs/Shaders/color.vertex";
  68474. /**
  68475. * A material to use for fast depth-only rendering.
  68476. */
  68477. export class OcclusionMaterial extends ShaderMaterial {
  68478. constructor(name: string, scene: Scene);
  68479. }
  68480. }
  68481. declare module "babylonjs/Materials/Occlusion/index" {
  68482. export * from "babylonjs/Materials/Occlusion/occlusionMaterial";
  68483. }
  68484. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  68485. import { Scene } from "babylonjs/scene";
  68486. import { Color3 } from "babylonjs/Maths/math.color";
  68487. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  68488. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68489. /**
  68490. * The Physically based simple base material of BJS.
  68491. *
  68492. * This enables better naming and convention enforcements on top of the pbrMaterial.
  68493. * It is used as the base class for both the specGloss and metalRough conventions.
  68494. */
  68495. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  68496. /**
  68497. * Number of Simultaneous lights allowed on the material.
  68498. */
  68499. maxSimultaneousLights: number;
  68500. /**
  68501. * If sets to true, disables all the lights affecting the material.
  68502. */
  68503. disableLighting: boolean;
  68504. /**
  68505. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  68506. */
  68507. environmentTexture: BaseTexture;
  68508. /**
  68509. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  68510. */
  68511. invertNormalMapX: boolean;
  68512. /**
  68513. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  68514. */
  68515. invertNormalMapY: boolean;
  68516. /**
  68517. * Normal map used in the model.
  68518. */
  68519. normalTexture: BaseTexture;
  68520. /**
  68521. * Emissivie color used to self-illuminate the model.
  68522. */
  68523. emissiveColor: Color3;
  68524. /**
  68525. * Emissivie texture used to self-illuminate the model.
  68526. */
  68527. emissiveTexture: BaseTexture;
  68528. /**
  68529. * Occlusion Channel Strenght.
  68530. */
  68531. occlusionStrength: number;
  68532. /**
  68533. * Occlusion Texture of the material (adding extra occlusion effects).
  68534. */
  68535. occlusionTexture: BaseTexture;
  68536. /**
  68537. * Defines the alpha limits in alpha test mode.
  68538. */
  68539. alphaCutOff: number;
  68540. /**
  68541. * Gets the current double sided mode.
  68542. */
  68543. get doubleSided(): boolean;
  68544. /**
  68545. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  68546. */
  68547. set doubleSided(value: boolean);
  68548. /**
  68549. * Stores the pre-calculated light information of a mesh in a texture.
  68550. */
  68551. lightmapTexture: BaseTexture;
  68552. /**
  68553. * If true, the light map contains occlusion information instead of lighting info.
  68554. */
  68555. useLightmapAsShadowmap: boolean;
  68556. /**
  68557. * Instantiates a new PBRMaterial instance.
  68558. *
  68559. * @param name The material name
  68560. * @param scene The scene the material will be use in.
  68561. */
  68562. constructor(name: string, scene: Scene);
  68563. getClassName(): string;
  68564. }
  68565. }
  68566. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  68567. import { Scene } from "babylonjs/scene";
  68568. import { Color3 } from "babylonjs/Maths/math.color";
  68569. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68570. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  68571. /**
  68572. * The PBR material of BJS following the metal roughness convention.
  68573. *
  68574. * This fits to the PBR convention in the GLTF definition:
  68575. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  68576. */
  68577. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  68578. /**
  68579. * The base color has two different interpretations depending on the value of metalness.
  68580. * When the material is a metal, the base color is the specific measured reflectance value
  68581. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  68582. * of the material.
  68583. */
  68584. baseColor: Color3;
  68585. /**
  68586. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  68587. * well as opacity information in the alpha channel.
  68588. */
  68589. baseTexture: BaseTexture;
  68590. /**
  68591. * Specifies the metallic scalar value of the material.
  68592. * Can also be used to scale the metalness values of the metallic texture.
  68593. */
  68594. metallic: number;
  68595. /**
  68596. * Specifies the roughness scalar value of the material.
  68597. * Can also be used to scale the roughness values of the metallic texture.
  68598. */
  68599. roughness: number;
  68600. /**
  68601. * Texture containing both the metallic value in the B channel and the
  68602. * roughness value in the G channel to keep better precision.
  68603. */
  68604. metallicRoughnessTexture: BaseTexture;
  68605. /**
  68606. * Instantiates a new PBRMetalRoughnessMaterial instance.
  68607. *
  68608. * @param name The material name
  68609. * @param scene The scene the material will be use in.
  68610. */
  68611. constructor(name: string, scene: Scene);
  68612. /**
  68613. * Return the currrent class name of the material.
  68614. */
  68615. getClassName(): string;
  68616. /**
  68617. * Makes a duplicate of the current material.
  68618. * @param name - name to use for the new material.
  68619. */
  68620. clone(name: string): PBRMetallicRoughnessMaterial;
  68621. /**
  68622. * Serialize the material to a parsable JSON object.
  68623. */
  68624. serialize(): any;
  68625. /**
  68626. * Parses a JSON object correponding to the serialize function.
  68627. */
  68628. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  68629. }
  68630. }
  68631. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  68632. import { Scene } from "babylonjs/scene";
  68633. import { Color3 } from "babylonjs/Maths/math.color";
  68634. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68635. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  68636. /**
  68637. * The PBR material of BJS following the specular glossiness convention.
  68638. *
  68639. * This fits to the PBR convention in the GLTF definition:
  68640. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  68641. */
  68642. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  68643. /**
  68644. * Specifies the diffuse color of the material.
  68645. */
  68646. diffuseColor: Color3;
  68647. /**
  68648. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  68649. * channel.
  68650. */
  68651. diffuseTexture: BaseTexture;
  68652. /**
  68653. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  68654. */
  68655. specularColor: Color3;
  68656. /**
  68657. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  68658. */
  68659. glossiness: number;
  68660. /**
  68661. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  68662. */
  68663. specularGlossinessTexture: BaseTexture;
  68664. /**
  68665. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  68666. */
  68667. get useMicroSurfaceFromReflectivityMapAlpha(): boolean;
  68668. /**
  68669. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  68670. *
  68671. * @param name The material name
  68672. * @param scene The scene the material will be use in.
  68673. */
  68674. constructor(name: string, scene: Scene);
  68675. /**
  68676. * Return the currrent class name of the material.
  68677. */
  68678. getClassName(): string;
  68679. /**
  68680. * Makes a duplicate of the current material.
  68681. * @param name - name to use for the new material.
  68682. */
  68683. clone(name: string): PBRSpecularGlossinessMaterial;
  68684. /**
  68685. * Serialize the material to a parsable JSON object.
  68686. */
  68687. serialize(): any;
  68688. /**
  68689. * Parses a JSON object correponding to the serialize function.
  68690. */
  68691. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  68692. }
  68693. }
  68694. declare module "babylonjs/Materials/PBR/index" {
  68695. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  68696. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  68697. export * from "babylonjs/Materials/PBR/pbrMaterial";
  68698. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  68699. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  68700. }
  68701. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  68702. import { Nullable } from "babylonjs/types";
  68703. import { Scene } from "babylonjs/scene";
  68704. import { Matrix } from "babylonjs/Maths/math.vector";
  68705. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68706. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  68707. import "babylonjs/Engines/Extensions/engine.rawTexture";
  68708. /**
  68709. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  68710. * It can help converting any input color in a desired output one. This can then be used to create effects
  68711. * from sepia, black and white to sixties or futuristic rendering...
  68712. *
  68713. * The only supported format is currently 3dl.
  68714. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  68715. */
  68716. export class ColorGradingTexture extends BaseTexture {
  68717. /**
  68718. * The texture URL.
  68719. */
  68720. url: string;
  68721. /**
  68722. * Empty line regex stored for GC.
  68723. */
  68724. private static _noneEmptyLineRegex;
  68725. private _textureMatrix;
  68726. private _onLoad;
  68727. /**
  68728. * Instantiates a ColorGradingTexture from the following parameters.
  68729. *
  68730. * @param url The location of the color gradind data (currently only supporting 3dl)
  68731. * @param sceneOrEngine The scene or engine the texture will be used in
  68732. * @param onLoad defines a callback triggered when the texture has been loaded
  68733. */
  68734. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  68735. /**
  68736. * Fires the onload event from the constructor if requested.
  68737. */
  68738. private _triggerOnLoad;
  68739. /**
  68740. * Returns the texture matrix used in most of the material.
  68741. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  68742. */
  68743. getTextureMatrix(): Matrix;
  68744. /**
  68745. * Occurs when the file being loaded is a .3dl LUT file.
  68746. */
  68747. private load3dlTexture;
  68748. /**
  68749. * Starts the loading process of the texture.
  68750. */
  68751. private loadTexture;
  68752. /**
  68753. * Clones the color gradind texture.
  68754. */
  68755. clone(): ColorGradingTexture;
  68756. /**
  68757. * Called during delayed load for textures.
  68758. */
  68759. delayLoad(): void;
  68760. /**
  68761. * Parses a color grading texture serialized by Babylon.
  68762. * @param parsedTexture The texture information being parsedTexture
  68763. * @param scene The scene to load the texture in
  68764. * @param rootUrl The root url of the data assets to load
  68765. * @return A color gradind texture
  68766. */
  68767. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  68768. /**
  68769. * Serializes the LUT texture to json format.
  68770. */
  68771. serialize(): any;
  68772. }
  68773. }
  68774. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  68775. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68776. import { Scene } from "babylonjs/scene";
  68777. import { Nullable } from "babylonjs/types";
  68778. import "babylonjs/Engines/Extensions/engine.rawTexture";
  68779. /**
  68780. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  68781. */
  68782. export class EquiRectangularCubeTexture extends BaseTexture {
  68783. /** The six faces of the cube. */
  68784. private static _FacesMapping;
  68785. private _noMipmap;
  68786. private _onLoad;
  68787. private _onError;
  68788. /** The size of the cubemap. */
  68789. private _size;
  68790. /** The buffer of the image. */
  68791. private _buffer;
  68792. /** The width of the input image. */
  68793. private _width;
  68794. /** The height of the input image. */
  68795. private _height;
  68796. /** The URL to the image. */
  68797. url: string;
  68798. /**
  68799. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  68800. * @param url The location of the image
  68801. * @param scene The scene the texture will be used in
  68802. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  68803. * @param noMipmap Forces to not generate the mipmap if true
  68804. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  68805. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  68806. * @param onLoad — defines a callback called when texture is loaded
  68807. * @param onError — defines a callback called if there is an error
  68808. */
  68809. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  68810. /**
  68811. * Load the image data, by putting the image on a canvas and extracting its buffer.
  68812. */
  68813. private loadImage;
  68814. /**
  68815. * Convert the image buffer into a cubemap and create a CubeTexture.
  68816. */
  68817. private loadTexture;
  68818. /**
  68819. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  68820. * @param buffer The ArrayBuffer that should be converted.
  68821. * @returns The buffer as Float32Array.
  68822. */
  68823. private getFloat32ArrayFromArrayBuffer;
  68824. /**
  68825. * Get the current class name of the texture useful for serialization or dynamic coding.
  68826. * @returns "EquiRectangularCubeTexture"
  68827. */
  68828. getClassName(): string;
  68829. /**
  68830. * Create a clone of the current EquiRectangularCubeTexture and return it.
  68831. * @returns A clone of the current EquiRectangularCubeTexture.
  68832. */
  68833. clone(): EquiRectangularCubeTexture;
  68834. }
  68835. }
  68836. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  68837. import { Nullable } from "babylonjs/types";
  68838. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68839. import { Matrix } from "babylonjs/Maths/math.vector";
  68840. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  68841. import "babylonjs/Engines/Extensions/engine.videoTexture";
  68842. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  68843. import { Scene } from "babylonjs/scene";
  68844. /**
  68845. * Defines the options related to the creation of an HtmlElementTexture
  68846. */
  68847. export interface IHtmlElementTextureOptions {
  68848. /**
  68849. * Defines wether mip maps should be created or not.
  68850. */
  68851. generateMipMaps?: boolean;
  68852. /**
  68853. * Defines the sampling mode of the texture.
  68854. */
  68855. samplingMode?: number;
  68856. /**
  68857. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  68858. */
  68859. engine: Nullable<ThinEngine>;
  68860. /**
  68861. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  68862. */
  68863. scene: Nullable<Scene>;
  68864. }
  68865. /**
  68866. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  68867. * To be as efficient as possible depending on your constraints nothing aside the first upload
  68868. * is automatically managed.
  68869. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  68870. * in your application.
  68871. *
  68872. * As the update is not automatic, you need to call them manually.
  68873. */
  68874. export class HtmlElementTexture extends BaseTexture {
  68875. /**
  68876. * The texture URL.
  68877. */
  68878. element: HTMLVideoElement | HTMLCanvasElement;
  68879. private static readonly DefaultOptions;
  68880. private _textureMatrix;
  68881. private _isVideo;
  68882. private _generateMipMaps;
  68883. private _samplingMode;
  68884. /**
  68885. * Instantiates a HtmlElementTexture from the following parameters.
  68886. *
  68887. * @param name Defines the name of the texture
  68888. * @param element Defines the video or canvas the texture is filled with
  68889. * @param options Defines the other none mandatory texture creation options
  68890. */
  68891. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  68892. private _createInternalTexture;
  68893. /**
  68894. * Returns the texture matrix used in most of the material.
  68895. */
  68896. getTextureMatrix(): Matrix;
  68897. /**
  68898. * Updates the content of the texture.
  68899. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  68900. */
  68901. update(invertY?: Nullable<boolean>): void;
  68902. }
  68903. }
  68904. declare module "babylonjs/Misc/tga" {
  68905. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  68906. /**
  68907. * Based on jsTGALoader - Javascript loader for TGA file
  68908. * By Vincent Thibault
  68909. * @see http://blog.robrowser.com/javascript-tga-loader.html
  68910. */
  68911. export class TGATools {
  68912. private static _TYPE_INDEXED;
  68913. private static _TYPE_RGB;
  68914. private static _TYPE_GREY;
  68915. private static _TYPE_RLE_INDEXED;
  68916. private static _TYPE_RLE_RGB;
  68917. private static _TYPE_RLE_GREY;
  68918. private static _ORIGIN_MASK;
  68919. private static _ORIGIN_SHIFT;
  68920. private static _ORIGIN_BL;
  68921. private static _ORIGIN_BR;
  68922. private static _ORIGIN_UL;
  68923. private static _ORIGIN_UR;
  68924. /**
  68925. * Gets the header of a TGA file
  68926. * @param data defines the TGA data
  68927. * @returns the header
  68928. */
  68929. static GetTGAHeader(data: Uint8Array): any;
  68930. /**
  68931. * Uploads TGA content to a Babylon Texture
  68932. * @hidden
  68933. */
  68934. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  68935. /** @hidden */
  68936. 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;
  68937. /** @hidden */
  68938. 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;
  68939. /** @hidden */
  68940. 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;
  68941. /** @hidden */
  68942. 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;
  68943. /** @hidden */
  68944. 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;
  68945. /** @hidden */
  68946. 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;
  68947. }
  68948. }
  68949. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  68950. import { Nullable } from "babylonjs/types";
  68951. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  68952. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  68953. /**
  68954. * Implementation of the TGA Texture Loader.
  68955. * @hidden
  68956. */
  68957. export class _TGATextureLoader implements IInternalTextureLoader {
  68958. /**
  68959. * Defines wether the loader supports cascade loading the different faces.
  68960. */
  68961. readonly supportCascades: boolean;
  68962. /**
  68963. * This returns if the loader support the current file information.
  68964. * @param extension defines the file extension of the file being loaded
  68965. * @returns true if the loader can load the specified file
  68966. */
  68967. canLoad(extension: string): boolean;
  68968. /**
  68969. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  68970. * @param data contains the texture data
  68971. * @param texture defines the BabylonJS internal texture
  68972. * @param createPolynomials will be true if polynomials have been requested
  68973. * @param onLoad defines the callback to trigger once the texture is ready
  68974. * @param onError defines the callback to trigger in case of error
  68975. */
  68976. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  68977. /**
  68978. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  68979. * @param data contains the texture data
  68980. * @param texture defines the BabylonJS internal texture
  68981. * @param callback defines the method to call once ready to upload
  68982. */
  68983. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  68984. }
  68985. }
  68986. declare module "babylonjs/Misc/basis" {
  68987. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  68988. /**
  68989. * Info about the .basis files
  68990. */
  68991. class BasisFileInfo {
  68992. /**
  68993. * If the file has alpha
  68994. */
  68995. hasAlpha: boolean;
  68996. /**
  68997. * Info about each image of the basis file
  68998. */
  68999. images: Array<{
  69000. levels: Array<{
  69001. width: number;
  69002. height: number;
  69003. transcodedPixels: ArrayBufferView;
  69004. }>;
  69005. }>;
  69006. }
  69007. /**
  69008. * Result of transcoding a basis file
  69009. */
  69010. class TranscodeResult {
  69011. /**
  69012. * Info about the .basis file
  69013. */
  69014. fileInfo: BasisFileInfo;
  69015. /**
  69016. * Format to use when loading the file
  69017. */
  69018. format: number;
  69019. }
  69020. /**
  69021. * Configuration options for the Basis transcoder
  69022. */
  69023. export class BasisTranscodeConfiguration {
  69024. /**
  69025. * Supported compression formats used to determine the supported output format of the transcoder
  69026. */
  69027. supportedCompressionFormats?: {
  69028. /**
  69029. * etc1 compression format
  69030. */
  69031. etc1?: boolean;
  69032. /**
  69033. * s3tc compression format
  69034. */
  69035. s3tc?: boolean;
  69036. /**
  69037. * pvrtc compression format
  69038. */
  69039. pvrtc?: boolean;
  69040. /**
  69041. * etc2 compression format
  69042. */
  69043. etc2?: boolean;
  69044. };
  69045. /**
  69046. * If mipmap levels should be loaded for transcoded images (Default: true)
  69047. */
  69048. loadMipmapLevels?: boolean;
  69049. /**
  69050. * Index of a single image to load (Default: all images)
  69051. */
  69052. loadSingleImage?: number;
  69053. }
  69054. /**
  69055. * Used to load .Basis files
  69056. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  69057. */
  69058. export class BasisTools {
  69059. private static _IgnoreSupportedFormats;
  69060. /**
  69061. * URL to use when loading the basis transcoder
  69062. */
  69063. static JSModuleURL: string;
  69064. /**
  69065. * URL to use when loading the wasm module for the transcoder
  69066. */
  69067. static WasmModuleURL: string;
  69068. /**
  69069. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  69070. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  69071. * @returns internal format corresponding to the Basis format
  69072. */
  69073. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  69074. private static _WorkerPromise;
  69075. private static _Worker;
  69076. private static _actionId;
  69077. private static _CreateWorkerAsync;
  69078. /**
  69079. * Transcodes a loaded image file to compressed pixel data
  69080. * @param data image data to transcode
  69081. * @param config configuration options for the transcoding
  69082. * @returns a promise resulting in the transcoded image
  69083. */
  69084. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  69085. /**
  69086. * Loads a texture from the transcode result
  69087. * @param texture texture load to
  69088. * @param transcodeResult the result of transcoding the basis file to load from
  69089. */
  69090. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  69091. }
  69092. }
  69093. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  69094. import { Nullable } from "babylonjs/types";
  69095. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  69096. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  69097. /**
  69098. * Loader for .basis file format
  69099. */
  69100. export class _BasisTextureLoader implements IInternalTextureLoader {
  69101. /**
  69102. * Defines whether the loader supports cascade loading the different faces.
  69103. */
  69104. readonly supportCascades: boolean;
  69105. /**
  69106. * This returns if the loader support the current file information.
  69107. * @param extension defines the file extension of the file being loaded
  69108. * @returns true if the loader can load the specified file
  69109. */
  69110. canLoad(extension: string): boolean;
  69111. /**
  69112. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  69113. * @param data contains the texture data
  69114. * @param texture defines the BabylonJS internal texture
  69115. * @param createPolynomials will be true if polynomials have been requested
  69116. * @param onLoad defines the callback to trigger once the texture is ready
  69117. * @param onError defines the callback to trigger in case of error
  69118. */
  69119. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  69120. /**
  69121. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  69122. * @param data contains the texture data
  69123. * @param texture defines the BabylonJS internal texture
  69124. * @param callback defines the method to call once ready to upload
  69125. */
  69126. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  69127. }
  69128. }
  69129. declare module "babylonjs/Materials/Textures/Loaders/index" {
  69130. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  69131. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  69132. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  69133. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  69134. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  69135. }
  69136. declare module "babylonjs/Materials/Textures/Packer/frame" {
  69137. import { Vector2 } from "babylonjs/Maths/math.vector";
  69138. /**
  69139. * Defines the basic options interface of a TexturePacker Frame
  69140. */
  69141. export interface ITexturePackerFrame {
  69142. /**
  69143. * The frame ID
  69144. */
  69145. id: number;
  69146. /**
  69147. * The frames Scale
  69148. */
  69149. scale: Vector2;
  69150. /**
  69151. * The Frames offset
  69152. */
  69153. offset: Vector2;
  69154. }
  69155. /**
  69156. * This is a support class for frame Data on texture packer sets.
  69157. */
  69158. export class TexturePackerFrame implements ITexturePackerFrame {
  69159. /**
  69160. * The frame ID
  69161. */
  69162. id: number;
  69163. /**
  69164. * The frames Scale
  69165. */
  69166. scale: Vector2;
  69167. /**
  69168. * The Frames offset
  69169. */
  69170. offset: Vector2;
  69171. /**
  69172. * Initializes a texture package frame.
  69173. * @param id The numerical frame identifier
  69174. * @param scale Scalar Vector2 for UV frame
  69175. * @param offset Vector2 for the frame position in UV units.
  69176. * @returns TexturePackerFrame
  69177. */
  69178. constructor(id: number, scale: Vector2, offset: Vector2);
  69179. }
  69180. }
  69181. declare module "babylonjs/Materials/Textures/Packer/packer" {
  69182. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69183. import { Scene } from "babylonjs/scene";
  69184. import { Nullable } from "babylonjs/types";
  69185. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  69186. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  69187. /**
  69188. * Defines the basic options interface of a TexturePacker
  69189. */
  69190. export interface ITexturePackerOptions {
  69191. /**
  69192. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  69193. */
  69194. map?: string[];
  69195. /**
  69196. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  69197. */
  69198. uvsIn?: string;
  69199. /**
  69200. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  69201. */
  69202. uvsOut?: string;
  69203. /**
  69204. * number representing the layout style. Defaults to LAYOUT_STRIP
  69205. */
  69206. layout?: number;
  69207. /**
  69208. * number of columns if using custom column count layout(2). This defaults to 4.
  69209. */
  69210. colnum?: number;
  69211. /**
  69212. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  69213. */
  69214. updateInputMeshes?: boolean;
  69215. /**
  69216. * boolean flag to dispose all the source textures. Defaults to true.
  69217. */
  69218. disposeSources?: boolean;
  69219. /**
  69220. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  69221. */
  69222. fillBlanks?: boolean;
  69223. /**
  69224. * string value representing the context fill style color. Defaults to 'black'.
  69225. */
  69226. customFillColor?: string;
  69227. /**
  69228. * Width and Height Value of each Frame in the TexturePacker Sets
  69229. */
  69230. frameSize?: number;
  69231. /**
  69232. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  69233. */
  69234. paddingRatio?: number;
  69235. /**
  69236. * Number that declares the fill method for the padding gutter.
  69237. */
  69238. paddingMode?: number;
  69239. /**
  69240. * If in SUBUV_COLOR padding mode what color to use.
  69241. */
  69242. paddingColor?: Color3 | Color4;
  69243. }
  69244. /**
  69245. * Defines the basic interface of a TexturePacker JSON File
  69246. */
  69247. export interface ITexturePackerJSON {
  69248. /**
  69249. * The frame ID
  69250. */
  69251. name: string;
  69252. /**
  69253. * The base64 channel data
  69254. */
  69255. sets: any;
  69256. /**
  69257. * The options of the Packer
  69258. */
  69259. options: ITexturePackerOptions;
  69260. /**
  69261. * The frame data of the Packer
  69262. */
  69263. frames: Array<number>;
  69264. }
  69265. /**
  69266. * This is a support class that generates a series of packed texture sets.
  69267. * @see https://doc.babylonjs.com/babylon101/materials
  69268. */
  69269. export class TexturePacker {
  69270. /** Packer Layout Constant 0 */
  69271. static readonly LAYOUT_STRIP: number;
  69272. /** Packer Layout Constant 1 */
  69273. static readonly LAYOUT_POWER2: number;
  69274. /** Packer Layout Constant 2 */
  69275. static readonly LAYOUT_COLNUM: number;
  69276. /** Packer Layout Constant 0 */
  69277. static readonly SUBUV_WRAP: number;
  69278. /** Packer Layout Constant 1 */
  69279. static readonly SUBUV_EXTEND: number;
  69280. /** Packer Layout Constant 2 */
  69281. static readonly SUBUV_COLOR: number;
  69282. /** The Name of the Texture Package */
  69283. name: string;
  69284. /** The scene scope of the TexturePacker */
  69285. scene: Scene;
  69286. /** The Meshes to target */
  69287. meshes: AbstractMesh[];
  69288. /** Arguments passed with the Constructor */
  69289. options: ITexturePackerOptions;
  69290. /** The promise that is started upon initialization */
  69291. promise: Nullable<Promise<TexturePacker | string>>;
  69292. /** The Container object for the channel sets that are generated */
  69293. sets: object;
  69294. /** The Container array for the frames that are generated */
  69295. frames: TexturePackerFrame[];
  69296. /** The expected number of textures the system is parsing. */
  69297. private _expecting;
  69298. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  69299. private _paddingValue;
  69300. /**
  69301. * Initializes a texture package series from an array of meshes or a single mesh.
  69302. * @param name The name of the package
  69303. * @param meshes The target meshes to compose the package from
  69304. * @param options The arguments that texture packer should follow while building.
  69305. * @param scene The scene which the textures are scoped to.
  69306. * @returns TexturePacker
  69307. */
  69308. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  69309. /**
  69310. * Starts the package process
  69311. * @param resolve The promises resolution function
  69312. * @returns TexturePacker
  69313. */
  69314. private _createFrames;
  69315. /**
  69316. * Calculates the Size of the Channel Sets
  69317. * @returns Vector2
  69318. */
  69319. private _calculateSize;
  69320. /**
  69321. * Calculates the UV data for the frames.
  69322. * @param baseSize the base frameSize
  69323. * @param padding the base frame padding
  69324. * @param dtSize size of the Dynamic Texture for that channel
  69325. * @param dtUnits is 1/dtSize
  69326. * @param update flag to update the input meshes
  69327. */
  69328. private _calculateMeshUVFrames;
  69329. /**
  69330. * Calculates the frames Offset.
  69331. * @param index of the frame
  69332. * @returns Vector2
  69333. */
  69334. private _getFrameOffset;
  69335. /**
  69336. * Updates a Mesh to the frame data
  69337. * @param mesh that is the target
  69338. * @param frameID or the frame index
  69339. */
  69340. private _updateMeshUV;
  69341. /**
  69342. * Updates a Meshes materials to use the texture packer channels
  69343. * @param m is the mesh to target
  69344. * @param force all channels on the packer to be set.
  69345. */
  69346. private _updateTextureReferences;
  69347. /**
  69348. * Public method to set a Mesh to a frame
  69349. * @param m that is the target
  69350. * @param frameID or the frame index
  69351. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  69352. */
  69353. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  69354. /**
  69355. * Starts the async promise to compile the texture packer.
  69356. * @returns Promise<void>
  69357. */
  69358. processAsync(): Promise<void>;
  69359. /**
  69360. * Disposes all textures associated with this packer
  69361. */
  69362. dispose(): void;
  69363. /**
  69364. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  69365. * @param imageType is the image type to use.
  69366. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  69367. */
  69368. download(imageType?: string, quality?: number): void;
  69369. /**
  69370. * Public method to load a texturePacker JSON file.
  69371. * @param data of the JSON file in string format.
  69372. */
  69373. updateFromJSON(data: string): void;
  69374. }
  69375. }
  69376. declare module "babylonjs/Materials/Textures/Packer/index" {
  69377. export * from "babylonjs/Materials/Textures/Packer/packer";
  69378. export * from "babylonjs/Materials/Textures/Packer/frame";
  69379. }
  69380. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  69381. import { Scene } from "babylonjs/scene";
  69382. import { Texture } from "babylonjs/Materials/Textures/texture";
  69383. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  69384. /**
  69385. * 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.
  69386. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  69387. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  69388. */
  69389. export class CustomProceduralTexture extends ProceduralTexture {
  69390. private _animate;
  69391. private _time;
  69392. private _config;
  69393. private _texturePath;
  69394. /**
  69395. * Instantiates a new Custom Procedural Texture.
  69396. * 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.
  69397. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  69398. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  69399. * @param name Define the name of the texture
  69400. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  69401. * @param size Define the size of the texture to create
  69402. * @param scene Define the scene the texture belongs to
  69403. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  69404. * @param generateMipMaps Define if the texture should creates mip maps or not
  69405. */
  69406. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  69407. private _loadJson;
  69408. /**
  69409. * Is the texture ready to be used ? (rendered at least once)
  69410. * @returns true if ready, otherwise, false.
  69411. */
  69412. isReady(): boolean;
  69413. /**
  69414. * Render the texture to its associated render target.
  69415. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  69416. */
  69417. render(useCameraPostProcess?: boolean): void;
  69418. /**
  69419. * Update the list of dependant textures samplers in the shader.
  69420. */
  69421. updateTextures(): void;
  69422. /**
  69423. * Update the uniform values of the procedural texture in the shader.
  69424. */
  69425. updateShaderUniforms(): void;
  69426. /**
  69427. * Define if the texture animates or not.
  69428. */
  69429. get animate(): boolean;
  69430. set animate(value: boolean);
  69431. }
  69432. }
  69433. declare module "babylonjs/Shaders/noise.fragment" {
  69434. /** @hidden */
  69435. export var noisePixelShader: {
  69436. name: string;
  69437. shader: string;
  69438. };
  69439. }
  69440. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  69441. import { Nullable } from "babylonjs/types";
  69442. import { Scene } from "babylonjs/scene";
  69443. import { Texture } from "babylonjs/Materials/Textures/texture";
  69444. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  69445. import "babylonjs/Shaders/noise.fragment";
  69446. /**
  69447. * Class used to generate noise procedural textures
  69448. */
  69449. export class NoiseProceduralTexture extends ProceduralTexture {
  69450. /** Gets or sets the start time (default is 0) */
  69451. time: number;
  69452. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  69453. brightness: number;
  69454. /** Defines the number of octaves to process */
  69455. octaves: number;
  69456. /** Defines the level of persistence (0.8 by default) */
  69457. persistence: number;
  69458. /** Gets or sets animation speed factor (default is 1) */
  69459. animationSpeedFactor: number;
  69460. /**
  69461. * Creates a new NoiseProceduralTexture
  69462. * @param name defines the name fo the texture
  69463. * @param size defines the size of the texture (default is 256)
  69464. * @param scene defines the hosting scene
  69465. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  69466. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  69467. */
  69468. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  69469. private _updateShaderUniforms;
  69470. protected _getDefines(): string;
  69471. /** Generate the current state of the procedural texture */
  69472. render(useCameraPostProcess?: boolean): void;
  69473. /**
  69474. * Serializes this noise procedural texture
  69475. * @returns a serialized noise procedural texture object
  69476. */
  69477. serialize(): any;
  69478. /**
  69479. * Clone the texture.
  69480. * @returns the cloned texture
  69481. */
  69482. clone(): NoiseProceduralTexture;
  69483. /**
  69484. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  69485. * @param parsedTexture defines parsed texture data
  69486. * @param scene defines the current scene
  69487. * @param rootUrl defines the root URL containing noise procedural texture information
  69488. * @returns a parsed NoiseProceduralTexture
  69489. */
  69490. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  69491. }
  69492. }
  69493. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  69494. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  69495. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  69496. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  69497. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  69498. }
  69499. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  69500. import { Nullable } from "babylonjs/types";
  69501. import { Scene } from "babylonjs/scene";
  69502. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  69503. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  69504. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  69505. import "babylonjs/Engines/Extensions/engine.rawTexture";
  69506. /**
  69507. * Raw cube texture where the raw buffers are passed in
  69508. */
  69509. export class RawCubeTexture extends CubeTexture {
  69510. /**
  69511. * Creates a cube texture where the raw buffers are passed in.
  69512. * @param scene defines the scene the texture is attached to
  69513. * @param data defines the array of data to use to create each face
  69514. * @param size defines the size of the textures
  69515. * @param format defines the format of the data
  69516. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  69517. * @param generateMipMaps defines if the engine should generate the mip levels
  69518. * @param invertY defines if data must be stored with Y axis inverted
  69519. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  69520. * @param compression defines the compression used (null by default)
  69521. */
  69522. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  69523. /**
  69524. * Updates the raw cube texture.
  69525. * @param data defines the data to store
  69526. * @param format defines the data format
  69527. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  69528. * @param invertY defines if data must be stored with Y axis inverted
  69529. * @param compression defines the compression used (null by default)
  69530. * @param level defines which level of the texture to update
  69531. */
  69532. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  69533. /**
  69534. * Updates a raw cube texture with RGBD encoded data.
  69535. * @param data defines the array of data [mipmap][face] to use to create each face
  69536. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  69537. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  69538. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  69539. * @returns a promsie that resolves when the operation is complete
  69540. */
  69541. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  69542. /**
  69543. * Clones the raw cube texture.
  69544. * @return a new cube texture
  69545. */
  69546. clone(): CubeTexture;
  69547. /** @hidden */
  69548. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  69549. }
  69550. }
  69551. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  69552. import { Scene } from "babylonjs/scene";
  69553. import { Texture } from "babylonjs/Materials/Textures/texture";
  69554. import "babylonjs/Engines/Extensions/engine.rawTexture";
  69555. /**
  69556. * Class used to store 2D array textures containing user data
  69557. */
  69558. export class RawTexture2DArray extends Texture {
  69559. /** Gets or sets the texture format to use */
  69560. format: number;
  69561. /**
  69562. * Create a new RawTexture2DArray
  69563. * @param data defines the data of the texture
  69564. * @param width defines the width of the texture
  69565. * @param height defines the height of the texture
  69566. * @param depth defines the number of layers of the texture
  69567. * @param format defines the texture format to use
  69568. * @param scene defines the hosting scene
  69569. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  69570. * @param invertY defines if texture must be stored with Y axis inverted
  69571. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  69572. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  69573. */
  69574. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  69575. /** Gets or sets the texture format to use */
  69576. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  69577. /**
  69578. * Update the texture with new data
  69579. * @param data defines the data to store in the texture
  69580. */
  69581. update(data: ArrayBufferView): void;
  69582. }
  69583. }
  69584. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  69585. import { Scene } from "babylonjs/scene";
  69586. import { Texture } from "babylonjs/Materials/Textures/texture";
  69587. import "babylonjs/Engines/Extensions/engine.rawTexture";
  69588. /**
  69589. * Class used to store 3D textures containing user data
  69590. */
  69591. export class RawTexture3D extends Texture {
  69592. /** Gets or sets the texture format to use */
  69593. format: number;
  69594. /**
  69595. * Create a new RawTexture3D
  69596. * @param data defines the data of the texture
  69597. * @param width defines the width of the texture
  69598. * @param height defines the height of the texture
  69599. * @param depth defines the depth of the texture
  69600. * @param format defines the texture format to use
  69601. * @param scene defines the hosting scene
  69602. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  69603. * @param invertY defines if texture must be stored with Y axis inverted
  69604. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  69605. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  69606. */
  69607. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  69608. /** Gets or sets the texture format to use */
  69609. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  69610. /**
  69611. * Update the texture with new data
  69612. * @param data defines the data to store in the texture
  69613. */
  69614. update(data: ArrayBufferView): void;
  69615. }
  69616. }
  69617. declare module "babylonjs/Materials/Textures/refractionTexture" {
  69618. import { Scene } from "babylonjs/scene";
  69619. import { Plane } from "babylonjs/Maths/math.plane";
  69620. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  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. */
  69626. export class RefractionTexture extends RenderTargetTexture {
  69627. /**
  69628. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  69629. * 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.
  69630. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  69631. */
  69632. refractionPlane: Plane;
  69633. /**
  69634. * Define how deep under the surface we should see.
  69635. */
  69636. depth: number;
  69637. /**
  69638. * Creates a refraction texture used by refraction channel of the standard material.
  69639. * It is like a mirror but to see through a material.
  69640. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  69641. * @param name Define the texture name
  69642. * @param size Define the size of the underlying texture
  69643. * @param scene Define the scene the refraction belongs to
  69644. * @param generateMipMaps Define if we need to generate mips level for the refraction
  69645. */
  69646. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  69647. /**
  69648. * Clone the refraction texture.
  69649. * @returns the cloned texture
  69650. */
  69651. clone(): RefractionTexture;
  69652. /**
  69653. * Serialize the texture to a JSON representation you could use in Parse later on
  69654. * @returns the serialized JSON representation
  69655. */
  69656. serialize(): any;
  69657. }
  69658. }
  69659. declare module "babylonjs/Materials/Textures/index" {
  69660. export * from "babylonjs/Materials/Textures/baseTexture";
  69661. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  69662. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  69663. export * from "babylonjs/Materials/Textures/cubeTexture";
  69664. export * from "babylonjs/Materials/Textures/dynamicTexture";
  69665. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  69666. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  69667. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  69668. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  69669. export * from "babylonjs/Materials/Textures/internalTexture";
  69670. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  69671. export * from "babylonjs/Materials/Textures/Loaders/index";
  69672. export * from "babylonjs/Materials/Textures/mirrorTexture";
  69673. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  69674. export * from "babylonjs/Materials/Textures/Packer/index";
  69675. export * from "babylonjs/Materials/Textures/Procedurals/index";
  69676. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  69677. export * from "babylonjs/Materials/Textures/rawTexture";
  69678. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  69679. export * from "babylonjs/Materials/Textures/rawTexture3D";
  69680. export * from "babylonjs/Materials/Textures/refractionTexture";
  69681. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  69682. export * from "babylonjs/Materials/Textures/texture";
  69683. export * from "babylonjs/Materials/Textures/videoTexture";
  69684. }
  69685. declare module "babylonjs/Materials/Node/Enums/index" {
  69686. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  69687. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  69688. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  69689. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  69690. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  69691. }
  69692. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  69693. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69694. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69696. import { Mesh } from "babylonjs/Meshes/mesh";
  69697. import { Effect } from "babylonjs/Materials/effect";
  69698. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69699. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69700. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  69701. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  69702. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  69703. /**
  69704. * Block used to add support for vertex skinning (bones)
  69705. */
  69706. export class BonesBlock extends NodeMaterialBlock {
  69707. /**
  69708. * Creates a new BonesBlock
  69709. * @param name defines the block name
  69710. */
  69711. constructor(name: string);
  69712. /**
  69713. * Initialize the block and prepare the context for build
  69714. * @param state defines the state that will be used for the build
  69715. */
  69716. initialize(state: NodeMaterialBuildState): void;
  69717. /**
  69718. * Gets the current class name
  69719. * @returns the class name
  69720. */
  69721. getClassName(): string;
  69722. /**
  69723. * Gets the matrix indices input component
  69724. */
  69725. get matricesIndices(): NodeMaterialConnectionPoint;
  69726. /**
  69727. * Gets the matrix weights input component
  69728. */
  69729. get matricesWeights(): NodeMaterialConnectionPoint;
  69730. /**
  69731. * Gets the extra matrix indices input component
  69732. */
  69733. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  69734. /**
  69735. * Gets the extra matrix weights input component
  69736. */
  69737. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  69738. /**
  69739. * Gets the world input component
  69740. */
  69741. get world(): NodeMaterialConnectionPoint;
  69742. /**
  69743. * Gets the output component
  69744. */
  69745. get output(): NodeMaterialConnectionPoint;
  69746. autoConfigure(material: NodeMaterial): void;
  69747. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  69748. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  69749. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69750. protected _buildBlock(state: NodeMaterialBuildState): this;
  69751. }
  69752. }
  69753. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  69754. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69755. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69756. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69757. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69758. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69759. import { SubMesh } from "babylonjs/Meshes/subMesh";
  69760. /**
  69761. * Block used to add support for instances
  69762. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  69763. */
  69764. export class InstancesBlock extends NodeMaterialBlock {
  69765. /**
  69766. * Creates a new InstancesBlock
  69767. * @param name defines the block name
  69768. */
  69769. constructor(name: string);
  69770. /**
  69771. * Gets the current class name
  69772. * @returns the class name
  69773. */
  69774. getClassName(): string;
  69775. /**
  69776. * Gets the first world row input component
  69777. */
  69778. get world0(): NodeMaterialConnectionPoint;
  69779. /**
  69780. * Gets the second world row input component
  69781. */
  69782. get world1(): NodeMaterialConnectionPoint;
  69783. /**
  69784. * Gets the third world row input component
  69785. */
  69786. get world2(): NodeMaterialConnectionPoint;
  69787. /**
  69788. * Gets the forth world row input component
  69789. */
  69790. get world3(): NodeMaterialConnectionPoint;
  69791. /**
  69792. * Gets the world input component
  69793. */
  69794. get world(): NodeMaterialConnectionPoint;
  69795. /**
  69796. * Gets the output component
  69797. */
  69798. get output(): NodeMaterialConnectionPoint;
  69799. /**
  69800. * Gets the isntanceID component
  69801. */
  69802. get instanceID(): NodeMaterialConnectionPoint;
  69803. autoConfigure(material: NodeMaterial): void;
  69804. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  69805. protected _buildBlock(state: NodeMaterialBuildState): this;
  69806. }
  69807. }
  69808. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  69809. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69810. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69811. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69812. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69813. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69814. import { Effect } from "babylonjs/Materials/effect";
  69815. import { Mesh } from "babylonjs/Meshes/mesh";
  69816. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  69817. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  69818. /**
  69819. * Block used to add morph targets support to vertex shader
  69820. */
  69821. export class MorphTargetsBlock extends NodeMaterialBlock {
  69822. private _repeatableContentAnchor;
  69823. /**
  69824. * Create a new MorphTargetsBlock
  69825. * @param name defines the block name
  69826. */
  69827. constructor(name: string);
  69828. /**
  69829. * Gets the current class name
  69830. * @returns the class name
  69831. */
  69832. getClassName(): string;
  69833. /**
  69834. * Gets the position input component
  69835. */
  69836. get position(): NodeMaterialConnectionPoint;
  69837. /**
  69838. * Gets the normal input component
  69839. */
  69840. get normal(): NodeMaterialConnectionPoint;
  69841. /**
  69842. * Gets the tangent input component
  69843. */
  69844. get tangent(): NodeMaterialConnectionPoint;
  69845. /**
  69846. * Gets the tangent input component
  69847. */
  69848. get uv(): NodeMaterialConnectionPoint;
  69849. /**
  69850. * Gets the position output component
  69851. */
  69852. get positionOutput(): NodeMaterialConnectionPoint;
  69853. /**
  69854. * Gets the normal output component
  69855. */
  69856. get normalOutput(): NodeMaterialConnectionPoint;
  69857. /**
  69858. * Gets the tangent output component
  69859. */
  69860. get tangentOutput(): NodeMaterialConnectionPoint;
  69861. /**
  69862. * Gets the tangent output component
  69863. */
  69864. get uvOutput(): NodeMaterialConnectionPoint;
  69865. initialize(state: NodeMaterialBuildState): void;
  69866. autoConfigure(material: NodeMaterial): void;
  69867. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69868. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  69869. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  69870. protected _buildBlock(state: NodeMaterialBuildState): this;
  69871. }
  69872. }
  69873. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  69874. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69875. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69876. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69877. import { Nullable } from "babylonjs/types";
  69878. import { Scene } from "babylonjs/scene";
  69879. import { Effect } from "babylonjs/Materials/effect";
  69880. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69881. import { Mesh } from "babylonjs/Meshes/mesh";
  69882. import { Light } from "babylonjs/Lights/light";
  69883. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69884. /**
  69885. * Block used to get data information from a light
  69886. */
  69887. export class LightInformationBlock extends NodeMaterialBlock {
  69888. private _lightDataUniformName;
  69889. private _lightColorUniformName;
  69890. private _lightTypeDefineName;
  69891. /**
  69892. * Gets or sets the light associated with this block
  69893. */
  69894. light: Nullable<Light>;
  69895. /**
  69896. * Creates a new LightInformationBlock
  69897. * @param name defines the block name
  69898. */
  69899. constructor(name: string);
  69900. /**
  69901. * Gets the current class name
  69902. * @returns the class name
  69903. */
  69904. getClassName(): string;
  69905. /**
  69906. * Gets the world position input component
  69907. */
  69908. get worldPosition(): NodeMaterialConnectionPoint;
  69909. /**
  69910. * Gets the direction output component
  69911. */
  69912. get direction(): NodeMaterialConnectionPoint;
  69913. /**
  69914. * Gets the direction output component
  69915. */
  69916. get color(): NodeMaterialConnectionPoint;
  69917. /**
  69918. * Gets the direction output component
  69919. */
  69920. get intensity(): NodeMaterialConnectionPoint;
  69921. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  69922. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69923. protected _buildBlock(state: NodeMaterialBuildState): this;
  69924. serialize(): any;
  69925. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69926. }
  69927. }
  69928. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  69929. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  69930. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  69931. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  69932. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  69933. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  69934. }
  69935. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  69936. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69937. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69938. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69940. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69941. import { Effect } from "babylonjs/Materials/effect";
  69942. import { Mesh } from "babylonjs/Meshes/mesh";
  69943. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  69944. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  69945. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  69946. /**
  69947. * Block used to add image processing support to fragment shader
  69948. */
  69949. export class ImageProcessingBlock extends NodeMaterialBlock {
  69950. /**
  69951. * Create a new ImageProcessingBlock
  69952. * @param name defines the block name
  69953. */
  69954. constructor(name: string);
  69955. /**
  69956. * Gets the current class name
  69957. * @returns the class name
  69958. */
  69959. getClassName(): string;
  69960. /**
  69961. * Gets the color input component
  69962. */
  69963. get color(): NodeMaterialConnectionPoint;
  69964. /**
  69965. * Gets the output component
  69966. */
  69967. get output(): NodeMaterialConnectionPoint;
  69968. /**
  69969. * Initialize the block and prepare the context for build
  69970. * @param state defines the state that will be used for the build
  69971. */
  69972. initialize(state: NodeMaterialBuildState): void;
  69973. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  69974. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69975. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  69976. protected _buildBlock(state: NodeMaterialBuildState): this;
  69977. }
  69978. }
  69979. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  69980. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69981. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69982. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69983. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69984. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69985. import { Effect } from "babylonjs/Materials/effect";
  69986. import { Mesh } from "babylonjs/Meshes/mesh";
  69987. import { Scene } from "babylonjs/scene";
  69988. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  69989. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  69990. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  69991. /**
  69992. * Block used to pertub normals based on a normal map
  69993. */
  69994. export class PerturbNormalBlock extends NodeMaterialBlock {
  69995. private _tangentSpaceParameterName;
  69996. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  69997. invertX: boolean;
  69998. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  69999. invertY: boolean;
  70000. /**
  70001. * Create a new PerturbNormalBlock
  70002. * @param name defines the block name
  70003. */
  70004. constructor(name: string);
  70005. /**
  70006. * Gets the current class name
  70007. * @returns the class name
  70008. */
  70009. getClassName(): string;
  70010. /**
  70011. * Gets the world position input component
  70012. */
  70013. get worldPosition(): NodeMaterialConnectionPoint;
  70014. /**
  70015. * Gets the world normal input component
  70016. */
  70017. get worldNormal(): NodeMaterialConnectionPoint;
  70018. /**
  70019. * Gets the world tangent input component
  70020. */
  70021. get worldTangent(): NodeMaterialConnectionPoint;
  70022. /**
  70023. * Gets the uv input component
  70024. */
  70025. get uv(): NodeMaterialConnectionPoint;
  70026. /**
  70027. * Gets the normal map color input component
  70028. */
  70029. get normalMapColor(): NodeMaterialConnectionPoint;
  70030. /**
  70031. * Gets the strength input component
  70032. */
  70033. get strength(): NodeMaterialConnectionPoint;
  70034. /**
  70035. * Gets the output component
  70036. */
  70037. get output(): NodeMaterialConnectionPoint;
  70038. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  70039. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  70040. autoConfigure(material: NodeMaterial): void;
  70041. protected _buildBlock(state: NodeMaterialBuildState): this;
  70042. protected _dumpPropertiesCode(): string;
  70043. serialize(): any;
  70044. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  70045. }
  70046. }
  70047. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  70048. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70049. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70050. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70051. /**
  70052. * Block used to discard a pixel if a value is smaller than a cutoff
  70053. */
  70054. export class DiscardBlock extends NodeMaterialBlock {
  70055. /**
  70056. * Create a new DiscardBlock
  70057. * @param name defines the block name
  70058. */
  70059. constructor(name: string);
  70060. /**
  70061. * Gets the current class name
  70062. * @returns the class name
  70063. */
  70064. getClassName(): string;
  70065. /**
  70066. * Gets the color input component
  70067. */
  70068. get value(): NodeMaterialConnectionPoint;
  70069. /**
  70070. * Gets the cutoff input component
  70071. */
  70072. get cutoff(): NodeMaterialConnectionPoint;
  70073. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  70074. }
  70075. }
  70076. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  70077. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70078. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70079. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70080. /**
  70081. * Block used to test if the fragment shader is front facing
  70082. */
  70083. export class FrontFacingBlock extends NodeMaterialBlock {
  70084. /**
  70085. * Creates a new FrontFacingBlock
  70086. * @param name defines the block name
  70087. */
  70088. constructor(name: string);
  70089. /**
  70090. * Gets the current class name
  70091. * @returns the class name
  70092. */
  70093. getClassName(): string;
  70094. /**
  70095. * Gets the output component
  70096. */
  70097. get output(): NodeMaterialConnectionPoint;
  70098. protected _buildBlock(state: NodeMaterialBuildState): this;
  70099. }
  70100. }
  70101. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  70102. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70103. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70104. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70105. /**
  70106. * Block used to get the derivative value on x and y of a given input
  70107. */
  70108. export class DerivativeBlock extends NodeMaterialBlock {
  70109. /**
  70110. * Create a new DerivativeBlock
  70111. * @param name defines the block name
  70112. */
  70113. constructor(name: string);
  70114. /**
  70115. * Gets the current class name
  70116. * @returns the class name
  70117. */
  70118. getClassName(): string;
  70119. /**
  70120. * Gets the input component
  70121. */
  70122. get input(): NodeMaterialConnectionPoint;
  70123. /**
  70124. * Gets the derivative output on x
  70125. */
  70126. get dx(): NodeMaterialConnectionPoint;
  70127. /**
  70128. * Gets the derivative output on y
  70129. */
  70130. get dy(): NodeMaterialConnectionPoint;
  70131. protected _buildBlock(state: NodeMaterialBuildState): this;
  70132. }
  70133. }
  70134. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  70135. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70136. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70137. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70138. /**
  70139. * Block used to make gl_FragCoord available
  70140. */
  70141. export class FragCoordBlock extends NodeMaterialBlock {
  70142. /**
  70143. * Creates a new FragCoordBlock
  70144. * @param name defines the block name
  70145. */
  70146. constructor(name: string);
  70147. /**
  70148. * Gets the current class name
  70149. * @returns the class name
  70150. */
  70151. getClassName(): string;
  70152. /**
  70153. * Gets the xy component
  70154. */
  70155. get xy(): NodeMaterialConnectionPoint;
  70156. /**
  70157. * Gets the xyz component
  70158. */
  70159. get xyz(): NodeMaterialConnectionPoint;
  70160. /**
  70161. * Gets the xyzw component
  70162. */
  70163. get xyzw(): NodeMaterialConnectionPoint;
  70164. /**
  70165. * Gets the x component
  70166. */
  70167. get x(): NodeMaterialConnectionPoint;
  70168. /**
  70169. * Gets the y component
  70170. */
  70171. get y(): NodeMaterialConnectionPoint;
  70172. /**
  70173. * Gets the z component
  70174. */
  70175. get z(): NodeMaterialConnectionPoint;
  70176. /**
  70177. * Gets the w component
  70178. */
  70179. get output(): NodeMaterialConnectionPoint;
  70180. protected writeOutputs(state: NodeMaterialBuildState): string;
  70181. protected _buildBlock(state: NodeMaterialBuildState): this;
  70182. }
  70183. }
  70184. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  70185. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70186. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70187. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70188. import { Effect } from "babylonjs/Materials/effect";
  70189. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  70190. import { Mesh } from "babylonjs/Meshes/mesh";
  70191. /**
  70192. * Block used to get the screen sizes
  70193. */
  70194. export class ScreenSizeBlock extends NodeMaterialBlock {
  70195. private _varName;
  70196. private _scene;
  70197. /**
  70198. * Creates a new ScreenSizeBlock
  70199. * @param name defines the block name
  70200. */
  70201. constructor(name: string);
  70202. /**
  70203. * Gets the current class name
  70204. * @returns the class name
  70205. */
  70206. getClassName(): string;
  70207. /**
  70208. * Gets the xy component
  70209. */
  70210. get xy(): NodeMaterialConnectionPoint;
  70211. /**
  70212. * Gets the x component
  70213. */
  70214. get x(): NodeMaterialConnectionPoint;
  70215. /**
  70216. * Gets the y component
  70217. */
  70218. get y(): NodeMaterialConnectionPoint;
  70219. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  70220. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  70221. protected _buildBlock(state: NodeMaterialBuildState): this;
  70222. }
  70223. }
  70224. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  70225. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  70226. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  70227. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  70228. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  70229. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  70230. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  70231. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  70232. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  70233. }
  70234. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  70235. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70236. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70237. import { Mesh } from "babylonjs/Meshes/mesh";
  70238. import { Effect } from "babylonjs/Materials/effect";
  70239. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70240. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70241. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  70242. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  70243. /**
  70244. * Block used to add support for scene fog
  70245. */
  70246. export class FogBlock extends NodeMaterialBlock {
  70247. private _fogDistanceName;
  70248. private _fogParameters;
  70249. /**
  70250. * Create a new FogBlock
  70251. * @param name defines the block name
  70252. */
  70253. constructor(name: string);
  70254. /**
  70255. * Gets the current class name
  70256. * @returns the class name
  70257. */
  70258. getClassName(): string;
  70259. /**
  70260. * Gets the world position input component
  70261. */
  70262. get worldPosition(): NodeMaterialConnectionPoint;
  70263. /**
  70264. * Gets the view input component
  70265. */
  70266. get view(): NodeMaterialConnectionPoint;
  70267. /**
  70268. * Gets the color input component
  70269. */
  70270. get input(): NodeMaterialConnectionPoint;
  70271. /**
  70272. * Gets the fog color input component
  70273. */
  70274. get fogColor(): NodeMaterialConnectionPoint;
  70275. /**
  70276. * Gets the output component
  70277. */
  70278. get output(): NodeMaterialConnectionPoint;
  70279. autoConfigure(material: NodeMaterial): void;
  70280. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  70281. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  70282. protected _buildBlock(state: NodeMaterialBuildState): this;
  70283. }
  70284. }
  70285. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  70286. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70287. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70288. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70289. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70290. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  70291. import { Effect } from "babylonjs/Materials/effect";
  70292. import { Mesh } from "babylonjs/Meshes/mesh";
  70293. import { Light } from "babylonjs/Lights/light";
  70294. import { Nullable } from "babylonjs/types";
  70295. import { Scene } from "babylonjs/scene";
  70296. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  70297. import "babylonjs/Shaders/ShadersInclude/lightVxFragmentDeclaration";
  70298. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  70299. import "babylonjs/Shaders/ShadersInclude/lightVxUboDeclaration";
  70300. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  70301. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  70302. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  70303. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  70304. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  70305. /**
  70306. * Block used to add light in the fragment shader
  70307. */
  70308. export class LightBlock extends NodeMaterialBlock {
  70309. private _lightId;
  70310. /**
  70311. * Gets or sets the light associated with this block
  70312. */
  70313. light: Nullable<Light>;
  70314. /**
  70315. * Create a new LightBlock
  70316. * @param name defines the block name
  70317. */
  70318. constructor(name: string);
  70319. /**
  70320. * Gets the current class name
  70321. * @returns the class name
  70322. */
  70323. getClassName(): string;
  70324. /**
  70325. * Gets the world position input component
  70326. */
  70327. get worldPosition(): NodeMaterialConnectionPoint;
  70328. /**
  70329. * Gets the world normal input component
  70330. */
  70331. get worldNormal(): NodeMaterialConnectionPoint;
  70332. /**
  70333. * Gets the camera (or eye) position component
  70334. */
  70335. get cameraPosition(): NodeMaterialConnectionPoint;
  70336. /**
  70337. * Gets the glossiness component
  70338. */
  70339. get glossiness(): NodeMaterialConnectionPoint;
  70340. /**
  70341. * Gets the glossinness power component
  70342. */
  70343. get glossPower(): NodeMaterialConnectionPoint;
  70344. /**
  70345. * Gets the diffuse color component
  70346. */
  70347. get diffuseColor(): NodeMaterialConnectionPoint;
  70348. /**
  70349. * Gets the specular color component
  70350. */
  70351. get specularColor(): NodeMaterialConnectionPoint;
  70352. /**
  70353. * Gets the view matrix component
  70354. */
  70355. get view(): NodeMaterialConnectionPoint;
  70356. /**
  70357. * Gets the diffuse output component
  70358. */
  70359. get diffuseOutput(): NodeMaterialConnectionPoint;
  70360. /**
  70361. * Gets the specular output component
  70362. */
  70363. get specularOutput(): NodeMaterialConnectionPoint;
  70364. /**
  70365. * Gets the shadow output component
  70366. */
  70367. get shadow(): NodeMaterialConnectionPoint;
  70368. autoConfigure(material: NodeMaterial): void;
  70369. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  70370. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  70371. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  70372. private _injectVertexCode;
  70373. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  70374. serialize(): any;
  70375. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  70376. }
  70377. }
  70378. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  70379. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70380. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70381. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  70382. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  70383. /**
  70384. * Block used to read a reflection texture from a sampler
  70385. */
  70386. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  70387. /**
  70388. * Create a new ReflectionTextureBlock
  70389. * @param name defines the block name
  70390. */
  70391. constructor(name: string);
  70392. /**
  70393. * Gets the current class name
  70394. * @returns the class name
  70395. */
  70396. getClassName(): string;
  70397. /**
  70398. * Gets the world position input component
  70399. */
  70400. get position(): NodeMaterialConnectionPoint;
  70401. /**
  70402. * Gets the world position input component
  70403. */
  70404. get worldPosition(): NodeMaterialConnectionPoint;
  70405. /**
  70406. * Gets the world normal input component
  70407. */
  70408. get worldNormal(): NodeMaterialConnectionPoint;
  70409. /**
  70410. * Gets the world input component
  70411. */
  70412. get world(): NodeMaterialConnectionPoint;
  70413. /**
  70414. * Gets the camera (or eye) position component
  70415. */
  70416. get cameraPosition(): NodeMaterialConnectionPoint;
  70417. /**
  70418. * Gets the view input component
  70419. */
  70420. get view(): NodeMaterialConnectionPoint;
  70421. /**
  70422. * Gets the rgb output component
  70423. */
  70424. get rgb(): NodeMaterialConnectionPoint;
  70425. /**
  70426. * Gets the rgba output component
  70427. */
  70428. get rgba(): NodeMaterialConnectionPoint;
  70429. /**
  70430. * Gets the r output component
  70431. */
  70432. get r(): NodeMaterialConnectionPoint;
  70433. /**
  70434. * Gets the g output component
  70435. */
  70436. get g(): NodeMaterialConnectionPoint;
  70437. /**
  70438. * Gets the b output component
  70439. */
  70440. get b(): NodeMaterialConnectionPoint;
  70441. /**
  70442. * Gets the a output component
  70443. */
  70444. get a(): NodeMaterialConnectionPoint;
  70445. autoConfigure(material: NodeMaterial): void;
  70446. protected _buildBlock(state: NodeMaterialBuildState): this;
  70447. }
  70448. }
  70449. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  70450. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  70451. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  70452. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  70453. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  70454. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  70455. }
  70456. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  70457. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  70458. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  70459. }
  70460. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  70461. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70462. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70463. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70464. /**
  70465. * Block used to add 2 vectors
  70466. */
  70467. export class AddBlock extends NodeMaterialBlock {
  70468. /**
  70469. * Creates a new AddBlock
  70470. * @param name defines the block name
  70471. */
  70472. constructor(name: string);
  70473. /**
  70474. * Gets the current class name
  70475. * @returns the class name
  70476. */
  70477. getClassName(): string;
  70478. /**
  70479. * Gets the left operand input component
  70480. */
  70481. get left(): NodeMaterialConnectionPoint;
  70482. /**
  70483. * Gets the right operand input component
  70484. */
  70485. get right(): NodeMaterialConnectionPoint;
  70486. /**
  70487. * Gets the output component
  70488. */
  70489. get output(): NodeMaterialConnectionPoint;
  70490. protected _buildBlock(state: NodeMaterialBuildState): this;
  70491. }
  70492. }
  70493. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  70494. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70495. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70496. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70497. /**
  70498. * Block used to scale a vector by a float
  70499. */
  70500. export class ScaleBlock extends NodeMaterialBlock {
  70501. /**
  70502. * Creates a new ScaleBlock
  70503. * @param name defines the block name
  70504. */
  70505. constructor(name: string);
  70506. /**
  70507. * Gets the current class name
  70508. * @returns the class name
  70509. */
  70510. getClassName(): string;
  70511. /**
  70512. * Gets the input component
  70513. */
  70514. get input(): NodeMaterialConnectionPoint;
  70515. /**
  70516. * Gets the factor input component
  70517. */
  70518. get factor(): NodeMaterialConnectionPoint;
  70519. /**
  70520. * Gets the output component
  70521. */
  70522. get output(): NodeMaterialConnectionPoint;
  70523. protected _buildBlock(state: NodeMaterialBuildState): this;
  70524. }
  70525. }
  70526. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  70527. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70528. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70529. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70530. import { Scene } from "babylonjs/scene";
  70531. /**
  70532. * Block used to clamp a float
  70533. */
  70534. export class ClampBlock extends NodeMaterialBlock {
  70535. /** Gets or sets the minimum range */
  70536. minimum: number;
  70537. /** Gets or sets the maximum range */
  70538. maximum: number;
  70539. /**
  70540. * Creates a new ClampBlock
  70541. * @param name defines the block name
  70542. */
  70543. constructor(name: string);
  70544. /**
  70545. * Gets the current class name
  70546. * @returns the class name
  70547. */
  70548. getClassName(): string;
  70549. /**
  70550. * Gets the value input component
  70551. */
  70552. get value(): NodeMaterialConnectionPoint;
  70553. /**
  70554. * Gets the output component
  70555. */
  70556. get output(): NodeMaterialConnectionPoint;
  70557. protected _buildBlock(state: NodeMaterialBuildState): this;
  70558. protected _dumpPropertiesCode(): string;
  70559. serialize(): any;
  70560. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  70561. }
  70562. }
  70563. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  70564. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70565. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70566. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70567. /**
  70568. * Block used to apply a cross product between 2 vectors
  70569. */
  70570. export class CrossBlock extends NodeMaterialBlock {
  70571. /**
  70572. * Creates a new CrossBlock
  70573. * @param name defines the block name
  70574. */
  70575. constructor(name: string);
  70576. /**
  70577. * Gets the current class name
  70578. * @returns the class name
  70579. */
  70580. getClassName(): string;
  70581. /**
  70582. * Gets the left operand input component
  70583. */
  70584. get left(): NodeMaterialConnectionPoint;
  70585. /**
  70586. * Gets the right operand input component
  70587. */
  70588. get right(): NodeMaterialConnectionPoint;
  70589. /**
  70590. * Gets the output component
  70591. */
  70592. get output(): NodeMaterialConnectionPoint;
  70593. protected _buildBlock(state: NodeMaterialBuildState): this;
  70594. }
  70595. }
  70596. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  70597. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70598. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70599. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70600. /**
  70601. * Block used to apply a dot product between 2 vectors
  70602. */
  70603. export class DotBlock extends NodeMaterialBlock {
  70604. /**
  70605. * Creates a new DotBlock
  70606. * @param name defines the block name
  70607. */
  70608. constructor(name: string);
  70609. /**
  70610. * Gets the current class name
  70611. * @returns the class name
  70612. */
  70613. getClassName(): string;
  70614. /**
  70615. * Gets the left operand input component
  70616. */
  70617. get left(): NodeMaterialConnectionPoint;
  70618. /**
  70619. * Gets the right operand input component
  70620. */
  70621. get right(): NodeMaterialConnectionPoint;
  70622. /**
  70623. * Gets the output component
  70624. */
  70625. get output(): NodeMaterialConnectionPoint;
  70626. protected _buildBlock(state: NodeMaterialBuildState): this;
  70627. }
  70628. }
  70629. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  70630. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70631. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70632. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70633. /**
  70634. * Block used to normalize a vector
  70635. */
  70636. export class NormalizeBlock extends NodeMaterialBlock {
  70637. /**
  70638. * Creates a new NormalizeBlock
  70639. * @param name defines the block name
  70640. */
  70641. constructor(name: string);
  70642. /**
  70643. * Gets the current class name
  70644. * @returns the class name
  70645. */
  70646. getClassName(): string;
  70647. /**
  70648. * Gets the input component
  70649. */
  70650. get input(): NodeMaterialConnectionPoint;
  70651. /**
  70652. * Gets the output component
  70653. */
  70654. get output(): NodeMaterialConnectionPoint;
  70655. protected _buildBlock(state: NodeMaterialBuildState): this;
  70656. }
  70657. }
  70658. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  70659. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70660. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70661. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70662. /**
  70663. * Block used to create a Color3/4 out of individual inputs (one for each component)
  70664. */
  70665. export class ColorMergerBlock extends NodeMaterialBlock {
  70666. /**
  70667. * Create a new ColorMergerBlock
  70668. * @param name defines the block name
  70669. */
  70670. constructor(name: string);
  70671. /**
  70672. * Gets the current class name
  70673. * @returns the class name
  70674. */
  70675. getClassName(): string;
  70676. /**
  70677. * Gets the rgb component (input)
  70678. */
  70679. get rgbIn(): NodeMaterialConnectionPoint;
  70680. /**
  70681. * Gets the r component (input)
  70682. */
  70683. get r(): NodeMaterialConnectionPoint;
  70684. /**
  70685. * Gets the g component (input)
  70686. */
  70687. get g(): NodeMaterialConnectionPoint;
  70688. /**
  70689. * Gets the b component (input)
  70690. */
  70691. get b(): NodeMaterialConnectionPoint;
  70692. /**
  70693. * Gets the a component (input)
  70694. */
  70695. get a(): NodeMaterialConnectionPoint;
  70696. /**
  70697. * Gets the rgba component (output)
  70698. */
  70699. get rgba(): NodeMaterialConnectionPoint;
  70700. /**
  70701. * Gets the rgb component (output)
  70702. */
  70703. get rgbOut(): NodeMaterialConnectionPoint;
  70704. /**
  70705. * Gets the rgb component (output)
  70706. * @deprecated Please use rgbOut instead.
  70707. */
  70708. get rgb(): NodeMaterialConnectionPoint;
  70709. protected _buildBlock(state: NodeMaterialBuildState): this;
  70710. }
  70711. }
  70712. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  70713. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70714. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70715. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70716. /**
  70717. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  70718. */
  70719. export class VectorSplitterBlock extends NodeMaterialBlock {
  70720. /**
  70721. * Create a new VectorSplitterBlock
  70722. * @param name defines the block name
  70723. */
  70724. constructor(name: string);
  70725. /**
  70726. * Gets the current class name
  70727. * @returns the class name
  70728. */
  70729. getClassName(): string;
  70730. /**
  70731. * Gets the xyzw component (input)
  70732. */
  70733. get xyzw(): NodeMaterialConnectionPoint;
  70734. /**
  70735. * Gets the xyz component (input)
  70736. */
  70737. get xyzIn(): NodeMaterialConnectionPoint;
  70738. /**
  70739. * Gets the xy component (input)
  70740. */
  70741. get xyIn(): NodeMaterialConnectionPoint;
  70742. /**
  70743. * Gets the xyz component (output)
  70744. */
  70745. get xyzOut(): NodeMaterialConnectionPoint;
  70746. /**
  70747. * Gets the xy component (output)
  70748. */
  70749. get xyOut(): NodeMaterialConnectionPoint;
  70750. /**
  70751. * Gets the x component (output)
  70752. */
  70753. get x(): NodeMaterialConnectionPoint;
  70754. /**
  70755. * Gets the y component (output)
  70756. */
  70757. get y(): NodeMaterialConnectionPoint;
  70758. /**
  70759. * Gets the z component (output)
  70760. */
  70761. get z(): NodeMaterialConnectionPoint;
  70762. /**
  70763. * Gets the w component (output)
  70764. */
  70765. get w(): NodeMaterialConnectionPoint;
  70766. protected _inputRename(name: string): string;
  70767. protected _outputRename(name: string): string;
  70768. protected _buildBlock(state: NodeMaterialBuildState): this;
  70769. }
  70770. }
  70771. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  70772. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70773. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70774. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70775. /**
  70776. * Block used to lerp between 2 values
  70777. */
  70778. export class LerpBlock extends NodeMaterialBlock {
  70779. /**
  70780. * Creates a new LerpBlock
  70781. * @param name defines the block name
  70782. */
  70783. constructor(name: string);
  70784. /**
  70785. * Gets the current class name
  70786. * @returns the class name
  70787. */
  70788. getClassName(): string;
  70789. /**
  70790. * Gets the left operand input component
  70791. */
  70792. get left(): NodeMaterialConnectionPoint;
  70793. /**
  70794. * Gets the right operand input component
  70795. */
  70796. get right(): NodeMaterialConnectionPoint;
  70797. /**
  70798. * Gets the gradient operand input component
  70799. */
  70800. get gradient(): NodeMaterialConnectionPoint;
  70801. /**
  70802. * Gets the output component
  70803. */
  70804. get output(): NodeMaterialConnectionPoint;
  70805. protected _buildBlock(state: NodeMaterialBuildState): this;
  70806. }
  70807. }
  70808. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  70809. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70810. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70811. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70812. /**
  70813. * Block used to divide 2 vectors
  70814. */
  70815. export class DivideBlock extends NodeMaterialBlock {
  70816. /**
  70817. * Creates a new DivideBlock
  70818. * @param name defines the block name
  70819. */
  70820. constructor(name: string);
  70821. /**
  70822. * Gets the current class name
  70823. * @returns the class name
  70824. */
  70825. getClassName(): string;
  70826. /**
  70827. * Gets the left operand input component
  70828. */
  70829. get left(): NodeMaterialConnectionPoint;
  70830. /**
  70831. * Gets the right operand input component
  70832. */
  70833. get right(): NodeMaterialConnectionPoint;
  70834. /**
  70835. * Gets the output component
  70836. */
  70837. get output(): NodeMaterialConnectionPoint;
  70838. protected _buildBlock(state: NodeMaterialBuildState): this;
  70839. }
  70840. }
  70841. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  70842. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70843. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70844. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70845. /**
  70846. * Block used to subtract 2 vectors
  70847. */
  70848. export class SubtractBlock extends NodeMaterialBlock {
  70849. /**
  70850. * Creates a new SubtractBlock
  70851. * @param name defines the block name
  70852. */
  70853. constructor(name: string);
  70854. /**
  70855. * Gets the current class name
  70856. * @returns the class name
  70857. */
  70858. getClassName(): string;
  70859. /**
  70860. * Gets the left operand input component
  70861. */
  70862. get left(): NodeMaterialConnectionPoint;
  70863. /**
  70864. * Gets the right operand input component
  70865. */
  70866. get right(): NodeMaterialConnectionPoint;
  70867. /**
  70868. * Gets the output component
  70869. */
  70870. get output(): NodeMaterialConnectionPoint;
  70871. protected _buildBlock(state: NodeMaterialBuildState): this;
  70872. }
  70873. }
  70874. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  70875. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70876. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70877. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70878. /**
  70879. * Block used to step a value
  70880. */
  70881. export class StepBlock extends NodeMaterialBlock {
  70882. /**
  70883. * Creates a new StepBlock
  70884. * @param name defines the block name
  70885. */
  70886. constructor(name: string);
  70887. /**
  70888. * Gets the current class name
  70889. * @returns the class name
  70890. */
  70891. getClassName(): string;
  70892. /**
  70893. * Gets the value operand input component
  70894. */
  70895. get value(): NodeMaterialConnectionPoint;
  70896. /**
  70897. * Gets the edge operand input component
  70898. */
  70899. get edge(): NodeMaterialConnectionPoint;
  70900. /**
  70901. * Gets the output component
  70902. */
  70903. get output(): NodeMaterialConnectionPoint;
  70904. protected _buildBlock(state: NodeMaterialBuildState): this;
  70905. }
  70906. }
  70907. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  70908. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70909. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70910. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70911. /**
  70912. * Block used to get the opposite (1 - x) of a value
  70913. */
  70914. export class OneMinusBlock extends NodeMaterialBlock {
  70915. /**
  70916. * Creates a new OneMinusBlock
  70917. * @param name defines the block name
  70918. */
  70919. constructor(name: string);
  70920. /**
  70921. * Gets the current class name
  70922. * @returns the class name
  70923. */
  70924. getClassName(): string;
  70925. /**
  70926. * Gets the input component
  70927. */
  70928. get input(): NodeMaterialConnectionPoint;
  70929. /**
  70930. * Gets the output component
  70931. */
  70932. get output(): NodeMaterialConnectionPoint;
  70933. protected _buildBlock(state: NodeMaterialBuildState): this;
  70934. }
  70935. }
  70936. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  70937. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70938. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70939. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70940. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  70941. /**
  70942. * Block used to get the view direction
  70943. */
  70944. export class ViewDirectionBlock extends NodeMaterialBlock {
  70945. /**
  70946. * Creates a new ViewDirectionBlock
  70947. * @param name defines the block name
  70948. */
  70949. constructor(name: string);
  70950. /**
  70951. * Gets the current class name
  70952. * @returns the class name
  70953. */
  70954. getClassName(): string;
  70955. /**
  70956. * Gets the world position component
  70957. */
  70958. get worldPosition(): NodeMaterialConnectionPoint;
  70959. /**
  70960. * Gets the camera position component
  70961. */
  70962. get cameraPosition(): NodeMaterialConnectionPoint;
  70963. /**
  70964. * Gets the output component
  70965. */
  70966. get output(): NodeMaterialConnectionPoint;
  70967. autoConfigure(material: NodeMaterial): void;
  70968. protected _buildBlock(state: NodeMaterialBuildState): this;
  70969. }
  70970. }
  70971. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  70972. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  70973. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  70974. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  70975. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  70976. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  70977. /**
  70978. * Block used to compute fresnel value
  70979. */
  70980. export class FresnelBlock extends NodeMaterialBlock {
  70981. /**
  70982. * Create a new FresnelBlock
  70983. * @param name defines the block name
  70984. */
  70985. constructor(name: string);
  70986. /**
  70987. * Gets the current class name
  70988. * @returns the class name
  70989. */
  70990. getClassName(): string;
  70991. /**
  70992. * Gets the world normal input component
  70993. */
  70994. get worldNormal(): NodeMaterialConnectionPoint;
  70995. /**
  70996. * Gets the view direction input component
  70997. */
  70998. get viewDirection(): NodeMaterialConnectionPoint;
  70999. /**
  71000. * Gets the bias input component
  71001. */
  71002. get bias(): NodeMaterialConnectionPoint;
  71003. /**
  71004. * Gets the camera (or eye) position component
  71005. */
  71006. get power(): NodeMaterialConnectionPoint;
  71007. /**
  71008. * Gets the fresnel output component
  71009. */
  71010. get fresnel(): NodeMaterialConnectionPoint;
  71011. autoConfigure(material: NodeMaterial): void;
  71012. protected _buildBlock(state: NodeMaterialBuildState): this;
  71013. }
  71014. }
  71015. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  71016. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71017. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71018. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71019. /**
  71020. * Block used to get the max of 2 values
  71021. */
  71022. export class MaxBlock extends NodeMaterialBlock {
  71023. /**
  71024. * Creates a new MaxBlock
  71025. * @param name defines the block name
  71026. */
  71027. constructor(name: string);
  71028. /**
  71029. * Gets the current class name
  71030. * @returns the class name
  71031. */
  71032. getClassName(): string;
  71033. /**
  71034. * Gets the left operand input component
  71035. */
  71036. get left(): NodeMaterialConnectionPoint;
  71037. /**
  71038. * Gets the right operand input component
  71039. */
  71040. get right(): NodeMaterialConnectionPoint;
  71041. /**
  71042. * Gets the output component
  71043. */
  71044. get output(): NodeMaterialConnectionPoint;
  71045. protected _buildBlock(state: NodeMaterialBuildState): this;
  71046. }
  71047. }
  71048. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  71049. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71050. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71051. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71052. /**
  71053. * Block used to get the min of 2 values
  71054. */
  71055. export class MinBlock extends NodeMaterialBlock {
  71056. /**
  71057. * Creates a new MinBlock
  71058. * @param name defines the block name
  71059. */
  71060. constructor(name: string);
  71061. /**
  71062. * Gets the current class name
  71063. * @returns the class name
  71064. */
  71065. getClassName(): string;
  71066. /**
  71067. * Gets the left operand input component
  71068. */
  71069. get left(): NodeMaterialConnectionPoint;
  71070. /**
  71071. * Gets the right operand input component
  71072. */
  71073. get right(): NodeMaterialConnectionPoint;
  71074. /**
  71075. * Gets the output component
  71076. */
  71077. get output(): NodeMaterialConnectionPoint;
  71078. protected _buildBlock(state: NodeMaterialBuildState): this;
  71079. }
  71080. }
  71081. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  71082. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71083. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71084. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71085. /**
  71086. * Block used to get the distance between 2 values
  71087. */
  71088. export class DistanceBlock extends NodeMaterialBlock {
  71089. /**
  71090. * Creates a new DistanceBlock
  71091. * @param name defines the block name
  71092. */
  71093. constructor(name: string);
  71094. /**
  71095. * Gets the current class name
  71096. * @returns the class name
  71097. */
  71098. getClassName(): string;
  71099. /**
  71100. * Gets the left operand input component
  71101. */
  71102. get left(): NodeMaterialConnectionPoint;
  71103. /**
  71104. * Gets the right operand input component
  71105. */
  71106. get right(): NodeMaterialConnectionPoint;
  71107. /**
  71108. * Gets the output component
  71109. */
  71110. get output(): NodeMaterialConnectionPoint;
  71111. protected _buildBlock(state: NodeMaterialBuildState): this;
  71112. }
  71113. }
  71114. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  71115. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71116. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71117. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71118. /**
  71119. * Block used to get the length of a vector
  71120. */
  71121. export class LengthBlock extends NodeMaterialBlock {
  71122. /**
  71123. * Creates a new LengthBlock
  71124. * @param name defines the block name
  71125. */
  71126. constructor(name: string);
  71127. /**
  71128. * Gets the current class name
  71129. * @returns the class name
  71130. */
  71131. getClassName(): string;
  71132. /**
  71133. * Gets the value input component
  71134. */
  71135. get value(): NodeMaterialConnectionPoint;
  71136. /**
  71137. * Gets the output component
  71138. */
  71139. get output(): NodeMaterialConnectionPoint;
  71140. protected _buildBlock(state: NodeMaterialBuildState): this;
  71141. }
  71142. }
  71143. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  71144. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71145. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71146. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71147. /**
  71148. * Block used to get negative version of a value (i.e. x * -1)
  71149. */
  71150. export class NegateBlock extends NodeMaterialBlock {
  71151. /**
  71152. * Creates a new NegateBlock
  71153. * @param name defines the block name
  71154. */
  71155. constructor(name: string);
  71156. /**
  71157. * Gets the current class name
  71158. * @returns the class name
  71159. */
  71160. getClassName(): string;
  71161. /**
  71162. * Gets the value input component
  71163. */
  71164. get value(): NodeMaterialConnectionPoint;
  71165. /**
  71166. * Gets the output component
  71167. */
  71168. get output(): NodeMaterialConnectionPoint;
  71169. protected _buildBlock(state: NodeMaterialBuildState): this;
  71170. }
  71171. }
  71172. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  71173. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71174. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71175. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71176. /**
  71177. * Block used to get the value of the first parameter raised to the power of the second
  71178. */
  71179. export class PowBlock extends NodeMaterialBlock {
  71180. /**
  71181. * Creates a new PowBlock
  71182. * @param name defines the block name
  71183. */
  71184. constructor(name: string);
  71185. /**
  71186. * Gets the current class name
  71187. * @returns the class name
  71188. */
  71189. getClassName(): string;
  71190. /**
  71191. * Gets the value operand input component
  71192. */
  71193. get value(): NodeMaterialConnectionPoint;
  71194. /**
  71195. * Gets the power operand input component
  71196. */
  71197. get power(): NodeMaterialConnectionPoint;
  71198. /**
  71199. * Gets the output component
  71200. */
  71201. get output(): NodeMaterialConnectionPoint;
  71202. protected _buildBlock(state: NodeMaterialBuildState): this;
  71203. }
  71204. }
  71205. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  71206. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71207. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71208. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71209. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71210. /**
  71211. * Block used to get a random number
  71212. */
  71213. export class RandomNumberBlock extends NodeMaterialBlock {
  71214. /**
  71215. * Creates a new RandomNumberBlock
  71216. * @param name defines the block name
  71217. */
  71218. constructor(name: string);
  71219. /**
  71220. * Gets the current class name
  71221. * @returns the class name
  71222. */
  71223. getClassName(): string;
  71224. /**
  71225. * Gets the seed input component
  71226. */
  71227. get seed(): NodeMaterialConnectionPoint;
  71228. /**
  71229. * Gets the output component
  71230. */
  71231. get output(): NodeMaterialConnectionPoint;
  71232. protected _buildBlock(state: NodeMaterialBuildState): this;
  71233. }
  71234. }
  71235. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  71236. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71237. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71238. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71239. /**
  71240. * Block used to compute arc tangent of 2 values
  71241. */
  71242. export class ArcTan2Block extends NodeMaterialBlock {
  71243. /**
  71244. * Creates a new ArcTan2Block
  71245. * @param name defines the block name
  71246. */
  71247. constructor(name: string);
  71248. /**
  71249. * Gets the current class name
  71250. * @returns the class name
  71251. */
  71252. getClassName(): string;
  71253. /**
  71254. * Gets the x operand input component
  71255. */
  71256. get x(): NodeMaterialConnectionPoint;
  71257. /**
  71258. * Gets the y operand input component
  71259. */
  71260. get y(): NodeMaterialConnectionPoint;
  71261. /**
  71262. * Gets the output component
  71263. */
  71264. get output(): NodeMaterialConnectionPoint;
  71265. protected _buildBlock(state: NodeMaterialBuildState): this;
  71266. }
  71267. }
  71268. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  71269. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71270. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71271. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71272. /**
  71273. * Block used to smooth step a value
  71274. */
  71275. export class SmoothStepBlock extends NodeMaterialBlock {
  71276. /**
  71277. * Creates a new SmoothStepBlock
  71278. * @param name defines the block name
  71279. */
  71280. constructor(name: string);
  71281. /**
  71282. * Gets the current class name
  71283. * @returns the class name
  71284. */
  71285. getClassName(): string;
  71286. /**
  71287. * Gets the value operand input component
  71288. */
  71289. get value(): NodeMaterialConnectionPoint;
  71290. /**
  71291. * Gets the first edge operand input component
  71292. */
  71293. get edge0(): NodeMaterialConnectionPoint;
  71294. /**
  71295. * Gets the second edge operand input component
  71296. */
  71297. get edge1(): NodeMaterialConnectionPoint;
  71298. /**
  71299. * Gets the output component
  71300. */
  71301. get output(): NodeMaterialConnectionPoint;
  71302. protected _buildBlock(state: NodeMaterialBuildState): this;
  71303. }
  71304. }
  71305. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  71306. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71307. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71308. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71309. /**
  71310. * Block used to get the reciprocal (1 / x) of a value
  71311. */
  71312. export class ReciprocalBlock extends NodeMaterialBlock {
  71313. /**
  71314. * Creates a new ReciprocalBlock
  71315. * @param name defines the block name
  71316. */
  71317. constructor(name: string);
  71318. /**
  71319. * Gets the current class name
  71320. * @returns the class name
  71321. */
  71322. getClassName(): string;
  71323. /**
  71324. * Gets the input component
  71325. */
  71326. get input(): NodeMaterialConnectionPoint;
  71327. /**
  71328. * Gets the output component
  71329. */
  71330. get output(): NodeMaterialConnectionPoint;
  71331. protected _buildBlock(state: NodeMaterialBuildState): this;
  71332. }
  71333. }
  71334. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  71335. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71336. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71337. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71338. /**
  71339. * Block used to replace a color by another one
  71340. */
  71341. export class ReplaceColorBlock extends NodeMaterialBlock {
  71342. /**
  71343. * Creates a new ReplaceColorBlock
  71344. * @param name defines the block name
  71345. */
  71346. constructor(name: string);
  71347. /**
  71348. * Gets the current class name
  71349. * @returns the class name
  71350. */
  71351. getClassName(): string;
  71352. /**
  71353. * Gets the value input component
  71354. */
  71355. get value(): NodeMaterialConnectionPoint;
  71356. /**
  71357. * Gets the reference input component
  71358. */
  71359. get reference(): NodeMaterialConnectionPoint;
  71360. /**
  71361. * Gets the distance input component
  71362. */
  71363. get distance(): NodeMaterialConnectionPoint;
  71364. /**
  71365. * Gets the replacement input component
  71366. */
  71367. get replacement(): NodeMaterialConnectionPoint;
  71368. /**
  71369. * Gets the output component
  71370. */
  71371. get output(): NodeMaterialConnectionPoint;
  71372. protected _buildBlock(state: NodeMaterialBuildState): this;
  71373. }
  71374. }
  71375. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  71376. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71377. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71378. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71379. /**
  71380. * Block used to posterize a value
  71381. * @see https://en.wikipedia.org/wiki/Posterization
  71382. */
  71383. export class PosterizeBlock extends NodeMaterialBlock {
  71384. /**
  71385. * Creates a new PosterizeBlock
  71386. * @param name defines the block name
  71387. */
  71388. constructor(name: string);
  71389. /**
  71390. * Gets the current class name
  71391. * @returns the class name
  71392. */
  71393. getClassName(): string;
  71394. /**
  71395. * Gets the value input component
  71396. */
  71397. get value(): NodeMaterialConnectionPoint;
  71398. /**
  71399. * Gets the steps input component
  71400. */
  71401. get steps(): NodeMaterialConnectionPoint;
  71402. /**
  71403. * Gets the output component
  71404. */
  71405. get output(): NodeMaterialConnectionPoint;
  71406. protected _buildBlock(state: NodeMaterialBuildState): this;
  71407. }
  71408. }
  71409. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  71410. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71411. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71412. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71413. import { Scene } from "babylonjs/scene";
  71414. /**
  71415. * Operations supported by the Wave block
  71416. */
  71417. export enum WaveBlockKind {
  71418. /** SawTooth */
  71419. SawTooth = 0,
  71420. /** Square */
  71421. Square = 1,
  71422. /** Triangle */
  71423. Triangle = 2
  71424. }
  71425. /**
  71426. * Block used to apply wave operation to floats
  71427. */
  71428. export class WaveBlock extends NodeMaterialBlock {
  71429. /**
  71430. * Gets or sets the kibnd of wave to be applied by the block
  71431. */
  71432. kind: WaveBlockKind;
  71433. /**
  71434. * Creates a new WaveBlock
  71435. * @param name defines the block name
  71436. */
  71437. constructor(name: string);
  71438. /**
  71439. * Gets the current class name
  71440. * @returns the class name
  71441. */
  71442. getClassName(): string;
  71443. /**
  71444. * Gets the input component
  71445. */
  71446. get input(): NodeMaterialConnectionPoint;
  71447. /**
  71448. * Gets the output component
  71449. */
  71450. get output(): NodeMaterialConnectionPoint;
  71451. protected _buildBlock(state: NodeMaterialBuildState): this;
  71452. serialize(): any;
  71453. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  71454. }
  71455. }
  71456. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  71457. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71458. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71459. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71460. import { Color3 } from "babylonjs/Maths/math.color";
  71461. import { Scene } from "babylonjs/scene";
  71462. import { Observable } from "babylonjs/Misc/observable";
  71463. /**
  71464. * Class used to store a color step for the GradientBlock
  71465. */
  71466. export class GradientBlockColorStep {
  71467. private _step;
  71468. /**
  71469. * Gets value indicating which step this color is associated with (between 0 and 1)
  71470. */
  71471. get step(): number;
  71472. /**
  71473. * Sets a value indicating which step this color is associated with (between 0 and 1)
  71474. */
  71475. set step(val: number);
  71476. private _color;
  71477. /**
  71478. * Gets the color associated with this step
  71479. */
  71480. get color(): Color3;
  71481. /**
  71482. * Sets the color associated with this step
  71483. */
  71484. set color(val: Color3);
  71485. /**
  71486. * Creates a new GradientBlockColorStep
  71487. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  71488. * @param color defines the color associated with this step
  71489. */
  71490. constructor(step: number, color: Color3);
  71491. }
  71492. /**
  71493. * Block used to return a color from a gradient based on an input value between 0 and 1
  71494. */
  71495. export class GradientBlock extends NodeMaterialBlock {
  71496. /**
  71497. * Gets or sets the list of color steps
  71498. */
  71499. colorSteps: GradientBlockColorStep[];
  71500. /** Gets an observable raised when the value is changed */
  71501. onValueChangedObservable: Observable<GradientBlock>;
  71502. /** calls observable when the value is changed*/
  71503. colorStepsUpdated(): void;
  71504. /**
  71505. * Creates a new GradientBlock
  71506. * @param name defines the block name
  71507. */
  71508. constructor(name: string);
  71509. /**
  71510. * Gets the current class name
  71511. * @returns the class name
  71512. */
  71513. getClassName(): string;
  71514. /**
  71515. * Gets the gradient input component
  71516. */
  71517. get gradient(): NodeMaterialConnectionPoint;
  71518. /**
  71519. * Gets the output component
  71520. */
  71521. get output(): NodeMaterialConnectionPoint;
  71522. private _writeColorConstant;
  71523. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  71524. serialize(): any;
  71525. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  71526. protected _dumpPropertiesCode(): string;
  71527. }
  71528. }
  71529. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  71530. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71531. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71532. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71533. /**
  71534. * Block used to normalize lerp between 2 values
  71535. */
  71536. export class NLerpBlock extends NodeMaterialBlock {
  71537. /**
  71538. * Creates a new NLerpBlock
  71539. * @param name defines the block name
  71540. */
  71541. constructor(name: string);
  71542. /**
  71543. * Gets the current class name
  71544. * @returns the class name
  71545. */
  71546. getClassName(): string;
  71547. /**
  71548. * Gets the left operand input component
  71549. */
  71550. get left(): NodeMaterialConnectionPoint;
  71551. /**
  71552. * Gets the right operand input component
  71553. */
  71554. get right(): NodeMaterialConnectionPoint;
  71555. /**
  71556. * Gets the gradient operand input component
  71557. */
  71558. get gradient(): NodeMaterialConnectionPoint;
  71559. /**
  71560. * Gets the output component
  71561. */
  71562. get output(): NodeMaterialConnectionPoint;
  71563. protected _buildBlock(state: NodeMaterialBuildState): this;
  71564. }
  71565. }
  71566. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  71567. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71568. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71569. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71570. import { Scene } from "babylonjs/scene";
  71571. /**
  71572. * block used to Generate a Worley Noise 3D Noise Pattern
  71573. */
  71574. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  71575. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  71576. manhattanDistance: boolean;
  71577. /**
  71578. * Creates a new WorleyNoise3DBlock
  71579. * @param name defines the block name
  71580. */
  71581. constructor(name: string);
  71582. /**
  71583. * Gets the current class name
  71584. * @returns the class name
  71585. */
  71586. getClassName(): string;
  71587. /**
  71588. * Gets the seed input component
  71589. */
  71590. get seed(): NodeMaterialConnectionPoint;
  71591. /**
  71592. * Gets the jitter input component
  71593. */
  71594. get jitter(): NodeMaterialConnectionPoint;
  71595. /**
  71596. * Gets the output component
  71597. */
  71598. get output(): NodeMaterialConnectionPoint;
  71599. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  71600. /**
  71601. * Exposes the properties to the UI?
  71602. */
  71603. protected _dumpPropertiesCode(): string;
  71604. /**
  71605. * Exposes the properties to the Seralize?
  71606. */
  71607. serialize(): any;
  71608. /**
  71609. * Exposes the properties to the deseralize?
  71610. */
  71611. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  71612. }
  71613. }
  71614. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  71615. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71616. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71617. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71618. /**
  71619. * block used to Generate a Simplex Perlin 3d Noise Pattern
  71620. */
  71621. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  71622. /**
  71623. * Creates a new SimplexPerlin3DBlock
  71624. * @param name defines the block name
  71625. */
  71626. constructor(name: string);
  71627. /**
  71628. * Gets the current class name
  71629. * @returns the class name
  71630. */
  71631. getClassName(): string;
  71632. /**
  71633. * Gets the seed operand input component
  71634. */
  71635. get seed(): NodeMaterialConnectionPoint;
  71636. /**
  71637. * Gets the output component
  71638. */
  71639. get output(): NodeMaterialConnectionPoint;
  71640. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  71641. }
  71642. }
  71643. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  71644. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71645. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71646. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71647. /**
  71648. * Block used to blend normals
  71649. */
  71650. export class NormalBlendBlock extends NodeMaterialBlock {
  71651. /**
  71652. * Creates a new NormalBlendBlock
  71653. * @param name defines the block name
  71654. */
  71655. constructor(name: string);
  71656. /**
  71657. * Gets the current class name
  71658. * @returns the class name
  71659. */
  71660. getClassName(): string;
  71661. /**
  71662. * Gets the first input component
  71663. */
  71664. get normalMap0(): NodeMaterialConnectionPoint;
  71665. /**
  71666. * Gets the second input component
  71667. */
  71668. get normalMap1(): NodeMaterialConnectionPoint;
  71669. /**
  71670. * Gets the output component
  71671. */
  71672. get output(): NodeMaterialConnectionPoint;
  71673. protected _buildBlock(state: NodeMaterialBuildState): this;
  71674. }
  71675. }
  71676. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  71677. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71678. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71679. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71680. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  71681. /**
  71682. * Block used to rotate a 2d vector by a given angle
  71683. */
  71684. export class Rotate2dBlock extends NodeMaterialBlock {
  71685. /**
  71686. * Creates a new Rotate2dBlock
  71687. * @param name defines the block name
  71688. */
  71689. constructor(name: string);
  71690. /**
  71691. * Gets the current class name
  71692. * @returns the class name
  71693. */
  71694. getClassName(): string;
  71695. /**
  71696. * Gets the input vector
  71697. */
  71698. get input(): NodeMaterialConnectionPoint;
  71699. /**
  71700. * Gets the input angle
  71701. */
  71702. get angle(): NodeMaterialConnectionPoint;
  71703. /**
  71704. * Gets the output component
  71705. */
  71706. get output(): NodeMaterialConnectionPoint;
  71707. autoConfigure(material: NodeMaterial): void;
  71708. protected _buildBlock(state: NodeMaterialBuildState): this;
  71709. }
  71710. }
  71711. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  71712. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71713. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71714. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71715. /**
  71716. * Block used to get the reflected vector from a direction and a normal
  71717. */
  71718. export class ReflectBlock extends NodeMaterialBlock {
  71719. /**
  71720. * Creates a new ReflectBlock
  71721. * @param name defines the block name
  71722. */
  71723. constructor(name: string);
  71724. /**
  71725. * Gets the current class name
  71726. * @returns the class name
  71727. */
  71728. getClassName(): string;
  71729. /**
  71730. * Gets the incident component
  71731. */
  71732. get incident(): NodeMaterialConnectionPoint;
  71733. /**
  71734. * Gets the normal component
  71735. */
  71736. get normal(): NodeMaterialConnectionPoint;
  71737. /**
  71738. * Gets the output component
  71739. */
  71740. get output(): NodeMaterialConnectionPoint;
  71741. protected _buildBlock(state: NodeMaterialBuildState): this;
  71742. }
  71743. }
  71744. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  71745. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71746. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71747. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71748. /**
  71749. * Block used to get the refracted vector from a direction and a normal
  71750. */
  71751. export class RefractBlock extends NodeMaterialBlock {
  71752. /**
  71753. * Creates a new RefractBlock
  71754. * @param name defines the block name
  71755. */
  71756. constructor(name: string);
  71757. /**
  71758. * Gets the current class name
  71759. * @returns the class name
  71760. */
  71761. getClassName(): string;
  71762. /**
  71763. * Gets the incident component
  71764. */
  71765. get incident(): NodeMaterialConnectionPoint;
  71766. /**
  71767. * Gets the normal component
  71768. */
  71769. get normal(): NodeMaterialConnectionPoint;
  71770. /**
  71771. * Gets the index of refraction component
  71772. */
  71773. get ior(): NodeMaterialConnectionPoint;
  71774. /**
  71775. * Gets the output component
  71776. */
  71777. get output(): NodeMaterialConnectionPoint;
  71778. protected _buildBlock(state: NodeMaterialBuildState): this;
  71779. }
  71780. }
  71781. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  71782. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71783. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71784. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71785. /**
  71786. * Block used to desaturate a color
  71787. */
  71788. export class DesaturateBlock extends NodeMaterialBlock {
  71789. /**
  71790. * Creates a new DesaturateBlock
  71791. * @param name defines the block name
  71792. */
  71793. constructor(name: string);
  71794. /**
  71795. * Gets the current class name
  71796. * @returns the class name
  71797. */
  71798. getClassName(): string;
  71799. /**
  71800. * Gets the color operand input component
  71801. */
  71802. get color(): NodeMaterialConnectionPoint;
  71803. /**
  71804. * Gets the level operand input component
  71805. */
  71806. get level(): NodeMaterialConnectionPoint;
  71807. /**
  71808. * Gets the output component
  71809. */
  71810. get output(): NodeMaterialConnectionPoint;
  71811. protected _buildBlock(state: NodeMaterialBuildState): this;
  71812. }
  71813. }
  71814. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  71815. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71816. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71817. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  71818. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  71819. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71820. import { Nullable } from "babylonjs/types";
  71821. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  71822. import { Mesh } from "babylonjs/Meshes/mesh";
  71823. import { SubMesh } from "babylonjs/Meshes/subMesh";
  71824. import { Effect } from "babylonjs/Materials/effect";
  71825. import { Scene } from "babylonjs/scene";
  71826. /**
  71827. * Block used to implement the reflection module of the PBR material
  71828. */
  71829. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  71830. /** @hidden */
  71831. _defineLODReflectionAlpha: string;
  71832. /** @hidden */
  71833. _defineLinearSpecularReflection: string;
  71834. private _vEnvironmentIrradianceName;
  71835. /** @hidden */
  71836. _vReflectionMicrosurfaceInfosName: string;
  71837. /** @hidden */
  71838. _vReflectionInfosName: string;
  71839. /** @hidden */
  71840. _vReflectionFilteringInfoName: string;
  71841. private _scene;
  71842. /**
  71843. * The properties below are set by the main PBR block prior to calling methods of this class.
  71844. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  71845. * It's less burden on the user side in the editor part.
  71846. */
  71847. /** @hidden */
  71848. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  71849. /** @hidden */
  71850. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  71851. /** @hidden */
  71852. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  71853. /** @hidden */
  71854. viewConnectionPoint: NodeMaterialConnectionPoint;
  71855. /**
  71856. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  71857. * diffuse part of the IBL.
  71858. */
  71859. useSphericalHarmonics: boolean;
  71860. /**
  71861. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  71862. */
  71863. forceIrradianceInFragment: boolean;
  71864. /**
  71865. * Create a new ReflectionBlock
  71866. * @param name defines the block name
  71867. */
  71868. constructor(name: string);
  71869. /**
  71870. * Gets the current class name
  71871. * @returns the class name
  71872. */
  71873. getClassName(): string;
  71874. /**
  71875. * Gets the position input component
  71876. */
  71877. get position(): NodeMaterialConnectionPoint;
  71878. /**
  71879. * Gets the world position input component
  71880. */
  71881. get worldPosition(): NodeMaterialConnectionPoint;
  71882. /**
  71883. * Gets the world normal input component
  71884. */
  71885. get worldNormal(): NodeMaterialConnectionPoint;
  71886. /**
  71887. * Gets the world input component
  71888. */
  71889. get world(): NodeMaterialConnectionPoint;
  71890. /**
  71891. * Gets the camera (or eye) position component
  71892. */
  71893. get cameraPosition(): NodeMaterialConnectionPoint;
  71894. /**
  71895. * Gets the view input component
  71896. */
  71897. get view(): NodeMaterialConnectionPoint;
  71898. /**
  71899. * Gets the color input component
  71900. */
  71901. get color(): NodeMaterialConnectionPoint;
  71902. /**
  71903. * Gets the reflection object output component
  71904. */
  71905. get reflection(): NodeMaterialConnectionPoint;
  71906. /**
  71907. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  71908. */
  71909. get hasTexture(): boolean;
  71910. /**
  71911. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  71912. */
  71913. get reflectionColor(): string;
  71914. protected _getTexture(): Nullable<BaseTexture>;
  71915. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  71916. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  71917. /**
  71918. * Gets the code to inject in the vertex shader
  71919. * @param state current state of the node material building
  71920. * @returns the shader code
  71921. */
  71922. handleVertexSide(state: NodeMaterialBuildState): string;
  71923. /**
  71924. * Gets the main code of the block (fragment side)
  71925. * @param state current state of the node material building
  71926. * @param normalVarName name of the existing variable corresponding to the normal
  71927. * @returns the shader code
  71928. */
  71929. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  71930. protected _buildBlock(state: NodeMaterialBuildState): this;
  71931. protected _dumpPropertiesCode(): string;
  71932. serialize(): any;
  71933. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  71934. }
  71935. }
  71936. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  71937. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  71938. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  71939. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  71940. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  71941. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71942. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  71943. import { Scene } from "babylonjs/scene";
  71944. import { Nullable } from "babylonjs/types";
  71945. /**
  71946. * Block used to implement the sheen module of the PBR material
  71947. */
  71948. export class SheenBlock extends NodeMaterialBlock {
  71949. /**
  71950. * Create a new SheenBlock
  71951. * @param name defines the block name
  71952. */
  71953. constructor(name: string);
  71954. /**
  71955. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  71956. * It allows the strength of the sheen effect to not depend on the base color of the material,
  71957. * making it easier to setup and tweak the effect
  71958. */
  71959. albedoScaling: boolean;
  71960. /**
  71961. * Defines if the sheen is linked to the sheen color.
  71962. */
  71963. linkSheenWithAlbedo: boolean;
  71964. /**
  71965. * Initialize the block and prepare the context for build
  71966. * @param state defines the state that will be used for the build
  71967. */
  71968. initialize(state: NodeMaterialBuildState): void;
  71969. /**
  71970. * Gets the current class name
  71971. * @returns the class name
  71972. */
  71973. getClassName(): string;
  71974. /**
  71975. * Gets the intensity input component
  71976. */
  71977. get intensity(): NodeMaterialConnectionPoint;
  71978. /**
  71979. * Gets the color input component
  71980. */
  71981. get color(): NodeMaterialConnectionPoint;
  71982. /**
  71983. * Gets the roughness input component
  71984. */
  71985. get roughness(): NodeMaterialConnectionPoint;
  71986. /**
  71987. * Gets the sheen object output component
  71988. */
  71989. get sheen(): NodeMaterialConnectionPoint;
  71990. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  71991. /**
  71992. * Gets the main code of the block (fragment side)
  71993. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  71994. * @returns the shader code
  71995. */
  71996. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  71997. protected _buildBlock(state: NodeMaterialBuildState): this;
  71998. protected _dumpPropertiesCode(): string;
  71999. serialize(): any;
  72000. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  72001. }
  72002. }
  72003. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  72004. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  72005. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72006. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72007. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72008. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72009. /**
  72010. * Block used to implement the anisotropy module of the PBR material
  72011. */
  72012. export class AnisotropyBlock extends NodeMaterialBlock {
  72013. /**
  72014. * The two properties below are set by the main PBR block prior to calling methods of this class.
  72015. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  72016. * It's less burden on the user side in the editor part.
  72017. */
  72018. /** @hidden */
  72019. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  72020. /** @hidden */
  72021. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  72022. /**
  72023. * Create a new AnisotropyBlock
  72024. * @param name defines the block name
  72025. */
  72026. constructor(name: string);
  72027. /**
  72028. * Initialize the block and prepare the context for build
  72029. * @param state defines the state that will be used for the build
  72030. */
  72031. initialize(state: NodeMaterialBuildState): void;
  72032. /**
  72033. * Gets the current class name
  72034. * @returns the class name
  72035. */
  72036. getClassName(): string;
  72037. /**
  72038. * Gets the intensity input component
  72039. */
  72040. get intensity(): NodeMaterialConnectionPoint;
  72041. /**
  72042. * Gets the direction input component
  72043. */
  72044. get direction(): NodeMaterialConnectionPoint;
  72045. /**
  72046. * Gets the uv input component
  72047. */
  72048. get uv(): NodeMaterialConnectionPoint;
  72049. /**
  72050. * Gets the worldTangent input component
  72051. */
  72052. get worldTangent(): NodeMaterialConnectionPoint;
  72053. /**
  72054. * Gets the anisotropy object output component
  72055. */
  72056. get anisotropy(): NodeMaterialConnectionPoint;
  72057. private _generateTBNSpace;
  72058. /**
  72059. * Gets the main code of the block (fragment side)
  72060. * @param state current state of the node material building
  72061. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  72062. * @returns the shader code
  72063. */
  72064. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  72065. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  72066. protected _buildBlock(state: NodeMaterialBuildState): this;
  72067. }
  72068. }
  72069. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  72070. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72071. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72072. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72073. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  72074. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72075. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  72076. import { Scene } from "babylonjs/scene";
  72077. import { Nullable } from "babylonjs/types";
  72078. import { Mesh } from "babylonjs/Meshes/mesh";
  72079. import { SubMesh } from "babylonjs/Meshes/subMesh";
  72080. import { Effect } from "babylonjs/Materials/effect";
  72081. /**
  72082. * Block used to implement the clear coat module of the PBR material
  72083. */
  72084. export class ClearCoatBlock extends NodeMaterialBlock {
  72085. private _scene;
  72086. /**
  72087. * Create a new ClearCoatBlock
  72088. * @param name defines the block name
  72089. */
  72090. constructor(name: string);
  72091. /**
  72092. * Defines if the F0 value should be remapped to account for the interface change in the material.
  72093. */
  72094. remapF0OnInterfaceChange: boolean;
  72095. /**
  72096. * Initialize the block and prepare the context for build
  72097. * @param state defines the state that will be used for the build
  72098. */
  72099. initialize(state: NodeMaterialBuildState): void;
  72100. /**
  72101. * Gets the current class name
  72102. * @returns the class name
  72103. */
  72104. getClassName(): string;
  72105. /**
  72106. * Gets the intensity input component
  72107. */
  72108. get intensity(): NodeMaterialConnectionPoint;
  72109. /**
  72110. * Gets the roughness input component
  72111. */
  72112. get roughness(): NodeMaterialConnectionPoint;
  72113. /**
  72114. * Gets the ior input component
  72115. */
  72116. get indexOfRefraction(): NodeMaterialConnectionPoint;
  72117. /**
  72118. * Gets the bump texture input component
  72119. */
  72120. get normalMapColor(): NodeMaterialConnectionPoint;
  72121. /**
  72122. * Gets the uv input component
  72123. */
  72124. get uv(): NodeMaterialConnectionPoint;
  72125. /**
  72126. * Gets the tint color input component
  72127. */
  72128. get tintColor(): NodeMaterialConnectionPoint;
  72129. /**
  72130. * Gets the tint "at distance" input component
  72131. */
  72132. get tintAtDistance(): NodeMaterialConnectionPoint;
  72133. /**
  72134. * Gets the tint thickness input component
  72135. */
  72136. get tintThickness(): NodeMaterialConnectionPoint;
  72137. /**
  72138. * Gets the world tangent input component
  72139. */
  72140. get worldTangent(): NodeMaterialConnectionPoint;
  72141. /**
  72142. * Gets the clear coat object output component
  72143. */
  72144. get clearcoat(): NodeMaterialConnectionPoint;
  72145. autoConfigure(material: NodeMaterial): void;
  72146. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  72147. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  72148. private _generateTBNSpace;
  72149. /**
  72150. * Gets the main code of the block (fragment side)
  72151. * @param state current state of the node material building
  72152. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  72153. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  72154. * @param worldPosVarName name of the variable holding the world position
  72155. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  72156. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  72157. * @param worldNormalVarName name of the variable holding the world normal
  72158. * @returns the shader code
  72159. */
  72160. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  72161. protected _buildBlock(state: NodeMaterialBuildState): this;
  72162. protected _dumpPropertiesCode(): string;
  72163. serialize(): any;
  72164. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  72165. }
  72166. }
  72167. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  72168. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72169. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72170. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72171. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  72172. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72173. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  72174. import { Nullable } from "babylonjs/types";
  72175. /**
  72176. * Block used to implement the sub surface module of the PBR material
  72177. */
  72178. export class SubSurfaceBlock extends NodeMaterialBlock {
  72179. /**
  72180. * Create a new SubSurfaceBlock
  72181. * @param name defines the block name
  72182. */
  72183. constructor(name: string);
  72184. /**
  72185. * Initialize the block and prepare the context for build
  72186. * @param state defines the state that will be used for the build
  72187. */
  72188. initialize(state: NodeMaterialBuildState): void;
  72189. /**
  72190. * Gets the current class name
  72191. * @returns the class name
  72192. */
  72193. getClassName(): string;
  72194. /**
  72195. * Gets the thickness component
  72196. */
  72197. get thickness(): NodeMaterialConnectionPoint;
  72198. /**
  72199. * Gets the tint color input component
  72200. */
  72201. get tintColor(): NodeMaterialConnectionPoint;
  72202. /**
  72203. * Gets the translucency intensity input component
  72204. */
  72205. get translucencyIntensity(): NodeMaterialConnectionPoint;
  72206. /**
  72207. * Gets the translucency diffusion distance input component
  72208. */
  72209. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  72210. /**
  72211. * Gets the refraction object parameters
  72212. */
  72213. get refraction(): NodeMaterialConnectionPoint;
  72214. /**
  72215. * Gets the sub surface object output component
  72216. */
  72217. get subsurface(): NodeMaterialConnectionPoint;
  72218. autoConfigure(material: NodeMaterial): void;
  72219. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  72220. /**
  72221. * Gets the main code of the block (fragment side)
  72222. * @param state current state of the node material building
  72223. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  72224. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  72225. * @param worldPosVarName name of the variable holding the world position
  72226. * @returns the shader code
  72227. */
  72228. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  72229. protected _buildBlock(state: NodeMaterialBuildState): this;
  72230. }
  72231. }
  72232. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  72233. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72234. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72235. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72236. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  72237. import { Light } from "babylonjs/Lights/light";
  72238. import { Nullable } from "babylonjs/types";
  72239. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72240. import { Effect } from "babylonjs/Materials/effect";
  72241. import { Mesh } from "babylonjs/Meshes/mesh";
  72242. import { Scene } from "babylonjs/scene";
  72243. /**
  72244. * Block used to implement the PBR metallic/roughness model
  72245. */
  72246. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  72247. /**
  72248. * Gets or sets the light associated with this block
  72249. */
  72250. light: Nullable<Light>;
  72251. private _lightId;
  72252. private _scene;
  72253. private _environmentBRDFTexture;
  72254. private _environmentBrdfSamplerName;
  72255. private _vNormalWName;
  72256. private _invertNormalName;
  72257. private _metallicReflectanceColor;
  72258. private _metallicF0Factor;
  72259. private _vMetallicReflectanceFactorsName;
  72260. /**
  72261. * Create a new ReflectionBlock
  72262. * @param name defines the block name
  72263. */
  72264. constructor(name: string);
  72265. /**
  72266. * Intensity of the direct lights e.g. the four lights available in your scene.
  72267. * This impacts both the direct diffuse and specular highlights.
  72268. */
  72269. directIntensity: number;
  72270. /**
  72271. * Intensity of the environment e.g. how much the environment will light the object
  72272. * either through harmonics for rough material or through the refelction for shiny ones.
  72273. */
  72274. environmentIntensity: number;
  72275. /**
  72276. * This is a special control allowing the reduction of the specular highlights coming from the
  72277. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  72278. */
  72279. specularIntensity: number;
  72280. /**
  72281. * Defines the falloff type used in this material.
  72282. * It by default is Physical.
  72283. */
  72284. lightFalloff: number;
  72285. /**
  72286. * Specifies that alpha test should be used
  72287. */
  72288. useAlphaTest: boolean;
  72289. /**
  72290. * Defines the alpha limits in alpha test mode.
  72291. */
  72292. alphaTestCutoff: number;
  72293. /**
  72294. * Specifies that alpha blending should be used
  72295. */
  72296. useAlphaBlending: boolean;
  72297. /**
  72298. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  72299. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  72300. */
  72301. useRadianceOverAlpha: boolean;
  72302. /**
  72303. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  72304. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  72305. */
  72306. useSpecularOverAlpha: boolean;
  72307. /**
  72308. * Enables specular anti aliasing in the PBR shader.
  72309. * It will both interacts on the Geometry for analytical and IBL lighting.
  72310. * It also prefilter the roughness map based on the bump values.
  72311. */
  72312. enableSpecularAntiAliasing: boolean;
  72313. /**
  72314. * Enables realtime filtering on the texture.
  72315. */
  72316. realTimeFiltering: boolean;
  72317. /**
  72318. * Quality switch for realtime filtering
  72319. */
  72320. realTimeFilteringQuality: number;
  72321. /**
  72322. * Defines if the material uses energy conservation.
  72323. */
  72324. useEnergyConservation: boolean;
  72325. /**
  72326. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  72327. * too much the area relying on ambient texture to define their ambient occlusion.
  72328. */
  72329. useRadianceOcclusion: boolean;
  72330. /**
  72331. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  72332. * makes the reflect vector face the model (under horizon).
  72333. */
  72334. useHorizonOcclusion: boolean;
  72335. /**
  72336. * If set to true, no lighting calculations will be applied.
  72337. */
  72338. unlit: boolean;
  72339. /**
  72340. * Force normal to face away from face.
  72341. */
  72342. forceNormalForward: boolean;
  72343. /**
  72344. * Defines the material debug mode.
  72345. * It helps seeing only some components of the material while troubleshooting.
  72346. */
  72347. debugMode: number;
  72348. /**
  72349. * Specify from where on screen the debug mode should start.
  72350. * The value goes from -1 (full screen) to 1 (not visible)
  72351. * It helps with side by side comparison against the final render
  72352. * This defaults to 0
  72353. */
  72354. debugLimit: number;
  72355. /**
  72356. * As the default viewing range might not be enough (if the ambient is really small for instance)
  72357. * You can use the factor to better multiply the final value.
  72358. */
  72359. debugFactor: number;
  72360. /**
  72361. * Initialize the block and prepare the context for build
  72362. * @param state defines the state that will be used for the build
  72363. */
  72364. initialize(state: NodeMaterialBuildState): void;
  72365. /**
  72366. * Gets the current class name
  72367. * @returns the class name
  72368. */
  72369. getClassName(): string;
  72370. /**
  72371. * Gets the world position input component
  72372. */
  72373. get worldPosition(): NodeMaterialConnectionPoint;
  72374. /**
  72375. * Gets the world normal input component
  72376. */
  72377. get worldNormal(): NodeMaterialConnectionPoint;
  72378. /**
  72379. * Gets the view matrix parameter
  72380. */
  72381. get view(): NodeMaterialConnectionPoint;
  72382. /**
  72383. * Gets the camera position input component
  72384. */
  72385. get cameraPosition(): NodeMaterialConnectionPoint;
  72386. /**
  72387. * Gets the perturbed normal input component
  72388. */
  72389. get perturbedNormal(): NodeMaterialConnectionPoint;
  72390. /**
  72391. * Gets the base color input component
  72392. */
  72393. get baseColor(): NodeMaterialConnectionPoint;
  72394. /**
  72395. * Gets the metallic input component
  72396. */
  72397. get metallic(): NodeMaterialConnectionPoint;
  72398. /**
  72399. * Gets the roughness input component
  72400. */
  72401. get roughness(): NodeMaterialConnectionPoint;
  72402. /**
  72403. * Gets the ambient occlusion input component
  72404. */
  72405. get ambientOcc(): NodeMaterialConnectionPoint;
  72406. /**
  72407. * Gets the opacity input component
  72408. */
  72409. get opacity(): NodeMaterialConnectionPoint;
  72410. /**
  72411. * Gets the index of refraction input component
  72412. */
  72413. get indexOfRefraction(): NodeMaterialConnectionPoint;
  72414. /**
  72415. * Gets the ambient color input component
  72416. */
  72417. get ambientColor(): NodeMaterialConnectionPoint;
  72418. /**
  72419. * Gets the reflection object parameters
  72420. */
  72421. get reflection(): NodeMaterialConnectionPoint;
  72422. /**
  72423. * Gets the clear coat object parameters
  72424. */
  72425. get clearcoat(): NodeMaterialConnectionPoint;
  72426. /**
  72427. * Gets the sheen object parameters
  72428. */
  72429. get sheen(): NodeMaterialConnectionPoint;
  72430. /**
  72431. * Gets the sub surface object parameters
  72432. */
  72433. get subsurface(): NodeMaterialConnectionPoint;
  72434. /**
  72435. * Gets the anisotropy object parameters
  72436. */
  72437. get anisotropy(): NodeMaterialConnectionPoint;
  72438. /**
  72439. * Gets the ambient output component
  72440. */
  72441. get ambientClr(): NodeMaterialConnectionPoint;
  72442. /**
  72443. * Gets the diffuse output component
  72444. */
  72445. get diffuseDir(): NodeMaterialConnectionPoint;
  72446. /**
  72447. * Gets the specular output component
  72448. */
  72449. get specularDir(): NodeMaterialConnectionPoint;
  72450. /**
  72451. * Gets the clear coat output component
  72452. */
  72453. get clearcoatDir(): NodeMaterialConnectionPoint;
  72454. /**
  72455. * Gets the sheen output component
  72456. */
  72457. get sheenDir(): NodeMaterialConnectionPoint;
  72458. /**
  72459. * Gets the indirect diffuse output component
  72460. */
  72461. get diffuseIndirect(): NodeMaterialConnectionPoint;
  72462. /**
  72463. * Gets the indirect specular output component
  72464. */
  72465. get specularIndirect(): NodeMaterialConnectionPoint;
  72466. /**
  72467. * Gets the indirect clear coat output component
  72468. */
  72469. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  72470. /**
  72471. * Gets the indirect sheen output component
  72472. */
  72473. get sheenIndirect(): NodeMaterialConnectionPoint;
  72474. /**
  72475. * Gets the refraction output component
  72476. */
  72477. get refraction(): NodeMaterialConnectionPoint;
  72478. /**
  72479. * Gets the global lighting output component
  72480. */
  72481. get lighting(): NodeMaterialConnectionPoint;
  72482. /**
  72483. * Gets the shadow output component
  72484. */
  72485. get shadow(): NodeMaterialConnectionPoint;
  72486. /**
  72487. * Gets the alpha output component
  72488. */
  72489. get alpha(): NodeMaterialConnectionPoint;
  72490. autoConfigure(material: NodeMaterial): void;
  72491. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  72492. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  72493. isReady(): boolean;
  72494. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  72495. private _injectVertexCode;
  72496. private _getAlbedoOpacityCode;
  72497. private _getAmbientOcclusionCode;
  72498. private _getReflectivityCode;
  72499. protected _buildBlock(state: NodeMaterialBuildState): this;
  72500. protected _dumpPropertiesCode(): string;
  72501. serialize(): any;
  72502. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  72503. }
  72504. }
  72505. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  72506. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  72507. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  72508. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  72509. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  72510. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  72511. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  72512. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  72513. }
  72514. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  72515. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  72516. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  72517. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  72518. }
  72519. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  72520. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  72521. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  72522. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72523. /**
  72524. * Block used to compute value of one parameter modulo another
  72525. */
  72526. export class ModBlock extends NodeMaterialBlock {
  72527. /**
  72528. * Creates a new ModBlock
  72529. * @param name defines the block name
  72530. */
  72531. constructor(name: string);
  72532. /**
  72533. * Gets the current class name
  72534. * @returns the class name
  72535. */
  72536. getClassName(): string;
  72537. /**
  72538. * Gets the left operand input component
  72539. */
  72540. get left(): NodeMaterialConnectionPoint;
  72541. /**
  72542. * Gets the right operand input component
  72543. */
  72544. get right(): NodeMaterialConnectionPoint;
  72545. /**
  72546. * Gets the output component
  72547. */
  72548. get output(): NodeMaterialConnectionPoint;
  72549. protected _buildBlock(state: NodeMaterialBuildState): this;
  72550. }
  72551. }
  72552. declare module "babylonjs/Materials/Node/Blocks/index" {
  72553. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  72554. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  72555. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  72556. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  72557. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  72558. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  72559. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  72560. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  72561. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  72562. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  72563. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  72564. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  72565. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  72566. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  72567. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  72568. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  72569. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  72570. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  72571. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  72572. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  72573. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  72574. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  72575. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  72576. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  72577. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  72578. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  72579. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  72580. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  72581. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  72582. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  72583. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  72584. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  72585. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  72586. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  72587. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  72588. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  72589. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  72590. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  72591. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  72592. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  72593. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  72594. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  72595. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  72596. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  72597. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  72598. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  72599. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  72600. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  72601. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  72602. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  72603. }
  72604. declare module "babylonjs/Materials/Node/Optimizers/index" {
  72605. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  72606. }
  72607. declare module "babylonjs/Materials/Node/index" {
  72608. export * from "babylonjs/Materials/Node/Enums/index";
  72609. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  72610. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  72611. export * from "babylonjs/Materials/Node/nodeMaterial";
  72612. export * from "babylonjs/Materials/Node/Blocks/index";
  72613. export * from "babylonjs/Materials/Node/Optimizers/index";
  72614. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  72615. }
  72616. declare module "babylonjs/Materials/index" {
  72617. export * from "babylonjs/Materials/Background/index";
  72618. export * from "babylonjs/Materials/colorCurves";
  72619. export * from "babylonjs/Materials/iEffectFallbacks";
  72620. export * from "babylonjs/Materials/effectFallbacks";
  72621. export * from "babylonjs/Materials/effect";
  72622. export * from "babylonjs/Materials/fresnelParameters";
  72623. export * from "babylonjs/Materials/imageProcessingConfiguration";
  72624. export * from "babylonjs/Materials/material";
  72625. export * from "babylonjs/Materials/materialDefines";
  72626. export * from "babylonjs/Materials/thinMaterialHelper";
  72627. export * from "babylonjs/Materials/materialHelper";
  72628. export * from "babylonjs/Materials/multiMaterial";
  72629. export * from "babylonjs/Materials/Occlusion/index";
  72630. export * from "babylonjs/Materials/PBR/index";
  72631. export * from "babylonjs/Materials/pushMaterial";
  72632. export * from "babylonjs/Materials/shaderMaterial";
  72633. export * from "babylonjs/Materials/standardMaterial";
  72634. export * from "babylonjs/Materials/Textures/index";
  72635. export * from "babylonjs/Materials/uniformBuffer";
  72636. export * from "babylonjs/Materials/materialFlags";
  72637. export * from "babylonjs/Materials/Node/index";
  72638. export * from "babylonjs/Materials/effectRenderer";
  72639. export * from "babylonjs/Materials/shadowDepthWrapper";
  72640. }
  72641. declare module "babylonjs/Maths/index" {
  72642. export * from "babylonjs/Maths/math.scalar";
  72643. export * from "babylonjs/Maths/math.functions";
  72644. export * from "babylonjs/Maths/math";
  72645. export * from "babylonjs/Maths/sphericalPolynomial";
  72646. }
  72647. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  72648. import { IDisposable } from "babylonjs/scene";
  72649. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  72650. /**
  72651. * Configuration for Draco compression
  72652. */
  72653. export interface IDracoCompressionConfiguration {
  72654. /**
  72655. * Configuration for the decoder.
  72656. */
  72657. decoder: {
  72658. /**
  72659. * The url to the WebAssembly module.
  72660. */
  72661. wasmUrl?: string;
  72662. /**
  72663. * The url to the WebAssembly binary.
  72664. */
  72665. wasmBinaryUrl?: string;
  72666. /**
  72667. * The url to the fallback JavaScript module.
  72668. */
  72669. fallbackUrl?: string;
  72670. };
  72671. }
  72672. /**
  72673. * Draco compression (https://google.github.io/draco/)
  72674. *
  72675. * This class wraps the Draco module.
  72676. *
  72677. * **Encoder**
  72678. *
  72679. * The encoder is not currently implemented.
  72680. *
  72681. * **Decoder**
  72682. *
  72683. * 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.
  72684. *
  72685. * To update the configuration, use the following code:
  72686. * ```javascript
  72687. * DracoCompression.Configuration = {
  72688. * decoder: {
  72689. * wasmUrl: "<url to the WebAssembly library>",
  72690. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  72691. * fallbackUrl: "<url to the fallback JavaScript library>",
  72692. * }
  72693. * };
  72694. * ```
  72695. *
  72696. * 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.
  72697. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  72698. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  72699. *
  72700. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  72701. * ```javascript
  72702. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  72703. * ```
  72704. *
  72705. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  72706. */
  72707. export class DracoCompression implements IDisposable {
  72708. private _workerPoolPromise?;
  72709. private _decoderModulePromise?;
  72710. /**
  72711. * The configuration. Defaults to the following urls:
  72712. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  72713. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  72714. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  72715. */
  72716. static Configuration: IDracoCompressionConfiguration;
  72717. /**
  72718. * Returns true if the decoder configuration is available.
  72719. */
  72720. static get DecoderAvailable(): boolean;
  72721. /**
  72722. * Default number of workers to create when creating the draco compression object.
  72723. */
  72724. static DefaultNumWorkers: number;
  72725. private static GetDefaultNumWorkers;
  72726. private static _Default;
  72727. /**
  72728. * Default instance for the draco compression object.
  72729. */
  72730. static get Default(): DracoCompression;
  72731. /**
  72732. * Constructor
  72733. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  72734. */
  72735. constructor(numWorkers?: number);
  72736. /**
  72737. * Stop all async operations and release resources.
  72738. */
  72739. dispose(): void;
  72740. /**
  72741. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  72742. * @returns a promise that resolves when ready
  72743. */
  72744. whenReadyAsync(): Promise<void>;
  72745. /**
  72746. * Decode Draco compressed mesh data to vertex data.
  72747. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  72748. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  72749. * @returns A promise that resolves with the decoded vertex data
  72750. */
  72751. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  72752. [kind: string]: number;
  72753. }): Promise<VertexData>;
  72754. }
  72755. }
  72756. declare module "babylonjs/Meshes/Compression/index" {
  72757. export * from "babylonjs/Meshes/Compression/dracoCompression";
  72758. }
  72759. declare module "babylonjs/Meshes/csg" {
  72760. import { Nullable } from "babylonjs/types";
  72761. import { Scene } from "babylonjs/scene";
  72762. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  72763. import { Mesh } from "babylonjs/Meshes/mesh";
  72764. import { Material } from "babylonjs/Materials/material";
  72765. /**
  72766. * Class for building Constructive Solid Geometry
  72767. */
  72768. export class CSG {
  72769. private polygons;
  72770. /**
  72771. * The world matrix
  72772. */
  72773. matrix: Matrix;
  72774. /**
  72775. * Stores the position
  72776. */
  72777. position: Vector3;
  72778. /**
  72779. * Stores the rotation
  72780. */
  72781. rotation: Vector3;
  72782. /**
  72783. * Stores the rotation quaternion
  72784. */
  72785. rotationQuaternion: Nullable<Quaternion>;
  72786. /**
  72787. * Stores the scaling vector
  72788. */
  72789. scaling: Vector3;
  72790. /**
  72791. * Convert the Mesh to CSG
  72792. * @param mesh The Mesh to convert to CSG
  72793. * @returns A new CSG from the Mesh
  72794. */
  72795. static FromMesh(mesh: Mesh): CSG;
  72796. /**
  72797. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  72798. * @param polygons Polygons used to construct a CSG solid
  72799. */
  72800. private static FromPolygons;
  72801. /**
  72802. * Clones, or makes a deep copy, of the CSG
  72803. * @returns A new CSG
  72804. */
  72805. clone(): CSG;
  72806. /**
  72807. * Unions this CSG with another CSG
  72808. * @param csg The CSG to union against this CSG
  72809. * @returns The unioned CSG
  72810. */
  72811. union(csg: CSG): CSG;
  72812. /**
  72813. * Unions this CSG with another CSG in place
  72814. * @param csg The CSG to union against this CSG
  72815. */
  72816. unionInPlace(csg: CSG): void;
  72817. /**
  72818. * Subtracts this CSG with another CSG
  72819. * @param csg The CSG to subtract against this CSG
  72820. * @returns A new CSG
  72821. */
  72822. subtract(csg: CSG): CSG;
  72823. /**
  72824. * Subtracts this CSG with another CSG in place
  72825. * @param csg The CSG to subtact against this CSG
  72826. */
  72827. subtractInPlace(csg: CSG): void;
  72828. /**
  72829. * Intersect this CSG with another CSG
  72830. * @param csg The CSG to intersect against this CSG
  72831. * @returns A new CSG
  72832. */
  72833. intersect(csg: CSG): CSG;
  72834. /**
  72835. * Intersects this CSG with another CSG in place
  72836. * @param csg The CSG to intersect against this CSG
  72837. */
  72838. intersectInPlace(csg: CSG): void;
  72839. /**
  72840. * Return a new CSG solid with solid and empty space switched. This solid is
  72841. * not modified.
  72842. * @returns A new CSG solid with solid and empty space switched
  72843. */
  72844. inverse(): CSG;
  72845. /**
  72846. * Inverses the CSG in place
  72847. */
  72848. inverseInPlace(): void;
  72849. /**
  72850. * This is used to keep meshes transformations so they can be restored
  72851. * when we build back a Babylon Mesh
  72852. * NB : All CSG operations are performed in world coordinates
  72853. * @param csg The CSG to copy the transform attributes from
  72854. * @returns This CSG
  72855. */
  72856. copyTransformAttributes(csg: CSG): CSG;
  72857. /**
  72858. * Build Raw mesh from CSG
  72859. * Coordinates here are in world space
  72860. * @param name The name of the mesh geometry
  72861. * @param scene The Scene
  72862. * @param keepSubMeshes Specifies if the submeshes should be kept
  72863. * @returns A new Mesh
  72864. */
  72865. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  72866. /**
  72867. * Build Mesh from CSG taking material and transforms into account
  72868. * @param name The name of the Mesh
  72869. * @param material The material of the Mesh
  72870. * @param scene The Scene
  72871. * @param keepSubMeshes Specifies if submeshes should be kept
  72872. * @returns The new Mesh
  72873. */
  72874. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  72875. }
  72876. }
  72877. declare module "babylonjs/Meshes/trailMesh" {
  72878. import { Mesh } from "babylonjs/Meshes/mesh";
  72879. import { Scene } from "babylonjs/scene";
  72880. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72881. /**
  72882. * Class used to create a trail following a mesh
  72883. */
  72884. export class TrailMesh extends Mesh {
  72885. private _generator;
  72886. private _autoStart;
  72887. private _running;
  72888. private _diameter;
  72889. private _length;
  72890. private _sectionPolygonPointsCount;
  72891. private _sectionVectors;
  72892. private _sectionNormalVectors;
  72893. private _beforeRenderObserver;
  72894. /**
  72895. * @constructor
  72896. * @param name The value used by scene.getMeshByName() to do a lookup.
  72897. * @param generator The mesh or transform node to generate a trail.
  72898. * @param scene The scene to add this mesh to.
  72899. * @param diameter Diameter of trailing mesh. Default is 1.
  72900. * @param length Length of trailing mesh. Default is 60.
  72901. * @param autoStart Automatically start trailing mesh. Default true.
  72902. */
  72903. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  72904. /**
  72905. * "TrailMesh"
  72906. * @returns "TrailMesh"
  72907. */
  72908. getClassName(): string;
  72909. private _createMesh;
  72910. /**
  72911. * Start trailing mesh.
  72912. */
  72913. start(): void;
  72914. /**
  72915. * Stop trailing mesh.
  72916. */
  72917. stop(): void;
  72918. /**
  72919. * Update trailing mesh geometry.
  72920. */
  72921. update(): void;
  72922. /**
  72923. * Returns a new TrailMesh object.
  72924. * @param name is a string, the name given to the new mesh
  72925. * @param newGenerator use new generator object for cloned trail mesh
  72926. * @returns a new mesh
  72927. */
  72928. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  72929. /**
  72930. * Serializes this trail mesh
  72931. * @param serializationObject object to write serialization to
  72932. */
  72933. serialize(serializationObject: any): void;
  72934. /**
  72935. * Parses a serialized trail mesh
  72936. * @param parsedMesh the serialized mesh
  72937. * @param scene the scene to create the trail mesh in
  72938. * @returns the created trail mesh
  72939. */
  72940. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  72941. }
  72942. }
  72943. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  72944. import { Nullable } from "babylonjs/types";
  72945. import { Scene } from "babylonjs/scene";
  72946. import { Vector4 } from "babylonjs/Maths/math.vector";
  72947. import { Color4 } from "babylonjs/Maths/math.color";
  72948. import { Mesh } from "babylonjs/Meshes/mesh";
  72949. /**
  72950. * Class containing static functions to help procedurally build meshes
  72951. */
  72952. export class TiledBoxBuilder {
  72953. /**
  72954. * Creates a box mesh
  72955. * 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)
  72956. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  72957. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  72958. * * 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
  72959. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  72960. * @param name defines the name of the mesh
  72961. * @param options defines the options used to create the mesh
  72962. * @param scene defines the hosting scene
  72963. * @returns the box mesh
  72964. */
  72965. static CreateTiledBox(name: string, options: {
  72966. pattern?: number;
  72967. width?: number;
  72968. height?: number;
  72969. depth?: number;
  72970. tileSize?: number;
  72971. tileWidth?: number;
  72972. tileHeight?: number;
  72973. alignHorizontal?: number;
  72974. alignVertical?: number;
  72975. faceUV?: Vector4[];
  72976. faceColors?: Color4[];
  72977. sideOrientation?: number;
  72978. updatable?: boolean;
  72979. }, scene?: Nullable<Scene>): Mesh;
  72980. }
  72981. }
  72982. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  72983. import { Vector4 } from "babylonjs/Maths/math.vector";
  72984. import { Mesh } from "babylonjs/Meshes/mesh";
  72985. /**
  72986. * Class containing static functions to help procedurally build meshes
  72987. */
  72988. export class TorusKnotBuilder {
  72989. /**
  72990. * Creates a torus knot mesh
  72991. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  72992. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  72993. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  72994. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  72995. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  72996. * * 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
  72997. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  72998. * @param name defines the name of the mesh
  72999. * @param options defines the options used to create the mesh
  73000. * @param scene defines the hosting scene
  73001. * @returns the torus knot mesh
  73002. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  73003. */
  73004. static CreateTorusKnot(name: string, options: {
  73005. radius?: number;
  73006. tube?: number;
  73007. radialSegments?: number;
  73008. tubularSegments?: number;
  73009. p?: number;
  73010. q?: number;
  73011. updatable?: boolean;
  73012. sideOrientation?: number;
  73013. frontUVs?: Vector4;
  73014. backUVs?: Vector4;
  73015. }, scene: any): Mesh;
  73016. }
  73017. }
  73018. declare module "babylonjs/Meshes/polygonMesh" {
  73019. import { Scene } from "babylonjs/scene";
  73020. import { Vector2 } from "babylonjs/Maths/math.vector";
  73021. import { Mesh } from "babylonjs/Meshes/mesh";
  73022. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  73023. import { Path2 } from "babylonjs/Maths/math.path";
  73024. /**
  73025. * Polygon
  73026. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  73027. */
  73028. export class Polygon {
  73029. /**
  73030. * Creates a rectangle
  73031. * @param xmin bottom X coord
  73032. * @param ymin bottom Y coord
  73033. * @param xmax top X coord
  73034. * @param ymax top Y coord
  73035. * @returns points that make the resulting rectation
  73036. */
  73037. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  73038. /**
  73039. * Creates a circle
  73040. * @param radius radius of circle
  73041. * @param cx scale in x
  73042. * @param cy scale in y
  73043. * @param numberOfSides number of sides that make up the circle
  73044. * @returns points that make the resulting circle
  73045. */
  73046. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  73047. /**
  73048. * Creates a polygon from input string
  73049. * @param input Input polygon data
  73050. * @returns the parsed points
  73051. */
  73052. static Parse(input: string): Vector2[];
  73053. /**
  73054. * Starts building a polygon from x and y coordinates
  73055. * @param x x coordinate
  73056. * @param y y coordinate
  73057. * @returns the started path2
  73058. */
  73059. static StartingAt(x: number, y: number): Path2;
  73060. }
  73061. /**
  73062. * Builds a polygon
  73063. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  73064. */
  73065. export class PolygonMeshBuilder {
  73066. private _points;
  73067. private _outlinepoints;
  73068. private _holes;
  73069. private _name;
  73070. private _scene;
  73071. private _epoints;
  73072. private _eholes;
  73073. private _addToepoint;
  73074. /**
  73075. * Babylon reference to the earcut plugin.
  73076. */
  73077. bjsEarcut: any;
  73078. /**
  73079. * Creates a PolygonMeshBuilder
  73080. * @param name name of the builder
  73081. * @param contours Path of the polygon
  73082. * @param scene scene to add to when creating the mesh
  73083. * @param earcutInjection can be used to inject your own earcut reference
  73084. */
  73085. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  73086. /**
  73087. * Adds a whole within the polygon
  73088. * @param hole Array of points defining the hole
  73089. * @returns this
  73090. */
  73091. addHole(hole: Vector2[]): PolygonMeshBuilder;
  73092. /**
  73093. * Creates the polygon
  73094. * @param updatable If the mesh should be updatable
  73095. * @param depth The depth of the mesh created
  73096. * @returns the created mesh
  73097. */
  73098. build(updatable?: boolean, depth?: number): Mesh;
  73099. /**
  73100. * Creates the polygon
  73101. * @param depth The depth of the mesh created
  73102. * @returns the created VertexData
  73103. */
  73104. buildVertexData(depth?: number): VertexData;
  73105. /**
  73106. * Adds a side to the polygon
  73107. * @param positions points that make the polygon
  73108. * @param normals normals of the polygon
  73109. * @param uvs uvs of the polygon
  73110. * @param indices indices of the polygon
  73111. * @param bounds bounds of the polygon
  73112. * @param points points of the polygon
  73113. * @param depth depth of the polygon
  73114. * @param flip flip of the polygon
  73115. */
  73116. private addSide;
  73117. }
  73118. }
  73119. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  73120. import { Scene } from "babylonjs/scene";
  73121. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  73122. import { Color4 } from "babylonjs/Maths/math.color";
  73123. import { Mesh } from "babylonjs/Meshes/mesh";
  73124. import { Nullable } from "babylonjs/types";
  73125. /**
  73126. * Class containing static functions to help procedurally build meshes
  73127. */
  73128. export class PolygonBuilder {
  73129. /**
  73130. * Creates a polygon mesh
  73131. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  73132. * * 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
  73133. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  73134. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73135. * * 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)
  73136. * * Remember you can only change the shape positions, not their number when updating a polygon
  73137. * @param name defines the name of the mesh
  73138. * @param options defines the options used to create the mesh
  73139. * @param scene defines the hosting scene
  73140. * @param earcutInjection can be used to inject your own earcut reference
  73141. * @returns the polygon mesh
  73142. */
  73143. static CreatePolygon(name: string, options: {
  73144. shape: Vector3[];
  73145. holes?: Vector3[][];
  73146. depth?: number;
  73147. faceUV?: Vector4[];
  73148. faceColors?: Color4[];
  73149. updatable?: boolean;
  73150. sideOrientation?: number;
  73151. frontUVs?: Vector4;
  73152. backUVs?: Vector4;
  73153. wrap?: boolean;
  73154. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  73155. /**
  73156. * Creates an extruded polygon mesh, with depth in the Y direction.
  73157. * * 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)
  73158. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  73159. * @param name defines the name of the mesh
  73160. * @param options defines the options used to create the mesh
  73161. * @param scene defines the hosting scene
  73162. * @param earcutInjection can be used to inject your own earcut reference
  73163. * @returns the polygon mesh
  73164. */
  73165. static ExtrudePolygon(name: string, options: {
  73166. shape: Vector3[];
  73167. holes?: Vector3[][];
  73168. depth?: number;
  73169. faceUV?: Vector4[];
  73170. faceColors?: Color4[];
  73171. updatable?: boolean;
  73172. sideOrientation?: number;
  73173. frontUVs?: Vector4;
  73174. backUVs?: Vector4;
  73175. wrap?: boolean;
  73176. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  73177. }
  73178. }
  73179. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  73180. import { Scene } from "babylonjs/scene";
  73181. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  73182. import { Mesh } from "babylonjs/Meshes/mesh";
  73183. import { Nullable } from "babylonjs/types";
  73184. /**
  73185. * Class containing static functions to help procedurally build meshes
  73186. */
  73187. export class LatheBuilder {
  73188. /**
  73189. * Creates lathe mesh.
  73190. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  73191. * * 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
  73192. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  73193. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  73194. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  73195. * * 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
  73196. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  73197. * * 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
  73198. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73199. * * 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
  73200. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  73201. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73202. * @param name defines the name of the mesh
  73203. * @param options defines the options used to create the mesh
  73204. * @param scene defines the hosting scene
  73205. * @returns the lathe mesh
  73206. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  73207. */
  73208. static CreateLathe(name: string, options: {
  73209. shape: Vector3[];
  73210. radius?: number;
  73211. tessellation?: number;
  73212. clip?: number;
  73213. arc?: number;
  73214. closed?: boolean;
  73215. updatable?: boolean;
  73216. sideOrientation?: number;
  73217. frontUVs?: Vector4;
  73218. backUVs?: Vector4;
  73219. cap?: number;
  73220. invertUV?: boolean;
  73221. }, scene?: Nullable<Scene>): Mesh;
  73222. }
  73223. }
  73224. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  73225. import { Nullable } from "babylonjs/types";
  73226. import { Scene } from "babylonjs/scene";
  73227. import { Vector4 } from "babylonjs/Maths/math.vector";
  73228. import { Mesh } from "babylonjs/Meshes/mesh";
  73229. /**
  73230. * Class containing static functions to help procedurally build meshes
  73231. */
  73232. export class TiledPlaneBuilder {
  73233. /**
  73234. * Creates a tiled plane mesh
  73235. * * The parameter `pattern` will, depending on value, do nothing or
  73236. * * * flip (reflect about central vertical) alternate tiles across and up
  73237. * * * flip every tile on alternate rows
  73238. * * * rotate (180 degs) alternate tiles across and up
  73239. * * * rotate every tile on alternate rows
  73240. * * * flip and rotate alternate tiles across and up
  73241. * * * flip and rotate every tile on alternate rows
  73242. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  73243. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  73244. * * 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
  73245. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  73246. * * 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)
  73247. * * 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)
  73248. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  73249. * @param name defines the name of the mesh
  73250. * @param options defines the options used to create the mesh
  73251. * @param scene defines the hosting scene
  73252. * @returns the box mesh
  73253. */
  73254. static CreateTiledPlane(name: string, options: {
  73255. pattern?: number;
  73256. tileSize?: number;
  73257. tileWidth?: number;
  73258. tileHeight?: number;
  73259. size?: number;
  73260. width?: number;
  73261. height?: number;
  73262. alignHorizontal?: number;
  73263. alignVertical?: number;
  73264. sideOrientation?: number;
  73265. frontUVs?: Vector4;
  73266. backUVs?: Vector4;
  73267. updatable?: boolean;
  73268. }, scene?: Nullable<Scene>): Mesh;
  73269. }
  73270. }
  73271. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  73272. import { Nullable } from "babylonjs/types";
  73273. import { Scene } from "babylonjs/scene";
  73274. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  73275. import { Mesh } from "babylonjs/Meshes/mesh";
  73276. /**
  73277. * Class containing static functions to help procedurally build meshes
  73278. */
  73279. export class TubeBuilder {
  73280. /**
  73281. * Creates a tube mesh.
  73282. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  73283. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  73284. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  73285. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  73286. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  73287. * * 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)
  73288. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  73289. * * 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
  73290. * * 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
  73291. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73292. * * 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
  73293. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  73294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73295. * @param name defines the name of the mesh
  73296. * @param options defines the options used to create the mesh
  73297. * @param scene defines the hosting scene
  73298. * @returns the tube mesh
  73299. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  73300. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  73301. */
  73302. static CreateTube(name: string, options: {
  73303. path: Vector3[];
  73304. radius?: number;
  73305. tessellation?: number;
  73306. radiusFunction?: {
  73307. (i: number, distance: number): number;
  73308. };
  73309. cap?: number;
  73310. arc?: number;
  73311. updatable?: boolean;
  73312. sideOrientation?: number;
  73313. frontUVs?: Vector4;
  73314. backUVs?: Vector4;
  73315. instance?: Mesh;
  73316. invertUV?: boolean;
  73317. }, scene?: Nullable<Scene>): Mesh;
  73318. }
  73319. }
  73320. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  73321. import { Scene } from "babylonjs/scene";
  73322. import { Vector4 } from "babylonjs/Maths/math.vector";
  73323. import { Mesh } from "babylonjs/Meshes/mesh";
  73324. import { Nullable } from "babylonjs/types";
  73325. /**
  73326. * Class containing static functions to help procedurally build meshes
  73327. */
  73328. export class IcoSphereBuilder {
  73329. /**
  73330. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  73331. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  73332. * * 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`)
  73333. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  73334. * * 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
  73335. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73336. * * 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
  73337. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73338. * @param name defines the name of the mesh
  73339. * @param options defines the options used to create the mesh
  73340. * @param scene defines the hosting scene
  73341. * @returns the icosahedron mesh
  73342. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  73343. */
  73344. static CreateIcoSphere(name: string, options: {
  73345. radius?: number;
  73346. radiusX?: number;
  73347. radiusY?: number;
  73348. radiusZ?: number;
  73349. flat?: boolean;
  73350. subdivisions?: number;
  73351. sideOrientation?: number;
  73352. frontUVs?: Vector4;
  73353. backUVs?: Vector4;
  73354. updatable?: boolean;
  73355. }, scene?: Nullable<Scene>): Mesh;
  73356. }
  73357. }
  73358. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  73359. import { Vector3 } from "babylonjs/Maths/math.vector";
  73360. import { Mesh } from "babylonjs/Meshes/mesh";
  73361. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73362. /**
  73363. * Class containing static functions to help procedurally build meshes
  73364. */
  73365. export class DecalBuilder {
  73366. /**
  73367. * Creates a decal mesh.
  73368. * 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
  73369. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  73370. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  73371. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  73372. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  73373. * @param name defines the name of the mesh
  73374. * @param sourceMesh defines the mesh where the decal must be applied
  73375. * @param options defines the options used to create the mesh
  73376. * @param scene defines the hosting scene
  73377. * @returns the decal mesh
  73378. * @see https://doc.babylonjs.com/how_to/decals
  73379. */
  73380. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  73381. position?: Vector3;
  73382. normal?: Vector3;
  73383. size?: Vector3;
  73384. angle?: number;
  73385. }): Mesh;
  73386. }
  73387. }
  73388. declare module "babylonjs/Meshes/meshBuilder" {
  73389. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  73390. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  73391. import { Nullable } from "babylonjs/types";
  73392. import { Scene } from "babylonjs/scene";
  73393. import { Mesh } from "babylonjs/Meshes/mesh";
  73394. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  73395. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  73396. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73397. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  73398. import { Plane } from "babylonjs/Maths/math.plane";
  73399. /**
  73400. * Class containing static functions to help procedurally build meshes
  73401. */
  73402. export class MeshBuilder {
  73403. /**
  73404. * Creates a box mesh
  73405. * * The parameter `size` sets the size (float) of each box side (default 1)
  73406. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  73407. * * 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)
  73408. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  73409. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73410. * * 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
  73411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73412. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  73413. * @param name defines the name of the mesh
  73414. * @param options defines the options used to create the mesh
  73415. * @param scene defines the hosting scene
  73416. * @returns the box mesh
  73417. */
  73418. static CreateBox(name: string, options: {
  73419. size?: number;
  73420. width?: number;
  73421. height?: number;
  73422. depth?: number;
  73423. faceUV?: Vector4[];
  73424. faceColors?: Color4[];
  73425. sideOrientation?: number;
  73426. frontUVs?: Vector4;
  73427. backUVs?: Vector4;
  73428. wrap?: boolean;
  73429. topBaseAt?: number;
  73430. bottomBaseAt?: number;
  73431. updatable?: boolean;
  73432. }, scene?: Nullable<Scene>): Mesh;
  73433. /**
  73434. * Creates a tiled box mesh
  73435. * * faceTiles sets the pattern, tile size and number of tiles for a face
  73436. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73437. * @param name defines the name of the mesh
  73438. * @param options defines the options used to create the mesh
  73439. * @param scene defines the hosting scene
  73440. * @returns the tiled box mesh
  73441. */
  73442. static CreateTiledBox(name: string, options: {
  73443. pattern?: number;
  73444. size?: number;
  73445. width?: number;
  73446. height?: number;
  73447. depth: number;
  73448. tileSize?: number;
  73449. tileWidth?: number;
  73450. tileHeight?: number;
  73451. faceUV?: Vector4[];
  73452. faceColors?: Color4[];
  73453. alignHorizontal?: number;
  73454. alignVertical?: number;
  73455. sideOrientation?: number;
  73456. updatable?: boolean;
  73457. }, scene?: Nullable<Scene>): Mesh;
  73458. /**
  73459. * Creates a sphere mesh
  73460. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  73461. * * 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`)
  73462. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  73463. * * 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
  73464. * * 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)
  73465. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73466. * * 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
  73467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73468. * @param name defines the name of the mesh
  73469. * @param options defines the options used to create the mesh
  73470. * @param scene defines the hosting scene
  73471. * @returns the sphere mesh
  73472. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  73473. */
  73474. static CreateSphere(name: string, options: {
  73475. segments?: number;
  73476. diameter?: number;
  73477. diameterX?: number;
  73478. diameterY?: number;
  73479. diameterZ?: number;
  73480. arc?: number;
  73481. slice?: number;
  73482. sideOrientation?: number;
  73483. frontUVs?: Vector4;
  73484. backUVs?: Vector4;
  73485. updatable?: boolean;
  73486. }, scene?: Nullable<Scene>): Mesh;
  73487. /**
  73488. * Creates a plane polygonal mesh. By default, this is a disc
  73489. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  73490. * * 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
  73491. * * 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
  73492. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73493. * * 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
  73494. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73495. * @param name defines the name of the mesh
  73496. * @param options defines the options used to create the mesh
  73497. * @param scene defines the hosting scene
  73498. * @returns the plane polygonal mesh
  73499. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  73500. */
  73501. static CreateDisc(name: string, options: {
  73502. radius?: number;
  73503. tessellation?: number;
  73504. arc?: number;
  73505. updatable?: boolean;
  73506. sideOrientation?: number;
  73507. frontUVs?: Vector4;
  73508. backUVs?: Vector4;
  73509. }, scene?: Nullable<Scene>): Mesh;
  73510. /**
  73511. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  73512. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  73513. * * 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`)
  73514. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  73515. * * 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
  73516. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73517. * * 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
  73518. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73519. * @param name defines the name of the mesh
  73520. * @param options defines the options used to create the mesh
  73521. * @param scene defines the hosting scene
  73522. * @returns the icosahedron mesh
  73523. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  73524. */
  73525. static CreateIcoSphere(name: string, options: {
  73526. radius?: number;
  73527. radiusX?: number;
  73528. radiusY?: number;
  73529. radiusZ?: number;
  73530. flat?: boolean;
  73531. subdivisions?: number;
  73532. sideOrientation?: number;
  73533. frontUVs?: Vector4;
  73534. backUVs?: Vector4;
  73535. updatable?: boolean;
  73536. }, scene?: Nullable<Scene>): Mesh;
  73537. /**
  73538. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  73539. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  73540. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  73541. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  73542. * * 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
  73543. * * 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
  73544. * * 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
  73545. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73546. * * 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
  73547. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  73548. * * 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
  73549. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  73550. * * 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
  73551. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  73552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73553. * @param name defines the name of the mesh
  73554. * @param options defines the options used to create the mesh
  73555. * @param scene defines the hosting scene
  73556. * @returns the ribbon mesh
  73557. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  73558. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  73559. */
  73560. static CreateRibbon(name: string, options: {
  73561. pathArray: Vector3[][];
  73562. closeArray?: boolean;
  73563. closePath?: boolean;
  73564. offset?: number;
  73565. updatable?: boolean;
  73566. sideOrientation?: number;
  73567. frontUVs?: Vector4;
  73568. backUVs?: Vector4;
  73569. instance?: Mesh;
  73570. invertUV?: boolean;
  73571. uvs?: Vector2[];
  73572. colors?: Color4[];
  73573. }, scene?: Nullable<Scene>): Mesh;
  73574. /**
  73575. * Creates a cylinder or a cone mesh
  73576. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  73577. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  73578. * * 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.
  73579. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  73580. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  73581. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  73582. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  73583. * * 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).
  73584. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  73585. * * 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).
  73586. * * 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
  73587. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  73588. * * 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
  73589. * * 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.
  73590. * * If `enclose` is false, a ring surface is one element.
  73591. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  73592. * * 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
  73593. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73594. * * 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
  73595. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  73596. * @param name defines the name of the mesh
  73597. * @param options defines the options used to create the mesh
  73598. * @param scene defines the hosting scene
  73599. * @returns the cylinder mesh
  73600. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  73601. */
  73602. static CreateCylinder(name: string, options: {
  73603. height?: number;
  73604. diameterTop?: number;
  73605. diameterBottom?: number;
  73606. diameter?: number;
  73607. tessellation?: number;
  73608. subdivisions?: number;
  73609. arc?: number;
  73610. faceColors?: Color4[];
  73611. faceUV?: Vector4[];
  73612. updatable?: boolean;
  73613. hasRings?: boolean;
  73614. enclose?: boolean;
  73615. cap?: number;
  73616. sideOrientation?: number;
  73617. frontUVs?: Vector4;
  73618. backUVs?: Vector4;
  73619. }, scene?: Nullable<Scene>): Mesh;
  73620. /**
  73621. * Creates a torus mesh
  73622. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  73623. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  73624. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  73625. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73626. * * 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
  73627. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  73628. * @param name defines the name of the mesh
  73629. * @param options defines the options used to create the mesh
  73630. * @param scene defines the hosting scene
  73631. * @returns the torus mesh
  73632. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  73633. */
  73634. static CreateTorus(name: string, options: {
  73635. diameter?: number;
  73636. thickness?: number;
  73637. tessellation?: number;
  73638. updatable?: boolean;
  73639. sideOrientation?: number;
  73640. frontUVs?: Vector4;
  73641. backUVs?: Vector4;
  73642. }, scene?: Nullable<Scene>): Mesh;
  73643. /**
  73644. * Creates a torus knot mesh
  73645. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  73646. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  73647. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  73648. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  73649. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73650. * * 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
  73651. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  73652. * @param name defines the name of the mesh
  73653. * @param options defines the options used to create the mesh
  73654. * @param scene defines the hosting scene
  73655. * @returns the torus knot mesh
  73656. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  73657. */
  73658. static CreateTorusKnot(name: string, options: {
  73659. radius?: number;
  73660. tube?: number;
  73661. radialSegments?: number;
  73662. tubularSegments?: number;
  73663. p?: number;
  73664. q?: number;
  73665. updatable?: boolean;
  73666. sideOrientation?: number;
  73667. frontUVs?: Vector4;
  73668. backUVs?: Vector4;
  73669. }, scene?: Nullable<Scene>): Mesh;
  73670. /**
  73671. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  73672. * * 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
  73673. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  73674. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  73675. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  73676. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  73677. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  73678. * * 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
  73679. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  73680. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73681. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  73682. * @param name defines the name of the new line system
  73683. * @param options defines the options used to create the line system
  73684. * @param scene defines the hosting scene
  73685. * @returns a new line system mesh
  73686. */
  73687. static CreateLineSystem(name: string, options: {
  73688. lines: Vector3[][];
  73689. updatable?: boolean;
  73690. instance?: Nullable<LinesMesh>;
  73691. colors?: Nullable<Color4[][]>;
  73692. useVertexAlpha?: boolean;
  73693. }, scene: Nullable<Scene>): LinesMesh;
  73694. /**
  73695. * Creates a line mesh
  73696. * 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
  73697. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  73698. * * The parameter `points` is an array successive Vector3
  73699. * * 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
  73700. * * The optional parameter `colors` is an array of successive Color4, one per line point
  73701. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  73702. * * When updating an instance, remember that only point positions can change, not the number of points
  73703. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73704. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  73705. * @param name defines the name of the new line system
  73706. * @param options defines the options used to create the line system
  73707. * @param scene defines the hosting scene
  73708. * @returns a new line mesh
  73709. */
  73710. static CreateLines(name: string, options: {
  73711. points: Vector3[];
  73712. updatable?: boolean;
  73713. instance?: Nullable<LinesMesh>;
  73714. colors?: Color4[];
  73715. useVertexAlpha?: boolean;
  73716. }, scene?: Nullable<Scene>): LinesMesh;
  73717. /**
  73718. * Creates a dashed line mesh
  73719. * * 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
  73720. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  73721. * * The parameter `points` is an array successive Vector3
  73722. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  73723. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  73724. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  73725. * * 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
  73726. * * When updating an instance, remember that only point positions can change, not the number of points
  73727. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73728. * @param name defines the name of the mesh
  73729. * @param options defines the options used to create the mesh
  73730. * @param scene defines the hosting scene
  73731. * @returns the dashed line mesh
  73732. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  73733. */
  73734. static CreateDashedLines(name: string, options: {
  73735. points: Vector3[];
  73736. dashSize?: number;
  73737. gapSize?: number;
  73738. dashNb?: number;
  73739. updatable?: boolean;
  73740. instance?: LinesMesh;
  73741. }, scene?: Nullable<Scene>): LinesMesh;
  73742. /**
  73743. * 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.
  73744. * * 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.
  73745. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  73746. * * 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.
  73747. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  73748. * * 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
  73749. * * 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
  73750. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  73751. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73752. * * 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
  73753. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  73754. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  73755. * @param name defines the name of the mesh
  73756. * @param options defines the options used to create the mesh
  73757. * @param scene defines the hosting scene
  73758. * @returns the extruded shape mesh
  73759. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  73760. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  73761. */
  73762. static ExtrudeShape(name: string, options: {
  73763. shape: Vector3[];
  73764. path: Vector3[];
  73765. scale?: number;
  73766. rotation?: number;
  73767. cap?: number;
  73768. updatable?: boolean;
  73769. sideOrientation?: number;
  73770. frontUVs?: Vector4;
  73771. backUVs?: Vector4;
  73772. instance?: Mesh;
  73773. invertUV?: boolean;
  73774. }, scene?: Nullable<Scene>): Mesh;
  73775. /**
  73776. * Creates an custom extruded shape mesh.
  73777. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  73778. * * 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.
  73779. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  73780. * * 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
  73781. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  73782. * * 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
  73783. * * It must returns a float value that will be the scale value applied to the shape on each path point
  73784. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  73785. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  73786. * * 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
  73787. * * 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
  73788. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  73789. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73790. * * 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
  73791. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  73792. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73793. * @param name defines the name of the mesh
  73794. * @param options defines the options used to create the mesh
  73795. * @param scene defines the hosting scene
  73796. * @returns the custom extruded shape mesh
  73797. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  73798. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  73799. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  73800. */
  73801. static ExtrudeShapeCustom(name: string, options: {
  73802. shape: Vector3[];
  73803. path: Vector3[];
  73804. scaleFunction?: any;
  73805. rotationFunction?: any;
  73806. ribbonCloseArray?: boolean;
  73807. ribbonClosePath?: boolean;
  73808. cap?: number;
  73809. updatable?: boolean;
  73810. sideOrientation?: number;
  73811. frontUVs?: Vector4;
  73812. backUVs?: Vector4;
  73813. instance?: Mesh;
  73814. invertUV?: boolean;
  73815. }, scene?: Nullable<Scene>): Mesh;
  73816. /**
  73817. * Creates lathe mesh.
  73818. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  73819. * * 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
  73820. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  73821. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  73822. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  73823. * * 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
  73824. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  73825. * * 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
  73826. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73827. * * 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
  73828. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  73829. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73830. * @param name defines the name of the mesh
  73831. * @param options defines the options used to create the mesh
  73832. * @param scene defines the hosting scene
  73833. * @returns the lathe mesh
  73834. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  73835. */
  73836. static CreateLathe(name: string, options: {
  73837. shape: Vector3[];
  73838. radius?: number;
  73839. tessellation?: number;
  73840. clip?: number;
  73841. arc?: number;
  73842. closed?: boolean;
  73843. updatable?: boolean;
  73844. sideOrientation?: number;
  73845. frontUVs?: Vector4;
  73846. backUVs?: Vector4;
  73847. cap?: number;
  73848. invertUV?: boolean;
  73849. }, scene?: Nullable<Scene>): Mesh;
  73850. /**
  73851. * Creates a tiled plane mesh
  73852. * * You can set a limited pattern arrangement with the tiles
  73853. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73854. * * 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
  73855. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73856. * @param name defines the name of the mesh
  73857. * @param options defines the options used to create the mesh
  73858. * @param scene defines the hosting scene
  73859. * @returns the plane mesh
  73860. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  73861. */
  73862. static CreateTiledPlane(name: string, options: {
  73863. pattern?: number;
  73864. tileSize?: number;
  73865. tileWidth?: number;
  73866. tileHeight?: number;
  73867. size?: number;
  73868. width?: number;
  73869. height?: number;
  73870. alignHorizontal?: number;
  73871. alignVertical?: number;
  73872. sideOrientation?: number;
  73873. frontUVs?: Vector4;
  73874. backUVs?: Vector4;
  73875. updatable?: boolean;
  73876. }, scene?: Nullable<Scene>): Mesh;
  73877. /**
  73878. * Creates a plane mesh
  73879. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  73880. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  73881. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  73882. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  73883. * * 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
  73884. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73885. * @param name defines the name of the mesh
  73886. * @param options defines the options used to create the mesh
  73887. * @param scene defines the hosting scene
  73888. * @returns the plane mesh
  73889. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  73890. */
  73891. static CreatePlane(name: string, options: {
  73892. size?: number;
  73893. width?: number;
  73894. height?: number;
  73895. sideOrientation?: number;
  73896. frontUVs?: Vector4;
  73897. backUVs?: Vector4;
  73898. updatable?: boolean;
  73899. sourcePlane?: Plane;
  73900. }, scene?: Nullable<Scene>): Mesh;
  73901. /**
  73902. * Creates a ground mesh
  73903. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  73904. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  73905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73906. * @param name defines the name of the mesh
  73907. * @param options defines the options used to create the mesh
  73908. * @param scene defines the hosting scene
  73909. * @returns the ground mesh
  73910. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  73911. */
  73912. static CreateGround(name: string, options: {
  73913. width?: number;
  73914. height?: number;
  73915. subdivisions?: number;
  73916. subdivisionsX?: number;
  73917. subdivisionsY?: number;
  73918. updatable?: boolean;
  73919. }, scene?: Nullable<Scene>): Mesh;
  73920. /**
  73921. * Creates a tiled ground mesh
  73922. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  73923. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  73924. * * 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
  73925. * * 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
  73926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  73927. * @param name defines the name of the mesh
  73928. * @param options defines the options used to create the mesh
  73929. * @param scene defines the hosting scene
  73930. * @returns the tiled ground mesh
  73931. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  73932. */
  73933. static CreateTiledGround(name: string, options: {
  73934. xmin: number;
  73935. zmin: number;
  73936. xmax: number;
  73937. zmax: number;
  73938. subdivisions?: {
  73939. w: number;
  73940. h: number;
  73941. };
  73942. precision?: {
  73943. w: number;
  73944. h: number;
  73945. };
  73946. updatable?: boolean;
  73947. }, scene?: Nullable<Scene>): Mesh;
  73948. /**
  73949. * Creates a ground mesh from a height map
  73950. * * The parameter `url` sets the URL of the height map image resource.
  73951. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  73952. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  73953. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  73954. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  73955. * * 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.
  73956. * * 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).
  73957. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  73958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  73959. * @param name defines the name of the mesh
  73960. * @param url defines the url to the height map
  73961. * @param options defines the options used to create the mesh
  73962. * @param scene defines the hosting scene
  73963. * @returns the ground mesh
  73964. * @see https://doc.babylonjs.com/babylon101/height_map
  73965. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  73966. */
  73967. static CreateGroundFromHeightMap(name: string, url: string, options: {
  73968. width?: number;
  73969. height?: number;
  73970. subdivisions?: number;
  73971. minHeight?: number;
  73972. maxHeight?: number;
  73973. colorFilter?: Color3;
  73974. alphaFilter?: number;
  73975. updatable?: boolean;
  73976. onReady?: (mesh: GroundMesh) => void;
  73977. }, scene?: Nullable<Scene>): GroundMesh;
  73978. /**
  73979. * Creates a polygon mesh
  73980. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  73981. * * 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
  73982. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  73983. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  73984. * * 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)
  73985. * * Remember you can only change the shape positions, not their number when updating a polygon
  73986. * @param name defines the name of the mesh
  73987. * @param options defines the options used to create the mesh
  73988. * @param scene defines the hosting scene
  73989. * @param earcutInjection can be used to inject your own earcut reference
  73990. * @returns the polygon mesh
  73991. */
  73992. static CreatePolygon(name: string, options: {
  73993. shape: Vector3[];
  73994. holes?: Vector3[][];
  73995. depth?: number;
  73996. faceUV?: Vector4[];
  73997. faceColors?: Color4[];
  73998. updatable?: boolean;
  73999. sideOrientation?: number;
  74000. frontUVs?: Vector4;
  74001. backUVs?: Vector4;
  74002. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  74003. /**
  74004. * Creates an extruded polygon mesh, with depth in the Y direction.
  74005. * * 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)
  74006. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  74007. * @param name defines the name of the mesh
  74008. * @param options defines the options used to create the mesh
  74009. * @param scene defines the hosting scene
  74010. * @param earcutInjection can be used to inject your own earcut reference
  74011. * @returns the polygon mesh
  74012. */
  74013. static ExtrudePolygon(name: string, options: {
  74014. shape: Vector3[];
  74015. holes?: Vector3[][];
  74016. depth?: number;
  74017. faceUV?: Vector4[];
  74018. faceColors?: Color4[];
  74019. updatable?: boolean;
  74020. sideOrientation?: number;
  74021. frontUVs?: Vector4;
  74022. backUVs?: Vector4;
  74023. wrap?: boolean;
  74024. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  74025. /**
  74026. * Creates a tube mesh.
  74027. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  74028. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  74029. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  74030. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  74031. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  74032. * * 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)
  74033. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  74034. * * 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
  74035. * * 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
  74036. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74037. * * 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
  74038. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  74039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74040. * @param name defines the name of the mesh
  74041. * @param options defines the options used to create the mesh
  74042. * @param scene defines the hosting scene
  74043. * @returns the tube mesh
  74044. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  74045. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  74046. */
  74047. static CreateTube(name: string, options: {
  74048. path: Vector3[];
  74049. radius?: number;
  74050. tessellation?: number;
  74051. radiusFunction?: {
  74052. (i: number, distance: number): number;
  74053. };
  74054. cap?: number;
  74055. arc?: number;
  74056. updatable?: boolean;
  74057. sideOrientation?: number;
  74058. frontUVs?: Vector4;
  74059. backUVs?: Vector4;
  74060. instance?: Mesh;
  74061. invertUV?: boolean;
  74062. }, scene?: Nullable<Scene>): Mesh;
  74063. /**
  74064. * Creates a polyhedron mesh
  74065. * * 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
  74066. * * The parameter `size` (positive float, default 1) sets the polygon size
  74067. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  74068. * * 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`
  74069. * * 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
  74070. * * 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)`)
  74071. * * 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
  74072. * * 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
  74073. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  74074. * * 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
  74075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  74076. * @param name defines the name of the mesh
  74077. * @param options defines the options used to create the mesh
  74078. * @param scene defines the hosting scene
  74079. * @returns the polyhedron mesh
  74080. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  74081. */
  74082. static CreatePolyhedron(name: string, options: {
  74083. type?: number;
  74084. size?: number;
  74085. sizeX?: number;
  74086. sizeY?: number;
  74087. sizeZ?: number;
  74088. custom?: any;
  74089. faceUV?: Vector4[];
  74090. faceColors?: Color4[];
  74091. flat?: boolean;
  74092. updatable?: boolean;
  74093. sideOrientation?: number;
  74094. frontUVs?: Vector4;
  74095. backUVs?: Vector4;
  74096. }, scene?: Nullable<Scene>): Mesh;
  74097. /**
  74098. * Creates a decal mesh.
  74099. * 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
  74100. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  74101. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  74102. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  74103. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  74104. * @param name defines the name of the mesh
  74105. * @param sourceMesh defines the mesh where the decal must be applied
  74106. * @param options defines the options used to create the mesh
  74107. * @param scene defines the hosting scene
  74108. * @returns the decal mesh
  74109. * @see https://doc.babylonjs.com/how_to/decals
  74110. */
  74111. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  74112. position?: Vector3;
  74113. normal?: Vector3;
  74114. size?: Vector3;
  74115. angle?: number;
  74116. }): Mesh;
  74117. /**
  74118. * Creates a Capsule Mesh
  74119. * @param name defines the name of the mesh.
  74120. * @param options the constructors options used to shape the mesh.
  74121. * @param scene defines the scene the mesh is scoped to.
  74122. * @returns the capsule mesh
  74123. * @see https://doc.babylonjs.com/how_to/capsule_shape
  74124. */
  74125. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  74126. }
  74127. }
  74128. declare module "babylonjs/Meshes/meshSimplification" {
  74129. import { Mesh } from "babylonjs/Meshes/mesh";
  74130. /**
  74131. * A simplifier interface for future simplification implementations
  74132. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  74133. */
  74134. export interface ISimplifier {
  74135. /**
  74136. * Simplification of a given mesh according to the given settings.
  74137. * Since this requires computation, it is assumed that the function runs async.
  74138. * @param settings The settings of the simplification, including quality and distance
  74139. * @param successCallback A callback that will be called after the mesh was simplified.
  74140. * @param errorCallback in case of an error, this callback will be called. optional.
  74141. */
  74142. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  74143. }
  74144. /**
  74145. * Expected simplification settings.
  74146. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  74147. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  74148. */
  74149. export interface ISimplificationSettings {
  74150. /**
  74151. * Gets or sets the expected quality
  74152. */
  74153. quality: number;
  74154. /**
  74155. * Gets or sets the distance when this optimized version should be used
  74156. */
  74157. distance: number;
  74158. /**
  74159. * Gets an already optimized mesh
  74160. */
  74161. optimizeMesh?: boolean;
  74162. }
  74163. /**
  74164. * Class used to specify simplification options
  74165. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  74166. */
  74167. export class SimplificationSettings implements ISimplificationSettings {
  74168. /** expected quality */
  74169. quality: number;
  74170. /** distance when this optimized version should be used */
  74171. distance: number;
  74172. /** already optimized mesh */
  74173. optimizeMesh?: boolean | undefined;
  74174. /**
  74175. * Creates a SimplificationSettings
  74176. * @param quality expected quality
  74177. * @param distance distance when this optimized version should be used
  74178. * @param optimizeMesh already optimized mesh
  74179. */
  74180. constructor(
  74181. /** expected quality */
  74182. quality: number,
  74183. /** distance when this optimized version should be used */
  74184. distance: number,
  74185. /** already optimized mesh */
  74186. optimizeMesh?: boolean | undefined);
  74187. }
  74188. /**
  74189. * Interface used to define a simplification task
  74190. */
  74191. export interface ISimplificationTask {
  74192. /**
  74193. * Array of settings
  74194. */
  74195. settings: Array<ISimplificationSettings>;
  74196. /**
  74197. * Simplification type
  74198. */
  74199. simplificationType: SimplificationType;
  74200. /**
  74201. * Mesh to simplify
  74202. */
  74203. mesh: Mesh;
  74204. /**
  74205. * Callback called on success
  74206. */
  74207. successCallback?: () => void;
  74208. /**
  74209. * Defines if parallel processing can be used
  74210. */
  74211. parallelProcessing: boolean;
  74212. }
  74213. /**
  74214. * Queue used to order the simplification tasks
  74215. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  74216. */
  74217. export class SimplificationQueue {
  74218. private _simplificationArray;
  74219. /**
  74220. * Gets a boolean indicating that the process is still running
  74221. */
  74222. running: boolean;
  74223. /**
  74224. * Creates a new queue
  74225. */
  74226. constructor();
  74227. /**
  74228. * Adds a new simplification task
  74229. * @param task defines a task to add
  74230. */
  74231. addTask(task: ISimplificationTask): void;
  74232. /**
  74233. * Execute next task
  74234. */
  74235. executeNext(): void;
  74236. /**
  74237. * Execute a simplification task
  74238. * @param task defines the task to run
  74239. */
  74240. runSimplification(task: ISimplificationTask): void;
  74241. private getSimplifier;
  74242. }
  74243. /**
  74244. * The implemented types of simplification
  74245. * At the moment only Quadratic Error Decimation is implemented
  74246. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  74247. */
  74248. export enum SimplificationType {
  74249. /** Quadratic error decimation */
  74250. QUADRATIC = 0
  74251. }
  74252. /**
  74253. * An implementation of the Quadratic Error simplification algorithm.
  74254. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  74255. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  74256. * @author RaananW
  74257. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  74258. */
  74259. export class QuadraticErrorSimplification implements ISimplifier {
  74260. private _mesh;
  74261. private triangles;
  74262. private vertices;
  74263. private references;
  74264. private _reconstructedMesh;
  74265. /** Gets or sets the number pf sync interations */
  74266. syncIterations: number;
  74267. /** Gets or sets the aggressiveness of the simplifier */
  74268. aggressiveness: number;
  74269. /** Gets or sets the number of allowed iterations for decimation */
  74270. decimationIterations: number;
  74271. /** Gets or sets the espilon to use for bounding box computation */
  74272. boundingBoxEpsilon: number;
  74273. /**
  74274. * Creates a new QuadraticErrorSimplification
  74275. * @param _mesh defines the target mesh
  74276. */
  74277. constructor(_mesh: Mesh);
  74278. /**
  74279. * Simplification of a given mesh according to the given settings.
  74280. * Since this requires computation, it is assumed that the function runs async.
  74281. * @param settings The settings of the simplification, including quality and distance
  74282. * @param successCallback A callback that will be called after the mesh was simplified.
  74283. */
  74284. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  74285. private runDecimation;
  74286. private initWithMesh;
  74287. private init;
  74288. private reconstructMesh;
  74289. private initDecimatedMesh;
  74290. private isFlipped;
  74291. private updateTriangles;
  74292. private identifyBorder;
  74293. private updateMesh;
  74294. private vertexError;
  74295. private calculateError;
  74296. }
  74297. }
  74298. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  74299. import { Scene } from "babylonjs/scene";
  74300. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  74301. import { ISceneComponent } from "babylonjs/sceneComponent";
  74302. module "babylonjs/scene" {
  74303. interface Scene {
  74304. /** @hidden (Backing field) */
  74305. _simplificationQueue: SimplificationQueue;
  74306. /**
  74307. * Gets or sets the simplification queue attached to the scene
  74308. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  74309. */
  74310. simplificationQueue: SimplificationQueue;
  74311. }
  74312. }
  74313. module "babylonjs/Meshes/mesh" {
  74314. interface Mesh {
  74315. /**
  74316. * Simplify the mesh according to the given array of settings.
  74317. * Function will return immediately and will simplify async
  74318. * @param settings a collection of simplification settings
  74319. * @param parallelProcessing should all levels calculate parallel or one after the other
  74320. * @param simplificationType the type of simplification to run
  74321. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  74322. * @returns the current mesh
  74323. */
  74324. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  74325. }
  74326. }
  74327. /**
  74328. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  74329. * created in a scene
  74330. */
  74331. export class SimplicationQueueSceneComponent implements ISceneComponent {
  74332. /**
  74333. * The component name helpfull to identify the component in the list of scene components.
  74334. */
  74335. readonly name: string;
  74336. /**
  74337. * The scene the component belongs to.
  74338. */
  74339. scene: Scene;
  74340. /**
  74341. * Creates a new instance of the component for the given scene
  74342. * @param scene Defines the scene to register the component in
  74343. */
  74344. constructor(scene: Scene);
  74345. /**
  74346. * Registers the component in a given scene
  74347. */
  74348. register(): void;
  74349. /**
  74350. * Rebuilds the elements related to this component in case of
  74351. * context lost for instance.
  74352. */
  74353. rebuild(): void;
  74354. /**
  74355. * Disposes the component and the associated ressources
  74356. */
  74357. dispose(): void;
  74358. private _beforeCameraUpdate;
  74359. }
  74360. }
  74361. declare module "babylonjs/Meshes/Builders/index" {
  74362. export * from "babylonjs/Meshes/Builders/boxBuilder";
  74363. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  74364. export * from "babylonjs/Meshes/Builders/discBuilder";
  74365. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  74366. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  74367. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  74368. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  74369. export * from "babylonjs/Meshes/Builders/torusBuilder";
  74370. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  74371. export * from "babylonjs/Meshes/Builders/linesBuilder";
  74372. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  74373. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  74374. export * from "babylonjs/Meshes/Builders/latheBuilder";
  74375. export * from "babylonjs/Meshes/Builders/planeBuilder";
  74376. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  74377. export * from "babylonjs/Meshes/Builders/groundBuilder";
  74378. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  74379. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  74380. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  74381. export * from "babylonjs/Meshes/Builders/decalBuilder";
  74382. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  74383. export * from "babylonjs/Meshes/Builders/capsuleBuilder";
  74384. }
  74385. declare module "babylonjs/Meshes/thinInstanceMesh" {
  74386. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  74387. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  74388. import { Matrix } from "babylonjs/Maths/math.vector";
  74389. module "babylonjs/Meshes/mesh" {
  74390. interface Mesh {
  74391. /**
  74392. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  74393. */
  74394. thinInstanceEnablePicking: boolean;
  74395. /**
  74396. * Creates a new thin instance
  74397. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  74398. * @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
  74399. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  74400. */
  74401. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  74402. /**
  74403. * Adds the transformation (matrix) of the current mesh as a thin instance
  74404. * @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
  74405. * @returns the thin instance index number
  74406. */
  74407. thinInstanceAddSelf(refresh: boolean): number;
  74408. /**
  74409. * Registers a custom attribute to be used with thin instances
  74410. * @param kind name of the attribute
  74411. * @param stride size in floats of the attribute
  74412. */
  74413. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  74414. /**
  74415. * Sets the matrix of a thin instance
  74416. * @param index index of the thin instance
  74417. * @param matrix matrix to set
  74418. * @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
  74419. */
  74420. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  74421. /**
  74422. * Sets the value of a custom attribute for a thin instance
  74423. * @param kind name of the attribute
  74424. * @param index index of the thin instance
  74425. * @param value value to set
  74426. * @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
  74427. */
  74428. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  74429. /**
  74430. * 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.
  74431. */
  74432. thinInstanceCount: number;
  74433. /**
  74434. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  74435. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  74436. * @param buffer buffer to set
  74437. * @param stride size in floats of each value of the buffer
  74438. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  74439. */
  74440. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  74441. /**
  74442. * Gets the list of world matrices
  74443. * @return an array containing all the world matrices from the thin instances
  74444. */
  74445. thinInstanceGetWorldMatrices(): Matrix[];
  74446. /**
  74447. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  74448. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  74449. */
  74450. thinInstanceBufferUpdated(kind: string): void;
  74451. /**
  74452. * Applies a partial update to a buffer directly on the GPU
  74453. * 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
  74454. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  74455. * @param data the data to set in the GPU buffer
  74456. * @param offset the offset in the GPU buffer where to update the data
  74457. */
  74458. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  74459. /**
  74460. * Refreshes the bounding info, taking into account all the thin instances defined
  74461. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  74462. */
  74463. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  74464. /** @hidden */
  74465. _thinInstanceInitializeUserStorage(): void;
  74466. /** @hidden */
  74467. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  74468. /** @hidden */
  74469. _userThinInstanceBuffersStorage: {
  74470. data: {
  74471. [key: string]: Float32Array;
  74472. };
  74473. sizes: {
  74474. [key: string]: number;
  74475. };
  74476. vertexBuffers: {
  74477. [key: string]: Nullable<VertexBuffer>;
  74478. };
  74479. strides: {
  74480. [key: string]: number;
  74481. };
  74482. };
  74483. }
  74484. }
  74485. }
  74486. declare module "babylonjs/Meshes/index" {
  74487. export * from "babylonjs/Meshes/abstractMesh";
  74488. export * from "babylonjs/Meshes/buffer";
  74489. export * from "babylonjs/Meshes/Compression/index";
  74490. export * from "babylonjs/Meshes/csg";
  74491. export * from "babylonjs/Meshes/geometry";
  74492. export * from "babylonjs/Meshes/groundMesh";
  74493. export * from "babylonjs/Meshes/trailMesh";
  74494. export * from "babylonjs/Meshes/instancedMesh";
  74495. export * from "babylonjs/Meshes/linesMesh";
  74496. export * from "babylonjs/Meshes/mesh";
  74497. export * from "babylonjs/Meshes/mesh.vertexData";
  74498. export * from "babylonjs/Meshes/meshBuilder";
  74499. export * from "babylonjs/Meshes/meshSimplification";
  74500. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  74501. export * from "babylonjs/Meshes/polygonMesh";
  74502. export * from "babylonjs/Meshes/subMesh";
  74503. export * from "babylonjs/Meshes/meshLODLevel";
  74504. export * from "babylonjs/Meshes/transformNode";
  74505. export * from "babylonjs/Meshes/Builders/index";
  74506. export * from "babylonjs/Meshes/dataBuffer";
  74507. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  74508. export * from "babylonjs/Meshes/WebGPU/webgpuDataBuffer";
  74509. import "babylonjs/Meshes/thinInstanceMesh";
  74510. export * from "babylonjs/Meshes/thinInstanceMesh";
  74511. }
  74512. declare module "babylonjs/Morph/index" {
  74513. export * from "babylonjs/Morph/morphTarget";
  74514. export * from "babylonjs/Morph/morphTargetManager";
  74515. }
  74516. declare module "babylonjs/Navigation/INavigationEngine" {
  74517. import { TransformNode } from "babylonjs/Meshes/transformNode";
  74518. import { Vector3 } from "babylonjs/Maths/math";
  74519. import { Mesh } from "babylonjs/Meshes/mesh";
  74520. import { Scene } from "babylonjs/scene";
  74521. /**
  74522. * Navigation plugin interface to add navigation constrained by a navigation mesh
  74523. */
  74524. export interface INavigationEnginePlugin {
  74525. /**
  74526. * plugin name
  74527. */
  74528. name: string;
  74529. /**
  74530. * Creates a navigation mesh
  74531. * @param meshes array of all the geometry used to compute the navigatio mesh
  74532. * @param parameters bunch of parameters used to filter geometry
  74533. */
  74534. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  74535. /**
  74536. * Create a navigation mesh debug mesh
  74537. * @param scene is where the mesh will be added
  74538. * @returns debug display mesh
  74539. */
  74540. createDebugNavMesh(scene: Scene): Mesh;
  74541. /**
  74542. * Get a navigation mesh constrained position, closest to the parameter position
  74543. * @param position world position
  74544. * @returns the closest point to position constrained by the navigation mesh
  74545. */
  74546. getClosestPoint(position: Vector3): Vector3;
  74547. /**
  74548. * Get a navigation mesh constrained position, closest to the parameter position
  74549. * @param position world position
  74550. * @param result output the closest point to position constrained by the navigation mesh
  74551. */
  74552. getClosestPointToRef(position: Vector3, result: Vector3): void;
  74553. /**
  74554. * Get a navigation mesh constrained position, within a particular radius
  74555. * @param position world position
  74556. * @param maxRadius the maximum distance to the constrained world position
  74557. * @returns the closest point to position constrained by the navigation mesh
  74558. */
  74559. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  74560. /**
  74561. * Get a navigation mesh constrained position, within a particular radius
  74562. * @param position world position
  74563. * @param maxRadius the maximum distance to the constrained world position
  74564. * @param result output the closest point to position constrained by the navigation mesh
  74565. */
  74566. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  74567. /**
  74568. * Compute the final position from a segment made of destination-position
  74569. * @param position world position
  74570. * @param destination world position
  74571. * @returns the resulting point along the navmesh
  74572. */
  74573. moveAlong(position: Vector3, destination: Vector3): Vector3;
  74574. /**
  74575. * Compute the final position from a segment made of destination-position
  74576. * @param position world position
  74577. * @param destination world position
  74578. * @param result output the resulting point along the navmesh
  74579. */
  74580. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  74581. /**
  74582. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  74583. * @param start world position
  74584. * @param end world position
  74585. * @returns array containing world position composing the path
  74586. */
  74587. computePath(start: Vector3, end: Vector3): Vector3[];
  74588. /**
  74589. * If this plugin is supported
  74590. * @returns true if plugin is supported
  74591. */
  74592. isSupported(): boolean;
  74593. /**
  74594. * Create a new Crowd so you can add agents
  74595. * @param maxAgents the maximum agent count in the crowd
  74596. * @param maxAgentRadius the maximum radius an agent can have
  74597. * @param scene to attach the crowd to
  74598. * @returns the crowd you can add agents to
  74599. */
  74600. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  74601. /**
  74602. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  74603. * The queries will try to find a solution within those bounds
  74604. * default is (1,1,1)
  74605. * @param extent x,y,z value that define the extent around the queries point of reference
  74606. */
  74607. setDefaultQueryExtent(extent: Vector3): void;
  74608. /**
  74609. * Get the Bounding box extent specified by setDefaultQueryExtent
  74610. * @returns the box extent values
  74611. */
  74612. getDefaultQueryExtent(): Vector3;
  74613. /**
  74614. * build the navmesh from a previously saved state using getNavmeshData
  74615. * @param data the Uint8Array returned by getNavmeshData
  74616. */
  74617. buildFromNavmeshData(data: Uint8Array): void;
  74618. /**
  74619. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  74620. * @returns data the Uint8Array that can be saved and reused
  74621. */
  74622. getNavmeshData(): Uint8Array;
  74623. /**
  74624. * Get the Bounding box extent result specified by setDefaultQueryExtent
  74625. * @param result output the box extent values
  74626. */
  74627. getDefaultQueryExtentToRef(result: Vector3): void;
  74628. /**
  74629. * Set the time step of the navigation tick update.
  74630. * Default is 1/60.
  74631. * A value of 0 will disable fixed time update
  74632. * @param newTimeStep the new timestep to apply to this world.
  74633. */
  74634. setTimeStep(newTimeStep: number): void;
  74635. /**
  74636. * Get the time step of the navigation tick update.
  74637. * @returns the current time step
  74638. */
  74639. getTimeStep(): number;
  74640. /**
  74641. * If delta time in navigation tick update is greater than the time step
  74642. * a number of sub iterations are done. If more iterations are need to reach deltatime
  74643. * they will be discarded.
  74644. * A value of 0 will set to no maximum and update will use as many substeps as needed
  74645. * @param newStepCount the maximum number of iterations
  74646. */
  74647. setMaximumSubStepCount(newStepCount: number): void;
  74648. /**
  74649. * Get the maximum number of iterations per navigation tick update
  74650. * @returns the maximum number of iterations
  74651. */
  74652. getMaximumSubStepCount(): number;
  74653. /**
  74654. * Release all resources
  74655. */
  74656. dispose(): void;
  74657. }
  74658. /**
  74659. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  74660. */
  74661. export interface ICrowd {
  74662. /**
  74663. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  74664. * You can attach anything to that node. The node position is updated in the scene update tick.
  74665. * @param pos world position that will be constrained by the navigation mesh
  74666. * @param parameters agent parameters
  74667. * @param transform hooked to the agent that will be update by the scene
  74668. * @returns agent index
  74669. */
  74670. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  74671. /**
  74672. * Returns the agent position in world space
  74673. * @param index agent index returned by addAgent
  74674. * @returns world space position
  74675. */
  74676. getAgentPosition(index: number): Vector3;
  74677. /**
  74678. * Gets the agent position result in world space
  74679. * @param index agent index returned by addAgent
  74680. * @param result output world space position
  74681. */
  74682. getAgentPositionToRef(index: number, result: Vector3): void;
  74683. /**
  74684. * Gets the agent velocity in world space
  74685. * @param index agent index returned by addAgent
  74686. * @returns world space velocity
  74687. */
  74688. getAgentVelocity(index: number): Vector3;
  74689. /**
  74690. * Gets the agent velocity result in world space
  74691. * @param index agent index returned by addAgent
  74692. * @param result output world space velocity
  74693. */
  74694. getAgentVelocityToRef(index: number, result: Vector3): void;
  74695. /**
  74696. * Gets the agent next target point on the path
  74697. * @param index agent index returned by addAgent
  74698. * @returns world space position
  74699. */
  74700. getAgentNextTargetPath(index: number): Vector3;
  74701. /**
  74702. * Gets the agent state
  74703. * @param index agent index returned by addAgent
  74704. * @returns agent state
  74705. */
  74706. getAgentState(index: number): number;
  74707. /**
  74708. * returns true if the agent in over an off mesh link connection
  74709. * @param index agent index returned by addAgent
  74710. * @returns true if over an off mesh link connection
  74711. */
  74712. overOffmeshConnection(index: number): boolean;
  74713. /**
  74714. * Gets the agent next target point on the path
  74715. * @param index agent index returned by addAgent
  74716. * @param result output world space position
  74717. */
  74718. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  74719. /**
  74720. * remove a particular agent previously created
  74721. * @param index agent index returned by addAgent
  74722. */
  74723. removeAgent(index: number): void;
  74724. /**
  74725. * get the list of all agents attached to this crowd
  74726. * @returns list of agent indices
  74727. */
  74728. getAgents(): number[];
  74729. /**
  74730. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  74731. * @param deltaTime in seconds
  74732. */
  74733. update(deltaTime: number): void;
  74734. /**
  74735. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  74736. * @param index agent index returned by addAgent
  74737. * @param destination targeted world position
  74738. */
  74739. agentGoto(index: number, destination: Vector3): void;
  74740. /**
  74741. * Teleport the agent to a new position
  74742. * @param index agent index returned by addAgent
  74743. * @param destination targeted world position
  74744. */
  74745. agentTeleport(index: number, destination: Vector3): void;
  74746. /**
  74747. * Update agent parameters
  74748. * @param index agent index returned by addAgent
  74749. * @param parameters agent parameters
  74750. */
  74751. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  74752. /**
  74753. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  74754. * The queries will try to find a solution within those bounds
  74755. * default is (1,1,1)
  74756. * @param extent x,y,z value that define the extent around the queries point of reference
  74757. */
  74758. setDefaultQueryExtent(extent: Vector3): void;
  74759. /**
  74760. * Get the Bounding box extent specified by setDefaultQueryExtent
  74761. * @returns the box extent values
  74762. */
  74763. getDefaultQueryExtent(): Vector3;
  74764. /**
  74765. * Get the Bounding box extent result specified by setDefaultQueryExtent
  74766. * @param result output the box extent values
  74767. */
  74768. getDefaultQueryExtentToRef(result: Vector3): void;
  74769. /**
  74770. * Release all resources
  74771. */
  74772. dispose(): void;
  74773. }
  74774. /**
  74775. * Configures an agent
  74776. */
  74777. export interface IAgentParameters {
  74778. /**
  74779. * Agent radius. [Limit: >= 0]
  74780. */
  74781. radius: number;
  74782. /**
  74783. * Agent height. [Limit: > 0]
  74784. */
  74785. height: number;
  74786. /**
  74787. * Maximum allowed acceleration. [Limit: >= 0]
  74788. */
  74789. maxAcceleration: number;
  74790. /**
  74791. * Maximum allowed speed. [Limit: >= 0]
  74792. */
  74793. maxSpeed: number;
  74794. /**
  74795. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  74796. */
  74797. collisionQueryRange: number;
  74798. /**
  74799. * The path visibility optimization range. [Limit: > 0]
  74800. */
  74801. pathOptimizationRange: number;
  74802. /**
  74803. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  74804. */
  74805. separationWeight: number;
  74806. }
  74807. /**
  74808. * Configures the navigation mesh creation
  74809. */
  74810. export interface INavMeshParameters {
  74811. /**
  74812. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  74813. */
  74814. cs: number;
  74815. /**
  74816. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  74817. */
  74818. ch: number;
  74819. /**
  74820. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  74821. */
  74822. walkableSlopeAngle: number;
  74823. /**
  74824. * Minimum floor to 'ceiling' height that will still allow the floor area to
  74825. * be considered walkable. [Limit: >= 3] [Units: vx]
  74826. */
  74827. walkableHeight: number;
  74828. /**
  74829. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  74830. */
  74831. walkableClimb: number;
  74832. /**
  74833. * The distance to erode/shrink the walkable area of the heightfield away from
  74834. * obstructions. [Limit: >=0] [Units: vx]
  74835. */
  74836. walkableRadius: number;
  74837. /**
  74838. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  74839. */
  74840. maxEdgeLen: number;
  74841. /**
  74842. * The maximum distance a simplfied contour's border edges should deviate
  74843. * the original raw contour. [Limit: >=0] [Units: vx]
  74844. */
  74845. maxSimplificationError: number;
  74846. /**
  74847. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  74848. */
  74849. minRegionArea: number;
  74850. /**
  74851. * Any regions with a span count smaller than this value will, if possible,
  74852. * be merged with larger regions. [Limit: >=0] [Units: vx]
  74853. */
  74854. mergeRegionArea: number;
  74855. /**
  74856. * The maximum number of vertices allowed for polygons generated during the
  74857. * contour to polygon conversion process. [Limit: >= 3]
  74858. */
  74859. maxVertsPerPoly: number;
  74860. /**
  74861. * Sets the sampling distance to use when generating the detail mesh.
  74862. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  74863. */
  74864. detailSampleDist: number;
  74865. /**
  74866. * The maximum distance the detail mesh surface should deviate from heightfield
  74867. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  74868. */
  74869. detailSampleMaxError: number;
  74870. }
  74871. }
  74872. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  74873. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  74874. import { Mesh } from "babylonjs/Meshes/mesh";
  74875. import { Scene } from "babylonjs/scene";
  74876. import { Vector3 } from "babylonjs/Maths/math";
  74877. import { TransformNode } from "babylonjs/Meshes/transformNode";
  74878. /**
  74879. * RecastJS navigation plugin
  74880. */
  74881. export class RecastJSPlugin implements INavigationEnginePlugin {
  74882. /**
  74883. * Reference to the Recast library
  74884. */
  74885. bjsRECAST: any;
  74886. /**
  74887. * plugin name
  74888. */
  74889. name: string;
  74890. /**
  74891. * the first navmesh created. We might extend this to support multiple navmeshes
  74892. */
  74893. navMesh: any;
  74894. private _maximumSubStepCount;
  74895. private _timeStep;
  74896. /**
  74897. * Initializes the recastJS plugin
  74898. * @param recastInjection can be used to inject your own recast reference
  74899. */
  74900. constructor(recastInjection?: any);
  74901. /**
  74902. * Set the time step of the navigation tick update.
  74903. * Default is 1/60.
  74904. * A value of 0 will disable fixed time update
  74905. * @param newTimeStep the new timestep to apply to this world.
  74906. */
  74907. setTimeStep(newTimeStep?: number): void;
  74908. /**
  74909. * Get the time step of the navigation tick update.
  74910. * @returns the current time step
  74911. */
  74912. getTimeStep(): number;
  74913. /**
  74914. * If delta time in navigation tick update is greater than the time step
  74915. * a number of sub iterations are done. If more iterations are need to reach deltatime
  74916. * they will be discarded.
  74917. * A value of 0 will set to no maximum and update will use as many substeps as needed
  74918. * @param newStepCount the maximum number of iterations
  74919. */
  74920. setMaximumSubStepCount(newStepCount?: number): void;
  74921. /**
  74922. * Get the maximum number of iterations per navigation tick update
  74923. * @returns the maximum number of iterations
  74924. */
  74925. getMaximumSubStepCount(): number;
  74926. /**
  74927. * Creates a navigation mesh
  74928. * @param meshes array of all the geometry used to compute the navigatio mesh
  74929. * @param parameters bunch of parameters used to filter geometry
  74930. */
  74931. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  74932. /**
  74933. * Create a navigation mesh debug mesh
  74934. * @param scene is where the mesh will be added
  74935. * @returns debug display mesh
  74936. */
  74937. createDebugNavMesh(scene: Scene): Mesh;
  74938. /**
  74939. * Get a navigation mesh constrained position, closest to the parameter position
  74940. * @param position world position
  74941. * @returns the closest point to position constrained by the navigation mesh
  74942. */
  74943. getClosestPoint(position: Vector3): Vector3;
  74944. /**
  74945. * Get a navigation mesh constrained position, closest to the parameter position
  74946. * @param position world position
  74947. * @param result output the closest point to position constrained by the navigation mesh
  74948. */
  74949. getClosestPointToRef(position: Vector3, result: Vector3): void;
  74950. /**
  74951. * Get a navigation mesh constrained position, within a particular radius
  74952. * @param position world position
  74953. * @param maxRadius the maximum distance to the constrained world position
  74954. * @returns the closest point to position constrained by the navigation mesh
  74955. */
  74956. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  74957. /**
  74958. * Get a navigation mesh constrained position, within a particular radius
  74959. * @param position world position
  74960. * @param maxRadius the maximum distance to the constrained world position
  74961. * @param result output the closest point to position constrained by the navigation mesh
  74962. */
  74963. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  74964. /**
  74965. * Compute the final position from a segment made of destination-position
  74966. * @param position world position
  74967. * @param destination world position
  74968. * @returns the resulting point along the navmesh
  74969. */
  74970. moveAlong(position: Vector3, destination: Vector3): Vector3;
  74971. /**
  74972. * Compute the final position from a segment made of destination-position
  74973. * @param position world position
  74974. * @param destination world position
  74975. * @param result output the resulting point along the navmesh
  74976. */
  74977. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  74978. /**
  74979. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  74980. * @param start world position
  74981. * @param end world position
  74982. * @returns array containing world position composing the path
  74983. */
  74984. computePath(start: Vector3, end: Vector3): Vector3[];
  74985. /**
  74986. * Create a new Crowd so you can add agents
  74987. * @param maxAgents the maximum agent count in the crowd
  74988. * @param maxAgentRadius the maximum radius an agent can have
  74989. * @param scene to attach the crowd to
  74990. * @returns the crowd you can add agents to
  74991. */
  74992. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  74993. /**
  74994. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  74995. * The queries will try to find a solution within those bounds
  74996. * default is (1,1,1)
  74997. * @param extent x,y,z value that define the extent around the queries point of reference
  74998. */
  74999. setDefaultQueryExtent(extent: Vector3): void;
  75000. /**
  75001. * Get the Bounding box extent specified by setDefaultQueryExtent
  75002. * @returns the box extent values
  75003. */
  75004. getDefaultQueryExtent(): Vector3;
  75005. /**
  75006. * build the navmesh from a previously saved state using getNavmeshData
  75007. * @param data the Uint8Array returned by getNavmeshData
  75008. */
  75009. buildFromNavmeshData(data: Uint8Array): void;
  75010. /**
  75011. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  75012. * @returns data the Uint8Array that can be saved and reused
  75013. */
  75014. getNavmeshData(): Uint8Array;
  75015. /**
  75016. * Get the Bounding box extent result specified by setDefaultQueryExtent
  75017. * @param result output the box extent values
  75018. */
  75019. getDefaultQueryExtentToRef(result: Vector3): void;
  75020. /**
  75021. * Disposes
  75022. */
  75023. dispose(): void;
  75024. /**
  75025. * If this plugin is supported
  75026. * @returns true if plugin is supported
  75027. */
  75028. isSupported(): boolean;
  75029. }
  75030. /**
  75031. * Recast detour crowd implementation
  75032. */
  75033. export class RecastJSCrowd implements ICrowd {
  75034. /**
  75035. * Recast/detour plugin
  75036. */
  75037. bjsRECASTPlugin: RecastJSPlugin;
  75038. /**
  75039. * Link to the detour crowd
  75040. */
  75041. recastCrowd: any;
  75042. /**
  75043. * One transform per agent
  75044. */
  75045. transforms: TransformNode[];
  75046. /**
  75047. * All agents created
  75048. */
  75049. agents: number[];
  75050. /**
  75051. * Link to the scene is kept to unregister the crowd from the scene
  75052. */
  75053. private _scene;
  75054. /**
  75055. * Observer for crowd updates
  75056. */
  75057. private _onBeforeAnimationsObserver;
  75058. /**
  75059. * Constructor
  75060. * @param plugin recastJS plugin
  75061. * @param maxAgents the maximum agent count in the crowd
  75062. * @param maxAgentRadius the maximum radius an agent can have
  75063. * @param scene to attach the crowd to
  75064. * @returns the crowd you can add agents to
  75065. */
  75066. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  75067. /**
  75068. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  75069. * You can attach anything to that node. The node position is updated in the scene update tick.
  75070. * @param pos world position that will be constrained by the navigation mesh
  75071. * @param parameters agent parameters
  75072. * @param transform hooked to the agent that will be update by the scene
  75073. * @returns agent index
  75074. */
  75075. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  75076. /**
  75077. * Returns the agent position in world space
  75078. * @param index agent index returned by addAgent
  75079. * @returns world space position
  75080. */
  75081. getAgentPosition(index: number): Vector3;
  75082. /**
  75083. * Returns the agent position result in world space
  75084. * @param index agent index returned by addAgent
  75085. * @param result output world space position
  75086. */
  75087. getAgentPositionToRef(index: number, result: Vector3): void;
  75088. /**
  75089. * Returns the agent velocity in world space
  75090. * @param index agent index returned by addAgent
  75091. * @returns world space velocity
  75092. */
  75093. getAgentVelocity(index: number): Vector3;
  75094. /**
  75095. * Returns the agent velocity result in world space
  75096. * @param index agent index returned by addAgent
  75097. * @param result output world space velocity
  75098. */
  75099. getAgentVelocityToRef(index: number, result: Vector3): void;
  75100. /**
  75101. * Returns the agent next target point on the path
  75102. * @param index agent index returned by addAgent
  75103. * @returns world space position
  75104. */
  75105. getAgentNextTargetPath(index: number): Vector3;
  75106. /**
  75107. * Returns the agent next target point on the path
  75108. * @param index agent index returned by addAgent
  75109. * @param result output world space position
  75110. */
  75111. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  75112. /**
  75113. * Gets the agent state
  75114. * @param index agent index returned by addAgent
  75115. * @returns agent state
  75116. */
  75117. getAgentState(index: number): number;
  75118. /**
  75119. * returns true if the agent in over an off mesh link connection
  75120. * @param index agent index returned by addAgent
  75121. * @returns true if over an off mesh link connection
  75122. */
  75123. overOffmeshConnection(index: number): boolean;
  75124. /**
  75125. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  75126. * @param index agent index returned by addAgent
  75127. * @param destination targeted world position
  75128. */
  75129. agentGoto(index: number, destination: Vector3): void;
  75130. /**
  75131. * Teleport the agent to a new position
  75132. * @param index agent index returned by addAgent
  75133. * @param destination targeted world position
  75134. */
  75135. agentTeleport(index: number, destination: Vector3): void;
  75136. /**
  75137. * Update agent parameters
  75138. * @param index agent index returned by addAgent
  75139. * @param parameters agent parameters
  75140. */
  75141. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  75142. /**
  75143. * remove a particular agent previously created
  75144. * @param index agent index returned by addAgent
  75145. */
  75146. removeAgent(index: number): void;
  75147. /**
  75148. * get the list of all agents attached to this crowd
  75149. * @returns list of agent indices
  75150. */
  75151. getAgents(): number[];
  75152. /**
  75153. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  75154. * @param deltaTime in seconds
  75155. */
  75156. update(deltaTime: number): void;
  75157. /**
  75158. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  75159. * The queries will try to find a solution within those bounds
  75160. * default is (1,1,1)
  75161. * @param extent x,y,z value that define the extent around the queries point of reference
  75162. */
  75163. setDefaultQueryExtent(extent: Vector3): void;
  75164. /**
  75165. * Get the Bounding box extent specified by setDefaultQueryExtent
  75166. * @returns the box extent values
  75167. */
  75168. getDefaultQueryExtent(): Vector3;
  75169. /**
  75170. * Get the Bounding box extent result specified by setDefaultQueryExtent
  75171. * @param result output the box extent values
  75172. */
  75173. getDefaultQueryExtentToRef(result: Vector3): void;
  75174. /**
  75175. * Release all resources
  75176. */
  75177. dispose(): void;
  75178. }
  75179. }
  75180. declare module "babylonjs/Navigation/Plugins/index" {
  75181. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  75182. }
  75183. declare module "babylonjs/Navigation/index" {
  75184. export * from "babylonjs/Navigation/INavigationEngine";
  75185. export * from "babylonjs/Navigation/Plugins/index";
  75186. }
  75187. declare module "babylonjs/Offline/database" {
  75188. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  75189. /**
  75190. * Class used to enable access to IndexedDB
  75191. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  75192. */
  75193. export class Database implements IOfflineProvider {
  75194. private _callbackManifestChecked;
  75195. private _currentSceneUrl;
  75196. private _db;
  75197. private _enableSceneOffline;
  75198. private _enableTexturesOffline;
  75199. private _manifestVersionFound;
  75200. private _mustUpdateRessources;
  75201. private _hasReachedQuota;
  75202. private _isSupported;
  75203. private _idbFactory;
  75204. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  75205. private static IsUASupportingBlobStorage;
  75206. /**
  75207. * Gets a boolean indicating if Database storate is enabled (off by default)
  75208. */
  75209. static IDBStorageEnabled: boolean;
  75210. /**
  75211. * Gets a boolean indicating if scene must be saved in the database
  75212. */
  75213. get enableSceneOffline(): boolean;
  75214. /**
  75215. * Gets a boolean indicating if textures must be saved in the database
  75216. */
  75217. get enableTexturesOffline(): boolean;
  75218. /**
  75219. * Creates a new Database
  75220. * @param urlToScene defines the url to load the scene
  75221. * @param callbackManifestChecked defines the callback to use when manifest is checked
  75222. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  75223. */
  75224. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  75225. private static _ParseURL;
  75226. private static _ReturnFullUrlLocation;
  75227. private _checkManifestFile;
  75228. /**
  75229. * Open the database and make it available
  75230. * @param successCallback defines the callback to call on success
  75231. * @param errorCallback defines the callback to call on error
  75232. */
  75233. open(successCallback: () => void, errorCallback: () => void): void;
  75234. /**
  75235. * Loads an image from the database
  75236. * @param url defines the url to load from
  75237. * @param image defines the target DOM image
  75238. */
  75239. loadImage(url: string, image: HTMLImageElement): void;
  75240. private _loadImageFromDBAsync;
  75241. private _saveImageIntoDBAsync;
  75242. private _checkVersionFromDB;
  75243. private _loadVersionFromDBAsync;
  75244. private _saveVersionIntoDBAsync;
  75245. /**
  75246. * Loads a file from database
  75247. * @param url defines the URL to load from
  75248. * @param sceneLoaded defines a callback to call on success
  75249. * @param progressCallBack defines a callback to call when progress changed
  75250. * @param errorCallback defines a callback to call on error
  75251. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  75252. */
  75253. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  75254. private _loadFileAsync;
  75255. private _saveFileAsync;
  75256. /**
  75257. * Validates if xhr data is correct
  75258. * @param xhr defines the request to validate
  75259. * @param dataType defines the expected data type
  75260. * @returns true if data is correct
  75261. */
  75262. private static _ValidateXHRData;
  75263. }
  75264. }
  75265. declare module "babylonjs/Offline/index" {
  75266. export * from "babylonjs/Offline/database";
  75267. export * from "babylonjs/Offline/IOfflineProvider";
  75268. }
  75269. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  75270. /** @hidden */
  75271. export var gpuUpdateParticlesPixelShader: {
  75272. name: string;
  75273. shader: string;
  75274. };
  75275. }
  75276. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  75277. /** @hidden */
  75278. export var gpuUpdateParticlesVertexShader: {
  75279. name: string;
  75280. shader: string;
  75281. };
  75282. }
  75283. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  75284. /** @hidden */
  75285. export var clipPlaneFragmentDeclaration2: {
  75286. name: string;
  75287. shader: string;
  75288. };
  75289. }
  75290. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  75291. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  75292. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  75293. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  75294. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  75295. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  75296. /** @hidden */
  75297. export var gpuRenderParticlesPixelShader: {
  75298. name: string;
  75299. shader: string;
  75300. };
  75301. }
  75302. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  75303. /** @hidden */
  75304. export var clipPlaneVertexDeclaration2: {
  75305. name: string;
  75306. shader: string;
  75307. };
  75308. }
  75309. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  75310. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  75311. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  75312. /** @hidden */
  75313. export var gpuRenderParticlesVertexShader: {
  75314. name: string;
  75315. shader: string;
  75316. };
  75317. }
  75318. declare module "babylonjs/Particles/gpuParticleSystem" {
  75319. import { Nullable } from "babylonjs/types";
  75320. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  75321. import { Observable } from "babylonjs/Misc/observable";
  75322. import { Matrix } from "babylonjs/Maths/math.vector";
  75323. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  75324. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  75325. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  75326. import { IDisposable } from "babylonjs/scene";
  75327. import { Effect } from "babylonjs/Materials/effect";
  75328. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  75329. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  75330. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  75331. import { Scene } from "babylonjs/scene";
  75332. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  75333. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  75334. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  75335. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  75336. /**
  75337. * This represents a GPU particle system in Babylon
  75338. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  75339. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  75340. */
  75341. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  75342. /**
  75343. * The layer mask we are rendering the particles through.
  75344. */
  75345. layerMask: number;
  75346. private _capacity;
  75347. private _activeCount;
  75348. private _currentActiveCount;
  75349. private _accumulatedCount;
  75350. private _renderEffect;
  75351. private _updateEffect;
  75352. private _buffer0;
  75353. private _buffer1;
  75354. private _spriteBuffer;
  75355. private _updateVAO;
  75356. private _renderVAO;
  75357. private _targetIndex;
  75358. private _sourceBuffer;
  75359. private _targetBuffer;
  75360. private _currentRenderId;
  75361. private _started;
  75362. private _stopped;
  75363. private _timeDelta;
  75364. private _randomTexture;
  75365. private _randomTexture2;
  75366. private _attributesStrideSize;
  75367. private _updateEffectOptions;
  75368. private _randomTextureSize;
  75369. private _actualFrame;
  75370. private _customEffect;
  75371. private readonly _rawTextureWidth;
  75372. /**
  75373. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  75374. */
  75375. static get IsSupported(): boolean;
  75376. /**
  75377. * An event triggered when the system is disposed.
  75378. */
  75379. onDisposeObservable: Observable<IParticleSystem>;
  75380. /**
  75381. * An event triggered when the system is stopped
  75382. */
  75383. onStoppedObservable: Observable<IParticleSystem>;
  75384. /**
  75385. * Gets the maximum number of particles active at the same time.
  75386. * @returns The max number of active particles.
  75387. */
  75388. getCapacity(): number;
  75389. /**
  75390. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  75391. * to override the particles.
  75392. */
  75393. forceDepthWrite: boolean;
  75394. /**
  75395. * Gets or set the number of active particles
  75396. */
  75397. get activeParticleCount(): number;
  75398. set activeParticleCount(value: number);
  75399. private _preWarmDone;
  75400. /**
  75401. * Specifies if the particles are updated in emitter local space or world space.
  75402. */
  75403. isLocal: boolean;
  75404. /** Gets or sets a matrix to use to compute projection */
  75405. defaultProjectionMatrix: Matrix;
  75406. /**
  75407. * Is this system ready to be used/rendered
  75408. * @return true if the system is ready
  75409. */
  75410. isReady(): boolean;
  75411. /**
  75412. * Gets if the system has been started. (Note: this will still be true after stop is called)
  75413. * @returns True if it has been started, otherwise false.
  75414. */
  75415. isStarted(): boolean;
  75416. /**
  75417. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  75418. * @returns True if it has been stopped, otherwise false.
  75419. */
  75420. isStopped(): boolean;
  75421. /**
  75422. * Gets a boolean indicating that the system is stopping
  75423. * @returns true if the system is currently stopping
  75424. */
  75425. isStopping(): boolean;
  75426. /**
  75427. * Gets the number of particles active at the same time.
  75428. * @returns The number of active particles.
  75429. */
  75430. getActiveCount(): number;
  75431. /**
  75432. * Starts the particle system and begins to emit
  75433. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  75434. */
  75435. start(delay?: number): void;
  75436. /**
  75437. * Stops the particle system.
  75438. */
  75439. stop(): void;
  75440. /**
  75441. * Remove all active particles
  75442. */
  75443. reset(): void;
  75444. /**
  75445. * Returns the string "GPUParticleSystem"
  75446. * @returns a string containing the class name
  75447. */
  75448. getClassName(): string;
  75449. /**
  75450. * Gets the custom effect used to render the particles
  75451. * @param blendMode Blend mode for which the effect should be retrieved
  75452. * @returns The effect
  75453. */
  75454. getCustomEffect(blendMode?: number): Nullable<Effect>;
  75455. /**
  75456. * Sets the custom effect used to render the particles
  75457. * @param effect The effect to set
  75458. * @param blendMode Blend mode for which the effect should be set
  75459. */
  75460. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  75461. /** @hidden */
  75462. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  75463. /**
  75464. * Observable that will be called just before the particles are drawn
  75465. */
  75466. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  75467. /**
  75468. * Gets the name of the particle vertex shader
  75469. */
  75470. get vertexShaderName(): string;
  75471. private _colorGradientsTexture;
  75472. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  75473. /**
  75474. * Adds a new color gradient
  75475. * @param gradient defines the gradient to use (between 0 and 1)
  75476. * @param color1 defines the color to affect to the specified gradient
  75477. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  75478. * @returns the current particle system
  75479. */
  75480. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  75481. private _refreshColorGradient;
  75482. /** Force the system to rebuild all gradients that need to be resync */
  75483. forceRefreshGradients(): void;
  75484. /**
  75485. * Remove a specific color gradient
  75486. * @param gradient defines the gradient to remove
  75487. * @returns the current particle system
  75488. */
  75489. removeColorGradient(gradient: number): GPUParticleSystem;
  75490. private _angularSpeedGradientsTexture;
  75491. private _sizeGradientsTexture;
  75492. private _velocityGradientsTexture;
  75493. private _limitVelocityGradientsTexture;
  75494. private _dragGradientsTexture;
  75495. private _addFactorGradient;
  75496. /**
  75497. * Adds a new size gradient
  75498. * @param gradient defines the gradient to use (between 0 and 1)
  75499. * @param factor defines the size factor to affect to the specified gradient
  75500. * @returns the current particle system
  75501. */
  75502. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  75503. /**
  75504. * Remove a specific size gradient
  75505. * @param gradient defines the gradient to remove
  75506. * @returns the current particle system
  75507. */
  75508. removeSizeGradient(gradient: number): GPUParticleSystem;
  75509. private _refreshFactorGradient;
  75510. /**
  75511. * Adds a new angular speed gradient
  75512. * @param gradient defines the gradient to use (between 0 and 1)
  75513. * @param factor defines the angular speed to affect to the specified gradient
  75514. * @returns the current particle system
  75515. */
  75516. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  75517. /**
  75518. * Remove a specific angular speed gradient
  75519. * @param gradient defines the gradient to remove
  75520. * @returns the current particle system
  75521. */
  75522. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  75523. /**
  75524. * Adds a new velocity gradient
  75525. * @param gradient defines the gradient to use (between 0 and 1)
  75526. * @param factor defines the velocity to affect to the specified gradient
  75527. * @returns the current particle system
  75528. */
  75529. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  75530. /**
  75531. * Remove a specific velocity gradient
  75532. * @param gradient defines the gradient to remove
  75533. * @returns the current particle system
  75534. */
  75535. removeVelocityGradient(gradient: number): GPUParticleSystem;
  75536. /**
  75537. * Adds a new limit velocity gradient
  75538. * @param gradient defines the gradient to use (between 0 and 1)
  75539. * @param factor defines the limit velocity value to affect to the specified gradient
  75540. * @returns the current particle system
  75541. */
  75542. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  75543. /**
  75544. * Remove a specific limit velocity gradient
  75545. * @param gradient defines the gradient to remove
  75546. * @returns the current particle system
  75547. */
  75548. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  75549. /**
  75550. * Adds a new drag gradient
  75551. * @param gradient defines the gradient to use (between 0 and 1)
  75552. * @param factor defines the drag value to affect to the specified gradient
  75553. * @returns the current particle system
  75554. */
  75555. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  75556. /**
  75557. * Remove a specific drag gradient
  75558. * @param gradient defines the gradient to remove
  75559. * @returns the current particle system
  75560. */
  75561. removeDragGradient(gradient: number): GPUParticleSystem;
  75562. /**
  75563. * Not supported by GPUParticleSystem
  75564. * @param gradient defines the gradient to use (between 0 and 1)
  75565. * @param factor defines the emit rate value to affect to the specified gradient
  75566. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75567. * @returns the current particle system
  75568. */
  75569. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75570. /**
  75571. * Not supported by GPUParticleSystem
  75572. * @param gradient defines the gradient to remove
  75573. * @returns the current particle system
  75574. */
  75575. removeEmitRateGradient(gradient: number): IParticleSystem;
  75576. /**
  75577. * Not supported by GPUParticleSystem
  75578. * @param gradient defines the gradient to use (between 0 and 1)
  75579. * @param factor defines the start size value to affect to the specified gradient
  75580. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75581. * @returns the current particle system
  75582. */
  75583. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75584. /**
  75585. * Not supported by GPUParticleSystem
  75586. * @param gradient defines the gradient to remove
  75587. * @returns the current particle system
  75588. */
  75589. removeStartSizeGradient(gradient: number): IParticleSystem;
  75590. /**
  75591. * Not supported by GPUParticleSystem
  75592. * @param gradient defines the gradient to use (between 0 and 1)
  75593. * @param min defines the color remap minimal range
  75594. * @param max defines the color remap maximal range
  75595. * @returns the current particle system
  75596. */
  75597. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75598. /**
  75599. * Not supported by GPUParticleSystem
  75600. * @param gradient defines the gradient to remove
  75601. * @returns the current particle system
  75602. */
  75603. removeColorRemapGradient(): IParticleSystem;
  75604. /**
  75605. * Not supported by GPUParticleSystem
  75606. * @param gradient defines the gradient to use (between 0 and 1)
  75607. * @param min defines the alpha remap minimal range
  75608. * @param max defines the alpha remap maximal range
  75609. * @returns the current particle system
  75610. */
  75611. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75612. /**
  75613. * Not supported by GPUParticleSystem
  75614. * @param gradient defines the gradient to remove
  75615. * @returns the current particle system
  75616. */
  75617. removeAlphaRemapGradient(): IParticleSystem;
  75618. /**
  75619. * Not supported by GPUParticleSystem
  75620. * @param gradient defines the gradient to use (between 0 and 1)
  75621. * @param color defines the color to affect to the specified gradient
  75622. * @returns the current particle system
  75623. */
  75624. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  75625. /**
  75626. * Not supported by GPUParticleSystem
  75627. * @param gradient defines the gradient to remove
  75628. * @returns the current particle system
  75629. */
  75630. removeRampGradient(): IParticleSystem;
  75631. /**
  75632. * Not supported by GPUParticleSystem
  75633. * @returns the list of ramp gradients
  75634. */
  75635. getRampGradients(): Nullable<Array<Color3Gradient>>;
  75636. /**
  75637. * Not supported by GPUParticleSystem
  75638. * Gets or sets a boolean indicating that ramp gradients must be used
  75639. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  75640. */
  75641. get useRampGradients(): boolean;
  75642. set useRampGradients(value: boolean);
  75643. /**
  75644. * Not supported by GPUParticleSystem
  75645. * @param gradient defines the gradient to use (between 0 and 1)
  75646. * @param factor defines the life time factor to affect to the specified gradient
  75647. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75648. * @returns the current particle system
  75649. */
  75650. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75651. /**
  75652. * Not supported by GPUParticleSystem
  75653. * @param gradient defines the gradient to remove
  75654. * @returns the current particle system
  75655. */
  75656. removeLifeTimeGradient(gradient: number): IParticleSystem;
  75657. /**
  75658. * Instantiates a GPU particle system.
  75659. * 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.
  75660. * @param name The name of the particle system
  75661. * @param options The options used to create the system
  75662. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  75663. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  75664. * @param customEffect a custom effect used to change the way particles are rendered by default
  75665. */
  75666. constructor(name: string, options: Partial<{
  75667. capacity: number;
  75668. randomTextureSize: number;
  75669. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  75670. protected _reset(): void;
  75671. private _createUpdateVAO;
  75672. private _createRenderVAO;
  75673. private _initialize;
  75674. /** @hidden */
  75675. _recreateUpdateEffect(): void;
  75676. private _getEffect;
  75677. /**
  75678. * Fill the defines array according to the current settings of the particle system
  75679. * @param defines Array to be updated
  75680. * @param blendMode blend mode to take into account when updating the array
  75681. */
  75682. fillDefines(defines: Array<string>, blendMode?: number): void;
  75683. /**
  75684. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  75685. * @param uniforms Uniforms array to fill
  75686. * @param attributes Attributes array to fill
  75687. * @param samplers Samplers array to fill
  75688. */
  75689. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  75690. /** @hidden */
  75691. _recreateRenderEffect(): Effect;
  75692. /**
  75693. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  75694. * @param preWarm defines if we are in the pre-warmimg phase
  75695. */
  75696. animate(preWarm?: boolean): void;
  75697. private _createFactorGradientTexture;
  75698. private _createSizeGradientTexture;
  75699. private _createAngularSpeedGradientTexture;
  75700. private _createVelocityGradientTexture;
  75701. private _createLimitVelocityGradientTexture;
  75702. private _createDragGradientTexture;
  75703. private _createColorGradientTexture;
  75704. /**
  75705. * Renders the particle system in its current state
  75706. * @param preWarm defines if the system should only update the particles but not render them
  75707. * @returns the current number of particles
  75708. */
  75709. render(preWarm?: boolean): number;
  75710. /**
  75711. * Rebuilds the particle system
  75712. */
  75713. rebuild(): void;
  75714. private _releaseBuffers;
  75715. private _releaseVAOs;
  75716. /**
  75717. * Disposes the particle system and free the associated resources
  75718. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  75719. */
  75720. dispose(disposeTexture?: boolean): void;
  75721. /**
  75722. * Clones the particle system.
  75723. * @param name The name of the cloned object
  75724. * @param newEmitter The new emitter to use
  75725. * @returns the cloned particle system
  75726. */
  75727. clone(name: string, newEmitter: any): GPUParticleSystem;
  75728. /**
  75729. * Serializes the particle system to a JSON object
  75730. * @param serializeTexture defines if the texture must be serialized as well
  75731. * @returns the JSON object
  75732. */
  75733. serialize(serializeTexture?: boolean): any;
  75734. /**
  75735. * Parses a JSON object to create a GPU particle system.
  75736. * @param parsedParticleSystem The JSON object to parse
  75737. * @param sceneOrEngine The scene or the engine to create the particle system in
  75738. * @param rootUrl The root url to use to load external dependencies like texture
  75739. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  75740. * @returns the parsed GPU particle system
  75741. */
  75742. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  75743. }
  75744. }
  75745. declare module "babylonjs/Particles/particleSystemSet" {
  75746. import { Nullable } from "babylonjs/types";
  75747. import { Color3 } from "babylonjs/Maths/math.color";
  75748. import { TransformNode } from "babylonjs/Meshes/transformNode";
  75749. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75750. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  75751. import { Scene, IDisposable } from "babylonjs/scene";
  75752. /**
  75753. * Represents a set of particle systems working together to create a specific effect
  75754. */
  75755. export class ParticleSystemSet implements IDisposable {
  75756. /**
  75757. * Gets or sets base Assets URL
  75758. */
  75759. static BaseAssetsUrl: string;
  75760. private _emitterCreationOptions;
  75761. private _emitterNode;
  75762. /**
  75763. * Gets the particle system list
  75764. */
  75765. systems: IParticleSystem[];
  75766. /**
  75767. * Gets the emitter node used with this set
  75768. */
  75769. get emitterNode(): Nullable<TransformNode>;
  75770. /**
  75771. * Creates a new emitter mesh as a sphere
  75772. * @param options defines the options used to create the sphere
  75773. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  75774. * @param scene defines the hosting scene
  75775. */
  75776. setEmitterAsSphere(options: {
  75777. diameter: number;
  75778. segments: number;
  75779. color: Color3;
  75780. }, renderingGroupId: number, scene: Scene): void;
  75781. /**
  75782. * Starts all particle systems of the set
  75783. * @param emitter defines an optional mesh to use as emitter for the particle systems
  75784. */
  75785. start(emitter?: AbstractMesh): void;
  75786. /**
  75787. * Release all associated resources
  75788. */
  75789. dispose(): void;
  75790. /**
  75791. * Serialize the set into a JSON compatible object
  75792. * @param serializeTexture defines if the texture must be serialized as well
  75793. * @returns a JSON compatible representation of the set
  75794. */
  75795. serialize(serializeTexture?: boolean): any;
  75796. /**
  75797. * Parse a new ParticleSystemSet from a serialized source
  75798. * @param data defines a JSON compatible representation of the set
  75799. * @param scene defines the hosting scene
  75800. * @param gpu defines if we want GPU particles or CPU particles
  75801. * @returns a new ParticleSystemSet
  75802. */
  75803. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  75804. }
  75805. }
  75806. declare module "babylonjs/Particles/particleHelper" {
  75807. import { Nullable } from "babylonjs/types";
  75808. import { Scene } from "babylonjs/scene";
  75809. import { Vector3 } from "babylonjs/Maths/math.vector";
  75810. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75811. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  75812. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  75813. /**
  75814. * This class is made for on one-liner static method to help creating particle system set.
  75815. */
  75816. export class ParticleHelper {
  75817. /**
  75818. * Gets or sets base Assets URL
  75819. */
  75820. static BaseAssetsUrl: string;
  75821. /** Define the Url to load snippets */
  75822. static SnippetUrl: string;
  75823. /**
  75824. * Create a default particle system that you can tweak
  75825. * @param emitter defines the emitter to use
  75826. * @param capacity defines the system capacity (default is 500 particles)
  75827. * @param scene defines the hosting scene
  75828. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  75829. * @returns the new Particle system
  75830. */
  75831. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  75832. /**
  75833. * This is the main static method (one-liner) of this helper to create different particle systems
  75834. * @param type This string represents the type to the particle system to create
  75835. * @param scene The scene where the particle system should live
  75836. * @param gpu If the system will use gpu
  75837. * @returns the ParticleSystemSet created
  75838. */
  75839. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  75840. /**
  75841. * Static function used to export a particle system to a ParticleSystemSet variable.
  75842. * Please note that the emitter shape is not exported
  75843. * @param systems defines the particle systems to export
  75844. * @returns the created particle system set
  75845. */
  75846. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  75847. /**
  75848. * Creates a particle system from a snippet saved in a remote file
  75849. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  75850. * @param url defines the url to load from
  75851. * @param scene defines the hosting scene
  75852. * @param gpu If the system will use gpu
  75853. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  75854. * @returns a promise that will resolve to the new particle system
  75855. */
  75856. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  75857. /**
  75858. * Creates a particle system from a snippet saved by the particle system editor
  75859. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  75860. * @param scene defines the hosting scene
  75861. * @param gpu If the system will use gpu
  75862. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  75863. * @returns a promise that will resolve to the new particle system
  75864. */
  75865. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  75866. }
  75867. }
  75868. declare module "babylonjs/Particles/particleSystemComponent" {
  75869. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  75870. import { Effect } from "babylonjs/Materials/effect";
  75871. import "babylonjs/Shaders/particles.vertex";
  75872. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  75873. module "babylonjs/Engines/engine" {
  75874. interface Engine {
  75875. /**
  75876. * Create an effect to use with particle systems.
  75877. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  75878. * the particle system for which you want to create a custom effect in the last parameter
  75879. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  75880. * @param uniformsNames defines a list of attribute names
  75881. * @param samplers defines an array of string used to represent textures
  75882. * @param defines defines the string containing the defines to use to compile the shaders
  75883. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  75884. * @param onCompiled defines a function to call when the effect creation is successful
  75885. * @param onError defines a function to call when the effect creation has failed
  75886. * @param particleSystem the particle system you want to create the effect for
  75887. * @returns the new Effect
  75888. */
  75889. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  75890. }
  75891. }
  75892. module "babylonjs/Meshes/mesh" {
  75893. interface Mesh {
  75894. /**
  75895. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  75896. * @returns an array of IParticleSystem
  75897. */
  75898. getEmittedParticleSystems(): IParticleSystem[];
  75899. /**
  75900. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  75901. * @returns an array of IParticleSystem
  75902. */
  75903. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  75904. }
  75905. }
  75906. }
  75907. declare module "babylonjs/Particles/pointsCloudSystem" {
  75908. import { Color4 } from "babylonjs/Maths/math";
  75909. import { Mesh } from "babylonjs/Meshes/mesh";
  75910. import { Scene, IDisposable } from "babylonjs/scene";
  75911. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  75912. /** Defines the 4 color options */
  75913. export enum PointColor {
  75914. /** color value */
  75915. Color = 2,
  75916. /** uv value */
  75917. UV = 1,
  75918. /** random value */
  75919. Random = 0,
  75920. /** stated value */
  75921. Stated = 3
  75922. }
  75923. /**
  75924. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  75925. * 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.
  75926. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  75927. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  75928. *
  75929. * Full documentation here : TO BE ENTERED
  75930. */
  75931. export class PointsCloudSystem implements IDisposable {
  75932. /**
  75933. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  75934. * Example : var p = SPS.particles[i];
  75935. */
  75936. particles: CloudPoint[];
  75937. /**
  75938. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  75939. */
  75940. nbParticles: number;
  75941. /**
  75942. * This a counter for your own usage. It's not set by any SPS functions.
  75943. */
  75944. counter: number;
  75945. /**
  75946. * The PCS name. This name is also given to the underlying mesh.
  75947. */
  75948. name: string;
  75949. /**
  75950. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  75951. */
  75952. mesh: Mesh;
  75953. /**
  75954. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  75955. * Please read :
  75956. */
  75957. vars: any;
  75958. /**
  75959. * @hidden
  75960. */
  75961. _size: number;
  75962. private _scene;
  75963. private _promises;
  75964. private _positions;
  75965. private _indices;
  75966. private _normals;
  75967. private _colors;
  75968. private _uvs;
  75969. private _indices32;
  75970. private _positions32;
  75971. private _colors32;
  75972. private _uvs32;
  75973. private _updatable;
  75974. private _isVisibilityBoxLocked;
  75975. private _alwaysVisible;
  75976. private _groups;
  75977. private _groupCounter;
  75978. private _computeParticleColor;
  75979. private _computeParticleTexture;
  75980. private _computeParticleRotation;
  75981. private _computeBoundingBox;
  75982. private _isReady;
  75983. /**
  75984. * Creates a PCS (Points Cloud System) object
  75985. * @param name (String) is the PCS name, this will be the underlying mesh name
  75986. * @param pointSize (number) is the size for each point
  75987. * @param scene (Scene) is the scene in which the PCS is added
  75988. * @param options defines the options of the PCS e.g.
  75989. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  75990. */
  75991. constructor(name: string, pointSize: number, scene: Scene, options?: {
  75992. updatable?: boolean;
  75993. });
  75994. /**
  75995. * Builds the PCS underlying mesh. Returns a standard Mesh.
  75996. * If no points were added to the PCS, the returned mesh is just a single point.
  75997. * @returns a promise for the created mesh
  75998. */
  75999. buildMeshAsync(): Promise<Mesh>;
  76000. /**
  76001. * @hidden
  76002. */
  76003. private _buildMesh;
  76004. private _addParticle;
  76005. private _randomUnitVector;
  76006. private _getColorIndicesForCoord;
  76007. private _setPointsColorOrUV;
  76008. private _colorFromTexture;
  76009. private _calculateDensity;
  76010. /**
  76011. * Adds points to the PCS in random positions within a unit sphere
  76012. * @param nb (positive integer) the number of particles to be created from this model
  76013. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  76014. * @returns the number of groups in the system
  76015. */
  76016. addPoints(nb: number, pointFunction?: any): number;
  76017. /**
  76018. * Adds points to the PCS from the surface of the model shape
  76019. * @param mesh is any Mesh object that will be used as a surface model for the points
  76020. * @param nb (positive integer) the number of particles to be created from this model
  76021. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  76022. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  76023. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  76024. * @returns the number of groups in the system
  76025. */
  76026. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  76027. /**
  76028. * Adds points to the PCS inside the model shape
  76029. * @param mesh is any Mesh object that will be used as a surface model for the points
  76030. * @param nb (positive integer) the number of particles to be created from this model
  76031. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  76032. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  76033. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  76034. * @returns the number of groups in the system
  76035. */
  76036. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  76037. /**
  76038. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  76039. * This method calls `updateParticle()` for each particle of the SPS.
  76040. * For an animated SPS, it is usually called within the render loop.
  76041. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  76042. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  76043. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  76044. * @returns the PCS.
  76045. */
  76046. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  76047. /**
  76048. * Disposes the PCS.
  76049. */
  76050. dispose(): void;
  76051. /**
  76052. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  76053. * doc :
  76054. * @returns the PCS.
  76055. */
  76056. refreshVisibleSize(): PointsCloudSystem;
  76057. /**
  76058. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  76059. * @param size the size (float) of the visibility box
  76060. * note : this doesn't lock the PCS mesh bounding box.
  76061. * doc :
  76062. */
  76063. setVisibilityBox(size: number): void;
  76064. /**
  76065. * Gets whether the PCS is always visible or not
  76066. * doc :
  76067. */
  76068. get isAlwaysVisible(): boolean;
  76069. /**
  76070. * Sets the PCS as always visible or not
  76071. * doc :
  76072. */
  76073. set isAlwaysVisible(val: boolean);
  76074. /**
  76075. * Tells to `setParticles()` to compute the particle rotations or not
  76076. * Default value : false. The PCS is faster when it's set to false
  76077. * Note : particle rotations are only applied to parent particles
  76078. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  76079. */
  76080. set computeParticleRotation(val: boolean);
  76081. /**
  76082. * Tells to `setParticles()` to compute the particle colors or not.
  76083. * Default value : true. The PCS is faster when it's set to false.
  76084. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  76085. */
  76086. set computeParticleColor(val: boolean);
  76087. set computeParticleTexture(val: boolean);
  76088. /**
  76089. * Gets if `setParticles()` computes the particle colors or not.
  76090. * Default value : false. The PCS is faster when it's set to false.
  76091. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  76092. */
  76093. get computeParticleColor(): boolean;
  76094. /**
  76095. * Gets if `setParticles()` computes the particle textures or not.
  76096. * Default value : false. The PCS is faster when it's set to false.
  76097. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  76098. */
  76099. get computeParticleTexture(): boolean;
  76100. /**
  76101. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  76102. */
  76103. set computeBoundingBox(val: boolean);
  76104. /**
  76105. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  76106. */
  76107. get computeBoundingBox(): boolean;
  76108. /**
  76109. * This function does nothing. It may be overwritten to set all the particle first values.
  76110. * The PCS doesn't call this function, you may have to call it by your own.
  76111. * doc :
  76112. */
  76113. initParticles(): void;
  76114. /**
  76115. * This function does nothing. It may be overwritten to recycle a particle
  76116. * The PCS doesn't call this function, you can to call it
  76117. * doc :
  76118. * @param particle The particle to recycle
  76119. * @returns the recycled particle
  76120. */
  76121. recycleParticle(particle: CloudPoint): CloudPoint;
  76122. /**
  76123. * Updates a particle : this function should be overwritten by the user.
  76124. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  76125. * doc :
  76126. * @example : just set a particle position or velocity and recycle conditions
  76127. * @param particle The particle to update
  76128. * @returns the updated particle
  76129. */
  76130. updateParticle(particle: CloudPoint): CloudPoint;
  76131. /**
  76132. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  76133. * This does nothing and may be overwritten by the user.
  76134. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  76135. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  76136. * @param update the boolean update value actually passed to setParticles()
  76137. */
  76138. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  76139. /**
  76140. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  76141. * This will be passed three parameters.
  76142. * This does nothing and may be overwritten by the user.
  76143. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  76144. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  76145. * @param update the boolean update value actually passed to setParticles()
  76146. */
  76147. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  76148. }
  76149. }
  76150. declare module "babylonjs/Particles/cloudPoint" {
  76151. import { Nullable } from "babylonjs/types";
  76152. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  76153. import { Mesh } from "babylonjs/Meshes/mesh";
  76154. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  76155. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  76156. /**
  76157. * Represents one particle of a points cloud system.
  76158. */
  76159. export class CloudPoint {
  76160. /**
  76161. * particle global index
  76162. */
  76163. idx: number;
  76164. /**
  76165. * The color of the particle
  76166. */
  76167. color: Nullable<Color4>;
  76168. /**
  76169. * The world space position of the particle.
  76170. */
  76171. position: Vector3;
  76172. /**
  76173. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  76174. */
  76175. rotation: Vector3;
  76176. /**
  76177. * The world space rotation quaternion of the particle.
  76178. */
  76179. rotationQuaternion: Nullable<Quaternion>;
  76180. /**
  76181. * The uv of the particle.
  76182. */
  76183. uv: Nullable<Vector2>;
  76184. /**
  76185. * The current speed of the particle.
  76186. */
  76187. velocity: Vector3;
  76188. /**
  76189. * The pivot point in the particle local space.
  76190. */
  76191. pivot: Vector3;
  76192. /**
  76193. * Must the particle be translated from its pivot point in its local space ?
  76194. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  76195. * Default : false
  76196. */
  76197. translateFromPivot: boolean;
  76198. /**
  76199. * Index of this particle in the global "positions" array (Internal use)
  76200. * @hidden
  76201. */
  76202. _pos: number;
  76203. /**
  76204. * @hidden Index of this particle in the global "indices" array (Internal use)
  76205. */
  76206. _ind: number;
  76207. /**
  76208. * Group this particle belongs to
  76209. */
  76210. _group: PointsGroup;
  76211. /**
  76212. * Group id of this particle
  76213. */
  76214. groupId: number;
  76215. /**
  76216. * Index of the particle in its group id (Internal use)
  76217. */
  76218. idxInGroup: number;
  76219. /**
  76220. * @hidden Particle BoundingInfo object (Internal use)
  76221. */
  76222. _boundingInfo: BoundingInfo;
  76223. /**
  76224. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  76225. */
  76226. _pcs: PointsCloudSystem;
  76227. /**
  76228. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  76229. */
  76230. _stillInvisible: boolean;
  76231. /**
  76232. * @hidden Last computed particle rotation matrix
  76233. */
  76234. _rotationMatrix: number[];
  76235. /**
  76236. * Parent particle Id, if any.
  76237. * Default null.
  76238. */
  76239. parentId: Nullable<number>;
  76240. /**
  76241. * @hidden Internal global position in the PCS.
  76242. */
  76243. _globalPosition: Vector3;
  76244. /**
  76245. * Creates a Point Cloud object.
  76246. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  76247. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  76248. * @param group (PointsGroup) is the group the particle belongs to
  76249. * @param groupId (integer) is the group identifier in the PCS.
  76250. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  76251. * @param pcs defines the PCS it is associated to
  76252. */
  76253. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  76254. /**
  76255. * get point size
  76256. */
  76257. get size(): Vector3;
  76258. /**
  76259. * Set point size
  76260. */
  76261. set size(scale: Vector3);
  76262. /**
  76263. * Legacy support, changed quaternion to rotationQuaternion
  76264. */
  76265. get quaternion(): Nullable<Quaternion>;
  76266. /**
  76267. * Legacy support, changed quaternion to rotationQuaternion
  76268. */
  76269. set quaternion(q: Nullable<Quaternion>);
  76270. /**
  76271. * Returns a boolean. True if the particle intersects a mesh, else false
  76272. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  76273. * @param target is the object (point or mesh) what the intersection is computed against
  76274. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  76275. * @returns true if it intersects
  76276. */
  76277. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  76278. /**
  76279. * get the rotation matrix of the particle
  76280. * @hidden
  76281. */
  76282. getRotationMatrix(m: Matrix): void;
  76283. }
  76284. /**
  76285. * Represents a group of points in a points cloud system
  76286. * * PCS internal tool, don't use it manually.
  76287. */
  76288. export class PointsGroup {
  76289. /**
  76290. * The group id
  76291. * @hidden
  76292. */
  76293. groupID: number;
  76294. /**
  76295. * image data for group (internal use)
  76296. * @hidden
  76297. */
  76298. _groupImageData: Nullable<ArrayBufferView>;
  76299. /**
  76300. * Image Width (internal use)
  76301. * @hidden
  76302. */
  76303. _groupImgWidth: number;
  76304. /**
  76305. * Image Height (internal use)
  76306. * @hidden
  76307. */
  76308. _groupImgHeight: number;
  76309. /**
  76310. * Custom position function (internal use)
  76311. * @hidden
  76312. */
  76313. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  76314. /**
  76315. * density per facet for surface points
  76316. * @hidden
  76317. */
  76318. _groupDensity: number[];
  76319. /**
  76320. * Only when points are colored by texture carries pointer to texture list array
  76321. * @hidden
  76322. */
  76323. _textureNb: number;
  76324. /**
  76325. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  76326. * PCS internal tool, don't use it manually.
  76327. * @hidden
  76328. */
  76329. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  76330. }
  76331. }
  76332. declare module "babylonjs/Particles/index" {
  76333. export * from "babylonjs/Particles/baseParticleSystem";
  76334. export * from "babylonjs/Particles/EmitterTypes/index";
  76335. export * from "babylonjs/Particles/gpuParticleSystem";
  76336. export * from "babylonjs/Particles/IParticleSystem";
  76337. export * from "babylonjs/Particles/particle";
  76338. export * from "babylonjs/Particles/particleHelper";
  76339. export * from "babylonjs/Particles/particleSystem";
  76340. import "babylonjs/Particles/particleSystemComponent";
  76341. export * from "babylonjs/Particles/particleSystemComponent";
  76342. export * from "babylonjs/Particles/particleSystemSet";
  76343. export * from "babylonjs/Particles/solidParticle";
  76344. export * from "babylonjs/Particles/solidParticleSystem";
  76345. export * from "babylonjs/Particles/cloudPoint";
  76346. export * from "babylonjs/Particles/pointsCloudSystem";
  76347. export * from "babylonjs/Particles/subEmitter";
  76348. }
  76349. declare module "babylonjs/Physics/physicsEngineComponent" {
  76350. import { Nullable } from "babylonjs/types";
  76351. import { Observable, Observer } from "babylonjs/Misc/observable";
  76352. import { Vector3 } from "babylonjs/Maths/math.vector";
  76353. import { Mesh } from "babylonjs/Meshes/mesh";
  76354. import { ISceneComponent } from "babylonjs/sceneComponent";
  76355. import { Scene } from "babylonjs/scene";
  76356. import { Node } from "babylonjs/node";
  76357. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  76358. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  76359. module "babylonjs/scene" {
  76360. interface Scene {
  76361. /** @hidden (Backing field) */
  76362. _physicsEngine: Nullable<IPhysicsEngine>;
  76363. /** @hidden */
  76364. _physicsTimeAccumulator: number;
  76365. /**
  76366. * Gets the current physics engine
  76367. * @returns a IPhysicsEngine or null if none attached
  76368. */
  76369. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  76370. /**
  76371. * Enables physics to the current scene
  76372. * @param gravity defines the scene's gravity for the physics engine
  76373. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  76374. * @return a boolean indicating if the physics engine was initialized
  76375. */
  76376. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  76377. /**
  76378. * Disables and disposes the physics engine associated with the scene
  76379. */
  76380. disablePhysicsEngine(): void;
  76381. /**
  76382. * Gets a boolean indicating if there is an active physics engine
  76383. * @returns a boolean indicating if there is an active physics engine
  76384. */
  76385. isPhysicsEnabled(): boolean;
  76386. /**
  76387. * Deletes a physics compound impostor
  76388. * @param compound defines the compound to delete
  76389. */
  76390. deleteCompoundImpostor(compound: any): void;
  76391. /**
  76392. * An event triggered when physic simulation is about to be run
  76393. */
  76394. onBeforePhysicsObservable: Observable<Scene>;
  76395. /**
  76396. * An event triggered when physic simulation has been done
  76397. */
  76398. onAfterPhysicsObservable: Observable<Scene>;
  76399. }
  76400. }
  76401. module "babylonjs/Meshes/abstractMesh" {
  76402. interface AbstractMesh {
  76403. /** @hidden */
  76404. _physicsImpostor: Nullable<PhysicsImpostor>;
  76405. /**
  76406. * Gets or sets impostor used for physic simulation
  76407. * @see https://doc.babylonjs.com/features/physics_engine
  76408. */
  76409. physicsImpostor: Nullable<PhysicsImpostor>;
  76410. /**
  76411. * Gets the current physics impostor
  76412. * @see https://doc.babylonjs.com/features/physics_engine
  76413. * @returns a physics impostor or null
  76414. */
  76415. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  76416. /** Apply a physic impulse to the mesh
  76417. * @param force defines the force to apply
  76418. * @param contactPoint defines where to apply the force
  76419. * @returns the current mesh
  76420. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76421. */
  76422. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  76423. /**
  76424. * Creates a physic joint between two meshes
  76425. * @param otherMesh defines the other mesh to use
  76426. * @param pivot1 defines the pivot to use on this mesh
  76427. * @param pivot2 defines the pivot to use on the other mesh
  76428. * @param options defines additional options (can be plugin dependent)
  76429. * @returns the current mesh
  76430. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  76431. */
  76432. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  76433. /** @hidden */
  76434. _disposePhysicsObserver: Nullable<Observer<Node>>;
  76435. }
  76436. }
  76437. /**
  76438. * Defines the physics engine scene component responsible to manage a physics engine
  76439. */
  76440. export class PhysicsEngineSceneComponent implements ISceneComponent {
  76441. /**
  76442. * The component name helpful to identify the component in the list of scene components.
  76443. */
  76444. readonly name: string;
  76445. /**
  76446. * The scene the component belongs to.
  76447. */
  76448. scene: Scene;
  76449. /**
  76450. * Creates a new instance of the component for the given scene
  76451. * @param scene Defines the scene to register the component in
  76452. */
  76453. constructor(scene: Scene);
  76454. /**
  76455. * Registers the component in a given scene
  76456. */
  76457. register(): void;
  76458. /**
  76459. * Rebuilds the elements related to this component in case of
  76460. * context lost for instance.
  76461. */
  76462. rebuild(): void;
  76463. /**
  76464. * Disposes the component and the associated ressources
  76465. */
  76466. dispose(): void;
  76467. }
  76468. }
  76469. declare module "babylonjs/Physics/physicsHelper" {
  76470. import { Nullable } from "babylonjs/types";
  76471. import { Vector3 } from "babylonjs/Maths/math.vector";
  76472. import { Mesh } from "babylonjs/Meshes/mesh";
  76473. import { Scene } from "babylonjs/scene";
  76474. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  76475. /**
  76476. * A helper for physics simulations
  76477. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  76478. */
  76479. export class PhysicsHelper {
  76480. private _scene;
  76481. private _physicsEngine;
  76482. /**
  76483. * Initializes the Physics helper
  76484. * @param scene Babylon.js scene
  76485. */
  76486. constructor(scene: Scene);
  76487. /**
  76488. * Applies a radial explosion impulse
  76489. * @param origin the origin of the explosion
  76490. * @param radiusOrEventOptions the radius or the options of radial explosion
  76491. * @param strength the explosion strength
  76492. * @param falloff possible options: Constant & Linear. Defaults to Constant
  76493. * @returns A physics radial explosion event, or null
  76494. */
  76495. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  76496. /**
  76497. * Applies a radial explosion force
  76498. * @param origin the origin of the explosion
  76499. * @param radiusOrEventOptions the radius or the options of radial explosion
  76500. * @param strength the explosion strength
  76501. * @param falloff possible options: Constant & Linear. Defaults to Constant
  76502. * @returns A physics radial explosion event, or null
  76503. */
  76504. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  76505. /**
  76506. * Creates a gravitational field
  76507. * @param origin the origin of the explosion
  76508. * @param radiusOrEventOptions the radius or the options of radial explosion
  76509. * @param strength the explosion strength
  76510. * @param falloff possible options: Constant & Linear. Defaults to Constant
  76511. * @returns A physics gravitational field event, or null
  76512. */
  76513. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  76514. /**
  76515. * Creates a physics updraft event
  76516. * @param origin the origin of the updraft
  76517. * @param radiusOrEventOptions the radius or the options of the updraft
  76518. * @param strength the strength of the updraft
  76519. * @param height the height of the updraft
  76520. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  76521. * @returns A physics updraft event, or null
  76522. */
  76523. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  76524. /**
  76525. * Creates a physics vortex event
  76526. * @param origin the of the vortex
  76527. * @param radiusOrEventOptions the radius or the options of the vortex
  76528. * @param strength the strength of the vortex
  76529. * @param height the height of the vortex
  76530. * @returns a Physics vortex event, or null
  76531. * A physics vortex event or null
  76532. */
  76533. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  76534. }
  76535. /**
  76536. * Represents a physics radial explosion event
  76537. */
  76538. class PhysicsRadialExplosionEvent {
  76539. private _scene;
  76540. private _options;
  76541. private _sphere;
  76542. private _dataFetched;
  76543. /**
  76544. * Initializes a radial explosioin event
  76545. * @param _scene BabylonJS scene
  76546. * @param _options The options for the vortex event
  76547. */
  76548. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  76549. /**
  76550. * Returns the data related to the radial explosion event (sphere).
  76551. * @returns The radial explosion event data
  76552. */
  76553. getData(): PhysicsRadialExplosionEventData;
  76554. /**
  76555. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  76556. * @param impostor A physics imposter
  76557. * @param origin the origin of the explosion
  76558. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  76559. */
  76560. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  76561. /**
  76562. * Triggers affecterd impostors callbacks
  76563. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  76564. */
  76565. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  76566. /**
  76567. * Disposes the sphere.
  76568. * @param force Specifies if the sphere should be disposed by force
  76569. */
  76570. dispose(force?: boolean): void;
  76571. /*** Helpers ***/
  76572. private _prepareSphere;
  76573. private _intersectsWithSphere;
  76574. }
  76575. /**
  76576. * Represents a gravitational field event
  76577. */
  76578. class PhysicsGravitationalFieldEvent {
  76579. private _physicsHelper;
  76580. private _scene;
  76581. private _origin;
  76582. private _options;
  76583. private _tickCallback;
  76584. private _sphere;
  76585. private _dataFetched;
  76586. /**
  76587. * Initializes the physics gravitational field event
  76588. * @param _physicsHelper A physics helper
  76589. * @param _scene BabylonJS scene
  76590. * @param _origin The origin position of the gravitational field event
  76591. * @param _options The options for the vortex event
  76592. */
  76593. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  76594. /**
  76595. * Returns the data related to the gravitational field event (sphere).
  76596. * @returns A gravitational field event
  76597. */
  76598. getData(): PhysicsGravitationalFieldEventData;
  76599. /**
  76600. * Enables the gravitational field.
  76601. */
  76602. enable(): void;
  76603. /**
  76604. * Disables the gravitational field.
  76605. */
  76606. disable(): void;
  76607. /**
  76608. * Disposes the sphere.
  76609. * @param force The force to dispose from the gravitational field event
  76610. */
  76611. dispose(force?: boolean): void;
  76612. private _tick;
  76613. }
  76614. /**
  76615. * Represents a physics updraft event
  76616. */
  76617. class PhysicsUpdraftEvent {
  76618. private _scene;
  76619. private _origin;
  76620. private _options;
  76621. private _physicsEngine;
  76622. private _originTop;
  76623. private _originDirection;
  76624. private _tickCallback;
  76625. private _cylinder;
  76626. private _cylinderPosition;
  76627. private _dataFetched;
  76628. /**
  76629. * Initializes the physics updraft event
  76630. * @param _scene BabylonJS scene
  76631. * @param _origin The origin position of the updraft
  76632. * @param _options The options for the updraft event
  76633. */
  76634. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  76635. /**
  76636. * Returns the data related to the updraft event (cylinder).
  76637. * @returns A physics updraft event
  76638. */
  76639. getData(): PhysicsUpdraftEventData;
  76640. /**
  76641. * Enables the updraft.
  76642. */
  76643. enable(): void;
  76644. /**
  76645. * Disables the updraft.
  76646. */
  76647. disable(): void;
  76648. /**
  76649. * Disposes the cylinder.
  76650. * @param force Specifies if the updraft should be disposed by force
  76651. */
  76652. dispose(force?: boolean): void;
  76653. private getImpostorHitData;
  76654. private _tick;
  76655. /*** Helpers ***/
  76656. private _prepareCylinder;
  76657. private _intersectsWithCylinder;
  76658. }
  76659. /**
  76660. * Represents a physics vortex event
  76661. */
  76662. class PhysicsVortexEvent {
  76663. private _scene;
  76664. private _origin;
  76665. private _options;
  76666. private _physicsEngine;
  76667. private _originTop;
  76668. private _tickCallback;
  76669. private _cylinder;
  76670. private _cylinderPosition;
  76671. private _dataFetched;
  76672. /**
  76673. * Initializes the physics vortex event
  76674. * @param _scene The BabylonJS scene
  76675. * @param _origin The origin position of the vortex
  76676. * @param _options The options for the vortex event
  76677. */
  76678. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  76679. /**
  76680. * Returns the data related to the vortex event (cylinder).
  76681. * @returns The physics vortex event data
  76682. */
  76683. getData(): PhysicsVortexEventData;
  76684. /**
  76685. * Enables the vortex.
  76686. */
  76687. enable(): void;
  76688. /**
  76689. * Disables the cortex.
  76690. */
  76691. disable(): void;
  76692. /**
  76693. * Disposes the sphere.
  76694. * @param force
  76695. */
  76696. dispose(force?: boolean): void;
  76697. private getImpostorHitData;
  76698. private _tick;
  76699. /*** Helpers ***/
  76700. private _prepareCylinder;
  76701. private _intersectsWithCylinder;
  76702. }
  76703. /**
  76704. * Options fot the radial explosion event
  76705. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  76706. */
  76707. export class PhysicsRadialExplosionEventOptions {
  76708. /**
  76709. * The radius of the sphere for the radial explosion.
  76710. */
  76711. radius: number;
  76712. /**
  76713. * The strenth of the explosion.
  76714. */
  76715. strength: number;
  76716. /**
  76717. * The strenght of the force in correspondence to the distance of the affected object
  76718. */
  76719. falloff: PhysicsRadialImpulseFalloff;
  76720. /**
  76721. * Sphere options for the radial explosion.
  76722. */
  76723. sphere: {
  76724. segments: number;
  76725. diameter: number;
  76726. };
  76727. /**
  76728. * Sphere options for the radial explosion.
  76729. */
  76730. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  76731. }
  76732. /**
  76733. * Options fot the updraft event
  76734. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  76735. */
  76736. export class PhysicsUpdraftEventOptions {
  76737. /**
  76738. * The radius of the cylinder for the vortex
  76739. */
  76740. radius: number;
  76741. /**
  76742. * The strenth of the updraft.
  76743. */
  76744. strength: number;
  76745. /**
  76746. * The height of the cylinder for the updraft.
  76747. */
  76748. height: number;
  76749. /**
  76750. * The mode for the the updraft.
  76751. */
  76752. updraftMode: PhysicsUpdraftMode;
  76753. }
  76754. /**
  76755. * Options fot the vortex event
  76756. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  76757. */
  76758. export class PhysicsVortexEventOptions {
  76759. /**
  76760. * The radius of the cylinder for the vortex
  76761. */
  76762. radius: number;
  76763. /**
  76764. * The strenth of the vortex.
  76765. */
  76766. strength: number;
  76767. /**
  76768. * The height of the cylinder for the vortex.
  76769. */
  76770. height: number;
  76771. /**
  76772. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  76773. */
  76774. centripetalForceThreshold: number;
  76775. /**
  76776. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  76777. */
  76778. centripetalForceMultiplier: number;
  76779. /**
  76780. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  76781. */
  76782. centrifugalForceMultiplier: number;
  76783. /**
  76784. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  76785. */
  76786. updraftForceMultiplier: number;
  76787. }
  76788. /**
  76789. * The strenght of the force in correspondence to the distance of the affected object
  76790. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  76791. */
  76792. export enum PhysicsRadialImpulseFalloff {
  76793. /** Defines that impulse is constant in strength across it's whole radius */
  76794. Constant = 0,
  76795. /** Defines that impulse gets weaker if it's further from the origin */
  76796. Linear = 1
  76797. }
  76798. /**
  76799. * The strength of the force in correspondence to the distance of the affected object
  76800. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  76801. */
  76802. export enum PhysicsUpdraftMode {
  76803. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  76804. Center = 0,
  76805. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  76806. Perpendicular = 1
  76807. }
  76808. /**
  76809. * Interface for a physics hit data
  76810. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  76811. */
  76812. export interface PhysicsHitData {
  76813. /**
  76814. * The force applied at the contact point
  76815. */
  76816. force: Vector3;
  76817. /**
  76818. * The contact point
  76819. */
  76820. contactPoint: Vector3;
  76821. /**
  76822. * The distance from the origin to the contact point
  76823. */
  76824. distanceFromOrigin: number;
  76825. }
  76826. /**
  76827. * Interface for radial explosion event data
  76828. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  76829. */
  76830. export interface PhysicsRadialExplosionEventData {
  76831. /**
  76832. * A sphere used for the radial explosion event
  76833. */
  76834. sphere: Mesh;
  76835. }
  76836. /**
  76837. * Interface for gravitational field event data
  76838. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  76839. */
  76840. export interface PhysicsGravitationalFieldEventData {
  76841. /**
  76842. * A sphere mesh used for the gravitational field event
  76843. */
  76844. sphere: Mesh;
  76845. }
  76846. /**
  76847. * Interface for updraft event data
  76848. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  76849. */
  76850. export interface PhysicsUpdraftEventData {
  76851. /**
  76852. * A cylinder used for the updraft event
  76853. */
  76854. cylinder: Mesh;
  76855. }
  76856. /**
  76857. * Interface for vortex event data
  76858. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  76859. */
  76860. export interface PhysicsVortexEventData {
  76861. /**
  76862. * A cylinder used for the vortex event
  76863. */
  76864. cylinder: Mesh;
  76865. }
  76866. /**
  76867. * Interface for an affected physics impostor
  76868. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  76869. */
  76870. export interface PhysicsAffectedImpostorWithData {
  76871. /**
  76872. * The impostor affected by the effect
  76873. */
  76874. impostor: PhysicsImpostor;
  76875. /**
  76876. * The data about the hit/horce from the explosion
  76877. */
  76878. hitData: PhysicsHitData;
  76879. }
  76880. }
  76881. declare module "babylonjs/Physics/Plugins/index" {
  76882. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  76883. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  76884. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  76885. }
  76886. declare module "babylonjs/Physics/index" {
  76887. export * from "babylonjs/Physics/IPhysicsEngine";
  76888. export * from "babylonjs/Physics/physicsEngine";
  76889. export * from "babylonjs/Physics/physicsEngineComponent";
  76890. export * from "babylonjs/Physics/physicsHelper";
  76891. export * from "babylonjs/Physics/physicsImpostor";
  76892. export * from "babylonjs/Physics/physicsJoint";
  76893. export * from "babylonjs/Physics/Plugins/index";
  76894. }
  76895. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  76896. /** @hidden */
  76897. export var blackAndWhitePixelShader: {
  76898. name: string;
  76899. shader: string;
  76900. };
  76901. }
  76902. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  76903. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76904. import { Camera } from "babylonjs/Cameras/camera";
  76905. import { Engine } from "babylonjs/Engines/engine";
  76906. import "babylonjs/Shaders/blackAndWhite.fragment";
  76907. import { Nullable } from "babylonjs/types";
  76908. import { Scene } from "babylonjs/scene";
  76909. /**
  76910. * Post process used to render in black and white
  76911. */
  76912. export class BlackAndWhitePostProcess extends PostProcess {
  76913. /**
  76914. * Linear about to convert he result to black and white (default: 1)
  76915. */
  76916. degree: number;
  76917. /**
  76918. * Gets a string identifying the name of the class
  76919. * @returns "BlackAndWhitePostProcess" string
  76920. */
  76921. getClassName(): string;
  76922. /**
  76923. * Creates a black and white post process
  76924. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  76925. * @param name The name of the effect.
  76926. * @param options The required width/height ratio to downsize to before computing the render pass.
  76927. * @param camera The camera to apply the render pass to.
  76928. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76929. * @param engine The engine which the post process will be applied. (default: current engine)
  76930. * @param reusable If the post process can be reused on the same frame. (default: false)
  76931. */
  76932. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  76933. /** @hidden */
  76934. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  76935. }
  76936. }
  76937. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  76938. import { Nullable } from "babylonjs/types";
  76939. import { Camera } from "babylonjs/Cameras/camera";
  76940. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76941. import { Engine } from "babylonjs/Engines/engine";
  76942. /**
  76943. * This represents a set of one or more post processes in Babylon.
  76944. * A post process can be used to apply a shader to a texture after it is rendered.
  76945. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  76946. */
  76947. export class PostProcessRenderEffect {
  76948. private _postProcesses;
  76949. private _getPostProcesses;
  76950. private _singleInstance;
  76951. private _cameras;
  76952. private _indicesForCamera;
  76953. /**
  76954. * Name of the effect
  76955. * @hidden
  76956. */
  76957. _name: string;
  76958. /**
  76959. * Instantiates a post process render effect.
  76960. * A post process can be used to apply a shader to a texture after it is rendered.
  76961. * @param engine The engine the effect is tied to
  76962. * @param name The name of the effect
  76963. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  76964. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  76965. */
  76966. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  76967. /**
  76968. * Checks if all the post processes in the effect are supported.
  76969. */
  76970. get isSupported(): boolean;
  76971. /**
  76972. * Updates the current state of the effect
  76973. * @hidden
  76974. */
  76975. _update(): void;
  76976. /**
  76977. * Attaches the effect on cameras
  76978. * @param cameras The camera to attach to.
  76979. * @hidden
  76980. */
  76981. _attachCameras(cameras: Camera): void;
  76982. /**
  76983. * Attaches the effect on cameras
  76984. * @param cameras The camera to attach to.
  76985. * @hidden
  76986. */
  76987. _attachCameras(cameras: Camera[]): void;
  76988. /**
  76989. * Detaches the effect on cameras
  76990. * @param cameras The camera to detatch from.
  76991. * @hidden
  76992. */
  76993. _detachCameras(cameras: Camera): void;
  76994. /**
  76995. * Detatches the effect on cameras
  76996. * @param cameras The camera to detatch from.
  76997. * @hidden
  76998. */
  76999. _detachCameras(cameras: Camera[]): void;
  77000. /**
  77001. * Enables the effect on given cameras
  77002. * @param cameras The camera to enable.
  77003. * @hidden
  77004. */
  77005. _enable(cameras: Camera): void;
  77006. /**
  77007. * Enables the effect on given cameras
  77008. * @param cameras The camera to enable.
  77009. * @hidden
  77010. */
  77011. _enable(cameras: Nullable<Camera[]>): void;
  77012. /**
  77013. * Disables the effect on the given cameras
  77014. * @param cameras The camera to disable.
  77015. * @hidden
  77016. */
  77017. _disable(cameras: Camera): void;
  77018. /**
  77019. * Disables the effect on the given cameras
  77020. * @param cameras The camera to disable.
  77021. * @hidden
  77022. */
  77023. _disable(cameras: Nullable<Camera[]>): void;
  77024. /**
  77025. * Gets a list of the post processes contained in the effect.
  77026. * @param camera The camera to get the post processes on.
  77027. * @returns The list of the post processes in the effect.
  77028. */
  77029. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  77030. }
  77031. }
  77032. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  77033. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  77034. /** @hidden */
  77035. export var extractHighlightsPixelShader: {
  77036. name: string;
  77037. shader: string;
  77038. };
  77039. }
  77040. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  77041. import { Nullable } from "babylonjs/types";
  77042. import { Camera } from "babylonjs/Cameras/camera";
  77043. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77044. import { Engine } from "babylonjs/Engines/engine";
  77045. import "babylonjs/Shaders/extractHighlights.fragment";
  77046. /**
  77047. * 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.
  77048. */
  77049. export class ExtractHighlightsPostProcess extends PostProcess {
  77050. /**
  77051. * The luminance threshold, pixels below this value will be set to black.
  77052. */
  77053. threshold: number;
  77054. /** @hidden */
  77055. _exposure: number;
  77056. /**
  77057. * Post process which has the input texture to be used when performing highlight extraction
  77058. * @hidden
  77059. */
  77060. _inputPostProcess: Nullable<PostProcess>;
  77061. /**
  77062. * Gets a string identifying the name of the class
  77063. * @returns "ExtractHighlightsPostProcess" string
  77064. */
  77065. getClassName(): string;
  77066. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  77067. }
  77068. }
  77069. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  77070. /** @hidden */
  77071. export var bloomMergePixelShader: {
  77072. name: string;
  77073. shader: string;
  77074. };
  77075. }
  77076. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  77077. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77078. import { Nullable } from "babylonjs/types";
  77079. import { Engine } from "babylonjs/Engines/engine";
  77080. import { Camera } from "babylonjs/Cameras/camera";
  77081. import "babylonjs/Shaders/bloomMerge.fragment";
  77082. /**
  77083. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  77084. */
  77085. export class BloomMergePostProcess extends PostProcess {
  77086. /** Weight of the bloom to be added to the original input. */
  77087. weight: number;
  77088. /**
  77089. * Gets a string identifying the name of the class
  77090. * @returns "BloomMergePostProcess" string
  77091. */
  77092. getClassName(): string;
  77093. /**
  77094. * Creates a new instance of @see BloomMergePostProcess
  77095. * @param name The name of the effect.
  77096. * @param originalFromInput Post process which's input will be used for the merge.
  77097. * @param blurred Blurred highlights post process which's output will be used.
  77098. * @param weight Weight of the bloom to be added to the original input.
  77099. * @param options The required width/height ratio to downsize to before computing the render pass.
  77100. * @param camera The camera to apply the render pass to.
  77101. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77102. * @param engine The engine which the post process will be applied. (default: current engine)
  77103. * @param reusable If the post process can be reused on the same frame. (default: false)
  77104. * @param textureType Type of textures used when performing the post process. (default: 0)
  77105. * @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)
  77106. */
  77107. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  77108. /** Weight of the bloom to be added to the original input. */
  77109. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  77110. }
  77111. }
  77112. declare module "babylonjs/PostProcesses/bloomEffect" {
  77113. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  77114. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  77115. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  77116. import { Camera } from "babylonjs/Cameras/camera";
  77117. import { Scene } from "babylonjs/scene";
  77118. /**
  77119. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  77120. */
  77121. export class BloomEffect extends PostProcessRenderEffect {
  77122. private bloomScale;
  77123. /**
  77124. * @hidden Internal
  77125. */
  77126. _effects: Array<PostProcess>;
  77127. /**
  77128. * @hidden Internal
  77129. */
  77130. _downscale: ExtractHighlightsPostProcess;
  77131. private _blurX;
  77132. private _blurY;
  77133. private _merge;
  77134. /**
  77135. * The luminance threshold to find bright areas of the image to bloom.
  77136. */
  77137. get threshold(): number;
  77138. set threshold(value: number);
  77139. /**
  77140. * The strength of the bloom.
  77141. */
  77142. get weight(): number;
  77143. set weight(value: number);
  77144. /**
  77145. * Specifies the size of the bloom blur kernel, relative to the final output size
  77146. */
  77147. get kernel(): number;
  77148. set kernel(value: number);
  77149. /**
  77150. * Creates a new instance of @see BloomEffect
  77151. * @param scene The scene the effect belongs to.
  77152. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  77153. * @param bloomKernel The size of the kernel to be used when applying the blur.
  77154. * @param bloomWeight The the strength of bloom.
  77155. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  77156. * @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)
  77157. */
  77158. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  77159. /**
  77160. * Disposes each of the internal effects for a given camera.
  77161. * @param camera The camera to dispose the effect on.
  77162. */
  77163. disposeEffects(camera: Camera): void;
  77164. /**
  77165. * @hidden Internal
  77166. */
  77167. _updateEffects(): void;
  77168. /**
  77169. * Internal
  77170. * @returns if all the contained post processes are ready.
  77171. * @hidden
  77172. */
  77173. _isReady(): boolean;
  77174. }
  77175. }
  77176. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  77177. /** @hidden */
  77178. export var chromaticAberrationPixelShader: {
  77179. name: string;
  77180. shader: string;
  77181. };
  77182. }
  77183. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  77184. import { Vector2 } from "babylonjs/Maths/math.vector";
  77185. import { Nullable } from "babylonjs/types";
  77186. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77187. import { Camera } from "babylonjs/Cameras/camera";
  77188. import { Engine } from "babylonjs/Engines/engine";
  77189. import "babylonjs/Shaders/chromaticAberration.fragment";
  77190. import { Scene } from "babylonjs/scene";
  77191. /**
  77192. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  77193. */
  77194. export class ChromaticAberrationPostProcess extends PostProcess {
  77195. /**
  77196. * The amount of seperation of rgb channels (default: 30)
  77197. */
  77198. aberrationAmount: number;
  77199. /**
  77200. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  77201. */
  77202. radialIntensity: number;
  77203. /**
  77204. * 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))
  77205. */
  77206. direction: Vector2;
  77207. /**
  77208. * 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))
  77209. */
  77210. centerPosition: Vector2;
  77211. /** The width of the screen to apply the effect on */
  77212. screenWidth: number;
  77213. /** The height of the screen to apply the effect on */
  77214. screenHeight: number;
  77215. /**
  77216. * Gets a string identifying the name of the class
  77217. * @returns "ChromaticAberrationPostProcess" string
  77218. */
  77219. getClassName(): string;
  77220. /**
  77221. * Creates a new instance ChromaticAberrationPostProcess
  77222. * @param name The name of the effect.
  77223. * @param screenWidth The width of the screen to apply the effect on.
  77224. * @param screenHeight The height of the screen to apply the effect on.
  77225. * @param options The required width/height ratio to downsize to before computing the render pass.
  77226. * @param camera The camera to apply the render pass to.
  77227. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77228. * @param engine The engine which the post process will be applied. (default: current engine)
  77229. * @param reusable If the post process can be reused on the same frame. (default: false)
  77230. * @param textureType Type of textures used when performing the post process. (default: 0)
  77231. * @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)
  77232. */
  77233. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  77234. /** @hidden */
  77235. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  77236. }
  77237. }
  77238. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  77239. /** @hidden */
  77240. export var circleOfConfusionPixelShader: {
  77241. name: string;
  77242. shader: string;
  77243. };
  77244. }
  77245. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  77246. import { Nullable } from "babylonjs/types";
  77247. import { Engine } from "babylonjs/Engines/engine";
  77248. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77249. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  77250. import { Camera } from "babylonjs/Cameras/camera";
  77251. import "babylonjs/Shaders/circleOfConfusion.fragment";
  77252. /**
  77253. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  77254. */
  77255. export class CircleOfConfusionPostProcess extends PostProcess {
  77256. /**
  77257. * 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.
  77258. */
  77259. lensSize: number;
  77260. /**
  77261. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  77262. */
  77263. fStop: number;
  77264. /**
  77265. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  77266. */
  77267. focusDistance: number;
  77268. /**
  77269. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  77270. */
  77271. focalLength: number;
  77272. /**
  77273. * Gets a string identifying the name of the class
  77274. * @returns "CircleOfConfusionPostProcess" string
  77275. */
  77276. getClassName(): string;
  77277. private _depthTexture;
  77278. /**
  77279. * Creates a new instance CircleOfConfusionPostProcess
  77280. * @param name The name of the effect.
  77281. * @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.
  77282. * @param options The required width/height ratio to downsize to before computing the render pass.
  77283. * @param camera The camera to apply the render pass to.
  77284. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77285. * @param engine The engine which the post process will be applied. (default: current engine)
  77286. * @param reusable If the post process can be reused on the same frame. (default: false)
  77287. * @param textureType Type of textures used when performing the post process. (default: 0)
  77288. * @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)
  77289. */
  77290. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  77291. /**
  77292. * 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.
  77293. */
  77294. set depthTexture(value: RenderTargetTexture);
  77295. }
  77296. }
  77297. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  77298. /** @hidden */
  77299. export var colorCorrectionPixelShader: {
  77300. name: string;
  77301. shader: string;
  77302. };
  77303. }
  77304. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  77305. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77306. import { Engine } from "babylonjs/Engines/engine";
  77307. import { Camera } from "babylonjs/Cameras/camera";
  77308. import "babylonjs/Shaders/colorCorrection.fragment";
  77309. import { Nullable } from "babylonjs/types";
  77310. import { Scene } from "babylonjs/scene";
  77311. /**
  77312. *
  77313. * This post-process allows the modification of rendered colors by using
  77314. * a 'look-up table' (LUT). This effect is also called Color Grading.
  77315. *
  77316. * The object needs to be provided an url to a texture containing the color
  77317. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  77318. * Use an image editing software to tweak the LUT to match your needs.
  77319. *
  77320. * For an example of a color LUT, see here:
  77321. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  77322. * For explanations on color grading, see here:
  77323. * @see http://udn.epicgames.com/Three/ColorGrading.html
  77324. *
  77325. */
  77326. export class ColorCorrectionPostProcess extends PostProcess {
  77327. private _colorTableTexture;
  77328. /**
  77329. * Gets the color table url used to create the LUT texture
  77330. */
  77331. colorTableUrl: string;
  77332. /**
  77333. * Gets a string identifying the name of the class
  77334. * @returns "ColorCorrectionPostProcess" string
  77335. */
  77336. getClassName(): string;
  77337. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  77338. /** @hidden */
  77339. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  77340. }
  77341. }
  77342. declare module "babylonjs/Shaders/convolution.fragment" {
  77343. /** @hidden */
  77344. export var convolutionPixelShader: {
  77345. name: string;
  77346. shader: string;
  77347. };
  77348. }
  77349. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  77350. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77351. import { Nullable } from "babylonjs/types";
  77352. import { Camera } from "babylonjs/Cameras/camera";
  77353. import { Engine } from "babylonjs/Engines/engine";
  77354. import "babylonjs/Shaders/convolution.fragment";
  77355. import { Scene } from "babylonjs/scene";
  77356. /**
  77357. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  77358. * input texture to perform effects such as edge detection or sharpening
  77359. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  77360. */
  77361. export class ConvolutionPostProcess extends PostProcess {
  77362. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  77363. kernel: number[];
  77364. /**
  77365. * Gets a string identifying the name of the class
  77366. * @returns "ConvolutionPostProcess" string
  77367. */
  77368. getClassName(): string;
  77369. /**
  77370. * Creates a new instance ConvolutionPostProcess
  77371. * @param name The name of the effect.
  77372. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  77373. * @param options The required width/height ratio to downsize to before computing the render pass.
  77374. * @param camera The camera to apply the render pass to.
  77375. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77376. * @param engine The engine which the post process will be applied. (default: current engine)
  77377. * @param reusable If the post process can be reused on the same frame. (default: false)
  77378. * @param textureType Type of textures used when performing the post process. (default: 0)
  77379. */
  77380. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  77381. /** @hidden */
  77382. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  77383. /**
  77384. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  77385. */
  77386. static EdgeDetect0Kernel: number[];
  77387. /**
  77388. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  77389. */
  77390. static EdgeDetect1Kernel: number[];
  77391. /**
  77392. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  77393. */
  77394. static EdgeDetect2Kernel: number[];
  77395. /**
  77396. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  77397. */
  77398. static SharpenKernel: number[];
  77399. /**
  77400. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  77401. */
  77402. static EmbossKernel: number[];
  77403. /**
  77404. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  77405. */
  77406. static GaussianKernel: number[];
  77407. }
  77408. }
  77409. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  77410. import { Nullable } from "babylonjs/types";
  77411. import { Vector2 } from "babylonjs/Maths/math.vector";
  77412. import { Camera } from "babylonjs/Cameras/camera";
  77413. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77414. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  77415. import { Engine } from "babylonjs/Engines/engine";
  77416. import { Scene } from "babylonjs/scene";
  77417. /**
  77418. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  77419. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  77420. * based on samples that have a large difference in distance than the center pixel.
  77421. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  77422. */
  77423. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  77424. /**
  77425. * The direction the blur should be applied
  77426. */
  77427. direction: Vector2;
  77428. /**
  77429. * Gets a string identifying the name of the class
  77430. * @returns "DepthOfFieldBlurPostProcess" string
  77431. */
  77432. getClassName(): string;
  77433. /**
  77434. * Creates a new instance CircleOfConfusionPostProcess
  77435. * @param name The name of the effect.
  77436. * @param scene The scene the effect belongs to.
  77437. * @param direction The direction the blur should be applied.
  77438. * @param kernel The size of the kernel used to blur.
  77439. * @param options The required width/height ratio to downsize to before computing the render pass.
  77440. * @param camera The camera to apply the render pass to.
  77441. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  77442. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  77443. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77444. * @param engine The engine which the post process will be applied. (default: current engine)
  77445. * @param reusable If the post process can be reused on the same frame. (default: false)
  77446. * @param textureType Type of textures used when performing the post process. (default: 0)
  77447. * @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)
  77448. */
  77449. 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);
  77450. }
  77451. }
  77452. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  77453. /** @hidden */
  77454. export var depthOfFieldMergePixelShader: {
  77455. name: string;
  77456. shader: string;
  77457. };
  77458. }
  77459. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  77460. import { Nullable } from "babylonjs/types";
  77461. import { Camera } from "babylonjs/Cameras/camera";
  77462. import { Effect } from "babylonjs/Materials/effect";
  77463. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77464. import { Engine } from "babylonjs/Engines/engine";
  77465. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  77466. /**
  77467. * Options to be set when merging outputs from the default pipeline.
  77468. */
  77469. export class DepthOfFieldMergePostProcessOptions {
  77470. /**
  77471. * The original image to merge on top of
  77472. */
  77473. originalFromInput: PostProcess;
  77474. /**
  77475. * Parameters to perform the merge of the depth of field effect
  77476. */
  77477. depthOfField?: {
  77478. circleOfConfusion: PostProcess;
  77479. blurSteps: Array<PostProcess>;
  77480. };
  77481. /**
  77482. * Parameters to perform the merge of bloom effect
  77483. */
  77484. bloom?: {
  77485. blurred: PostProcess;
  77486. weight: number;
  77487. };
  77488. }
  77489. /**
  77490. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  77491. */
  77492. export class DepthOfFieldMergePostProcess extends PostProcess {
  77493. private blurSteps;
  77494. /**
  77495. * Gets a string identifying the name of the class
  77496. * @returns "DepthOfFieldMergePostProcess" string
  77497. */
  77498. getClassName(): string;
  77499. /**
  77500. * Creates a new instance of DepthOfFieldMergePostProcess
  77501. * @param name The name of the effect.
  77502. * @param originalFromInput Post process which's input will be used for the merge.
  77503. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  77504. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  77505. * @param options The required width/height ratio to downsize to before computing the render pass.
  77506. * @param camera The camera to apply the render pass to.
  77507. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77508. * @param engine The engine which the post process will be applied. (default: current engine)
  77509. * @param reusable If the post process can be reused on the same frame. (default: false)
  77510. * @param textureType Type of textures used when performing the post process. (default: 0)
  77511. * @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)
  77512. */
  77513. 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);
  77514. /**
  77515. * Updates the effect with the current post process compile time values and recompiles the shader.
  77516. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  77517. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  77518. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  77519. * @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
  77520. * @param onCompiled Called when the shader has been compiled.
  77521. * @param onError Called if there is an error when compiling a shader.
  77522. */
  77523. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  77524. }
  77525. }
  77526. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  77527. import { Nullable } from "babylonjs/types";
  77528. import { Camera } from "babylonjs/Cameras/camera";
  77529. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  77530. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  77531. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  77532. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  77533. import { Scene } from "babylonjs/scene";
  77534. /**
  77535. * Specifies the level of max blur that should be applied when using the depth of field effect
  77536. */
  77537. export enum DepthOfFieldEffectBlurLevel {
  77538. /**
  77539. * Subtle blur
  77540. */
  77541. Low = 0,
  77542. /**
  77543. * Medium blur
  77544. */
  77545. Medium = 1,
  77546. /**
  77547. * Large blur
  77548. */
  77549. High = 2
  77550. }
  77551. /**
  77552. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  77553. */
  77554. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  77555. private _circleOfConfusion;
  77556. /**
  77557. * @hidden Internal, blurs from high to low
  77558. */
  77559. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  77560. private _depthOfFieldBlurY;
  77561. private _dofMerge;
  77562. /**
  77563. * @hidden Internal post processes in depth of field effect
  77564. */
  77565. _effects: Array<PostProcess>;
  77566. /**
  77567. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  77568. */
  77569. set focalLength(value: number);
  77570. get focalLength(): number;
  77571. /**
  77572. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  77573. */
  77574. set fStop(value: number);
  77575. get fStop(): number;
  77576. /**
  77577. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  77578. */
  77579. set focusDistance(value: number);
  77580. get focusDistance(): number;
  77581. /**
  77582. * 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.
  77583. */
  77584. set lensSize(value: number);
  77585. get lensSize(): number;
  77586. /**
  77587. * Creates a new instance DepthOfFieldEffect
  77588. * @param scene The scene the effect belongs to.
  77589. * @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.
  77590. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  77591. * @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)
  77592. */
  77593. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  77594. /**
  77595. * Get the current class name of the current effet
  77596. * @returns "DepthOfFieldEffect"
  77597. */
  77598. getClassName(): string;
  77599. /**
  77600. * 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.
  77601. */
  77602. set depthTexture(value: RenderTargetTexture);
  77603. /**
  77604. * Disposes each of the internal effects for a given camera.
  77605. * @param camera The camera to dispose the effect on.
  77606. */
  77607. disposeEffects(camera: Camera): void;
  77608. /**
  77609. * @hidden Internal
  77610. */
  77611. _updateEffects(): void;
  77612. /**
  77613. * Internal
  77614. * @returns if all the contained post processes are ready.
  77615. * @hidden
  77616. */
  77617. _isReady(): boolean;
  77618. }
  77619. }
  77620. declare module "babylonjs/Shaders/displayPass.fragment" {
  77621. /** @hidden */
  77622. export var displayPassPixelShader: {
  77623. name: string;
  77624. shader: string;
  77625. };
  77626. }
  77627. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  77628. import { Nullable } from "babylonjs/types";
  77629. import { Camera } from "babylonjs/Cameras/camera";
  77630. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77631. import { Engine } from "babylonjs/Engines/engine";
  77632. import "babylonjs/Shaders/displayPass.fragment";
  77633. import { Scene } from "babylonjs/scene";
  77634. /**
  77635. * DisplayPassPostProcess which produces an output the same as it's input
  77636. */
  77637. export class DisplayPassPostProcess extends PostProcess {
  77638. /**
  77639. * Gets a string identifying the name of the class
  77640. * @returns "DisplayPassPostProcess" string
  77641. */
  77642. getClassName(): string;
  77643. /**
  77644. * Creates the DisplayPassPostProcess
  77645. * @param name The name of the effect.
  77646. * @param options The required width/height ratio to downsize to before computing the render pass.
  77647. * @param camera The camera to apply the render pass to.
  77648. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77649. * @param engine The engine which the post process will be applied. (default: current engine)
  77650. * @param reusable If the post process can be reused on the same frame. (default: false)
  77651. */
  77652. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  77653. /** @hidden */
  77654. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  77655. }
  77656. }
  77657. declare module "babylonjs/Shaders/filter.fragment" {
  77658. /** @hidden */
  77659. export var filterPixelShader: {
  77660. name: string;
  77661. shader: string;
  77662. };
  77663. }
  77664. declare module "babylonjs/PostProcesses/filterPostProcess" {
  77665. import { Nullable } from "babylonjs/types";
  77666. import { Matrix } from "babylonjs/Maths/math.vector";
  77667. import { Camera } from "babylonjs/Cameras/camera";
  77668. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77669. import { Engine } from "babylonjs/Engines/engine";
  77670. import "babylonjs/Shaders/filter.fragment";
  77671. import { Scene } from "babylonjs/scene";
  77672. /**
  77673. * Applies a kernel filter to the image
  77674. */
  77675. export class FilterPostProcess extends PostProcess {
  77676. /** The matrix to be applied to the image */
  77677. kernelMatrix: Matrix;
  77678. /**
  77679. * Gets a string identifying the name of the class
  77680. * @returns "FilterPostProcess" string
  77681. */
  77682. getClassName(): string;
  77683. /**
  77684. *
  77685. * @param name The name of the effect.
  77686. * @param kernelMatrix The matrix to be applied to the image
  77687. * @param options The required width/height ratio to downsize to before computing the render pass.
  77688. * @param camera The camera to apply the render pass to.
  77689. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77690. * @param engine The engine which the post process will be applied. (default: current engine)
  77691. * @param reusable If the post process can be reused on the same frame. (default: false)
  77692. */
  77693. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  77694. /** @hidden */
  77695. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  77696. }
  77697. }
  77698. declare module "babylonjs/Shaders/fxaa.fragment" {
  77699. /** @hidden */
  77700. export var fxaaPixelShader: {
  77701. name: string;
  77702. shader: string;
  77703. };
  77704. }
  77705. declare module "babylonjs/Shaders/fxaa.vertex" {
  77706. /** @hidden */
  77707. export var fxaaVertexShader: {
  77708. name: string;
  77709. shader: string;
  77710. };
  77711. }
  77712. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  77713. import { Nullable } from "babylonjs/types";
  77714. import { Camera } from "babylonjs/Cameras/camera";
  77715. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77716. import { Engine } from "babylonjs/Engines/engine";
  77717. import "babylonjs/Shaders/fxaa.fragment";
  77718. import "babylonjs/Shaders/fxaa.vertex";
  77719. import { Scene } from "babylonjs/scene";
  77720. /**
  77721. * Fxaa post process
  77722. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  77723. */
  77724. export class FxaaPostProcess extends PostProcess {
  77725. /**
  77726. * Gets a string identifying the name of the class
  77727. * @returns "FxaaPostProcess" string
  77728. */
  77729. getClassName(): string;
  77730. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  77731. private _getDefines;
  77732. /** @hidden */
  77733. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  77734. }
  77735. }
  77736. declare module "babylonjs/Shaders/grain.fragment" {
  77737. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  77738. /** @hidden */
  77739. export var grainPixelShader: {
  77740. name: string;
  77741. shader: string;
  77742. };
  77743. }
  77744. declare module "babylonjs/PostProcesses/grainPostProcess" {
  77745. import { Nullable } from "babylonjs/types";
  77746. import { Camera } from "babylonjs/Cameras/camera";
  77747. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77748. import { Engine } from "babylonjs/Engines/engine";
  77749. import "babylonjs/Shaders/grain.fragment";
  77750. import { Scene } from "babylonjs/scene";
  77751. /**
  77752. * The GrainPostProcess adds noise to the image at mid luminance levels
  77753. */
  77754. export class GrainPostProcess extends PostProcess {
  77755. /**
  77756. * The intensity of the grain added (default: 30)
  77757. */
  77758. intensity: number;
  77759. /**
  77760. * If the grain should be randomized on every frame
  77761. */
  77762. animated: boolean;
  77763. /**
  77764. * Gets a string identifying the name of the class
  77765. * @returns "GrainPostProcess" string
  77766. */
  77767. getClassName(): string;
  77768. /**
  77769. * Creates a new instance of @see GrainPostProcess
  77770. * @param name The name of the effect.
  77771. * @param options The required width/height ratio to downsize to before computing the render pass.
  77772. * @param camera The camera to apply the render pass to.
  77773. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77774. * @param engine The engine which the post process will be applied. (default: current engine)
  77775. * @param reusable If the post process can be reused on the same frame. (default: false)
  77776. * @param textureType Type of textures used when performing the post process. (default: 0)
  77777. * @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)
  77778. */
  77779. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  77780. /** @hidden */
  77781. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  77782. }
  77783. }
  77784. declare module "babylonjs/Shaders/highlights.fragment" {
  77785. /** @hidden */
  77786. export var highlightsPixelShader: {
  77787. name: string;
  77788. shader: string;
  77789. };
  77790. }
  77791. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  77792. import { Nullable } from "babylonjs/types";
  77793. import { Camera } from "babylonjs/Cameras/camera";
  77794. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77795. import { Engine } from "babylonjs/Engines/engine";
  77796. import "babylonjs/Shaders/highlights.fragment";
  77797. /**
  77798. * Extracts highlights from the image
  77799. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  77800. */
  77801. export class HighlightsPostProcess extends PostProcess {
  77802. /**
  77803. * Gets a string identifying the name of the class
  77804. * @returns "HighlightsPostProcess" string
  77805. */
  77806. getClassName(): string;
  77807. /**
  77808. * Extracts highlights from the image
  77809. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  77810. * @param name The name of the effect.
  77811. * @param options The required width/height ratio to downsize to before computing the render pass.
  77812. * @param camera The camera to apply the render pass to.
  77813. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77814. * @param engine The engine which the post process will be applied. (default: current engine)
  77815. * @param reusable If the post process can be reused on the same frame. (default: false)
  77816. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  77817. */
  77818. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  77819. }
  77820. }
  77821. declare module "babylonjs/Rendering/motionBlurConfiguration" {
  77822. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  77823. /**
  77824. * Contains all parameters needed for the prepass to perform
  77825. * motion blur
  77826. */
  77827. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  77828. /**
  77829. * Is motion blur enabled
  77830. */
  77831. enabled: boolean;
  77832. /**
  77833. * Name of the configuration
  77834. */
  77835. name: string;
  77836. /**
  77837. * Textures that should be present in the MRT for this effect to work
  77838. */
  77839. readonly texturesRequired: number[];
  77840. }
  77841. }
  77842. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  77843. import { Nullable } from "babylonjs/types";
  77844. import { Scene } from "babylonjs/scene";
  77845. import { ISceneComponent } from "babylonjs/sceneComponent";
  77846. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  77847. module "babylonjs/scene" {
  77848. interface Scene {
  77849. /** @hidden (Backing field) */
  77850. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  77851. /**
  77852. * Gets or Sets the current geometry buffer associated to the scene.
  77853. */
  77854. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  77855. /**
  77856. * Enables a GeometryBufferRender and associates it with the scene
  77857. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  77858. * @returns the GeometryBufferRenderer
  77859. */
  77860. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  77861. /**
  77862. * Disables the GeometryBufferRender associated with the scene
  77863. */
  77864. disableGeometryBufferRenderer(): void;
  77865. }
  77866. }
  77867. /**
  77868. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  77869. * in several rendering techniques.
  77870. */
  77871. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  77872. /**
  77873. * The component name helpful to identify the component in the list of scene components.
  77874. */
  77875. readonly name: string;
  77876. /**
  77877. * The scene the component belongs to.
  77878. */
  77879. scene: Scene;
  77880. /**
  77881. * Creates a new instance of the component for the given scene
  77882. * @param scene Defines the scene to register the component in
  77883. */
  77884. constructor(scene: Scene);
  77885. /**
  77886. * Registers the component in a given scene
  77887. */
  77888. register(): void;
  77889. /**
  77890. * Rebuilds the elements related to this component in case of
  77891. * context lost for instance.
  77892. */
  77893. rebuild(): void;
  77894. /**
  77895. * Disposes the component and the associated ressources
  77896. */
  77897. dispose(): void;
  77898. private _gatherRenderTargets;
  77899. }
  77900. }
  77901. declare module "babylonjs/Shaders/motionBlur.fragment" {
  77902. /** @hidden */
  77903. export var motionBlurPixelShader: {
  77904. name: string;
  77905. shader: string;
  77906. };
  77907. }
  77908. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  77909. import { Nullable } from "babylonjs/types";
  77910. import { Camera } from "babylonjs/Cameras/camera";
  77911. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77912. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77913. import "babylonjs/Animations/animatable";
  77914. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  77915. import "babylonjs/Shaders/motionBlur.fragment";
  77916. import { Engine } from "babylonjs/Engines/engine";
  77917. import { Scene } from "babylonjs/scene";
  77918. /**
  77919. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  77920. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  77921. * As an example, all you have to do is to create the post-process:
  77922. * var mb = new BABYLON.MotionBlurPostProcess(
  77923. * 'mb', // The name of the effect.
  77924. * scene, // The scene containing the objects to blur according to their velocity.
  77925. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  77926. * camera // The camera to apply the render pass to.
  77927. * );
  77928. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  77929. */
  77930. export class MotionBlurPostProcess extends PostProcess {
  77931. /**
  77932. * Defines how much the image is blurred by the movement. Default value is equal to 1
  77933. */
  77934. motionStrength: number;
  77935. /**
  77936. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  77937. */
  77938. get motionBlurSamples(): number;
  77939. /**
  77940. * Sets the number of iterations to be used for motion blur quality
  77941. */
  77942. set motionBlurSamples(samples: number);
  77943. private _motionBlurSamples;
  77944. /**
  77945. * Gets wether or not the motion blur post-process is in object based mode.
  77946. */
  77947. get isObjectBased(): boolean;
  77948. /**
  77949. * Sets wether or not the motion blur post-process is in object based mode.
  77950. */
  77951. set isObjectBased(value: boolean);
  77952. private _isObjectBased;
  77953. private _forceGeometryBuffer;
  77954. private _geometryBufferRenderer;
  77955. private _prePassRenderer;
  77956. private _invViewProjection;
  77957. private _previousViewProjection;
  77958. /**
  77959. * Gets a string identifying the name of the class
  77960. * @returns "MotionBlurPostProcess" string
  77961. */
  77962. getClassName(): string;
  77963. /**
  77964. * Creates a new instance MotionBlurPostProcess
  77965. * @param name The name of the effect.
  77966. * @param scene The scene containing the objects to blur according to their velocity.
  77967. * @param options The required width/height ratio to downsize to before computing the render pass.
  77968. * @param camera The camera to apply the render pass to.
  77969. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77970. * @param engine The engine which the post process will be applied. (default: current engine)
  77971. * @param reusable If the post process can be reused on the same frame. (default: false)
  77972. * @param textureType Type of textures used when performing the post process. (default: 0)
  77973. * @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)
  77974. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  77975. */
  77976. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  77977. /**
  77978. * Excludes the given skinned mesh from computing bones velocities.
  77979. * 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.
  77980. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  77981. */
  77982. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  77983. /**
  77984. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  77985. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  77986. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  77987. */
  77988. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  77989. /**
  77990. * Disposes the post process.
  77991. * @param camera The camera to dispose the post process on.
  77992. */
  77993. dispose(camera?: Camera): void;
  77994. /**
  77995. * Called on the mode changed (object based or screen based).
  77996. */
  77997. private _applyMode;
  77998. /**
  77999. * Called on the effect is applied when the motion blur post-process is in object based mode.
  78000. */
  78001. private _onApplyObjectBased;
  78002. /**
  78003. * Called on the effect is applied when the motion blur post-process is in screen based mode.
  78004. */
  78005. private _onApplyScreenBased;
  78006. /**
  78007. * Called on the effect must be updated (changed mode, samples count, etc.).
  78008. */
  78009. private _updateEffect;
  78010. /** @hidden */
  78011. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  78012. }
  78013. }
  78014. declare module "babylonjs/Shaders/refraction.fragment" {
  78015. /** @hidden */
  78016. export var refractionPixelShader: {
  78017. name: string;
  78018. shader: string;
  78019. };
  78020. }
  78021. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  78022. import { Color3 } from "babylonjs/Maths/math.color";
  78023. import { Camera } from "babylonjs/Cameras/camera";
  78024. import { Texture } from "babylonjs/Materials/Textures/texture";
  78025. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  78026. import { Engine } from "babylonjs/Engines/engine";
  78027. import "babylonjs/Shaders/refraction.fragment";
  78028. import { Scene } from "babylonjs/scene";
  78029. /**
  78030. * Post process which applies a refractin texture
  78031. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  78032. */
  78033. export class RefractionPostProcess extends PostProcess {
  78034. private _refTexture;
  78035. private _ownRefractionTexture;
  78036. /** the base color of the refraction (used to taint the rendering) */
  78037. color: Color3;
  78038. /** simulated refraction depth */
  78039. depth: number;
  78040. /** the coefficient of the base color (0 to remove base color tainting) */
  78041. colorLevel: number;
  78042. /** Gets the url used to load the refraction texture */
  78043. refractionTextureUrl: string;
  78044. /**
  78045. * Gets or sets the refraction texture
  78046. * Please note that you are responsible for disposing the texture if you set it manually
  78047. */
  78048. get refractionTexture(): Texture;
  78049. set refractionTexture(value: Texture);
  78050. /**
  78051. * Gets a string identifying the name of the class
  78052. * @returns "RefractionPostProcess" string
  78053. */
  78054. getClassName(): string;
  78055. /**
  78056. * Initializes the RefractionPostProcess
  78057. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  78058. * @param name The name of the effect.
  78059. * @param refractionTextureUrl Url of the refraction texture to use
  78060. * @param color the base color of the refraction (used to taint the rendering)
  78061. * @param depth simulated refraction depth
  78062. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  78063. * @param camera The camera to apply the render pass to.
  78064. * @param options The required width/height ratio to downsize to before computing the render pass.
  78065. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  78066. * @param engine The engine which the post process will be applied. (default: current engine)
  78067. * @param reusable If the post process can be reused on the same frame. (default: false)
  78068. */
  78069. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  78070. /**
  78071. * Disposes of the post process
  78072. * @param camera Camera to dispose post process on
  78073. */
  78074. dispose(camera: Camera): void;
  78075. /** @hidden */
  78076. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  78077. }
  78078. }
  78079. declare module "babylonjs/Shaders/sharpen.fragment" {
  78080. /** @hidden */
  78081. export var sharpenPixelShader: {
  78082. name: string;
  78083. shader: string;
  78084. };
  78085. }
  78086. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  78087. import { Nullable } from "babylonjs/types";
  78088. import { Camera } from "babylonjs/Cameras/camera";
  78089. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  78090. import "babylonjs/Shaders/sharpen.fragment";
  78091. import { Engine } from "babylonjs/Engines/engine";
  78092. import { Scene } from "babylonjs/scene";
  78093. /**
  78094. * The SharpenPostProcess applies a sharpen kernel to every pixel
  78095. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  78096. */
  78097. export class SharpenPostProcess extends PostProcess {
  78098. /**
  78099. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  78100. */
  78101. colorAmount: number;
  78102. /**
  78103. * How much sharpness should be applied (default: 0.3)
  78104. */
  78105. edgeAmount: number;
  78106. /**
  78107. * Gets a string identifying the name of the class
  78108. * @returns "SharpenPostProcess" string
  78109. */
  78110. getClassName(): string;
  78111. /**
  78112. * Creates a new instance ConvolutionPostProcess
  78113. * @param name The name of the effect.
  78114. * @param options The required width/height ratio to downsize to before computing the render pass.
  78115. * @param camera The camera to apply the render pass to.
  78116. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  78117. * @param engine The engine which the post process will be applied. (default: current engine)
  78118. * @param reusable If the post process can be reused on the same frame. (default: false)
  78119. * @param textureType Type of textures used when performing the post process. (default: 0)
  78120. * @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)
  78121. */
  78122. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  78123. /** @hidden */
  78124. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  78125. }
  78126. }
  78127. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  78128. import { Nullable } from "babylonjs/types";
  78129. import { Camera } from "babylonjs/Cameras/camera";
  78130. import { Engine } from "babylonjs/Engines/engine";
  78131. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  78132. import { IInspectable } from "babylonjs/Misc/iInspectable";
  78133. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  78134. /**
  78135. * PostProcessRenderPipeline
  78136. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  78137. */
  78138. export class PostProcessRenderPipeline {
  78139. private engine;
  78140. private _renderEffects;
  78141. private _renderEffectsForIsolatedPass;
  78142. /**
  78143. * List of inspectable custom properties (used by the Inspector)
  78144. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78145. */
  78146. inspectableCustomProperties: IInspectable[];
  78147. /**
  78148. * @hidden
  78149. */
  78150. protected _cameras: Camera[];
  78151. /** @hidden */
  78152. _name: string;
  78153. /**
  78154. * Gets pipeline name
  78155. */
  78156. get name(): string;
  78157. /** Gets the list of attached cameras */
  78158. get cameras(): Camera[];
  78159. /**
  78160. * Initializes a PostProcessRenderPipeline
  78161. * @param engine engine to add the pipeline to
  78162. * @param name name of the pipeline
  78163. */
  78164. constructor(engine: Engine, name: string);
  78165. /**
  78166. * Gets the class name
  78167. * @returns "PostProcessRenderPipeline"
  78168. */
  78169. getClassName(): string;
  78170. /**
  78171. * If all the render effects in the pipeline are supported
  78172. */
  78173. get isSupported(): boolean;
  78174. /**
  78175. * Adds an effect to the pipeline
  78176. * @param renderEffect the effect to add
  78177. */
  78178. addEffect(renderEffect: PostProcessRenderEffect): void;
  78179. /** @hidden */
  78180. _rebuild(): void;
  78181. /** @hidden */
  78182. _enableEffect(renderEffectName: string, cameras: Camera): void;
  78183. /** @hidden */
  78184. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  78185. /** @hidden */
  78186. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  78187. /** @hidden */
  78188. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  78189. /** @hidden */
  78190. _attachCameras(cameras: Camera, unique: boolean): void;
  78191. /** @hidden */
  78192. _attachCameras(cameras: Camera[], unique: boolean): void;
  78193. /** @hidden */
  78194. _detachCameras(cameras: Camera): void;
  78195. /** @hidden */
  78196. _detachCameras(cameras: Nullable<Camera[]>): void;
  78197. /** @hidden */
  78198. _update(): void;
  78199. /** @hidden */
  78200. _reset(): void;
  78201. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  78202. /**
  78203. * Sets the required values to the prepass renderer.
  78204. * @param prePassRenderer defines the prepass renderer to setup.
  78205. * @returns true if the pre pass is needed.
  78206. */
  78207. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  78208. /**
  78209. * Disposes of the pipeline
  78210. */
  78211. dispose(): void;
  78212. }
  78213. }
  78214. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  78215. import { Camera } from "babylonjs/Cameras/camera";
  78216. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  78217. /**
  78218. * PostProcessRenderPipelineManager class
  78219. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  78220. */
  78221. export class PostProcessRenderPipelineManager {
  78222. private _renderPipelines;
  78223. /**
  78224. * Initializes a PostProcessRenderPipelineManager
  78225. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  78226. */
  78227. constructor();
  78228. /**
  78229. * Gets the list of supported render pipelines
  78230. */
  78231. get supportedPipelines(): PostProcessRenderPipeline[];
  78232. /**
  78233. * Adds a pipeline to the manager
  78234. * @param renderPipeline The pipeline to add
  78235. */
  78236. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  78237. /**
  78238. * Attaches a camera to the pipeline
  78239. * @param renderPipelineName The name of the pipeline to attach to
  78240. * @param cameras the camera to attach
  78241. * @param unique if the camera can be attached multiple times to the pipeline
  78242. */
  78243. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  78244. /**
  78245. * Detaches a camera from the pipeline
  78246. * @param renderPipelineName The name of the pipeline to detach from
  78247. * @param cameras the camera to detach
  78248. */
  78249. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  78250. /**
  78251. * Enables an effect by name on a pipeline
  78252. * @param renderPipelineName the name of the pipeline to enable the effect in
  78253. * @param renderEffectName the name of the effect to enable
  78254. * @param cameras the cameras that the effect should be enabled on
  78255. */
  78256. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  78257. /**
  78258. * Disables an effect by name on a pipeline
  78259. * @param renderPipelineName the name of the pipeline to disable the effect in
  78260. * @param renderEffectName the name of the effect to disable
  78261. * @param cameras the cameras that the effect should be disabled on
  78262. */
  78263. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  78264. /**
  78265. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  78266. */
  78267. update(): void;
  78268. /** @hidden */
  78269. _rebuild(): void;
  78270. /**
  78271. * Disposes of the manager and pipelines
  78272. */
  78273. dispose(): void;
  78274. }
  78275. }
  78276. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  78277. import { ISceneComponent } from "babylonjs/sceneComponent";
  78278. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  78279. import { Scene } from "babylonjs/scene";
  78280. module "babylonjs/scene" {
  78281. interface Scene {
  78282. /** @hidden (Backing field) */
  78283. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  78284. /**
  78285. * Gets the postprocess render pipeline manager
  78286. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  78287. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  78288. */
  78289. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  78290. }
  78291. }
  78292. /**
  78293. * Defines the Render Pipeline scene component responsible to rendering pipelines
  78294. */
  78295. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  78296. /**
  78297. * The component name helpfull to identify the component in the list of scene components.
  78298. */
  78299. readonly name: string;
  78300. /**
  78301. * The scene the component belongs to.
  78302. */
  78303. scene: Scene;
  78304. /**
  78305. * Creates a new instance of the component for the given scene
  78306. * @param scene Defines the scene to register the component in
  78307. */
  78308. constructor(scene: Scene);
  78309. /**
  78310. * Registers the component in a given scene
  78311. */
  78312. register(): void;
  78313. /**
  78314. * Rebuilds the elements related to this component in case of
  78315. * context lost for instance.
  78316. */
  78317. rebuild(): void;
  78318. /**
  78319. * Disposes the component and the associated ressources
  78320. */
  78321. dispose(): void;
  78322. private _gatherRenderTargets;
  78323. }
  78324. }
  78325. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  78326. import { Nullable } from "babylonjs/types";
  78327. import { Observable } from "babylonjs/Misc/observable";
  78328. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  78329. import { Camera } from "babylonjs/Cameras/camera";
  78330. import { IDisposable } from "babylonjs/scene";
  78331. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  78332. import { Scene } from "babylonjs/scene";
  78333. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  78334. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  78335. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  78336. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  78337. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  78338. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  78339. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  78340. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  78341. import { Animation } from "babylonjs/Animations/animation";
  78342. /**
  78343. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  78344. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  78345. */
  78346. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  78347. private _scene;
  78348. private _camerasToBeAttached;
  78349. /**
  78350. * ID of the sharpen post process,
  78351. */
  78352. private readonly SharpenPostProcessId;
  78353. /**
  78354. * @ignore
  78355. * ID of the image processing post process;
  78356. */
  78357. readonly ImageProcessingPostProcessId: string;
  78358. /**
  78359. * @ignore
  78360. * ID of the Fast Approximate Anti-Aliasing post process;
  78361. */
  78362. readonly FxaaPostProcessId: string;
  78363. /**
  78364. * ID of the chromatic aberration post process,
  78365. */
  78366. private readonly ChromaticAberrationPostProcessId;
  78367. /**
  78368. * ID of the grain post process
  78369. */
  78370. private readonly GrainPostProcessId;
  78371. /**
  78372. * Sharpen post process which will apply a sharpen convolution to enhance edges
  78373. */
  78374. sharpen: SharpenPostProcess;
  78375. private _sharpenEffect;
  78376. private bloom;
  78377. /**
  78378. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  78379. */
  78380. depthOfField: DepthOfFieldEffect;
  78381. /**
  78382. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  78383. */
  78384. fxaa: FxaaPostProcess;
  78385. /**
  78386. * Image post processing pass used to perform operations such as tone mapping or color grading.
  78387. */
  78388. imageProcessing: ImageProcessingPostProcess;
  78389. /**
  78390. * Chromatic aberration post process which will shift rgb colors in the image
  78391. */
  78392. chromaticAberration: ChromaticAberrationPostProcess;
  78393. private _chromaticAberrationEffect;
  78394. /**
  78395. * Grain post process which add noise to the image
  78396. */
  78397. grain: GrainPostProcess;
  78398. private _grainEffect;
  78399. /**
  78400. * Glow post process which adds a glow to emissive areas of the image
  78401. */
  78402. private _glowLayer;
  78403. /**
  78404. * Animations which can be used to tweak settings over a period of time
  78405. */
  78406. animations: Animation[];
  78407. private _imageProcessingConfigurationObserver;
  78408. private _sharpenEnabled;
  78409. private _bloomEnabled;
  78410. private _depthOfFieldEnabled;
  78411. private _depthOfFieldBlurLevel;
  78412. private _fxaaEnabled;
  78413. private _imageProcessingEnabled;
  78414. private _defaultPipelineTextureType;
  78415. private _bloomScale;
  78416. private _chromaticAberrationEnabled;
  78417. private _grainEnabled;
  78418. private _buildAllowed;
  78419. /**
  78420. * This is triggered each time the pipeline has been built.
  78421. */
  78422. onBuildObservable: Observable<DefaultRenderingPipeline>;
  78423. /**
  78424. * Gets active scene
  78425. */
  78426. get scene(): Scene;
  78427. /**
  78428. * Enable or disable the sharpen process from the pipeline
  78429. */
  78430. set sharpenEnabled(enabled: boolean);
  78431. get sharpenEnabled(): boolean;
  78432. private _resizeObserver;
  78433. private _hardwareScaleLevel;
  78434. private _bloomKernel;
  78435. /**
  78436. * Specifies the size of the bloom blur kernel, relative to the final output size
  78437. */
  78438. get bloomKernel(): number;
  78439. set bloomKernel(value: number);
  78440. /**
  78441. * Specifies the weight of the bloom in the final rendering
  78442. */
  78443. private _bloomWeight;
  78444. /**
  78445. * Specifies the luma threshold for the area that will be blurred by the bloom
  78446. */
  78447. private _bloomThreshold;
  78448. private _hdr;
  78449. /**
  78450. * The strength of the bloom.
  78451. */
  78452. set bloomWeight(value: number);
  78453. get bloomWeight(): number;
  78454. /**
  78455. * The strength of the bloom.
  78456. */
  78457. set bloomThreshold(value: number);
  78458. get bloomThreshold(): number;
  78459. /**
  78460. * The scale of the bloom, lower value will provide better performance.
  78461. */
  78462. set bloomScale(value: number);
  78463. get bloomScale(): number;
  78464. /**
  78465. * Enable or disable the bloom from the pipeline
  78466. */
  78467. set bloomEnabled(enabled: boolean);
  78468. get bloomEnabled(): boolean;
  78469. private _rebuildBloom;
  78470. /**
  78471. * If the depth of field is enabled.
  78472. */
  78473. get depthOfFieldEnabled(): boolean;
  78474. set depthOfFieldEnabled(enabled: boolean);
  78475. /**
  78476. * Blur level of the depth of field effect. (Higher blur will effect performance)
  78477. */
  78478. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  78479. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  78480. /**
  78481. * If the anti aliasing is enabled.
  78482. */
  78483. set fxaaEnabled(enabled: boolean);
  78484. get fxaaEnabled(): boolean;
  78485. private _samples;
  78486. /**
  78487. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  78488. */
  78489. set samples(sampleCount: number);
  78490. get samples(): number;
  78491. /**
  78492. * If image processing is enabled.
  78493. */
  78494. set imageProcessingEnabled(enabled: boolean);
  78495. get imageProcessingEnabled(): boolean;
  78496. /**
  78497. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  78498. */
  78499. set glowLayerEnabled(enabled: boolean);
  78500. get glowLayerEnabled(): boolean;
  78501. /**
  78502. * Gets the glow layer (or null if not defined)
  78503. */
  78504. get glowLayer(): Nullable<GlowLayer>;
  78505. /**
  78506. * Enable or disable the chromaticAberration process from the pipeline
  78507. */
  78508. set chromaticAberrationEnabled(enabled: boolean);
  78509. get chromaticAberrationEnabled(): boolean;
  78510. /**
  78511. * Enable or disable the grain process from the pipeline
  78512. */
  78513. set grainEnabled(enabled: boolean);
  78514. get grainEnabled(): boolean;
  78515. /**
  78516. * @constructor
  78517. * @param name - The rendering pipeline name (default: "")
  78518. * @param hdr - If high dynamic range textures should be used (default: true)
  78519. * @param scene - The scene linked to this pipeline (default: the last created scene)
  78520. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  78521. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  78522. */
  78523. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  78524. /**
  78525. * Get the class name
  78526. * @returns "DefaultRenderingPipeline"
  78527. */
  78528. getClassName(): string;
  78529. /**
  78530. * Force the compilation of the entire pipeline.
  78531. */
  78532. prepare(): void;
  78533. private _hasCleared;
  78534. private _prevPostProcess;
  78535. private _prevPrevPostProcess;
  78536. private _setAutoClearAndTextureSharing;
  78537. private _depthOfFieldSceneObserver;
  78538. private _buildPipeline;
  78539. private _disposePostProcesses;
  78540. /**
  78541. * Adds a camera to the pipeline
  78542. * @param camera the camera to be added
  78543. */
  78544. addCamera(camera: Camera): void;
  78545. /**
  78546. * Removes a camera from the pipeline
  78547. * @param camera the camera to remove
  78548. */
  78549. removeCamera(camera: Camera): void;
  78550. /**
  78551. * Dispose of the pipeline and stop all post processes
  78552. */
  78553. dispose(): void;
  78554. /**
  78555. * Serialize the rendering pipeline (Used when exporting)
  78556. * @returns the serialized object
  78557. */
  78558. serialize(): any;
  78559. /**
  78560. * Parse the serialized pipeline
  78561. * @param source Source pipeline.
  78562. * @param scene The scene to load the pipeline to.
  78563. * @param rootUrl The URL of the serialized pipeline.
  78564. * @returns An instantiated pipeline from the serialized object.
  78565. */
  78566. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  78567. }
  78568. }
  78569. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  78570. /** @hidden */
  78571. export var lensHighlightsPixelShader: {
  78572. name: string;
  78573. shader: string;
  78574. };
  78575. }
  78576. declare module "babylonjs/Shaders/depthOfField.fragment" {
  78577. /** @hidden */
  78578. export var depthOfFieldPixelShader: {
  78579. name: string;
  78580. shader: string;
  78581. };
  78582. }
  78583. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  78584. import { Camera } from "babylonjs/Cameras/camera";
  78585. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  78586. import { Scene } from "babylonjs/scene";
  78587. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  78588. import "babylonjs/Shaders/chromaticAberration.fragment";
  78589. import "babylonjs/Shaders/lensHighlights.fragment";
  78590. import "babylonjs/Shaders/depthOfField.fragment";
  78591. /**
  78592. * BABYLON.JS Chromatic Aberration GLSL Shader
  78593. * Author: Olivier Guyot
  78594. * Separates very slightly R, G and B colors on the edges of the screen
  78595. * Inspired by Francois Tarlier & Martins Upitis
  78596. */
  78597. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  78598. /**
  78599. * @ignore
  78600. * The chromatic aberration PostProcess id in the pipeline
  78601. */
  78602. LensChromaticAberrationEffect: string;
  78603. /**
  78604. * @ignore
  78605. * The highlights enhancing PostProcess id in the pipeline
  78606. */
  78607. HighlightsEnhancingEffect: string;
  78608. /**
  78609. * @ignore
  78610. * The depth-of-field PostProcess id in the pipeline
  78611. */
  78612. LensDepthOfFieldEffect: string;
  78613. private _scene;
  78614. private _depthTexture;
  78615. private _grainTexture;
  78616. private _chromaticAberrationPostProcess;
  78617. private _highlightsPostProcess;
  78618. private _depthOfFieldPostProcess;
  78619. private _edgeBlur;
  78620. private _grainAmount;
  78621. private _chromaticAberration;
  78622. private _distortion;
  78623. private _highlightsGain;
  78624. private _highlightsThreshold;
  78625. private _dofDistance;
  78626. private _dofAperture;
  78627. private _dofDarken;
  78628. private _dofPentagon;
  78629. private _blurNoise;
  78630. /**
  78631. * @constructor
  78632. *
  78633. * Effect parameters are as follow:
  78634. * {
  78635. * chromatic_aberration: number; // from 0 to x (1 for realism)
  78636. * edge_blur: number; // from 0 to x (1 for realism)
  78637. * distortion: number; // from 0 to x (1 for realism)
  78638. * grain_amount: number; // from 0 to 1
  78639. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  78640. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  78641. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  78642. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  78643. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  78644. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  78645. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  78646. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  78647. * }
  78648. * Note: if an effect parameter is unset, effect is disabled
  78649. *
  78650. * @param name The rendering pipeline name
  78651. * @param parameters - An object containing all parameters (see above)
  78652. * @param scene The scene linked to this pipeline
  78653. * @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)
  78654. * @param cameras The array of cameras that the rendering pipeline will be attached to
  78655. */
  78656. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  78657. /**
  78658. * Get the class name
  78659. * @returns "LensRenderingPipeline"
  78660. */
  78661. getClassName(): string;
  78662. /**
  78663. * Gets associated scene
  78664. */
  78665. get scene(): Scene;
  78666. /**
  78667. * Gets or sets the edge blur
  78668. */
  78669. get edgeBlur(): number;
  78670. set edgeBlur(value: number);
  78671. /**
  78672. * Gets or sets the grain amount
  78673. */
  78674. get grainAmount(): number;
  78675. set grainAmount(value: number);
  78676. /**
  78677. * Gets or sets the chromatic aberration amount
  78678. */
  78679. get chromaticAberration(): number;
  78680. set chromaticAberration(value: number);
  78681. /**
  78682. * Gets or sets the depth of field aperture
  78683. */
  78684. get dofAperture(): number;
  78685. set dofAperture(value: number);
  78686. /**
  78687. * Gets or sets the edge distortion
  78688. */
  78689. get edgeDistortion(): number;
  78690. set edgeDistortion(value: number);
  78691. /**
  78692. * Gets or sets the depth of field distortion
  78693. */
  78694. get dofDistortion(): number;
  78695. set dofDistortion(value: number);
  78696. /**
  78697. * Gets or sets the darken out of focus amount
  78698. */
  78699. get darkenOutOfFocus(): number;
  78700. set darkenOutOfFocus(value: number);
  78701. /**
  78702. * Gets or sets a boolean indicating if blur noise is enabled
  78703. */
  78704. get blurNoise(): boolean;
  78705. set blurNoise(value: boolean);
  78706. /**
  78707. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  78708. */
  78709. get pentagonBokeh(): boolean;
  78710. set pentagonBokeh(value: boolean);
  78711. /**
  78712. * Gets or sets the highlight grain amount
  78713. */
  78714. get highlightsGain(): number;
  78715. set highlightsGain(value: number);
  78716. /**
  78717. * Gets or sets the highlight threshold
  78718. */
  78719. get highlightsThreshold(): number;
  78720. set highlightsThreshold(value: number);
  78721. /**
  78722. * Sets the amount of blur at the edges
  78723. * @param amount blur amount
  78724. */
  78725. setEdgeBlur(amount: number): void;
  78726. /**
  78727. * Sets edge blur to 0
  78728. */
  78729. disableEdgeBlur(): void;
  78730. /**
  78731. * Sets the amout of grain
  78732. * @param amount Amount of grain
  78733. */
  78734. setGrainAmount(amount: number): void;
  78735. /**
  78736. * Set grain amount to 0
  78737. */
  78738. disableGrain(): void;
  78739. /**
  78740. * Sets the chromatic aberration amount
  78741. * @param amount amount of chromatic aberration
  78742. */
  78743. setChromaticAberration(amount: number): void;
  78744. /**
  78745. * Sets chromatic aberration amount to 0
  78746. */
  78747. disableChromaticAberration(): void;
  78748. /**
  78749. * Sets the EdgeDistortion amount
  78750. * @param amount amount of EdgeDistortion
  78751. */
  78752. setEdgeDistortion(amount: number): void;
  78753. /**
  78754. * Sets edge distortion to 0
  78755. */
  78756. disableEdgeDistortion(): void;
  78757. /**
  78758. * Sets the FocusDistance amount
  78759. * @param amount amount of FocusDistance
  78760. */
  78761. setFocusDistance(amount: number): void;
  78762. /**
  78763. * Disables depth of field
  78764. */
  78765. disableDepthOfField(): void;
  78766. /**
  78767. * Sets the Aperture amount
  78768. * @param amount amount of Aperture
  78769. */
  78770. setAperture(amount: number): void;
  78771. /**
  78772. * Sets the DarkenOutOfFocus amount
  78773. * @param amount amount of DarkenOutOfFocus
  78774. */
  78775. setDarkenOutOfFocus(amount: number): void;
  78776. private _pentagonBokehIsEnabled;
  78777. /**
  78778. * Creates a pentagon bokeh effect
  78779. */
  78780. enablePentagonBokeh(): void;
  78781. /**
  78782. * Disables the pentagon bokeh effect
  78783. */
  78784. disablePentagonBokeh(): void;
  78785. /**
  78786. * Enables noise blur
  78787. */
  78788. enableNoiseBlur(): void;
  78789. /**
  78790. * Disables noise blur
  78791. */
  78792. disableNoiseBlur(): void;
  78793. /**
  78794. * Sets the HighlightsGain amount
  78795. * @param amount amount of HighlightsGain
  78796. */
  78797. setHighlightsGain(amount: number): void;
  78798. /**
  78799. * Sets the HighlightsThreshold amount
  78800. * @param amount amount of HighlightsThreshold
  78801. */
  78802. setHighlightsThreshold(amount: number): void;
  78803. /**
  78804. * Disables highlights
  78805. */
  78806. disableHighlights(): void;
  78807. /**
  78808. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  78809. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  78810. */
  78811. dispose(disableDepthRender?: boolean): void;
  78812. private _createChromaticAberrationPostProcess;
  78813. private _createHighlightsPostProcess;
  78814. private _createDepthOfFieldPostProcess;
  78815. private _createGrainTexture;
  78816. }
  78817. }
  78818. declare module "babylonjs/Rendering/ssao2Configuration" {
  78819. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  78820. /**
  78821. * Contains all parameters needed for the prepass to perform
  78822. * screen space subsurface scattering
  78823. */
  78824. export class SSAO2Configuration implements PrePassEffectConfiguration {
  78825. /**
  78826. * Is subsurface enabled
  78827. */
  78828. enabled: boolean;
  78829. /**
  78830. * Name of the configuration
  78831. */
  78832. name: string;
  78833. /**
  78834. * Textures that should be present in the MRT for this effect to work
  78835. */
  78836. readonly texturesRequired: number[];
  78837. }
  78838. }
  78839. declare module "babylonjs/Shaders/ssao2.fragment" {
  78840. /** @hidden */
  78841. export var ssao2PixelShader: {
  78842. name: string;
  78843. shader: string;
  78844. };
  78845. }
  78846. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  78847. /** @hidden */
  78848. export var ssaoCombinePixelShader: {
  78849. name: string;
  78850. shader: string;
  78851. };
  78852. }
  78853. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  78854. import { Camera } from "babylonjs/Cameras/camera";
  78855. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  78856. import { Scene } from "babylonjs/scene";
  78857. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  78858. import "babylonjs/Shaders/ssao2.fragment";
  78859. import "babylonjs/Shaders/ssaoCombine.fragment";
  78860. /**
  78861. * Render pipeline to produce ssao effect
  78862. */
  78863. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  78864. /**
  78865. * @ignore
  78866. * The PassPostProcess id in the pipeline that contains the original scene color
  78867. */
  78868. SSAOOriginalSceneColorEffect: string;
  78869. /**
  78870. * @ignore
  78871. * The SSAO PostProcess id in the pipeline
  78872. */
  78873. SSAORenderEffect: string;
  78874. /**
  78875. * @ignore
  78876. * The horizontal blur PostProcess id in the pipeline
  78877. */
  78878. SSAOBlurHRenderEffect: string;
  78879. /**
  78880. * @ignore
  78881. * The vertical blur PostProcess id in the pipeline
  78882. */
  78883. SSAOBlurVRenderEffect: string;
  78884. /**
  78885. * @ignore
  78886. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  78887. */
  78888. SSAOCombineRenderEffect: string;
  78889. /**
  78890. * The output strength of the SSAO post-process. Default value is 1.0.
  78891. */
  78892. totalStrength: number;
  78893. /**
  78894. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  78895. */
  78896. maxZ: number;
  78897. /**
  78898. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  78899. */
  78900. minZAspect: number;
  78901. private _samples;
  78902. /**
  78903. * Number of samples used for the SSAO calculations. Default value is 8
  78904. */
  78905. set samples(n: number);
  78906. get samples(): number;
  78907. private _textureSamples;
  78908. /**
  78909. * Number of samples to use for antialiasing
  78910. */
  78911. set textureSamples(n: number);
  78912. get textureSamples(): number;
  78913. /**
  78914. * Force rendering the geometry through geometry buffer
  78915. */
  78916. private _forceGeometryBuffer;
  78917. /**
  78918. * Ratio object used for SSAO ratio and blur ratio
  78919. */
  78920. private _ratio;
  78921. /**
  78922. * Dynamically generated sphere sampler.
  78923. */
  78924. private _sampleSphere;
  78925. /**
  78926. * Blur filter offsets
  78927. */
  78928. private _samplerOffsets;
  78929. private _expensiveBlur;
  78930. /**
  78931. * If bilateral blur should be used
  78932. */
  78933. set expensiveBlur(b: boolean);
  78934. get expensiveBlur(): boolean;
  78935. /**
  78936. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  78937. */
  78938. radius: number;
  78939. /**
  78940. * The base color of the SSAO post-process
  78941. * The final result is "base + ssao" between [0, 1]
  78942. */
  78943. base: number;
  78944. /**
  78945. * Support test.
  78946. */
  78947. static get IsSupported(): boolean;
  78948. private _scene;
  78949. private _randomTexture;
  78950. private _originalColorPostProcess;
  78951. private _ssaoPostProcess;
  78952. private _blurHPostProcess;
  78953. private _blurVPostProcess;
  78954. private _ssaoCombinePostProcess;
  78955. private _prePassRenderer;
  78956. /**
  78957. * Gets active scene
  78958. */
  78959. get scene(): Scene;
  78960. /**
  78961. * @constructor
  78962. * @param name The rendering pipeline name
  78963. * @param scene The scene linked to this pipeline
  78964. * @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 }
  78965. * @param cameras The array of cameras that the rendering pipeline will be attached to
  78966. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  78967. */
  78968. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  78969. /**
  78970. * Get the class name
  78971. * @returns "SSAO2RenderingPipeline"
  78972. */
  78973. getClassName(): string;
  78974. /**
  78975. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  78976. */
  78977. dispose(disableGeometryBufferRenderer?: boolean): void;
  78978. private _createBlurPostProcess;
  78979. /** @hidden */
  78980. _rebuild(): void;
  78981. private _bits;
  78982. private _radicalInverse_VdC;
  78983. private _hammersley;
  78984. private _hemisphereSample_uniform;
  78985. private _generateHemisphere;
  78986. private _getDefinesForSSAO;
  78987. private static readonly ORTHO_DEPTH_PROJECTION;
  78988. private static readonly PERSPECTIVE_DEPTH_PROJECTION;
  78989. private _createSSAOPostProcess;
  78990. private _createSSAOCombinePostProcess;
  78991. private _createRandomTexture;
  78992. /**
  78993. * Serialize the rendering pipeline (Used when exporting)
  78994. * @returns the serialized object
  78995. */
  78996. serialize(): any;
  78997. /**
  78998. * Parse the serialized pipeline
  78999. * @param source Source pipeline.
  79000. * @param scene The scene to load the pipeline to.
  79001. * @param rootUrl The URL of the serialized pipeline.
  79002. * @returns An instantiated pipeline from the serialized object.
  79003. */
  79004. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  79005. }
  79006. }
  79007. declare module "babylonjs/Shaders/ssao.fragment" {
  79008. /** @hidden */
  79009. export var ssaoPixelShader: {
  79010. name: string;
  79011. shader: string;
  79012. };
  79013. }
  79014. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  79015. import { Camera } from "babylonjs/Cameras/camera";
  79016. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  79017. import { Scene } from "babylonjs/scene";
  79018. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  79019. import "babylonjs/Shaders/ssao.fragment";
  79020. import "babylonjs/Shaders/ssaoCombine.fragment";
  79021. /**
  79022. * Render pipeline to produce ssao effect
  79023. */
  79024. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  79025. /**
  79026. * @ignore
  79027. * The PassPostProcess id in the pipeline that contains the original scene color
  79028. */
  79029. SSAOOriginalSceneColorEffect: string;
  79030. /**
  79031. * @ignore
  79032. * The SSAO PostProcess id in the pipeline
  79033. */
  79034. SSAORenderEffect: string;
  79035. /**
  79036. * @ignore
  79037. * The horizontal blur PostProcess id in the pipeline
  79038. */
  79039. SSAOBlurHRenderEffect: string;
  79040. /**
  79041. * @ignore
  79042. * The vertical blur PostProcess id in the pipeline
  79043. */
  79044. SSAOBlurVRenderEffect: string;
  79045. /**
  79046. * @ignore
  79047. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  79048. */
  79049. SSAOCombineRenderEffect: string;
  79050. /**
  79051. * The output strength of the SSAO post-process. Default value is 1.0.
  79052. */
  79053. totalStrength: number;
  79054. /**
  79055. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  79056. */
  79057. radius: number;
  79058. /**
  79059. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  79060. * Must not be equal to fallOff and superior to fallOff.
  79061. * Default value is 0.0075
  79062. */
  79063. area: number;
  79064. /**
  79065. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  79066. * Must not be equal to area and inferior to area.
  79067. * Default value is 0.000001
  79068. */
  79069. fallOff: number;
  79070. /**
  79071. * The base color of the SSAO post-process
  79072. * The final result is "base + ssao" between [0, 1]
  79073. */
  79074. base: number;
  79075. private _scene;
  79076. private _depthTexture;
  79077. private _randomTexture;
  79078. private _originalColorPostProcess;
  79079. private _ssaoPostProcess;
  79080. private _blurHPostProcess;
  79081. private _blurVPostProcess;
  79082. private _ssaoCombinePostProcess;
  79083. private _firstUpdate;
  79084. /**
  79085. * Gets active scene
  79086. */
  79087. get scene(): Scene;
  79088. /**
  79089. * @constructor
  79090. * @param name - The rendering pipeline name
  79091. * @param scene - The scene linked to this pipeline
  79092. * @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 }
  79093. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  79094. */
  79095. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  79096. /**
  79097. * Get the class name
  79098. * @returns "SSAORenderingPipeline"
  79099. */
  79100. getClassName(): string;
  79101. /**
  79102. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  79103. */
  79104. dispose(disableDepthRender?: boolean): void;
  79105. private _createBlurPostProcess;
  79106. /** @hidden */
  79107. _rebuild(): void;
  79108. private _createSSAOPostProcess;
  79109. private _createSSAOCombinePostProcess;
  79110. private _createRandomTexture;
  79111. }
  79112. }
  79113. declare module "babylonjs/Rendering/screenSpaceReflectionsConfiguration" {
  79114. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  79115. /**
  79116. * Contains all parameters needed for the prepass to perform
  79117. * screen space reflections
  79118. */
  79119. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  79120. /**
  79121. * Is ssr enabled
  79122. */
  79123. enabled: boolean;
  79124. /**
  79125. * Name of the configuration
  79126. */
  79127. name: string;
  79128. /**
  79129. * Textures that should be present in the MRT for this effect to work
  79130. */
  79131. readonly texturesRequired: number[];
  79132. }
  79133. }
  79134. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  79135. /** @hidden */
  79136. export var screenSpaceReflectionPixelShader: {
  79137. name: string;
  79138. shader: string;
  79139. };
  79140. }
  79141. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  79142. import { Nullable } from "babylonjs/types";
  79143. import { Camera } from "babylonjs/Cameras/camera";
  79144. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  79145. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  79146. import { Engine } from "babylonjs/Engines/engine";
  79147. import { Scene } from "babylonjs/scene";
  79148. /**
  79149. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  79150. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  79151. */
  79152. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  79153. /**
  79154. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  79155. */
  79156. threshold: number;
  79157. /**
  79158. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  79159. */
  79160. strength: number;
  79161. /**
  79162. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  79163. */
  79164. reflectionSpecularFalloffExponent: number;
  79165. /**
  79166. * 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]
  79167. */
  79168. step: number;
  79169. /**
  79170. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  79171. */
  79172. roughnessFactor: number;
  79173. private _forceGeometryBuffer;
  79174. private _geometryBufferRenderer;
  79175. private _prePassRenderer;
  79176. private _enableSmoothReflections;
  79177. private _reflectionSamples;
  79178. private _smoothSteps;
  79179. /**
  79180. * Gets a string identifying the name of the class
  79181. * @returns "ScreenSpaceReflectionPostProcess" string
  79182. */
  79183. getClassName(): string;
  79184. /**
  79185. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  79186. * @param name The name of the effect.
  79187. * @param scene The scene containing the objects to calculate reflections.
  79188. * @param options The required width/height ratio to downsize to before computing the render pass.
  79189. * @param camera The camera to apply the render pass to.
  79190. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  79191. * @param engine The engine which the post process will be applied. (default: current engine)
  79192. * @param reusable If the post process can be reused on the same frame. (default: false)
  79193. * @param textureType Type of textures used when performing the post process. (default: 0)
  79194. * @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)
  79195. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  79196. */
  79197. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  79198. /**
  79199. * Gets wether or not smoothing reflections is enabled.
  79200. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  79201. */
  79202. get enableSmoothReflections(): boolean;
  79203. /**
  79204. * Sets wether or not smoothing reflections is enabled.
  79205. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  79206. */
  79207. set enableSmoothReflections(enabled: boolean);
  79208. /**
  79209. * Gets the number of samples taken while computing reflections. More samples count is high,
  79210. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  79211. */
  79212. get reflectionSamples(): number;
  79213. /**
  79214. * Sets the number of samples taken while computing reflections. More samples count is high,
  79215. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  79216. */
  79217. set reflectionSamples(samples: number);
  79218. /**
  79219. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  79220. * more the post-process will require GPU power and can generate a drop in FPS.
  79221. * Default value (5.0) work pretty well in all cases but can be adjusted.
  79222. */
  79223. get smoothSteps(): number;
  79224. set smoothSteps(steps: number);
  79225. private _updateEffectDefines;
  79226. /** @hidden */
  79227. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  79228. }
  79229. }
  79230. declare module "babylonjs/Shaders/standard.fragment" {
  79231. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  79232. /** @hidden */
  79233. export var standardPixelShader: {
  79234. name: string;
  79235. shader: string;
  79236. };
  79237. }
  79238. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  79239. import { Nullable } from "babylonjs/types";
  79240. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  79241. import { Camera } from "babylonjs/Cameras/camera";
  79242. import { Texture } from "babylonjs/Materials/Textures/texture";
  79243. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  79244. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  79245. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  79246. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  79247. import { IDisposable } from "babylonjs/scene";
  79248. import { SpotLight } from "babylonjs/Lights/spotLight";
  79249. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  79250. import { Scene } from "babylonjs/scene";
  79251. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  79252. import { Animation } from "babylonjs/Animations/animation";
  79253. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  79254. import "babylonjs/Shaders/standard.fragment";
  79255. /**
  79256. * Standard rendering pipeline
  79257. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  79258. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  79259. */
  79260. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  79261. /**
  79262. * Public members
  79263. */
  79264. /**
  79265. * Post-process which contains the original scene color before the pipeline applies all the effects
  79266. */
  79267. originalPostProcess: Nullable<PostProcess>;
  79268. /**
  79269. * Post-process used to down scale an image x4
  79270. */
  79271. downSampleX4PostProcess: Nullable<PostProcess>;
  79272. /**
  79273. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  79274. */
  79275. brightPassPostProcess: Nullable<PostProcess>;
  79276. /**
  79277. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  79278. */
  79279. blurHPostProcesses: PostProcess[];
  79280. /**
  79281. * Post-process array storing all the vertical blur post-processes used by the pipeline
  79282. */
  79283. blurVPostProcesses: PostProcess[];
  79284. /**
  79285. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  79286. */
  79287. textureAdderPostProcess: Nullable<PostProcess>;
  79288. /**
  79289. * Post-process used to create volumetric lighting effect
  79290. */
  79291. volumetricLightPostProcess: Nullable<PostProcess>;
  79292. /**
  79293. * Post-process used to smooth the previous volumetric light post-process on the X axis
  79294. */
  79295. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  79296. /**
  79297. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  79298. */
  79299. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  79300. /**
  79301. * Post-process used to merge the volumetric light effect and the real scene color
  79302. */
  79303. volumetricLightMergePostProces: Nullable<PostProcess>;
  79304. /**
  79305. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  79306. */
  79307. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  79308. /**
  79309. * Base post-process used to calculate the average luminance of the final image for HDR
  79310. */
  79311. luminancePostProcess: Nullable<PostProcess>;
  79312. /**
  79313. * Post-processes used to create down sample post-processes in order to get
  79314. * the average luminance of the final image for HDR
  79315. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  79316. */
  79317. luminanceDownSamplePostProcesses: PostProcess[];
  79318. /**
  79319. * Post-process used to create a HDR effect (light adaptation)
  79320. */
  79321. hdrPostProcess: Nullable<PostProcess>;
  79322. /**
  79323. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  79324. */
  79325. textureAdderFinalPostProcess: Nullable<PostProcess>;
  79326. /**
  79327. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  79328. */
  79329. lensFlareFinalPostProcess: Nullable<PostProcess>;
  79330. /**
  79331. * Post-process used to merge the final HDR post-process and the real scene color
  79332. */
  79333. hdrFinalPostProcess: Nullable<PostProcess>;
  79334. /**
  79335. * Post-process used to create a lens flare effect
  79336. */
  79337. lensFlarePostProcess: Nullable<PostProcess>;
  79338. /**
  79339. * Post-process that merges the result of the lens flare post-process and the real scene color
  79340. */
  79341. lensFlareComposePostProcess: Nullable<PostProcess>;
  79342. /**
  79343. * Post-process used to create a motion blur effect
  79344. */
  79345. motionBlurPostProcess: Nullable<PostProcess>;
  79346. /**
  79347. * Post-process used to create a depth of field effect
  79348. */
  79349. depthOfFieldPostProcess: Nullable<PostProcess>;
  79350. /**
  79351. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  79352. */
  79353. fxaaPostProcess: Nullable<FxaaPostProcess>;
  79354. /**
  79355. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  79356. */
  79357. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  79358. /**
  79359. * Represents the brightness threshold in order to configure the illuminated surfaces
  79360. */
  79361. brightThreshold: number;
  79362. /**
  79363. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  79364. */
  79365. blurWidth: number;
  79366. /**
  79367. * Sets if the blur for highlighted surfaces must be only horizontal
  79368. */
  79369. horizontalBlur: boolean;
  79370. /**
  79371. * Gets the overall exposure used by the pipeline
  79372. */
  79373. get exposure(): number;
  79374. /**
  79375. * Sets the overall exposure used by the pipeline
  79376. */
  79377. set exposure(value: number);
  79378. /**
  79379. * Texture used typically to simulate "dirty" on camera lens
  79380. */
  79381. lensTexture: Nullable<Texture>;
  79382. /**
  79383. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  79384. */
  79385. volumetricLightCoefficient: number;
  79386. /**
  79387. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  79388. */
  79389. volumetricLightPower: number;
  79390. /**
  79391. * Used the set the blur intensity to smooth the volumetric lights
  79392. */
  79393. volumetricLightBlurScale: number;
  79394. /**
  79395. * Light (spot or directional) used to generate the volumetric lights rays
  79396. * The source light must have a shadow generate so the pipeline can get its
  79397. * depth map
  79398. */
  79399. sourceLight: Nullable<SpotLight | DirectionalLight>;
  79400. /**
  79401. * For eye adaptation, represents the minimum luminance the eye can see
  79402. */
  79403. hdrMinimumLuminance: number;
  79404. /**
  79405. * For eye adaptation, represents the decrease luminance speed
  79406. */
  79407. hdrDecreaseRate: number;
  79408. /**
  79409. * For eye adaptation, represents the increase luminance speed
  79410. */
  79411. hdrIncreaseRate: number;
  79412. /**
  79413. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  79414. */
  79415. get hdrAutoExposure(): boolean;
  79416. /**
  79417. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  79418. */
  79419. set hdrAutoExposure(value: boolean);
  79420. /**
  79421. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  79422. */
  79423. lensColorTexture: Nullable<Texture>;
  79424. /**
  79425. * The overall strengh for the lens flare effect
  79426. */
  79427. lensFlareStrength: number;
  79428. /**
  79429. * Dispersion coefficient for lens flare ghosts
  79430. */
  79431. lensFlareGhostDispersal: number;
  79432. /**
  79433. * Main lens flare halo width
  79434. */
  79435. lensFlareHaloWidth: number;
  79436. /**
  79437. * Based on the lens distortion effect, defines how much the lens flare result
  79438. * is distorted
  79439. */
  79440. lensFlareDistortionStrength: number;
  79441. /**
  79442. * Configures the blur intensity used for for lens flare (halo)
  79443. */
  79444. lensFlareBlurWidth: number;
  79445. /**
  79446. * Lens star texture must be used to simulate rays on the flares and is available
  79447. * in the documentation
  79448. */
  79449. lensStarTexture: Nullable<Texture>;
  79450. /**
  79451. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  79452. * flare effect by taking account of the dirt texture
  79453. */
  79454. lensFlareDirtTexture: Nullable<Texture>;
  79455. /**
  79456. * Represents the focal length for the depth of field effect
  79457. */
  79458. depthOfFieldDistance: number;
  79459. /**
  79460. * Represents the blur intensity for the blurred part of the depth of field effect
  79461. */
  79462. depthOfFieldBlurWidth: number;
  79463. /**
  79464. * Gets how much the image is blurred by the movement while using the motion blur post-process
  79465. */
  79466. get motionStrength(): number;
  79467. /**
  79468. * Sets how much the image is blurred by the movement while using the motion blur post-process
  79469. */
  79470. set motionStrength(strength: number);
  79471. /**
  79472. * Gets wether or not the motion blur post-process is object based or screen based.
  79473. */
  79474. get objectBasedMotionBlur(): boolean;
  79475. /**
  79476. * Sets wether or not the motion blur post-process should be object based or screen based
  79477. */
  79478. set objectBasedMotionBlur(value: boolean);
  79479. /**
  79480. * List of animations for the pipeline (IAnimatable implementation)
  79481. */
  79482. animations: Animation[];
  79483. /**
  79484. * Private members
  79485. */
  79486. private _scene;
  79487. private _currentDepthOfFieldSource;
  79488. private _basePostProcess;
  79489. private _fixedExposure;
  79490. private _currentExposure;
  79491. private _hdrAutoExposure;
  79492. private _hdrCurrentLuminance;
  79493. private _motionStrength;
  79494. private _isObjectBasedMotionBlur;
  79495. private _floatTextureType;
  79496. private _camerasToBeAttached;
  79497. private _ratio;
  79498. private _bloomEnabled;
  79499. private _depthOfFieldEnabled;
  79500. private _vlsEnabled;
  79501. private _lensFlareEnabled;
  79502. private _hdrEnabled;
  79503. private _motionBlurEnabled;
  79504. private _fxaaEnabled;
  79505. private _screenSpaceReflectionsEnabled;
  79506. private _motionBlurSamples;
  79507. private _volumetricLightStepsCount;
  79508. private _samples;
  79509. /**
  79510. * @ignore
  79511. * Specifies if the bloom pipeline is enabled
  79512. */
  79513. get BloomEnabled(): boolean;
  79514. set BloomEnabled(enabled: boolean);
  79515. /**
  79516. * @ignore
  79517. * Specifies if the depth of field pipeline is enabed
  79518. */
  79519. get DepthOfFieldEnabled(): boolean;
  79520. set DepthOfFieldEnabled(enabled: boolean);
  79521. /**
  79522. * @ignore
  79523. * Specifies if the lens flare pipeline is enabed
  79524. */
  79525. get LensFlareEnabled(): boolean;
  79526. set LensFlareEnabled(enabled: boolean);
  79527. /**
  79528. * @ignore
  79529. * Specifies if the HDR pipeline is enabled
  79530. */
  79531. get HDREnabled(): boolean;
  79532. set HDREnabled(enabled: boolean);
  79533. /**
  79534. * @ignore
  79535. * Specifies if the volumetric lights scattering effect is enabled
  79536. */
  79537. get VLSEnabled(): boolean;
  79538. set VLSEnabled(enabled: boolean);
  79539. /**
  79540. * @ignore
  79541. * Specifies if the motion blur effect is enabled
  79542. */
  79543. get MotionBlurEnabled(): boolean;
  79544. set MotionBlurEnabled(enabled: boolean);
  79545. /**
  79546. * Specifies if anti-aliasing is enabled
  79547. */
  79548. get fxaaEnabled(): boolean;
  79549. set fxaaEnabled(enabled: boolean);
  79550. /**
  79551. * Specifies if screen space reflections are enabled.
  79552. */
  79553. get screenSpaceReflectionsEnabled(): boolean;
  79554. set screenSpaceReflectionsEnabled(enabled: boolean);
  79555. /**
  79556. * Specifies the number of steps used to calculate the volumetric lights
  79557. * Typically in interval [50, 200]
  79558. */
  79559. get volumetricLightStepsCount(): number;
  79560. set volumetricLightStepsCount(count: number);
  79561. /**
  79562. * Specifies the number of samples used for the motion blur effect
  79563. * Typically in interval [16, 64]
  79564. */
  79565. get motionBlurSamples(): number;
  79566. set motionBlurSamples(samples: number);
  79567. /**
  79568. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  79569. */
  79570. get samples(): number;
  79571. set samples(sampleCount: number);
  79572. /**
  79573. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  79574. * @constructor
  79575. * @param name The rendering pipeline name
  79576. * @param scene The scene linked to this pipeline
  79577. * @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)
  79578. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  79579. * @param cameras The array of cameras that the rendering pipeline will be attached to
  79580. */
  79581. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  79582. private _buildPipeline;
  79583. private _createDownSampleX4PostProcess;
  79584. private _createBrightPassPostProcess;
  79585. private _createBlurPostProcesses;
  79586. private _createTextureAdderPostProcess;
  79587. private _createVolumetricLightPostProcess;
  79588. private _createLuminancePostProcesses;
  79589. private _createHdrPostProcess;
  79590. private _createLensFlarePostProcess;
  79591. private _createDepthOfFieldPostProcess;
  79592. private _createMotionBlurPostProcess;
  79593. private _getDepthTexture;
  79594. private _disposePostProcesses;
  79595. /**
  79596. * Dispose of the pipeline and stop all post processes
  79597. */
  79598. dispose(): void;
  79599. /**
  79600. * Serialize the rendering pipeline (Used when exporting)
  79601. * @returns the serialized object
  79602. */
  79603. serialize(): any;
  79604. /**
  79605. * Parse the serialized pipeline
  79606. * @param source Source pipeline.
  79607. * @param scene The scene to load the pipeline to.
  79608. * @param rootUrl The URL of the serialized pipeline.
  79609. * @returns An instantiated pipeline from the serialized object.
  79610. */
  79611. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  79612. /**
  79613. * Luminance steps
  79614. */
  79615. static LuminanceSteps: number;
  79616. }
  79617. }
  79618. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  79619. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  79620. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  79621. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  79622. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  79623. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  79624. }
  79625. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  79626. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  79627. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  79628. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  79629. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  79630. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  79631. }
  79632. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  79633. /** @hidden */
  79634. export var stereoscopicInterlacePixelShader: {
  79635. name: string;
  79636. shader: string;
  79637. };
  79638. }
  79639. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  79640. import { Camera } from "babylonjs/Cameras/camera";
  79641. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  79642. import { Engine } from "babylonjs/Engines/engine";
  79643. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  79644. /**
  79645. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  79646. */
  79647. export class StereoscopicInterlacePostProcessI extends PostProcess {
  79648. private _stepSize;
  79649. private _passedProcess;
  79650. /**
  79651. * Gets a string identifying the name of the class
  79652. * @returns "StereoscopicInterlacePostProcessI" string
  79653. */
  79654. getClassName(): string;
  79655. /**
  79656. * Initializes a StereoscopicInterlacePostProcessI
  79657. * @param name The name of the effect.
  79658. * @param rigCameras The rig cameras to be appled to the post process
  79659. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  79660. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  79661. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  79662. * @param engine The engine which the post process will be applied. (default: current engine)
  79663. * @param reusable If the post process can be reused on the same frame. (default: false)
  79664. */
  79665. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  79666. }
  79667. /**
  79668. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  79669. */
  79670. export class StereoscopicInterlacePostProcess extends PostProcess {
  79671. private _stepSize;
  79672. private _passedProcess;
  79673. /**
  79674. * Gets a string identifying the name of the class
  79675. * @returns "StereoscopicInterlacePostProcess" string
  79676. */
  79677. getClassName(): string;
  79678. /**
  79679. * Initializes a StereoscopicInterlacePostProcess
  79680. * @param name The name of the effect.
  79681. * @param rigCameras The rig cameras to be appled to the post process
  79682. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  79683. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  79684. * @param engine The engine which the post process will be applied. (default: current engine)
  79685. * @param reusable If the post process can be reused on the same frame. (default: false)
  79686. */
  79687. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  79688. }
  79689. }
  79690. declare module "babylonjs/Shaders/tonemap.fragment" {
  79691. /** @hidden */
  79692. export var tonemapPixelShader: {
  79693. name: string;
  79694. shader: string;
  79695. };
  79696. }
  79697. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  79698. import { Camera } from "babylonjs/Cameras/camera";
  79699. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  79700. import "babylonjs/Shaders/tonemap.fragment";
  79701. import { Engine } from "babylonjs/Engines/engine";
  79702. /** Defines operator used for tonemapping */
  79703. export enum TonemappingOperator {
  79704. /** Hable */
  79705. Hable = 0,
  79706. /** Reinhard */
  79707. Reinhard = 1,
  79708. /** HejiDawson */
  79709. HejiDawson = 2,
  79710. /** Photographic */
  79711. Photographic = 3
  79712. }
  79713. /**
  79714. * Defines a post process to apply tone mapping
  79715. */
  79716. export class TonemapPostProcess extends PostProcess {
  79717. private _operator;
  79718. /** Defines the required exposure adjustement */
  79719. exposureAdjustment: number;
  79720. /**
  79721. * Gets a string identifying the name of the class
  79722. * @returns "TonemapPostProcess" string
  79723. */
  79724. getClassName(): string;
  79725. /**
  79726. * Creates a new TonemapPostProcess
  79727. * @param name defines the name of the postprocess
  79728. * @param _operator defines the operator to use
  79729. * @param exposureAdjustment defines the required exposure adjustement
  79730. * @param camera defines the camera to use (can be null)
  79731. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  79732. * @param engine defines the hosting engine (can be ignore if camera is set)
  79733. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79734. */
  79735. constructor(name: string, _operator: TonemappingOperator,
  79736. /** Defines the required exposure adjustement */
  79737. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  79738. }
  79739. }
  79740. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  79741. /** @hidden */
  79742. export var volumetricLightScatteringPixelShader: {
  79743. name: string;
  79744. shader: string;
  79745. };
  79746. }
  79747. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  79748. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  79749. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  79750. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  79751. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  79752. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  79753. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  79754. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  79755. /** @hidden */
  79756. export var volumetricLightScatteringPassVertexShader: {
  79757. name: string;
  79758. shader: string;
  79759. };
  79760. }
  79761. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  79762. /** @hidden */
  79763. export var volumetricLightScatteringPassPixelShader: {
  79764. name: string;
  79765. shader: string;
  79766. };
  79767. }
  79768. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  79769. import { Vector3 } from "babylonjs/Maths/math.vector";
  79770. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79771. import { Mesh } from "babylonjs/Meshes/mesh";
  79772. import { Camera } from "babylonjs/Cameras/camera";
  79773. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  79774. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  79775. import { Scene } from "babylonjs/scene";
  79776. import "babylonjs/Meshes/Builders/planeBuilder";
  79777. import "babylonjs/Shaders/depth.vertex";
  79778. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  79779. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  79780. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  79781. import { Engine } from "babylonjs/Engines/engine";
  79782. /**
  79783. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  79784. */
  79785. export class VolumetricLightScatteringPostProcess extends PostProcess {
  79786. private _volumetricLightScatteringPass;
  79787. private _volumetricLightScatteringRTT;
  79788. private _viewPort;
  79789. private _screenCoordinates;
  79790. private _cachedDefines;
  79791. /**
  79792. * If not undefined, the mesh position is computed from the attached node position
  79793. */
  79794. attachedNode: {
  79795. position: Vector3;
  79796. };
  79797. /**
  79798. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  79799. */
  79800. customMeshPosition: Vector3;
  79801. /**
  79802. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  79803. */
  79804. useCustomMeshPosition: boolean;
  79805. /**
  79806. * If the post-process should inverse the light scattering direction
  79807. */
  79808. invert: boolean;
  79809. /**
  79810. * The internal mesh used by the post-process
  79811. */
  79812. mesh: Mesh;
  79813. /**
  79814. * @hidden
  79815. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  79816. */
  79817. get useDiffuseColor(): boolean;
  79818. set useDiffuseColor(useDiffuseColor: boolean);
  79819. /**
  79820. * Array containing the excluded meshes not rendered in the internal pass
  79821. */
  79822. excludedMeshes: AbstractMesh[];
  79823. /**
  79824. * Controls the overall intensity of the post-process
  79825. */
  79826. exposure: number;
  79827. /**
  79828. * Dissipates each sample's contribution in range [0, 1]
  79829. */
  79830. decay: number;
  79831. /**
  79832. * Controls the overall intensity of each sample
  79833. */
  79834. weight: number;
  79835. /**
  79836. * Controls the density of each sample
  79837. */
  79838. density: number;
  79839. /**
  79840. * @constructor
  79841. * @param name The post-process name
  79842. * @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)
  79843. * @param camera The camera that the post-process will be attached to
  79844. * @param mesh The mesh used to create the light scattering
  79845. * @param samples The post-process quality, default 100
  79846. * @param samplingModeThe post-process filtering mode
  79847. * @param engine The babylon engine
  79848. * @param reusable If the post-process is reusable
  79849. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  79850. */
  79851. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  79852. /**
  79853. * Returns the string "VolumetricLightScatteringPostProcess"
  79854. * @returns "VolumetricLightScatteringPostProcess"
  79855. */
  79856. getClassName(): string;
  79857. private _isReady;
  79858. /**
  79859. * Sets the new light position for light scattering effect
  79860. * @param position The new custom light position
  79861. */
  79862. setCustomMeshPosition(position: Vector3): void;
  79863. /**
  79864. * Returns the light position for light scattering effect
  79865. * @return Vector3 The custom light position
  79866. */
  79867. getCustomMeshPosition(): Vector3;
  79868. /**
  79869. * Disposes the internal assets and detaches the post-process from the camera
  79870. */
  79871. dispose(camera: Camera): void;
  79872. /**
  79873. * Returns the render target texture used by the post-process
  79874. * @return the render target texture used by the post-process
  79875. */
  79876. getPass(): RenderTargetTexture;
  79877. private _meshExcluded;
  79878. private _createPass;
  79879. private _updateMeshScreenCoordinates;
  79880. /**
  79881. * Creates a default mesh for the Volumeric Light Scattering post-process
  79882. * @param name The mesh name
  79883. * @param scene The scene where to create the mesh
  79884. * @return the default mesh
  79885. */
  79886. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  79887. }
  79888. }
  79889. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  79890. /** @hidden */
  79891. export var screenSpaceCurvaturePixelShader: {
  79892. name: string;
  79893. shader: string;
  79894. };
  79895. }
  79896. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  79897. import { Nullable } from "babylonjs/types";
  79898. import { Camera } from "babylonjs/Cameras/camera";
  79899. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  79900. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  79901. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  79902. import { Engine } from "babylonjs/Engines/engine";
  79903. import { Scene } from "babylonjs/scene";
  79904. /**
  79905. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  79906. */
  79907. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  79908. /**
  79909. * Defines how much ridge the curvature effect displays.
  79910. */
  79911. ridge: number;
  79912. /**
  79913. * Defines how much valley the curvature effect displays.
  79914. */
  79915. valley: number;
  79916. private _geometryBufferRenderer;
  79917. /**
  79918. * Gets a string identifying the name of the class
  79919. * @returns "ScreenSpaceCurvaturePostProcess" string
  79920. */
  79921. getClassName(): string;
  79922. /**
  79923. * Creates a new instance ScreenSpaceCurvaturePostProcess
  79924. * @param name The name of the effect.
  79925. * @param scene The scene containing the objects to blur according to their velocity.
  79926. * @param options The required width/height ratio to downsize to before computing the render pass.
  79927. * @param camera The camera to apply the render pass to.
  79928. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  79929. * @param engine The engine which the post process will be applied. (default: current engine)
  79930. * @param reusable If the post process can be reused on the same frame. (default: false)
  79931. * @param textureType Type of textures used when performing the post process. (default: 0)
  79932. * @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)
  79933. */
  79934. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  79935. /**
  79936. * Support test.
  79937. */
  79938. static get IsSupported(): boolean;
  79939. /** @hidden */
  79940. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  79941. }
  79942. }
  79943. declare module "babylonjs/PostProcesses/index" {
  79944. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  79945. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  79946. export * from "babylonjs/PostProcesses/bloomEffect";
  79947. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  79948. export * from "babylonjs/PostProcesses/blurPostProcess";
  79949. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  79950. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  79951. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  79952. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  79953. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  79954. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  79955. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  79956. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  79957. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  79958. export * from "babylonjs/PostProcesses/filterPostProcess";
  79959. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  79960. export * from "babylonjs/PostProcesses/grainPostProcess";
  79961. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  79962. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  79963. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  79964. export * from "babylonjs/PostProcesses/passPostProcess";
  79965. export * from "babylonjs/PostProcesses/postProcess";
  79966. export * from "babylonjs/PostProcesses/postProcessManager";
  79967. export * from "babylonjs/PostProcesses/refractionPostProcess";
  79968. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  79969. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  79970. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  79971. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  79972. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  79973. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  79974. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  79975. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  79976. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  79977. }
  79978. declare module "babylonjs/Probes/index" {
  79979. export * from "babylonjs/Probes/reflectionProbe";
  79980. }
  79981. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  79982. import { Scene } from "babylonjs/scene";
  79983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79984. import { SmartArray } from "babylonjs/Misc/smartArray";
  79985. import { ISceneComponent } from "babylonjs/sceneComponent";
  79986. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  79987. import "babylonjs/Meshes/Builders/boxBuilder";
  79988. import "babylonjs/Shaders/color.fragment";
  79989. import "babylonjs/Shaders/color.vertex";
  79990. import { Color3 } from "babylonjs/Maths/math.color";
  79991. import { Observable } from "babylonjs/Misc/observable";
  79992. module "babylonjs/scene" {
  79993. interface Scene {
  79994. /** @hidden (Backing field) */
  79995. _boundingBoxRenderer: BoundingBoxRenderer;
  79996. /** @hidden (Backing field) */
  79997. _forceShowBoundingBoxes: boolean;
  79998. /**
  79999. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  80000. */
  80001. forceShowBoundingBoxes: boolean;
  80002. /**
  80003. * Gets the bounding box renderer associated with the scene
  80004. * @returns a BoundingBoxRenderer
  80005. */
  80006. getBoundingBoxRenderer(): BoundingBoxRenderer;
  80007. }
  80008. }
  80009. module "babylonjs/Meshes/abstractMesh" {
  80010. interface AbstractMesh {
  80011. /** @hidden (Backing field) */
  80012. _showBoundingBox: boolean;
  80013. /**
  80014. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  80015. */
  80016. showBoundingBox: boolean;
  80017. }
  80018. }
  80019. /**
  80020. * Component responsible of rendering the bounding box of the meshes in a scene.
  80021. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  80022. */
  80023. export class BoundingBoxRenderer implements ISceneComponent {
  80024. /**
  80025. * The component name helpfull to identify the component in the list of scene components.
  80026. */
  80027. readonly name: string;
  80028. /**
  80029. * The scene the component belongs to.
  80030. */
  80031. scene: Scene;
  80032. /**
  80033. * Color of the bounding box lines placed in front of an object
  80034. */
  80035. frontColor: Color3;
  80036. /**
  80037. * Color of the bounding box lines placed behind an object
  80038. */
  80039. backColor: Color3;
  80040. /**
  80041. * Defines if the renderer should show the back lines or not
  80042. */
  80043. showBackLines: boolean;
  80044. /**
  80045. * Observable raised before rendering a bounding box
  80046. */
  80047. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  80048. /**
  80049. * Observable raised after rendering a bounding box
  80050. */
  80051. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  80052. /**
  80053. * Observable raised after resources are created
  80054. */
  80055. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  80056. /**
  80057. * When false, no bounding boxes will be rendered
  80058. */
  80059. enabled: boolean;
  80060. /**
  80061. * @hidden
  80062. */
  80063. renderList: SmartArray<BoundingBox>;
  80064. private _colorShader;
  80065. private _vertexBuffers;
  80066. private _indexBuffer;
  80067. private _fillIndexBuffer;
  80068. private _fillIndexData;
  80069. /**
  80070. * Instantiates a new bounding box renderer in a scene.
  80071. * @param scene the scene the renderer renders in
  80072. */
  80073. constructor(scene: Scene);
  80074. /**
  80075. * Registers the component in a given scene
  80076. */
  80077. register(): void;
  80078. private _evaluateSubMesh;
  80079. private _preActiveMesh;
  80080. private _prepareResources;
  80081. private _createIndexBuffer;
  80082. /**
  80083. * Rebuilds the elements related to this component in case of
  80084. * context lost for instance.
  80085. */
  80086. rebuild(): void;
  80087. /**
  80088. * @hidden
  80089. */
  80090. reset(): void;
  80091. /**
  80092. * Render the bounding boxes of a specific rendering group
  80093. * @param renderingGroupId defines the rendering group to render
  80094. */
  80095. render(renderingGroupId: number): void;
  80096. /**
  80097. * In case of occlusion queries, we can render the occlusion bounding box through this method
  80098. * @param mesh Define the mesh to render the occlusion bounding box for
  80099. */
  80100. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  80101. /**
  80102. * Dispose and release the resources attached to this renderer.
  80103. */
  80104. dispose(): void;
  80105. }
  80106. }
  80107. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  80108. import { Nullable } from "babylonjs/types";
  80109. import { Scene } from "babylonjs/scene";
  80110. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  80111. import { Camera } from "babylonjs/Cameras/camera";
  80112. import { ISceneComponent } from "babylonjs/sceneComponent";
  80113. module "babylonjs/scene" {
  80114. interface Scene {
  80115. /** @hidden (Backing field) */
  80116. _depthRenderer: {
  80117. [id: string]: DepthRenderer;
  80118. };
  80119. /**
  80120. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  80121. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  80122. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  80123. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  80124. * @returns the created depth renderer
  80125. */
  80126. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  80127. /**
  80128. * Disables a depth renderer for a given camera
  80129. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  80130. */
  80131. disableDepthRenderer(camera?: Nullable<Camera>): void;
  80132. }
  80133. }
  80134. /**
  80135. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  80136. * in several rendering techniques.
  80137. */
  80138. export class DepthRendererSceneComponent implements ISceneComponent {
  80139. /**
  80140. * The component name helpfull to identify the component in the list of scene components.
  80141. */
  80142. readonly name: string;
  80143. /**
  80144. * The scene the component belongs to.
  80145. */
  80146. scene: Scene;
  80147. /**
  80148. * Creates a new instance of the component for the given scene
  80149. * @param scene Defines the scene to register the component in
  80150. */
  80151. constructor(scene: Scene);
  80152. /**
  80153. * Registers the component in a given scene
  80154. */
  80155. register(): void;
  80156. /**
  80157. * Rebuilds the elements related to this component in case of
  80158. * context lost for instance.
  80159. */
  80160. rebuild(): void;
  80161. /**
  80162. * Disposes the component and the associated ressources
  80163. */
  80164. dispose(): void;
  80165. private _gatherRenderTargets;
  80166. private _gatherActiveCameraRenderTargets;
  80167. }
  80168. }
  80169. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  80170. import { Nullable } from "babylonjs/types";
  80171. import { Scene } from "babylonjs/scene";
  80172. import { ISceneComponent } from "babylonjs/sceneComponent";
  80173. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  80174. module "babylonjs/abstractScene" {
  80175. interface AbstractScene {
  80176. /** @hidden (Backing field) */
  80177. _prePassRenderer: Nullable<PrePassRenderer>;
  80178. /**
  80179. * Gets or Sets the current prepass renderer associated to the scene.
  80180. */
  80181. prePassRenderer: Nullable<PrePassRenderer>;
  80182. /**
  80183. * Enables the prepass and associates it with the scene
  80184. * @returns the PrePassRenderer
  80185. */
  80186. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  80187. /**
  80188. * Disables the prepass associated with the scene
  80189. */
  80190. disablePrePassRenderer(): void;
  80191. }
  80192. }
  80193. /**
  80194. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  80195. * in several rendering techniques.
  80196. */
  80197. export class PrePassRendererSceneComponent implements ISceneComponent {
  80198. /**
  80199. * The component name helpful to identify the component in the list of scene components.
  80200. */
  80201. readonly name: string;
  80202. /**
  80203. * The scene the component belongs to.
  80204. */
  80205. scene: Scene;
  80206. /**
  80207. * Creates a new instance of the component for the given scene
  80208. * @param scene Defines the scene to register the component in
  80209. */
  80210. constructor(scene: Scene);
  80211. /**
  80212. * Registers the component in a given scene
  80213. */
  80214. register(): void;
  80215. private _beforeCameraDraw;
  80216. private _afterCameraDraw;
  80217. private _beforeClearStage;
  80218. private _beforeRenderingMeshStage;
  80219. private _afterRenderingMeshStage;
  80220. /**
  80221. * Rebuilds the elements related to this component in case of
  80222. * context lost for instance.
  80223. */
  80224. rebuild(): void;
  80225. /**
  80226. * Disposes the component and the associated ressources
  80227. */
  80228. dispose(): void;
  80229. }
  80230. }
  80231. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  80232. /** @hidden */
  80233. export var fibonacci: {
  80234. name: string;
  80235. shader: string;
  80236. };
  80237. }
  80238. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  80239. /** @hidden */
  80240. export var diffusionProfile: {
  80241. name: string;
  80242. shader: string;
  80243. };
  80244. }
  80245. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  80246. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  80247. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  80248. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  80249. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  80250. /** @hidden */
  80251. export var subSurfaceScatteringPixelShader: {
  80252. name: string;
  80253. shader: string;
  80254. };
  80255. }
  80256. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  80257. import { Nullable } from "babylonjs/types";
  80258. import { Camera } from "babylonjs/Cameras/camera";
  80259. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  80260. import { Engine } from "babylonjs/Engines/engine";
  80261. import { Scene } from "babylonjs/scene";
  80262. import "babylonjs/Shaders/imageProcessing.fragment";
  80263. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  80264. import "babylonjs/Shaders/postprocess.vertex";
  80265. /**
  80266. * Sub surface scattering post process
  80267. */
  80268. export class SubSurfaceScatteringPostProcess extends PostProcess {
  80269. /**
  80270. * Gets a string identifying the name of the class
  80271. * @returns "SubSurfaceScatteringPostProcess" string
  80272. */
  80273. getClassName(): string;
  80274. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  80275. }
  80276. }
  80277. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  80278. import { Scene } from "babylonjs/scene";
  80279. import { Color3 } from "babylonjs/Maths/math.color";
  80280. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  80281. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  80282. /**
  80283. * Contains all parameters needed for the prepass to perform
  80284. * screen space subsurface scattering
  80285. */
  80286. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  80287. /** @hidden */
  80288. static _SceneComponentInitialization: (scene: Scene) => void;
  80289. private _ssDiffusionS;
  80290. private _ssFilterRadii;
  80291. private _ssDiffusionD;
  80292. /**
  80293. * Post process to attach for screen space subsurface scattering
  80294. */
  80295. postProcess: SubSurfaceScatteringPostProcess;
  80296. /**
  80297. * Diffusion profile color for subsurface scattering
  80298. */
  80299. get ssDiffusionS(): number[];
  80300. /**
  80301. * Diffusion profile max color channel value for subsurface scattering
  80302. */
  80303. get ssDiffusionD(): number[];
  80304. /**
  80305. * Diffusion profile filter radius for subsurface scattering
  80306. */
  80307. get ssFilterRadii(): number[];
  80308. /**
  80309. * Is subsurface enabled
  80310. */
  80311. enabled: boolean;
  80312. /**
  80313. * Name of the configuration
  80314. */
  80315. name: string;
  80316. /**
  80317. * Diffusion profile colors for subsurface scattering
  80318. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  80319. * See ...
  80320. * Note that you can only store up to 5 of them
  80321. */
  80322. ssDiffusionProfileColors: Color3[];
  80323. /**
  80324. * Defines the ratio real world => scene units.
  80325. * Used for subsurface scattering
  80326. */
  80327. metersPerUnit: number;
  80328. /**
  80329. * Textures that should be present in the MRT for this effect to work
  80330. */
  80331. readonly texturesRequired: number[];
  80332. private _scene;
  80333. /**
  80334. * Builds a subsurface configuration object
  80335. * @param scene The scene
  80336. */
  80337. constructor(scene: Scene);
  80338. /**
  80339. * Adds a new diffusion profile.
  80340. * Useful for more realistic subsurface scattering on diverse materials.
  80341. * @param color The color of the diffusion profile. Should be the average color of the material.
  80342. * @return The index of the diffusion profile for the material subsurface configuration
  80343. */
  80344. addDiffusionProfile(color: Color3): number;
  80345. /**
  80346. * Creates the sss post process
  80347. * @return The created post process
  80348. */
  80349. createPostProcess(): SubSurfaceScatteringPostProcess;
  80350. /**
  80351. * Deletes all diffusion profiles.
  80352. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  80353. */
  80354. clearAllDiffusionProfiles(): void;
  80355. /**
  80356. * Disposes this object
  80357. */
  80358. dispose(): void;
  80359. /**
  80360. * @hidden
  80361. * https://zero-radiance.github.io/post/sampling-diffusion/
  80362. *
  80363. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  80364. * ------------------------------------------------------------------------------------
  80365. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  80366. * PDF[r, phi, s] = r * R[r, phi, s]
  80367. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  80368. * ------------------------------------------------------------------------------------
  80369. * We importance sample the color channel with the widest scattering distance.
  80370. */
  80371. getDiffusionProfileParameters(color: Color3): number;
  80372. /**
  80373. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  80374. * 'u' is the random number (the value of the CDF): [0, 1).
  80375. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  80376. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  80377. */
  80378. private _sampleBurleyDiffusionProfile;
  80379. }
  80380. }
  80381. declare module "babylonjs/Rendering/subSurfaceSceneComponent" {
  80382. import { Nullable } from "babylonjs/types";
  80383. import { Scene } from "babylonjs/scene";
  80384. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  80385. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  80386. import { AbstractScene } from "babylonjs/abstractScene";
  80387. module "babylonjs/abstractScene" {
  80388. interface AbstractScene {
  80389. /** @hidden (Backing field) */
  80390. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  80391. /**
  80392. * Gets or Sets the current prepass renderer associated to the scene.
  80393. */
  80394. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  80395. /**
  80396. * Enables the subsurface effect for prepass
  80397. * @returns the SubSurfaceConfiguration
  80398. */
  80399. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  80400. /**
  80401. * Disables the subsurface effect for prepass
  80402. */
  80403. disableSubSurfaceForPrePass(): void;
  80404. }
  80405. }
  80406. /**
  80407. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  80408. * in several rendering techniques.
  80409. */
  80410. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  80411. /**
  80412. * The component name helpful to identify the component in the list of scene components.
  80413. */
  80414. readonly name: string;
  80415. /**
  80416. * The scene the component belongs to.
  80417. */
  80418. scene: Scene;
  80419. /**
  80420. * Creates a new instance of the component for the given scene
  80421. * @param scene Defines the scene to register the component in
  80422. */
  80423. constructor(scene: Scene);
  80424. /**
  80425. * Registers the component in a given scene
  80426. */
  80427. register(): void;
  80428. /**
  80429. * Serializes the component data to the specified json object
  80430. * @param serializationObject The object to serialize to
  80431. */
  80432. serialize(serializationObject: any): void;
  80433. /**
  80434. * Adds all the elements from the container to the scene
  80435. * @param container the container holding the elements
  80436. */
  80437. addFromContainer(container: AbstractScene): void;
  80438. /**
  80439. * Removes all the elements in the container from the scene
  80440. * @param container contains the elements to remove
  80441. * @param dispose if the removed element should be disposed (default: false)
  80442. */
  80443. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  80444. /**
  80445. * Rebuilds the elements related to this component in case of
  80446. * context lost for instance.
  80447. */
  80448. rebuild(): void;
  80449. /**
  80450. * Disposes the component and the associated ressources
  80451. */
  80452. dispose(): void;
  80453. }
  80454. }
  80455. declare module "babylonjs/Shaders/outline.fragment" {
  80456. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  80457. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  80458. /** @hidden */
  80459. export var outlinePixelShader: {
  80460. name: string;
  80461. shader: string;
  80462. };
  80463. }
  80464. declare module "babylonjs/Shaders/outline.vertex" {
  80465. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  80466. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  80467. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  80468. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  80469. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  80470. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  80471. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  80472. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  80473. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  80474. /** @hidden */
  80475. export var outlineVertexShader: {
  80476. name: string;
  80477. shader: string;
  80478. };
  80479. }
  80480. declare module "babylonjs/Rendering/outlineRenderer" {
  80481. import { SubMesh } from "babylonjs/Meshes/subMesh";
  80482. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  80483. import { Scene } from "babylonjs/scene";
  80484. import { ISceneComponent } from "babylonjs/sceneComponent";
  80485. import "babylonjs/Shaders/outline.fragment";
  80486. import "babylonjs/Shaders/outline.vertex";
  80487. module "babylonjs/scene" {
  80488. interface Scene {
  80489. /** @hidden */
  80490. _outlineRenderer: OutlineRenderer;
  80491. /**
  80492. * Gets the outline renderer associated with the scene
  80493. * @returns a OutlineRenderer
  80494. */
  80495. getOutlineRenderer(): OutlineRenderer;
  80496. }
  80497. }
  80498. module "babylonjs/Meshes/abstractMesh" {
  80499. interface AbstractMesh {
  80500. /** @hidden (Backing field) */
  80501. _renderOutline: boolean;
  80502. /**
  80503. * Gets or sets a boolean indicating if the outline must be rendered as well
  80504. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  80505. */
  80506. renderOutline: boolean;
  80507. /** @hidden (Backing field) */
  80508. _renderOverlay: boolean;
  80509. /**
  80510. * Gets or sets a boolean indicating if the overlay must be rendered as well
  80511. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  80512. */
  80513. renderOverlay: boolean;
  80514. }
  80515. }
  80516. /**
  80517. * This class is responsible to draw bothe outline/overlay of meshes.
  80518. * It should not be used directly but through the available method on mesh.
  80519. */
  80520. export class OutlineRenderer implements ISceneComponent {
  80521. /**
  80522. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  80523. */
  80524. private static _StencilReference;
  80525. /**
  80526. * The name of the component. Each component must have a unique name.
  80527. */
  80528. name: string;
  80529. /**
  80530. * The scene the component belongs to.
  80531. */
  80532. scene: Scene;
  80533. /**
  80534. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  80535. */
  80536. zOffset: number;
  80537. private _engine;
  80538. private _effect;
  80539. private _cachedDefines;
  80540. private _savedDepthWrite;
  80541. /**
  80542. * Instantiates a new outline renderer. (There could be only one per scene).
  80543. * @param scene Defines the scene it belongs to
  80544. */
  80545. constructor(scene: Scene);
  80546. /**
  80547. * Register the component to one instance of a scene.
  80548. */
  80549. register(): void;
  80550. /**
  80551. * Rebuilds the elements related to this component in case of
  80552. * context lost for instance.
  80553. */
  80554. rebuild(): void;
  80555. /**
  80556. * Disposes the component and the associated ressources.
  80557. */
  80558. dispose(): void;
  80559. /**
  80560. * Renders the outline in the canvas.
  80561. * @param subMesh Defines the sumesh to render
  80562. * @param batch Defines the batch of meshes in case of instances
  80563. * @param useOverlay Defines if the rendering is for the overlay or the outline
  80564. */
  80565. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  80566. /**
  80567. * Returns whether or not the outline renderer is ready for a given submesh.
  80568. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  80569. * @param subMesh Defines the submesh to check readyness for
  80570. * @param useInstances Defines wheter wee are trying to render instances or not
  80571. * @returns true if ready otherwise false
  80572. */
  80573. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  80574. private _beforeRenderingMesh;
  80575. private _afterRenderingMesh;
  80576. }
  80577. }
  80578. declare module "babylonjs/Rendering/index" {
  80579. export * from "babylonjs/Rendering/boundingBoxRenderer";
  80580. export * from "babylonjs/Rendering/depthRenderer";
  80581. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  80582. export * from "babylonjs/Rendering/edgesRenderer";
  80583. export * from "babylonjs/Rendering/geometryBufferRenderer";
  80584. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  80585. export * from "babylonjs/Rendering/prePassRenderer";
  80586. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  80587. export * from "babylonjs/Rendering/subSurfaceSceneComponent";
  80588. export * from "babylonjs/Rendering/outlineRenderer";
  80589. export * from "babylonjs/Rendering/renderingGroup";
  80590. export * from "babylonjs/Rendering/renderingManager";
  80591. export * from "babylonjs/Rendering/utilityLayerRenderer";
  80592. }
  80593. declare module "babylonjs/Sprites/ISprites" {
  80594. /**
  80595. * Defines the basic options interface of a Sprite Frame Source Size.
  80596. */
  80597. export interface ISpriteJSONSpriteSourceSize {
  80598. /**
  80599. * number of the original width of the Frame
  80600. */
  80601. w: number;
  80602. /**
  80603. * number of the original height of the Frame
  80604. */
  80605. h: number;
  80606. }
  80607. /**
  80608. * Defines the basic options interface of a Sprite Frame Data.
  80609. */
  80610. export interface ISpriteJSONSpriteFrameData {
  80611. /**
  80612. * number of the x offset of the Frame
  80613. */
  80614. x: number;
  80615. /**
  80616. * number of the y offset of the Frame
  80617. */
  80618. y: number;
  80619. /**
  80620. * number of the width of the Frame
  80621. */
  80622. w: number;
  80623. /**
  80624. * number of the height of the Frame
  80625. */
  80626. h: number;
  80627. }
  80628. /**
  80629. * Defines the basic options interface of a JSON Sprite.
  80630. */
  80631. export interface ISpriteJSONSprite {
  80632. /**
  80633. * string name of the Frame
  80634. */
  80635. filename: string;
  80636. /**
  80637. * ISpriteJSONSpriteFrame basic object of the frame data
  80638. */
  80639. frame: ISpriteJSONSpriteFrameData;
  80640. /**
  80641. * boolean to flag is the frame was rotated.
  80642. */
  80643. rotated: boolean;
  80644. /**
  80645. * boolean to flag is the frame was trimmed.
  80646. */
  80647. trimmed: boolean;
  80648. /**
  80649. * ISpriteJSONSpriteFrame basic object of the source data
  80650. */
  80651. spriteSourceSize: ISpriteJSONSpriteFrameData;
  80652. /**
  80653. * ISpriteJSONSpriteFrame basic object of the source data
  80654. */
  80655. sourceSize: ISpriteJSONSpriteSourceSize;
  80656. }
  80657. /**
  80658. * Defines the basic options interface of a JSON atlas.
  80659. */
  80660. export interface ISpriteJSONAtlas {
  80661. /**
  80662. * Array of objects that contain the frame data.
  80663. */
  80664. frames: Array<ISpriteJSONSprite>;
  80665. /**
  80666. * object basic object containing the sprite meta data.
  80667. */
  80668. meta?: object;
  80669. }
  80670. }
  80671. declare module "babylonjs/Shaders/spriteMap.fragment" {
  80672. /** @hidden */
  80673. export var spriteMapPixelShader: {
  80674. name: string;
  80675. shader: string;
  80676. };
  80677. }
  80678. declare module "babylonjs/Shaders/spriteMap.vertex" {
  80679. /** @hidden */
  80680. export var spriteMapVertexShader: {
  80681. name: string;
  80682. shader: string;
  80683. };
  80684. }
  80685. declare module "babylonjs/Sprites/spriteMap" {
  80686. import { IDisposable, Scene } from "babylonjs/scene";
  80687. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  80688. import { Texture } from "babylonjs/Materials/Textures/texture";
  80689. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  80690. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  80691. import "babylonjs/Meshes/Builders/planeBuilder";
  80692. import "babylonjs/Shaders/spriteMap.fragment";
  80693. import "babylonjs/Shaders/spriteMap.vertex";
  80694. /**
  80695. * Defines the basic options interface of a SpriteMap
  80696. */
  80697. export interface ISpriteMapOptions {
  80698. /**
  80699. * Vector2 of the number of cells in the grid.
  80700. */
  80701. stageSize?: Vector2;
  80702. /**
  80703. * Vector2 of the size of the output plane in World Units.
  80704. */
  80705. outputSize?: Vector2;
  80706. /**
  80707. * Vector3 of the position of the output plane in World Units.
  80708. */
  80709. outputPosition?: Vector3;
  80710. /**
  80711. * Vector3 of the rotation of the output plane.
  80712. */
  80713. outputRotation?: Vector3;
  80714. /**
  80715. * number of layers that the system will reserve in resources.
  80716. */
  80717. layerCount?: number;
  80718. /**
  80719. * number of max animation frames a single cell will reserve in resources.
  80720. */
  80721. maxAnimationFrames?: number;
  80722. /**
  80723. * number cell index of the base tile when the system compiles.
  80724. */
  80725. baseTile?: number;
  80726. /**
  80727. * boolean flip the sprite after its been repositioned by the framing data.
  80728. */
  80729. flipU?: boolean;
  80730. /**
  80731. * Vector3 scalar of the global RGB values of the SpriteMap.
  80732. */
  80733. colorMultiply?: Vector3;
  80734. }
  80735. /**
  80736. * Defines the IDisposable interface in order to be cleanable from resources.
  80737. */
  80738. export interface ISpriteMap extends IDisposable {
  80739. /**
  80740. * String name of the SpriteMap.
  80741. */
  80742. name: string;
  80743. /**
  80744. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  80745. */
  80746. atlasJSON: ISpriteJSONAtlas;
  80747. /**
  80748. * Texture of the SpriteMap.
  80749. */
  80750. spriteSheet: Texture;
  80751. /**
  80752. * The parameters to initialize the SpriteMap with.
  80753. */
  80754. options: ISpriteMapOptions;
  80755. }
  80756. /**
  80757. * Class used to manage a grid restricted sprite deployment on an Output plane.
  80758. */
  80759. export class SpriteMap implements ISpriteMap {
  80760. /** The Name of the spriteMap */
  80761. name: string;
  80762. /** The JSON file with the frame and meta data */
  80763. atlasJSON: ISpriteJSONAtlas;
  80764. /** The systems Sprite Sheet Texture */
  80765. spriteSheet: Texture;
  80766. /** Arguments passed with the Constructor */
  80767. options: ISpriteMapOptions;
  80768. /** Public Sprite Storage array, parsed from atlasJSON */
  80769. sprites: Array<ISpriteJSONSprite>;
  80770. /** Returns the Number of Sprites in the System */
  80771. get spriteCount(): number;
  80772. /** Returns the Position of Output Plane*/
  80773. get position(): Vector3;
  80774. /** Returns the Position of Output Plane*/
  80775. set position(v: Vector3);
  80776. /** Returns the Rotation of Output Plane*/
  80777. get rotation(): Vector3;
  80778. /** Returns the Rotation of Output Plane*/
  80779. set rotation(v: Vector3);
  80780. /** Sets the AnimationMap*/
  80781. get animationMap(): RawTexture;
  80782. /** Sets the AnimationMap*/
  80783. set animationMap(v: RawTexture);
  80784. /** Scene that the SpriteMap was created in */
  80785. private _scene;
  80786. /** Texture Buffer of Float32 that holds tile frame data*/
  80787. private _frameMap;
  80788. /** Texture Buffers of Float32 that holds tileMap data*/
  80789. private _tileMaps;
  80790. /** Texture Buffer of Float32 that holds Animation Data*/
  80791. private _animationMap;
  80792. /** Custom ShaderMaterial Central to the System*/
  80793. private _material;
  80794. /** Custom ShaderMaterial Central to the System*/
  80795. private _output;
  80796. /** Systems Time Ticker*/
  80797. private _time;
  80798. /**
  80799. * Creates a new SpriteMap
  80800. * @param name defines the SpriteMaps Name
  80801. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  80802. * @param spriteSheet is the Texture that the Sprites are on.
  80803. * @param options a basic deployment configuration
  80804. * @param scene The Scene that the map is deployed on
  80805. */
  80806. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  80807. /**
  80808. * Returns tileID location
  80809. * @returns Vector2 the cell position ID
  80810. */
  80811. getTileID(): Vector2;
  80812. /**
  80813. * Gets the UV location of the mouse over the SpriteMap.
  80814. * @returns Vector2 the UV position of the mouse interaction
  80815. */
  80816. getMousePosition(): Vector2;
  80817. /**
  80818. * Creates the "frame" texture Buffer
  80819. * -------------------------------------
  80820. * Structure of frames
  80821. * "filename": "Falling-Water-2.png",
  80822. * "frame": {"x":69,"y":103,"w":24,"h":32},
  80823. * "rotated": true,
  80824. * "trimmed": true,
  80825. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  80826. * "sourceSize": {"w":32,"h":32}
  80827. * @returns RawTexture of the frameMap
  80828. */
  80829. private _createFrameBuffer;
  80830. /**
  80831. * Creates the tileMap texture Buffer
  80832. * @param buffer normally and array of numbers, or a false to generate from scratch
  80833. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  80834. * @returns RawTexture of the tileMap
  80835. */
  80836. private _createTileBuffer;
  80837. /**
  80838. * Modifies the data of the tileMaps
  80839. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  80840. * @param pos is the iVector2 Coordinates of the Tile
  80841. * @param tile The SpriteIndex of the new Tile
  80842. */
  80843. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  80844. /**
  80845. * Creates the animationMap texture Buffer
  80846. * @param buffer normally and array of numbers, or a false to generate from scratch
  80847. * @returns RawTexture of the animationMap
  80848. */
  80849. private _createTileAnimationBuffer;
  80850. /**
  80851. * Modifies the data of the animationMap
  80852. * @param cellID is the Index of the Sprite
  80853. * @param _frame is the target Animation frame
  80854. * @param toCell is the Target Index of the next frame of the animation
  80855. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  80856. * @param speed is a global scalar of the time variable on the map.
  80857. */
  80858. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  80859. /**
  80860. * Exports the .tilemaps file
  80861. */
  80862. saveTileMaps(): void;
  80863. /**
  80864. * Imports the .tilemaps file
  80865. * @param url of the .tilemaps file
  80866. */
  80867. loadTileMaps(url: string): void;
  80868. /**
  80869. * Release associated resources
  80870. */
  80871. dispose(): void;
  80872. }
  80873. }
  80874. declare module "babylonjs/Sprites/spritePackedManager" {
  80875. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  80876. import { Scene } from "babylonjs/scene";
  80877. /**
  80878. * Class used to manage multiple sprites of different sizes on the same spritesheet
  80879. * @see https://doc.babylonjs.com/babylon101/sprites
  80880. */
  80881. export class SpritePackedManager extends SpriteManager {
  80882. /** defines the packed manager's name */
  80883. name: string;
  80884. /**
  80885. * Creates a new sprite manager from a packed sprite sheet
  80886. * @param name defines the manager's name
  80887. * @param imgUrl defines the sprite sheet url
  80888. * @param capacity defines the maximum allowed number of sprites
  80889. * @param scene defines the hosting scene
  80890. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  80891. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  80892. * @param samplingMode defines the smapling mode to use with spritesheet
  80893. * @param fromPacked set to true; do not alter
  80894. */
  80895. constructor(
  80896. /** defines the packed manager's name */
  80897. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  80898. }
  80899. }
  80900. declare module "babylonjs/Sprites/index" {
  80901. export * from "babylonjs/Sprites/sprite";
  80902. export * from "babylonjs/Sprites/ISprites";
  80903. export * from "babylonjs/Sprites/spriteManager";
  80904. export * from "babylonjs/Sprites/spriteMap";
  80905. export * from "babylonjs/Sprites/spritePackedManager";
  80906. export * from "babylonjs/Sprites/spriteSceneComponent";
  80907. }
  80908. declare module "babylonjs/States/index" {
  80909. export * from "babylonjs/States/alphaCullingState";
  80910. export * from "babylonjs/States/depthCullingState";
  80911. export * from "babylonjs/States/stencilState";
  80912. }
  80913. declare module "babylonjs/Misc/assetsManager" {
  80914. import { Scene } from "babylonjs/scene";
  80915. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80916. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  80917. import { Skeleton } from "babylonjs/Bones/skeleton";
  80918. import { Observable } from "babylonjs/Misc/observable";
  80919. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  80920. import { Texture } from "babylonjs/Materials/Textures/texture";
  80921. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  80922. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  80923. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  80924. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  80925. import { AssetContainer } from "babylonjs/assetContainer";
  80926. /**
  80927. * Defines the list of states available for a task inside a AssetsManager
  80928. */
  80929. export enum AssetTaskState {
  80930. /**
  80931. * Initialization
  80932. */
  80933. INIT = 0,
  80934. /**
  80935. * Running
  80936. */
  80937. RUNNING = 1,
  80938. /**
  80939. * Done
  80940. */
  80941. DONE = 2,
  80942. /**
  80943. * Error
  80944. */
  80945. ERROR = 3
  80946. }
  80947. /**
  80948. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  80949. */
  80950. export abstract class AbstractAssetTask {
  80951. /**
  80952. * Task name
  80953. */ name: string;
  80954. /**
  80955. * Callback called when the task is successful
  80956. */
  80957. onSuccess: (task: any) => void;
  80958. /**
  80959. * Callback called when the task is not successful
  80960. */
  80961. onError: (task: any, message?: string, exception?: any) => void;
  80962. /**
  80963. * Creates a new AssetsManager
  80964. * @param name defines the name of the task
  80965. */
  80966. constructor(
  80967. /**
  80968. * Task name
  80969. */ name: string);
  80970. private _isCompleted;
  80971. private _taskState;
  80972. private _errorObject;
  80973. /**
  80974. * Get if the task is completed
  80975. */
  80976. get isCompleted(): boolean;
  80977. /**
  80978. * Gets the current state of the task
  80979. */
  80980. get taskState(): AssetTaskState;
  80981. /**
  80982. * Gets the current error object (if task is in error)
  80983. */
  80984. get errorObject(): {
  80985. message?: string;
  80986. exception?: any;
  80987. };
  80988. /**
  80989. * Internal only
  80990. * @hidden
  80991. */
  80992. _setErrorObject(message?: string, exception?: any): void;
  80993. /**
  80994. * Execute the current task
  80995. * @param scene defines the scene where you want your assets to be loaded
  80996. * @param onSuccess is a callback called when the task is successfully executed
  80997. * @param onError is a callback called if an error occurs
  80998. */
  80999. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81000. /**
  81001. * Execute the current task
  81002. * @param scene defines the scene where you want your assets to be loaded
  81003. * @param onSuccess is a callback called when the task is successfully executed
  81004. * @param onError is a callback called if an error occurs
  81005. */
  81006. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81007. /**
  81008. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  81009. * This can be used with failed tasks that have the reason for failure fixed.
  81010. */
  81011. reset(): void;
  81012. private onErrorCallback;
  81013. private onDoneCallback;
  81014. }
  81015. /**
  81016. * Define the interface used by progress events raised during assets loading
  81017. */
  81018. export interface IAssetsProgressEvent {
  81019. /**
  81020. * Defines the number of remaining tasks to process
  81021. */
  81022. remainingCount: number;
  81023. /**
  81024. * Defines the total number of tasks
  81025. */
  81026. totalCount: number;
  81027. /**
  81028. * Defines the task that was just processed
  81029. */
  81030. task: AbstractAssetTask;
  81031. }
  81032. /**
  81033. * Class used to share progress information about assets loading
  81034. */
  81035. export class AssetsProgressEvent implements IAssetsProgressEvent {
  81036. /**
  81037. * Defines the number of remaining tasks to process
  81038. */
  81039. remainingCount: number;
  81040. /**
  81041. * Defines the total number of tasks
  81042. */
  81043. totalCount: number;
  81044. /**
  81045. * Defines the task that was just processed
  81046. */
  81047. task: AbstractAssetTask;
  81048. /**
  81049. * Creates a AssetsProgressEvent
  81050. * @param remainingCount defines the number of remaining tasks to process
  81051. * @param totalCount defines the total number of tasks
  81052. * @param task defines the task that was just processed
  81053. */
  81054. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  81055. }
  81056. /**
  81057. * Define a task used by AssetsManager to load assets into a container
  81058. */
  81059. export class ContainerAssetTask extends AbstractAssetTask {
  81060. /**
  81061. * Defines the name of the task
  81062. */
  81063. name: string;
  81064. /**
  81065. * Defines the list of mesh's names you want to load
  81066. */
  81067. meshesNames: any;
  81068. /**
  81069. * Defines the root url to use as a base to load your meshes and associated resources
  81070. */
  81071. rootUrl: string;
  81072. /**
  81073. * Defines the filename or File of the scene to load from
  81074. */
  81075. sceneFilename: string | File;
  81076. /**
  81077. * Get the loaded asset container
  81078. */
  81079. loadedContainer: AssetContainer;
  81080. /**
  81081. * Gets the list of loaded meshes
  81082. */
  81083. loadedMeshes: Array<AbstractMesh>;
  81084. /**
  81085. * Gets the list of loaded particle systems
  81086. */
  81087. loadedParticleSystems: Array<IParticleSystem>;
  81088. /**
  81089. * Gets the list of loaded skeletons
  81090. */
  81091. loadedSkeletons: Array<Skeleton>;
  81092. /**
  81093. * Gets the list of loaded animation groups
  81094. */
  81095. loadedAnimationGroups: Array<AnimationGroup>;
  81096. /**
  81097. * Callback called when the task is successful
  81098. */
  81099. onSuccess: (task: ContainerAssetTask) => void;
  81100. /**
  81101. * Callback called when the task is successful
  81102. */
  81103. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  81104. /**
  81105. * Creates a new ContainerAssetTask
  81106. * @param name defines the name of the task
  81107. * @param meshesNames defines the list of mesh's names you want to load
  81108. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  81109. * @param sceneFilename defines the filename or File of the scene to load from
  81110. */
  81111. constructor(
  81112. /**
  81113. * Defines the name of the task
  81114. */
  81115. name: string,
  81116. /**
  81117. * Defines the list of mesh's names you want to load
  81118. */
  81119. meshesNames: any,
  81120. /**
  81121. * Defines the root url to use as a base to load your meshes and associated resources
  81122. */
  81123. rootUrl: string,
  81124. /**
  81125. * Defines the filename or File of the scene to load from
  81126. */
  81127. sceneFilename: string | File);
  81128. /**
  81129. * Execute the current task
  81130. * @param scene defines the scene where you want your assets to be loaded
  81131. * @param onSuccess is a callback called when the task is successfully executed
  81132. * @param onError is a callback called if an error occurs
  81133. */
  81134. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81135. }
  81136. /**
  81137. * Define a task used by AssetsManager to load meshes
  81138. */
  81139. export class MeshAssetTask extends AbstractAssetTask {
  81140. /**
  81141. * Defines the name of the task
  81142. */
  81143. name: string;
  81144. /**
  81145. * Defines the list of mesh's names you want to load
  81146. */
  81147. meshesNames: any;
  81148. /**
  81149. * Defines the root url to use as a base to load your meshes and associated resources
  81150. */
  81151. rootUrl: string;
  81152. /**
  81153. * Defines the filename or File of the scene to load from
  81154. */
  81155. sceneFilename: string | File;
  81156. /**
  81157. * Gets the list of loaded meshes
  81158. */
  81159. loadedMeshes: Array<AbstractMesh>;
  81160. /**
  81161. * Gets the list of loaded particle systems
  81162. */
  81163. loadedParticleSystems: Array<IParticleSystem>;
  81164. /**
  81165. * Gets the list of loaded skeletons
  81166. */
  81167. loadedSkeletons: Array<Skeleton>;
  81168. /**
  81169. * Gets the list of loaded animation groups
  81170. */
  81171. loadedAnimationGroups: Array<AnimationGroup>;
  81172. /**
  81173. * Callback called when the task is successful
  81174. */
  81175. onSuccess: (task: MeshAssetTask) => void;
  81176. /**
  81177. * Callback called when the task is successful
  81178. */
  81179. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  81180. /**
  81181. * Creates a new MeshAssetTask
  81182. * @param name defines the name of the task
  81183. * @param meshesNames defines the list of mesh's names you want to load
  81184. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  81185. * @param sceneFilename defines the filename or File of the scene to load from
  81186. */
  81187. constructor(
  81188. /**
  81189. * Defines the name of the task
  81190. */
  81191. name: string,
  81192. /**
  81193. * Defines the list of mesh's names you want to load
  81194. */
  81195. meshesNames: any,
  81196. /**
  81197. * Defines the root url to use as a base to load your meshes and associated resources
  81198. */
  81199. rootUrl: string,
  81200. /**
  81201. * Defines the filename or File of the scene to load from
  81202. */
  81203. sceneFilename: string | File);
  81204. /**
  81205. * Execute the current task
  81206. * @param scene defines the scene where you want your assets to be loaded
  81207. * @param onSuccess is a callback called when the task is successfully executed
  81208. * @param onError is a callback called if an error occurs
  81209. */
  81210. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81211. }
  81212. /**
  81213. * Define a task used by AssetsManager to load text content
  81214. */
  81215. export class TextFileAssetTask extends AbstractAssetTask {
  81216. /**
  81217. * Defines the name of the task
  81218. */
  81219. name: string;
  81220. /**
  81221. * Defines the location of the file to load
  81222. */
  81223. url: string;
  81224. /**
  81225. * Gets the loaded text string
  81226. */
  81227. text: string;
  81228. /**
  81229. * Callback called when the task is successful
  81230. */
  81231. onSuccess: (task: TextFileAssetTask) => void;
  81232. /**
  81233. * Callback called when the task is successful
  81234. */
  81235. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  81236. /**
  81237. * Creates a new TextFileAssetTask object
  81238. * @param name defines the name of the task
  81239. * @param url defines the location of the file to load
  81240. */
  81241. constructor(
  81242. /**
  81243. * Defines the name of the task
  81244. */
  81245. name: string,
  81246. /**
  81247. * Defines the location of the file to load
  81248. */
  81249. url: string);
  81250. /**
  81251. * Execute the current task
  81252. * @param scene defines the scene where you want your assets to be loaded
  81253. * @param onSuccess is a callback called when the task is successfully executed
  81254. * @param onError is a callback called if an error occurs
  81255. */
  81256. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81257. }
  81258. /**
  81259. * Define a task used by AssetsManager to load binary data
  81260. */
  81261. export class BinaryFileAssetTask extends AbstractAssetTask {
  81262. /**
  81263. * Defines the name of the task
  81264. */
  81265. name: string;
  81266. /**
  81267. * Defines the location of the file to load
  81268. */
  81269. url: string;
  81270. /**
  81271. * Gets the lodaded data (as an array buffer)
  81272. */
  81273. data: ArrayBuffer;
  81274. /**
  81275. * Callback called when the task is successful
  81276. */
  81277. onSuccess: (task: BinaryFileAssetTask) => void;
  81278. /**
  81279. * Callback called when the task is successful
  81280. */
  81281. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  81282. /**
  81283. * Creates a new BinaryFileAssetTask object
  81284. * @param name defines the name of the new task
  81285. * @param url defines the location of the file to load
  81286. */
  81287. constructor(
  81288. /**
  81289. * Defines the name of the task
  81290. */
  81291. name: string,
  81292. /**
  81293. * Defines the location of the file to load
  81294. */
  81295. url: string);
  81296. /**
  81297. * Execute the current task
  81298. * @param scene defines the scene where you want your assets to be loaded
  81299. * @param onSuccess is a callback called when the task is successfully executed
  81300. * @param onError is a callback called if an error occurs
  81301. */
  81302. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81303. }
  81304. /**
  81305. * Define a task used by AssetsManager to load images
  81306. */
  81307. export class ImageAssetTask extends AbstractAssetTask {
  81308. /**
  81309. * Defines the name of the task
  81310. */
  81311. name: string;
  81312. /**
  81313. * Defines the location of the image to load
  81314. */
  81315. url: string;
  81316. /**
  81317. * Gets the loaded images
  81318. */
  81319. image: HTMLImageElement;
  81320. /**
  81321. * Callback called when the task is successful
  81322. */
  81323. onSuccess: (task: ImageAssetTask) => void;
  81324. /**
  81325. * Callback called when the task is successful
  81326. */
  81327. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  81328. /**
  81329. * Creates a new ImageAssetTask
  81330. * @param name defines the name of the task
  81331. * @param url defines the location of the image to load
  81332. */
  81333. constructor(
  81334. /**
  81335. * Defines the name of the task
  81336. */
  81337. name: string,
  81338. /**
  81339. * Defines the location of the image to load
  81340. */
  81341. url: string);
  81342. /**
  81343. * Execute the current task
  81344. * @param scene defines the scene where you want your assets to be loaded
  81345. * @param onSuccess is a callback called when the task is successfully executed
  81346. * @param onError is a callback called if an error occurs
  81347. */
  81348. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81349. }
  81350. /**
  81351. * Defines the interface used by texture loading tasks
  81352. */
  81353. export interface ITextureAssetTask<TEX extends BaseTexture> {
  81354. /**
  81355. * Gets the loaded texture
  81356. */
  81357. texture: TEX;
  81358. }
  81359. /**
  81360. * Define a task used by AssetsManager to load 2D textures
  81361. */
  81362. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  81363. /**
  81364. * Defines the name of the task
  81365. */
  81366. name: string;
  81367. /**
  81368. * Defines the location of the file to load
  81369. */
  81370. url: string;
  81371. /**
  81372. * Defines if mipmap should not be generated (default is false)
  81373. */
  81374. noMipmap?: boolean | undefined;
  81375. /**
  81376. * Defines if texture must be inverted on Y axis (default is true)
  81377. */
  81378. invertY: boolean;
  81379. /**
  81380. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  81381. */
  81382. samplingMode: number;
  81383. /**
  81384. * Gets the loaded texture
  81385. */
  81386. texture: Texture;
  81387. /**
  81388. * Callback called when the task is successful
  81389. */
  81390. onSuccess: (task: TextureAssetTask) => void;
  81391. /**
  81392. * Callback called when the task is successful
  81393. */
  81394. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  81395. /**
  81396. * Creates a new TextureAssetTask object
  81397. * @param name defines the name of the task
  81398. * @param url defines the location of the file to load
  81399. * @param noMipmap defines if mipmap should not be generated (default is false)
  81400. * @param invertY defines if texture must be inverted on Y axis (default is true)
  81401. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  81402. */
  81403. constructor(
  81404. /**
  81405. * Defines the name of the task
  81406. */
  81407. name: string,
  81408. /**
  81409. * Defines the location of the file to load
  81410. */
  81411. url: string,
  81412. /**
  81413. * Defines if mipmap should not be generated (default is false)
  81414. */
  81415. noMipmap?: boolean | undefined,
  81416. /**
  81417. * Defines if texture must be inverted on Y axis (default is true)
  81418. */
  81419. invertY?: boolean,
  81420. /**
  81421. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  81422. */
  81423. samplingMode?: number);
  81424. /**
  81425. * Execute the current task
  81426. * @param scene defines the scene where you want your assets to be loaded
  81427. * @param onSuccess is a callback called when the task is successfully executed
  81428. * @param onError is a callback called if an error occurs
  81429. */
  81430. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81431. }
  81432. /**
  81433. * Define a task used by AssetsManager to load cube textures
  81434. */
  81435. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  81436. /**
  81437. * Defines the name of the task
  81438. */
  81439. name: string;
  81440. /**
  81441. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  81442. */
  81443. url: string;
  81444. /**
  81445. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  81446. */
  81447. extensions?: string[] | undefined;
  81448. /**
  81449. * Defines if mipmaps should not be generated (default is false)
  81450. */
  81451. noMipmap?: boolean | undefined;
  81452. /**
  81453. * Defines the explicit list of files (undefined by default)
  81454. */
  81455. files?: string[] | undefined;
  81456. /**
  81457. * Gets the loaded texture
  81458. */
  81459. texture: CubeTexture;
  81460. /**
  81461. * Callback called when the task is successful
  81462. */
  81463. onSuccess: (task: CubeTextureAssetTask) => void;
  81464. /**
  81465. * Callback called when the task is successful
  81466. */
  81467. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  81468. /**
  81469. * Creates a new CubeTextureAssetTask
  81470. * @param name defines the name of the task
  81471. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  81472. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  81473. * @param noMipmap defines if mipmaps should not be generated (default is false)
  81474. * @param files defines the explicit list of files (undefined by default)
  81475. */
  81476. constructor(
  81477. /**
  81478. * Defines the name of the task
  81479. */
  81480. name: string,
  81481. /**
  81482. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  81483. */
  81484. url: string,
  81485. /**
  81486. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  81487. */
  81488. extensions?: string[] | undefined,
  81489. /**
  81490. * Defines if mipmaps should not be generated (default is false)
  81491. */
  81492. noMipmap?: boolean | undefined,
  81493. /**
  81494. * Defines the explicit list of files (undefined by default)
  81495. */
  81496. files?: string[] | undefined);
  81497. /**
  81498. * Execute the current task
  81499. * @param scene defines the scene where you want your assets to be loaded
  81500. * @param onSuccess is a callback called when the task is successfully executed
  81501. * @param onError is a callback called if an error occurs
  81502. */
  81503. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81504. }
  81505. /**
  81506. * Define a task used by AssetsManager to load HDR cube textures
  81507. */
  81508. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  81509. /**
  81510. * Defines the name of the task
  81511. */
  81512. name: string;
  81513. /**
  81514. * Defines the location of the file to load
  81515. */
  81516. url: string;
  81517. /**
  81518. * Defines the desired size (the more it increases the longer the generation will be)
  81519. */
  81520. size: number;
  81521. /**
  81522. * Defines if mipmaps should not be generated (default is false)
  81523. */
  81524. noMipmap: boolean;
  81525. /**
  81526. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  81527. */
  81528. generateHarmonics: boolean;
  81529. /**
  81530. * 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)
  81531. */
  81532. gammaSpace: boolean;
  81533. /**
  81534. * Internal Use Only
  81535. */
  81536. reserved: boolean;
  81537. /**
  81538. * Gets the loaded texture
  81539. */
  81540. texture: HDRCubeTexture;
  81541. /**
  81542. * Callback called when the task is successful
  81543. */
  81544. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  81545. /**
  81546. * Callback called when the task is successful
  81547. */
  81548. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  81549. /**
  81550. * Creates a new HDRCubeTextureAssetTask object
  81551. * @param name defines the name of the task
  81552. * @param url defines the location of the file to load
  81553. * @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.
  81554. * @param noMipmap defines if mipmaps should not be generated (default is false)
  81555. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  81556. * @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)
  81557. * @param reserved Internal use only
  81558. */
  81559. constructor(
  81560. /**
  81561. * Defines the name of the task
  81562. */
  81563. name: string,
  81564. /**
  81565. * Defines the location of the file to load
  81566. */
  81567. url: string,
  81568. /**
  81569. * Defines the desired size (the more it increases the longer the generation will be)
  81570. */
  81571. size: number,
  81572. /**
  81573. * Defines if mipmaps should not be generated (default is false)
  81574. */
  81575. noMipmap?: boolean,
  81576. /**
  81577. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  81578. */
  81579. generateHarmonics?: boolean,
  81580. /**
  81581. * 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)
  81582. */
  81583. gammaSpace?: boolean,
  81584. /**
  81585. * Internal Use Only
  81586. */
  81587. reserved?: boolean);
  81588. /**
  81589. * Execute the current task
  81590. * @param scene defines the scene where you want your assets to be loaded
  81591. * @param onSuccess is a callback called when the task is successfully executed
  81592. * @param onError is a callback called if an error occurs
  81593. */
  81594. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81595. }
  81596. /**
  81597. * Define a task used by AssetsManager to load Equirectangular cube textures
  81598. */
  81599. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  81600. /**
  81601. * Defines the name of the task
  81602. */
  81603. name: string;
  81604. /**
  81605. * Defines the location of the file to load
  81606. */
  81607. url: string;
  81608. /**
  81609. * Defines the desired size (the more it increases the longer the generation will be)
  81610. */
  81611. size: number;
  81612. /**
  81613. * Defines if mipmaps should not be generated (default is false)
  81614. */
  81615. noMipmap: boolean;
  81616. /**
  81617. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  81618. * but the standard material would require them in Gamma space) (default is true)
  81619. */
  81620. gammaSpace: boolean;
  81621. /**
  81622. * Gets the loaded texture
  81623. */
  81624. texture: EquiRectangularCubeTexture;
  81625. /**
  81626. * Callback called when the task is successful
  81627. */
  81628. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  81629. /**
  81630. * Callback called when the task is successful
  81631. */
  81632. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  81633. /**
  81634. * Creates a new EquiRectangularCubeTextureAssetTask object
  81635. * @param name defines the name of the task
  81636. * @param url defines the location of the file to load
  81637. * @param size defines the desired size (the more it increases the longer the generation will be)
  81638. * If the size is omitted this implies you are using a preprocessed cubemap.
  81639. * @param noMipmap defines if mipmaps should not be generated (default is false)
  81640. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  81641. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  81642. * (default is true)
  81643. */
  81644. constructor(
  81645. /**
  81646. * Defines the name of the task
  81647. */
  81648. name: string,
  81649. /**
  81650. * Defines the location of the file to load
  81651. */
  81652. url: string,
  81653. /**
  81654. * Defines the desired size (the more it increases the longer the generation will be)
  81655. */
  81656. size: number,
  81657. /**
  81658. * Defines if mipmaps should not be generated (default is false)
  81659. */
  81660. noMipmap?: boolean,
  81661. /**
  81662. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  81663. * but the standard material would require them in Gamma space) (default is true)
  81664. */
  81665. gammaSpace?: boolean);
  81666. /**
  81667. * Execute the current task
  81668. * @param scene defines the scene where you want your assets to be loaded
  81669. * @param onSuccess is a callback called when the task is successfully executed
  81670. * @param onError is a callback called if an error occurs
  81671. */
  81672. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  81673. }
  81674. /**
  81675. * This class can be used to easily import assets into a scene
  81676. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  81677. */
  81678. export class AssetsManager {
  81679. private _scene;
  81680. private _isLoading;
  81681. protected _tasks: AbstractAssetTask[];
  81682. protected _waitingTasksCount: number;
  81683. protected _totalTasksCount: number;
  81684. /**
  81685. * Callback called when all tasks are processed
  81686. */
  81687. onFinish: (tasks: AbstractAssetTask[]) => void;
  81688. /**
  81689. * Callback called when a task is successful
  81690. */
  81691. onTaskSuccess: (task: AbstractAssetTask) => void;
  81692. /**
  81693. * Callback called when a task had an error
  81694. */
  81695. onTaskError: (task: AbstractAssetTask) => void;
  81696. /**
  81697. * Callback called when a task is done (whatever the result is)
  81698. */
  81699. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  81700. /**
  81701. * Observable called when all tasks are processed
  81702. */
  81703. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  81704. /**
  81705. * Observable called when a task had an error
  81706. */
  81707. onTaskErrorObservable: Observable<AbstractAssetTask>;
  81708. /**
  81709. * Observable called when all tasks were executed
  81710. */
  81711. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  81712. /**
  81713. * Observable called when a task is done (whatever the result is)
  81714. */
  81715. onProgressObservable: Observable<IAssetsProgressEvent>;
  81716. /**
  81717. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  81718. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  81719. */
  81720. useDefaultLoadingScreen: boolean;
  81721. /**
  81722. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  81723. * when all assets have been downloaded.
  81724. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  81725. */
  81726. autoHideLoadingUI: boolean;
  81727. /**
  81728. * Creates a new AssetsManager
  81729. * @param scene defines the scene to work on
  81730. */
  81731. constructor(scene: Scene);
  81732. /**
  81733. * Add a ContainerAssetTask to the list of active tasks
  81734. * @param taskName defines the name of the new task
  81735. * @param meshesNames defines the name of meshes to load
  81736. * @param rootUrl defines the root url to use to locate files
  81737. * @param sceneFilename defines the filename of the scene file
  81738. * @returns a new ContainerAssetTask object
  81739. */
  81740. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  81741. /**
  81742. * Add a MeshAssetTask to the list of active tasks
  81743. * @param taskName defines the name of the new task
  81744. * @param meshesNames defines the name of meshes to load
  81745. * @param rootUrl defines the root url to use to locate files
  81746. * @param sceneFilename defines the filename of the scene file
  81747. * @returns a new MeshAssetTask object
  81748. */
  81749. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  81750. /**
  81751. * Add a TextFileAssetTask to the list of active tasks
  81752. * @param taskName defines the name of the new task
  81753. * @param url defines the url of the file to load
  81754. * @returns a new TextFileAssetTask object
  81755. */
  81756. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  81757. /**
  81758. * Add a BinaryFileAssetTask to the list of active tasks
  81759. * @param taskName defines the name of the new task
  81760. * @param url defines the url of the file to load
  81761. * @returns a new BinaryFileAssetTask object
  81762. */
  81763. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  81764. /**
  81765. * Add a ImageAssetTask to the list of active tasks
  81766. * @param taskName defines the name of the new task
  81767. * @param url defines the url of the file to load
  81768. * @returns a new ImageAssetTask object
  81769. */
  81770. addImageTask(taskName: string, url: string): ImageAssetTask;
  81771. /**
  81772. * Add a TextureAssetTask to the list of active tasks
  81773. * @param taskName defines the name of the new task
  81774. * @param url defines the url of the file to load
  81775. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  81776. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  81777. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  81778. * @returns a new TextureAssetTask object
  81779. */
  81780. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  81781. /**
  81782. * Add a CubeTextureAssetTask to the list of active tasks
  81783. * @param taskName defines the name of the new task
  81784. * @param url defines the url of the file to load
  81785. * @param extensions defines the extension to use to load the cube map (can be null)
  81786. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  81787. * @param files defines the list of files to load (can be null)
  81788. * @returns a new CubeTextureAssetTask object
  81789. */
  81790. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  81791. /**
  81792. *
  81793. * Add a HDRCubeTextureAssetTask to the list of active tasks
  81794. * @param taskName defines the name of the new task
  81795. * @param url defines the url of the file to load
  81796. * @param size defines the size you want for the cubemap (can be null)
  81797. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  81798. * @param generateHarmonics defines if you want to automatically generate (true by default)
  81799. * @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)
  81800. * @param reserved Internal use only
  81801. * @returns a new HDRCubeTextureAssetTask object
  81802. */
  81803. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  81804. /**
  81805. *
  81806. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  81807. * @param taskName defines the name of the new task
  81808. * @param url defines the url of the file to load
  81809. * @param size defines the size you want for the cubemap (can be null)
  81810. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  81811. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  81812. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  81813. * @returns a new EquiRectangularCubeTextureAssetTask object
  81814. */
  81815. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  81816. /**
  81817. * Remove a task from the assets manager.
  81818. * @param task the task to remove
  81819. */
  81820. removeTask(task: AbstractAssetTask): void;
  81821. private _decreaseWaitingTasksCount;
  81822. private _runTask;
  81823. /**
  81824. * Reset the AssetsManager and remove all tasks
  81825. * @return the current instance of the AssetsManager
  81826. */
  81827. reset(): AssetsManager;
  81828. /**
  81829. * Start the loading process
  81830. * @return the current instance of the AssetsManager
  81831. */
  81832. load(): AssetsManager;
  81833. /**
  81834. * Start the loading process as an async operation
  81835. * @return a promise returning the list of failed tasks
  81836. */
  81837. loadAsync(): Promise<void>;
  81838. }
  81839. }
  81840. declare module "babylonjs/Misc/deferred" {
  81841. /**
  81842. * Wrapper class for promise with external resolve and reject.
  81843. */
  81844. export class Deferred<T> {
  81845. /**
  81846. * The promise associated with this deferred object.
  81847. */
  81848. readonly promise: Promise<T>;
  81849. private _resolve;
  81850. private _reject;
  81851. /**
  81852. * The resolve method of the promise associated with this deferred object.
  81853. */
  81854. get resolve(): (value: T | PromiseLike<T>) => void;
  81855. /**
  81856. * The reject method of the promise associated with this deferred object.
  81857. */
  81858. get reject(): (reason?: any) => void;
  81859. /**
  81860. * Constructor for this deferred object.
  81861. */
  81862. constructor();
  81863. }
  81864. }
  81865. declare module "babylonjs/Misc/meshExploder" {
  81866. import { Mesh } from "babylonjs/Meshes/mesh";
  81867. /**
  81868. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  81869. */
  81870. export class MeshExploder {
  81871. private _centerMesh;
  81872. private _meshes;
  81873. private _meshesOrigins;
  81874. private _toCenterVectors;
  81875. private _scaledDirection;
  81876. private _newPosition;
  81877. private _centerPosition;
  81878. /**
  81879. * Explodes meshes from a center mesh.
  81880. * @param meshes The meshes to explode.
  81881. * @param centerMesh The mesh to be center of explosion.
  81882. */
  81883. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  81884. private _setCenterMesh;
  81885. /**
  81886. * Get class name
  81887. * @returns "MeshExploder"
  81888. */
  81889. getClassName(): string;
  81890. /**
  81891. * "Exploded meshes"
  81892. * @returns Array of meshes with the centerMesh at index 0.
  81893. */
  81894. getMeshes(): Array<Mesh>;
  81895. /**
  81896. * Explodes meshes giving a specific direction
  81897. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  81898. */
  81899. explode(direction?: number): void;
  81900. }
  81901. }
  81902. declare module "babylonjs/Misc/filesInput" {
  81903. import { Engine } from "babylonjs/Engines/engine";
  81904. import { Scene } from "babylonjs/scene";
  81905. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  81906. import { Nullable } from "babylonjs/types";
  81907. /**
  81908. * Class used to help managing file picking and drag'n'drop
  81909. */
  81910. export class FilesInput {
  81911. /**
  81912. * List of files ready to be loaded
  81913. */
  81914. static get FilesToLoad(): {
  81915. [key: string]: File;
  81916. };
  81917. /**
  81918. * Callback called when a file is processed
  81919. */
  81920. onProcessFileCallback: (file: File, name: string, extension: string, setSceneFileToLoad: (sceneFile: File) => void) => boolean;
  81921. /**
  81922. * Function used when loading the scene file
  81923. */
  81924. loadAsync: (sceneFile: File, onProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>) => Promise<Scene>;
  81925. private _engine;
  81926. private _currentScene;
  81927. private _sceneLoadedCallback;
  81928. private _progressCallback;
  81929. private _additionalRenderLoopLogicCallback;
  81930. private _textureLoadingCallback;
  81931. private _startingProcessingFilesCallback;
  81932. private _onReloadCallback;
  81933. private _errorCallback;
  81934. private _elementToMonitor;
  81935. private _sceneFileToLoad;
  81936. private _filesToLoad;
  81937. /**
  81938. * Creates a new FilesInput
  81939. * @param engine defines the rendering engine
  81940. * @param scene defines the hosting scene
  81941. * @param sceneLoadedCallback callback called when scene is loaded
  81942. * @param progressCallback callback called to track progress
  81943. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  81944. * @param textureLoadingCallback callback called when a texture is loading
  81945. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  81946. * @param onReloadCallback callback called when a reload is requested
  81947. * @param errorCallback callback call if an error occurs
  81948. */
  81949. 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>);
  81950. private _dragEnterHandler;
  81951. private _dragOverHandler;
  81952. private _dropHandler;
  81953. /**
  81954. * Calls this function to listen to drag'n'drop events on a specific DOM element
  81955. * @param elementToMonitor defines the DOM element to track
  81956. */
  81957. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  81958. /** Gets the current list of files to load */
  81959. get filesToLoad(): File[];
  81960. /**
  81961. * Release all associated resources
  81962. */
  81963. dispose(): void;
  81964. private renderFunction;
  81965. private drag;
  81966. private drop;
  81967. private _traverseFolder;
  81968. private _processFiles;
  81969. /**
  81970. * Load files from a drop event
  81971. * @param event defines the drop event to use as source
  81972. */
  81973. loadFiles(event: any): void;
  81974. private _processReload;
  81975. /**
  81976. * Reload the current scene from the loaded files
  81977. */
  81978. reload(): void;
  81979. }
  81980. }
  81981. declare module "babylonjs/Misc/HighDynamicRange/index" {
  81982. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  81983. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  81984. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  81985. }
  81986. declare module "babylonjs/Misc/sceneOptimizer" {
  81987. import { Scene, IDisposable } from "babylonjs/scene";
  81988. import { Observable } from "babylonjs/Misc/observable";
  81989. /**
  81990. * Defines the root class used to create scene optimization to use with SceneOptimizer
  81991. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  81992. */
  81993. export class SceneOptimization {
  81994. /**
  81995. * Defines the priority of this optimization (0 by default which means first in the list)
  81996. */
  81997. priority: number;
  81998. /**
  81999. * Gets a string describing the action executed by the current optimization
  82000. * @returns description string
  82001. */
  82002. getDescription(): string;
  82003. /**
  82004. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82005. * @param scene defines the current scene where to apply this optimization
  82006. * @param optimizer defines the current optimizer
  82007. * @returns true if everything that can be done was applied
  82008. */
  82009. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  82010. /**
  82011. * Creates the SceneOptimization object
  82012. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  82013. * @param desc defines the description associated with the optimization
  82014. */
  82015. constructor(
  82016. /**
  82017. * Defines the priority of this optimization (0 by default which means first in the list)
  82018. */
  82019. priority?: number);
  82020. }
  82021. /**
  82022. * Defines an optimization used to reduce the size of render target textures
  82023. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82024. */
  82025. export class TextureOptimization extends SceneOptimization {
  82026. /**
  82027. * Defines the priority of this optimization (0 by default which means first in the list)
  82028. */
  82029. priority: number;
  82030. /**
  82031. * 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
  82032. */
  82033. maximumSize: number;
  82034. /**
  82035. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  82036. */
  82037. step: number;
  82038. /**
  82039. * Gets a string describing the action executed by the current optimization
  82040. * @returns description string
  82041. */
  82042. getDescription(): string;
  82043. /**
  82044. * Creates the TextureOptimization object
  82045. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  82046. * @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
  82047. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  82048. */
  82049. constructor(
  82050. /**
  82051. * Defines the priority of this optimization (0 by default which means first in the list)
  82052. */
  82053. priority?: number,
  82054. /**
  82055. * 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
  82056. */
  82057. maximumSize?: number,
  82058. /**
  82059. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  82060. */
  82061. step?: number);
  82062. /**
  82063. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82064. * @param scene defines the current scene where to apply this optimization
  82065. * @param optimizer defines the current optimizer
  82066. * @returns true if everything that can be done was applied
  82067. */
  82068. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  82069. }
  82070. /**
  82071. * Defines an optimization used to increase or decrease the rendering resolution
  82072. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82073. */
  82074. export class HardwareScalingOptimization extends SceneOptimization {
  82075. /**
  82076. * Defines the priority of this optimization (0 by default which means first in the list)
  82077. */
  82078. priority: number;
  82079. /**
  82080. * Defines the maximum scale to use (2 by default)
  82081. */
  82082. maximumScale: number;
  82083. /**
  82084. * Defines the step to use between two passes (0.5 by default)
  82085. */
  82086. step: number;
  82087. private _currentScale;
  82088. private _directionOffset;
  82089. /**
  82090. * Gets a string describing the action executed by the current optimization
  82091. * @return description string
  82092. */
  82093. getDescription(): string;
  82094. /**
  82095. * Creates the HardwareScalingOptimization object
  82096. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  82097. * @param maximumScale defines the maximum scale to use (2 by default)
  82098. * @param step defines the step to use between two passes (0.5 by default)
  82099. */
  82100. constructor(
  82101. /**
  82102. * Defines the priority of this optimization (0 by default which means first in the list)
  82103. */
  82104. priority?: number,
  82105. /**
  82106. * Defines the maximum scale to use (2 by default)
  82107. */
  82108. maximumScale?: number,
  82109. /**
  82110. * Defines the step to use between two passes (0.5 by default)
  82111. */
  82112. step?: number);
  82113. /**
  82114. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82115. * @param scene defines the current scene where to apply this optimization
  82116. * @param optimizer defines the current optimizer
  82117. * @returns true if everything that can be done was applied
  82118. */
  82119. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  82120. }
  82121. /**
  82122. * Defines an optimization used to remove shadows
  82123. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82124. */
  82125. export class ShadowsOptimization extends SceneOptimization {
  82126. /**
  82127. * Gets a string describing the action executed by the current optimization
  82128. * @return description string
  82129. */
  82130. getDescription(): string;
  82131. /**
  82132. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82133. * @param scene defines the current scene where to apply this optimization
  82134. * @param optimizer defines the current optimizer
  82135. * @returns true if everything that can be done was applied
  82136. */
  82137. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  82138. }
  82139. /**
  82140. * Defines an optimization used to turn post-processes off
  82141. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82142. */
  82143. export class PostProcessesOptimization extends SceneOptimization {
  82144. /**
  82145. * Gets a string describing the action executed by the current optimization
  82146. * @return description string
  82147. */
  82148. getDescription(): string;
  82149. /**
  82150. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82151. * @param scene defines the current scene where to apply this optimization
  82152. * @param optimizer defines the current optimizer
  82153. * @returns true if everything that can be done was applied
  82154. */
  82155. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  82156. }
  82157. /**
  82158. * Defines an optimization used to turn lens flares off
  82159. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82160. */
  82161. export class LensFlaresOptimization extends SceneOptimization {
  82162. /**
  82163. * Gets a string describing the action executed by the current optimization
  82164. * @return description string
  82165. */
  82166. getDescription(): string;
  82167. /**
  82168. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82169. * @param scene defines the current scene where to apply this optimization
  82170. * @param optimizer defines the current optimizer
  82171. * @returns true if everything that can be done was applied
  82172. */
  82173. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  82174. }
  82175. /**
  82176. * Defines an optimization based on user defined callback.
  82177. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82178. */
  82179. export class CustomOptimization extends SceneOptimization {
  82180. /**
  82181. * Callback called to apply the custom optimization.
  82182. */
  82183. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  82184. /**
  82185. * Callback called to get custom description
  82186. */
  82187. onGetDescription: () => string;
  82188. /**
  82189. * Gets a string describing the action executed by the current optimization
  82190. * @returns description string
  82191. */
  82192. getDescription(): string;
  82193. /**
  82194. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82195. * @param scene defines the current scene where to apply this optimization
  82196. * @param optimizer defines the current optimizer
  82197. * @returns true if everything that can be done was applied
  82198. */
  82199. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  82200. }
  82201. /**
  82202. * Defines an optimization used to turn particles off
  82203. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82204. */
  82205. export class ParticlesOptimization extends SceneOptimization {
  82206. /**
  82207. * Gets a string describing the action executed by the current optimization
  82208. * @return description string
  82209. */
  82210. getDescription(): string;
  82211. /**
  82212. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82213. * @param scene defines the current scene where to apply this optimization
  82214. * @param optimizer defines the current optimizer
  82215. * @returns true if everything that can be done was applied
  82216. */
  82217. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  82218. }
  82219. /**
  82220. * Defines an optimization used to turn render targets off
  82221. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82222. */
  82223. export class RenderTargetsOptimization extends SceneOptimization {
  82224. /**
  82225. * Gets a string describing the action executed by the current optimization
  82226. * @return description string
  82227. */
  82228. getDescription(): string;
  82229. /**
  82230. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82231. * @param scene defines the current scene where to apply this optimization
  82232. * @param optimizer defines the current optimizer
  82233. * @returns true if everything that can be done was applied
  82234. */
  82235. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  82236. }
  82237. /**
  82238. * Defines an optimization used to merge meshes with compatible materials
  82239. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82240. */
  82241. export class MergeMeshesOptimization extends SceneOptimization {
  82242. private static _UpdateSelectionTree;
  82243. /**
  82244. * Gets or sets a boolean which defines if optimization octree has to be updated
  82245. */
  82246. static get UpdateSelectionTree(): boolean;
  82247. /**
  82248. * Gets or sets a boolean which defines if optimization octree has to be updated
  82249. */
  82250. static set UpdateSelectionTree(value: boolean);
  82251. /**
  82252. * Gets a string describing the action executed by the current optimization
  82253. * @return description string
  82254. */
  82255. getDescription(): string;
  82256. private _canBeMerged;
  82257. /**
  82258. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  82259. * @param scene defines the current scene where to apply this optimization
  82260. * @param optimizer defines the current optimizer
  82261. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  82262. * @returns true if everything that can be done was applied
  82263. */
  82264. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  82265. }
  82266. /**
  82267. * Defines a list of options used by SceneOptimizer
  82268. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82269. */
  82270. export class SceneOptimizerOptions {
  82271. /**
  82272. * Defines the target frame rate to reach (60 by default)
  82273. */
  82274. targetFrameRate: number;
  82275. /**
  82276. * Defines the interval between two checkes (2000ms by default)
  82277. */
  82278. trackerDuration: number;
  82279. /**
  82280. * Gets the list of optimizations to apply
  82281. */
  82282. optimizations: SceneOptimization[];
  82283. /**
  82284. * Creates a new list of options used by SceneOptimizer
  82285. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  82286. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  82287. */
  82288. constructor(
  82289. /**
  82290. * Defines the target frame rate to reach (60 by default)
  82291. */
  82292. targetFrameRate?: number,
  82293. /**
  82294. * Defines the interval between two checkes (2000ms by default)
  82295. */
  82296. trackerDuration?: number);
  82297. /**
  82298. * Add a new optimization
  82299. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  82300. * @returns the current SceneOptimizerOptions
  82301. */
  82302. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  82303. /**
  82304. * Add a new custom optimization
  82305. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  82306. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  82307. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  82308. * @returns the current SceneOptimizerOptions
  82309. */
  82310. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  82311. /**
  82312. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  82313. * @param targetFrameRate defines the target frame rate (60 by default)
  82314. * @returns a SceneOptimizerOptions object
  82315. */
  82316. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  82317. /**
  82318. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  82319. * @param targetFrameRate defines the target frame rate (60 by default)
  82320. * @returns a SceneOptimizerOptions object
  82321. */
  82322. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  82323. /**
  82324. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  82325. * @param targetFrameRate defines the target frame rate (60 by default)
  82326. * @returns a SceneOptimizerOptions object
  82327. */
  82328. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  82329. }
  82330. /**
  82331. * Class used to run optimizations in order to reach a target frame rate
  82332. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  82333. */
  82334. export class SceneOptimizer implements IDisposable {
  82335. private _isRunning;
  82336. private _options;
  82337. private _scene;
  82338. private _currentPriorityLevel;
  82339. private _targetFrameRate;
  82340. private _trackerDuration;
  82341. private _currentFrameRate;
  82342. private _sceneDisposeObserver;
  82343. private _improvementMode;
  82344. /**
  82345. * Defines an observable called when the optimizer reaches the target frame rate
  82346. */
  82347. onSuccessObservable: Observable<SceneOptimizer>;
  82348. /**
  82349. * Defines an observable called when the optimizer enables an optimization
  82350. */
  82351. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  82352. /**
  82353. * Defines an observable called when the optimizer is not able to reach the target frame rate
  82354. */
  82355. onFailureObservable: Observable<SceneOptimizer>;
  82356. /**
  82357. * Gets a boolean indicating if the optimizer is in improvement mode
  82358. */
  82359. get isInImprovementMode(): boolean;
  82360. /**
  82361. * Gets the current priority level (0 at start)
  82362. */
  82363. get currentPriorityLevel(): number;
  82364. /**
  82365. * Gets the current frame rate checked by the SceneOptimizer
  82366. */
  82367. get currentFrameRate(): number;
  82368. /**
  82369. * Gets or sets the current target frame rate (60 by default)
  82370. */
  82371. get targetFrameRate(): number;
  82372. /**
  82373. * Gets or sets the current target frame rate (60 by default)
  82374. */
  82375. set targetFrameRate(value: number);
  82376. /**
  82377. * Gets or sets the current interval between two checks (every 2000ms by default)
  82378. */
  82379. get trackerDuration(): number;
  82380. /**
  82381. * Gets or sets the current interval between two checks (every 2000ms by default)
  82382. */
  82383. set trackerDuration(value: number);
  82384. /**
  82385. * Gets the list of active optimizations
  82386. */
  82387. get optimizations(): SceneOptimization[];
  82388. /**
  82389. * Creates a new SceneOptimizer
  82390. * @param scene defines the scene to work on
  82391. * @param options defines the options to use with the SceneOptimizer
  82392. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  82393. * @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)
  82394. */
  82395. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  82396. /**
  82397. * Stops the current optimizer
  82398. */
  82399. stop(): void;
  82400. /**
  82401. * Reset the optimizer to initial step (current priority level = 0)
  82402. */
  82403. reset(): void;
  82404. /**
  82405. * Start the optimizer. By default it will try to reach a specific framerate
  82406. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  82407. */
  82408. start(): void;
  82409. private _checkCurrentState;
  82410. /**
  82411. * Release all resources
  82412. */
  82413. dispose(): void;
  82414. /**
  82415. * Helper function to create a SceneOptimizer with one single line of code
  82416. * @param scene defines the scene to work on
  82417. * @param options defines the options to use with the SceneOptimizer
  82418. * @param onSuccess defines a callback to call on success
  82419. * @param onFailure defines a callback to call on failure
  82420. * @returns the new SceneOptimizer object
  82421. */
  82422. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  82423. }
  82424. }
  82425. declare module "babylonjs/Misc/sceneSerializer" {
  82426. import { Scene } from "babylonjs/scene";
  82427. /**
  82428. * Class used to serialize a scene into a string
  82429. */
  82430. export class SceneSerializer {
  82431. /**
  82432. * Clear cache used by a previous serialization
  82433. */
  82434. static ClearCache(): void;
  82435. /**
  82436. * Serialize a scene into a JSON compatible object
  82437. * @param scene defines the scene to serialize
  82438. * @returns a JSON compatible object
  82439. */
  82440. static Serialize(scene: Scene): any;
  82441. /**
  82442. * Serialize a mesh into a JSON compatible object
  82443. * @param toSerialize defines the mesh to serialize
  82444. * @param withParents defines if parents must be serialized as well
  82445. * @param withChildren defines if children must be serialized as well
  82446. * @returns a JSON compatible object
  82447. */
  82448. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  82449. }
  82450. }
  82451. declare module "babylonjs/Misc/videoRecorder" {
  82452. import { Nullable } from "babylonjs/types";
  82453. import { Engine } from "babylonjs/Engines/engine";
  82454. /**
  82455. * This represents the different options available for the video capture.
  82456. */
  82457. export interface VideoRecorderOptions {
  82458. /** Defines the mime type of the video. */
  82459. mimeType: string;
  82460. /** Defines the FPS the video should be recorded at. */
  82461. fps: number;
  82462. /** Defines the chunk size for the recording data. */
  82463. recordChunckSize: number;
  82464. /** The audio tracks to attach to the recording. */
  82465. audioTracks?: MediaStreamTrack[];
  82466. }
  82467. /**
  82468. * This can help with recording videos from BabylonJS.
  82469. * This is based on the available WebRTC functionalities of the browser.
  82470. *
  82471. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  82472. */
  82473. export class VideoRecorder {
  82474. private static readonly _defaultOptions;
  82475. /**
  82476. * Returns whether or not the VideoRecorder is available in your browser.
  82477. * @param engine Defines the Babylon Engine.
  82478. * @returns true if supported otherwise false.
  82479. */
  82480. static IsSupported(engine: Engine): boolean;
  82481. private readonly _options;
  82482. private _canvas;
  82483. private _mediaRecorder;
  82484. private _recordedChunks;
  82485. private _fileName;
  82486. private _resolve;
  82487. private _reject;
  82488. /**
  82489. * True when a recording is already in progress.
  82490. */
  82491. get isRecording(): boolean;
  82492. /**
  82493. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  82494. * @param engine Defines the BabylonJS Engine you wish to record.
  82495. * @param options Defines options that can be used to customize the capture.
  82496. */
  82497. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  82498. /**
  82499. * Stops the current recording before the default capture timeout passed in the startRecording function.
  82500. */
  82501. stopRecording(): void;
  82502. /**
  82503. * Starts recording the canvas for a max duration specified in parameters.
  82504. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  82505. * If null no automatic download will start and you can rely on the promise to get the data back.
  82506. * @param maxDuration Defines the maximum recording time in seconds.
  82507. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  82508. * @return A promise callback at the end of the recording with the video data in Blob.
  82509. */
  82510. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  82511. /**
  82512. * Releases internal resources used during the recording.
  82513. */
  82514. dispose(): void;
  82515. private _handleDataAvailable;
  82516. private _handleError;
  82517. private _handleStop;
  82518. }
  82519. }
  82520. declare module "babylonjs/Misc/screenshotTools" {
  82521. import { Camera } from "babylonjs/Cameras/camera";
  82522. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  82523. import { Engine } from "babylonjs/Engines/engine";
  82524. /**
  82525. * Class containing a set of static utilities functions for screenshots
  82526. */
  82527. export class ScreenshotTools {
  82528. /**
  82529. * Captures a screenshot of the current rendering
  82530. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  82531. * @param engine defines the rendering engine
  82532. * @param camera defines the source camera
  82533. * @param size This parameter can be set to a single number or to an object with the
  82534. * following (optional) properties: precision, width, height. If a single number is passed,
  82535. * it will be used for both width and height. If an object is passed, the screenshot size
  82536. * will be derived from the parameters. The precision property is a multiplier allowing
  82537. * rendering at a higher or lower resolution
  82538. * @param successCallback defines the callback receives a single parameter which contains the
  82539. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  82540. * src parameter of an <img> to display it
  82541. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  82542. * Check your browser for supported MIME types
  82543. */
  82544. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  82545. /**
  82546. * Captures a screenshot of the current rendering
  82547. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  82548. * @param engine defines the rendering engine
  82549. * @param camera defines the source camera
  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 mimeType defines the MIME type of the screenshot image (default: image/png).
  82556. * Check your browser for supported MIME types
  82557. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  82558. * to the src parameter of an <img> to display it
  82559. */
  82560. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  82561. /**
  82562. * Generates an image screenshot from the specified camera.
  82563. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  82564. * @param engine The engine to use for rendering
  82565. * @param camera The camera to use for rendering
  82566. * @param size This parameter can be set to a single number or to an object with the
  82567. * following (optional) properties: precision, width, height. If a single number is passed,
  82568. * it will be used for both width and height. If an object is passed, the screenshot size
  82569. * will be derived from the parameters. The precision property is a multiplier allowing
  82570. * rendering at a higher or lower resolution
  82571. * @param successCallback The callback receives a single parameter which contains the
  82572. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  82573. * src parameter of an <img> to display it
  82574. * @param mimeType The MIME type of the screenshot image (default: image/png).
  82575. * Check your browser for supported MIME types
  82576. * @param samples Texture samples (default: 1)
  82577. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  82578. * @param fileName A name for for the downloaded file.
  82579. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  82580. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  82581. */
  82582. 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;
  82583. /**
  82584. * Generates an image screenshot from the specified camera.
  82585. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  82586. * @param engine The engine to use for rendering
  82587. * @param camera The camera to use for rendering
  82588. * @param size This parameter can be set to a single number or to an object with the
  82589. * following (optional) properties: precision, width, height. If a single number is passed,
  82590. * it will be used for both width and height. If an object is passed, the screenshot size
  82591. * will be derived from the parameters. The precision property is a multiplier allowing
  82592. * rendering at a higher or lower resolution
  82593. * @param mimeType The MIME type of the screenshot image (default: image/png).
  82594. * Check your browser for supported MIME types
  82595. * @param samples Texture samples (default: 1)
  82596. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  82597. * @param fileName A name for for the downloaded file.
  82598. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  82599. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  82600. * to the src parameter of an <img> to display it
  82601. */
  82602. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  82603. /**
  82604. * Gets height and width for screenshot size
  82605. * @private
  82606. */
  82607. private static _getScreenshotSize;
  82608. }
  82609. }
  82610. declare module "babylonjs/Misc/dataReader" {
  82611. /**
  82612. * Interface for a data buffer
  82613. */
  82614. export interface IDataBuffer {
  82615. /**
  82616. * Reads bytes from the data buffer.
  82617. * @param byteOffset The byte offset to read
  82618. * @param byteLength The byte length to read
  82619. * @returns A promise that resolves when the bytes are read
  82620. */
  82621. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  82622. /**
  82623. * The byte length of the buffer.
  82624. */
  82625. readonly byteLength: number;
  82626. }
  82627. /**
  82628. * Utility class for reading from a data buffer
  82629. */
  82630. export class DataReader {
  82631. /**
  82632. * The data buffer associated with this data reader.
  82633. */
  82634. readonly buffer: IDataBuffer;
  82635. /**
  82636. * The current byte offset from the beginning of the data buffer.
  82637. */
  82638. byteOffset: number;
  82639. private _dataView;
  82640. private _dataByteOffset;
  82641. /**
  82642. * Constructor
  82643. * @param buffer The buffer to read
  82644. */
  82645. constructor(buffer: IDataBuffer);
  82646. /**
  82647. * Loads the given byte length.
  82648. * @param byteLength The byte length to load
  82649. * @returns A promise that resolves when the load is complete
  82650. */
  82651. loadAsync(byteLength: number): Promise<void>;
  82652. /**
  82653. * Read a unsigned 32-bit integer from the currently loaded data range.
  82654. * @returns The 32-bit integer read
  82655. */
  82656. readUint32(): number;
  82657. /**
  82658. * Read a byte array from the currently loaded data range.
  82659. * @param byteLength The byte length to read
  82660. * @returns The byte array read
  82661. */
  82662. readUint8Array(byteLength: number): Uint8Array;
  82663. /**
  82664. * Read a string from the currently loaded data range.
  82665. * @param byteLength The byte length to read
  82666. * @returns The string read
  82667. */
  82668. readString(byteLength: number): string;
  82669. /**
  82670. * Skips the given byte length the currently loaded data range.
  82671. * @param byteLength The byte length to skip
  82672. */
  82673. skipBytes(byteLength: number): void;
  82674. }
  82675. }
  82676. declare module "babylonjs/Misc/dataStorage" {
  82677. /**
  82678. * Class for storing data to local storage if available or in-memory storage otherwise
  82679. */
  82680. export class DataStorage {
  82681. private static _Storage;
  82682. private static _GetStorage;
  82683. /**
  82684. * Reads a string from the data storage
  82685. * @param key The key to read
  82686. * @param defaultValue The value if the key doesn't exist
  82687. * @returns The string value
  82688. */
  82689. static ReadString(key: string, defaultValue: string): string;
  82690. /**
  82691. * Writes a string to the data storage
  82692. * @param key The key to write
  82693. * @param value The value to write
  82694. */
  82695. static WriteString(key: string, value: string): void;
  82696. /**
  82697. * Reads a boolean from the data storage
  82698. * @param key The key to read
  82699. * @param defaultValue The value if the key doesn't exist
  82700. * @returns The boolean value
  82701. */
  82702. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  82703. /**
  82704. * Writes a boolean to the data storage
  82705. * @param key The key to write
  82706. * @param value The value to write
  82707. */
  82708. static WriteBoolean(key: string, value: boolean): void;
  82709. /**
  82710. * Reads a number from the data storage
  82711. * @param key The key to read
  82712. * @param defaultValue The value if the key doesn't exist
  82713. * @returns The number value
  82714. */
  82715. static ReadNumber(key: string, defaultValue: number): number;
  82716. /**
  82717. * Writes a number to the data storage
  82718. * @param key The key to write
  82719. * @param value The value to write
  82720. */
  82721. static WriteNumber(key: string, value: number): void;
  82722. }
  82723. }
  82724. declare module "babylonjs/Misc/sceneRecorder" {
  82725. import { Scene } from "babylonjs/scene";
  82726. /**
  82727. * Class used to record delta files between 2 scene states
  82728. */
  82729. export class SceneRecorder {
  82730. private _trackedScene;
  82731. private _savedJSON;
  82732. /**
  82733. * Track a given scene. This means the current scene state will be considered the original state
  82734. * @param scene defines the scene to track
  82735. */
  82736. track(scene: Scene): void;
  82737. /**
  82738. * Get the delta between current state and original state
  82739. * @returns a string containing the delta
  82740. */
  82741. getDelta(): any;
  82742. private _compareArray;
  82743. private _compareObjects;
  82744. private _compareCollections;
  82745. private static GetShadowGeneratorById;
  82746. /**
  82747. * Apply a given delta to a given scene
  82748. * @param deltaJSON defines the JSON containing the delta
  82749. * @param scene defines the scene to apply the delta to
  82750. */
  82751. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  82752. private static _ApplyPropertiesToEntity;
  82753. private static _ApplyDeltaForEntity;
  82754. }
  82755. }
  82756. declare module "babylonjs/Misc/trajectoryClassifier" {
  82757. import { DeepImmutable, Nullable } from "babylonjs/types";
  82758. import { Vector3 } from "babylonjs/Maths/math.vector";
  82759. /**
  82760. * A 3D trajectory consisting of an order list of vectors describing a
  82761. * path of motion through 3D space.
  82762. */
  82763. export class Trajectory {
  82764. private _points;
  82765. private readonly _segmentLength;
  82766. /**
  82767. * Serialize to JSON.
  82768. * @returns serialized JSON string
  82769. */
  82770. serialize(): string;
  82771. /**
  82772. * Deserialize from JSON.
  82773. * @param json serialized JSON string
  82774. * @returns deserialized Trajectory
  82775. */
  82776. static Deserialize(json: string): Trajectory;
  82777. /**
  82778. * Create a new empty Trajectory.
  82779. * @param segmentLength radius of discretization for Trajectory points
  82780. */
  82781. constructor(segmentLength?: number);
  82782. /**
  82783. * Get the length of the Trajectory.
  82784. * @returns length of the Trajectory
  82785. */
  82786. getLength(): number;
  82787. /**
  82788. * Append a new point to the Trajectory.
  82789. * NOTE: This implementation has many allocations.
  82790. * @param point point to append to the Trajectory
  82791. */
  82792. add(point: DeepImmutable<Vector3>): void;
  82793. /**
  82794. * Create a new Trajectory with a segment length chosen to make it
  82795. * probable that the new Trajectory will have a specified number of
  82796. * segments. This operation is imprecise.
  82797. * @param targetResolution number of segments desired
  82798. * @returns new Trajectory with approximately the requested number of segments
  82799. */
  82800. resampleAtTargetResolution(targetResolution: number): Trajectory;
  82801. /**
  82802. * Convert Trajectory segments into tokenized representation. This
  82803. * representation is an array of numbers where each nth number is the
  82804. * index of the token which is most similar to the nth segment of the
  82805. * Trajectory.
  82806. * @param tokens list of vectors which serve as discrete tokens
  82807. * @returns list of indices of most similar token per segment
  82808. */
  82809. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  82810. private static _forwardDir;
  82811. private static _inverseFromVec;
  82812. private static _upDir;
  82813. private static _fromToVec;
  82814. private static _lookMatrix;
  82815. /**
  82816. * Transform the rotation (i.e., direction) of a segment to isolate
  82817. * the relative transformation represented by the segment. This operation
  82818. * may or may not succeed due to singularities in the equations that define
  82819. * motion relativity in this context.
  82820. * @param priorVec the origin of the prior segment
  82821. * @param fromVec the origin of the current segment
  82822. * @param toVec the destination of the current segment
  82823. * @param result reference to output variable
  82824. * @returns whether or not transformation was successful
  82825. */
  82826. private static _transformSegmentDirToRef;
  82827. private static _bestMatch;
  82828. private static _score;
  82829. private static _bestScore;
  82830. /**
  82831. * Determine which token vector is most similar to the
  82832. * segment vector.
  82833. * @param segment segment vector
  82834. * @param tokens token vector list
  82835. * @returns index of the most similar token to the segment
  82836. */
  82837. private static _tokenizeSegment;
  82838. }
  82839. /**
  82840. * Class representing a set of known, named trajectories to which Trajectories can be
  82841. * added and using which Trajectories can be recognized.
  82842. */
  82843. export class TrajectoryClassifier {
  82844. private _maximumAllowableMatchCost;
  82845. private _vector3Alphabet;
  82846. private _levenshteinAlphabet;
  82847. private _nameToDescribedTrajectory;
  82848. /**
  82849. * Serialize to JSON.
  82850. * @returns JSON serialization
  82851. */
  82852. serialize(): string;
  82853. /**
  82854. * Deserialize from JSON.
  82855. * @param json JSON serialization
  82856. * @returns deserialized TrajectorySet
  82857. */
  82858. static Deserialize(json: string): TrajectoryClassifier;
  82859. /**
  82860. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  82861. * VERY naive, need to be generating these things from known
  82862. * sets. Better version later, probably eliminating this one.
  82863. * @returns auto-generated TrajectorySet
  82864. */
  82865. static Generate(): TrajectoryClassifier;
  82866. private constructor();
  82867. /**
  82868. * Add a new Trajectory to the set with a given name.
  82869. * @param trajectory new Trajectory to be added
  82870. * @param classification name to which to add the Trajectory
  82871. */
  82872. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  82873. /**
  82874. * Remove a known named trajectory and all Trajectories associated with it.
  82875. * @param classification name to remove
  82876. * @returns whether anything was removed
  82877. */
  82878. deleteClassification(classification: string): boolean;
  82879. /**
  82880. * Attempt to recognize a Trajectory from among all the classifications
  82881. * already known to the classifier.
  82882. * @param trajectory Trajectory to be recognized
  82883. * @returns classification of Trajectory if recognized, null otherwise
  82884. */
  82885. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  82886. }
  82887. }
  82888. declare module "babylonjs/Misc/index" {
  82889. export * from "babylonjs/Misc/andOrNotEvaluator";
  82890. export * from "babylonjs/Misc/assetsManager";
  82891. export * from "babylonjs/Misc/basis";
  82892. export * from "babylonjs/Misc/dds";
  82893. export * from "babylonjs/Misc/decorators";
  82894. export * from "babylonjs/Misc/deferred";
  82895. export * from "babylonjs/Misc/environmentTextureTools";
  82896. export * from "babylonjs/Misc/meshExploder";
  82897. export * from "babylonjs/Misc/filesInput";
  82898. export * from "babylonjs/Misc/HighDynamicRange/index";
  82899. export * from "babylonjs/Misc/khronosTextureContainer";
  82900. export * from "babylonjs/Misc/observable";
  82901. export * from "babylonjs/Misc/performanceMonitor";
  82902. export * from "babylonjs/Misc/promise";
  82903. export * from "babylonjs/Misc/sceneOptimizer";
  82904. export * from "babylonjs/Misc/sceneSerializer";
  82905. export * from "babylonjs/Misc/smartArray";
  82906. export * from "babylonjs/Misc/stringDictionary";
  82907. export * from "babylonjs/Misc/tags";
  82908. export * from "babylonjs/Misc/textureTools";
  82909. export * from "babylonjs/Misc/tga";
  82910. export * from "babylonjs/Misc/tools";
  82911. export * from "babylonjs/Misc/videoRecorder";
  82912. export * from "babylonjs/Misc/virtualJoystick";
  82913. export * from "babylonjs/Misc/workerPool";
  82914. export * from "babylonjs/Misc/logger";
  82915. export * from "babylonjs/Misc/typeStore";
  82916. export * from "babylonjs/Misc/filesInputStore";
  82917. export * from "babylonjs/Misc/deepCopier";
  82918. export * from "babylonjs/Misc/pivotTools";
  82919. export * from "babylonjs/Misc/precisionDate";
  82920. export * from "babylonjs/Misc/screenshotTools";
  82921. export * from "babylonjs/Misc/typeStore";
  82922. export * from "babylonjs/Misc/webRequest";
  82923. export * from "babylonjs/Misc/iInspectable";
  82924. export * from "babylonjs/Misc/brdfTextureTools";
  82925. export * from "babylonjs/Misc/rgbdTextureTools";
  82926. export * from "babylonjs/Misc/gradients";
  82927. export * from "babylonjs/Misc/perfCounter";
  82928. export * from "babylonjs/Misc/fileRequest";
  82929. export * from "babylonjs/Misc/customAnimationFrameRequester";
  82930. export * from "babylonjs/Misc/retryStrategy";
  82931. export * from "babylonjs/Misc/interfaces/screenshotSize";
  82932. export * from "babylonjs/Misc/canvasGenerator";
  82933. export * from "babylonjs/Misc/fileTools";
  82934. export * from "babylonjs/Misc/stringTools";
  82935. export * from "babylonjs/Misc/dataReader";
  82936. export * from "babylonjs/Misc/minMaxReducer";
  82937. export * from "babylonjs/Misc/depthReducer";
  82938. export * from "babylonjs/Misc/dataStorage";
  82939. export * from "babylonjs/Misc/sceneRecorder";
  82940. export * from "babylonjs/Misc/khronosTextureContainer2";
  82941. export * from "babylonjs/Misc/trajectoryClassifier";
  82942. export * from "babylonjs/Misc/timer";
  82943. export * from "babylonjs/Misc/copyTools";
  82944. }
  82945. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  82946. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  82947. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  82948. import { Observable } from "babylonjs/Misc/observable";
  82949. import { Matrix } from "babylonjs/Maths/math.vector";
  82950. import { TransformNode } from "babylonjs/Meshes/transformNode";
  82951. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  82952. /**
  82953. * An interface for all Hit test features
  82954. */
  82955. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  82956. /**
  82957. * Triggered when new babylon (transformed) hit test results are available
  82958. */
  82959. onHitTestResultObservable: Observable<T[]>;
  82960. }
  82961. /**
  82962. * Options used for hit testing
  82963. */
  82964. export interface IWebXRLegacyHitTestOptions {
  82965. /**
  82966. * Only test when user interacted with the scene. Default - hit test every frame
  82967. */
  82968. testOnPointerDownOnly?: boolean;
  82969. /**
  82970. * The node to use to transform the local results to world coordinates
  82971. */
  82972. worldParentNode?: TransformNode;
  82973. }
  82974. /**
  82975. * Interface defining the babylon result of raycasting/hit-test
  82976. */
  82977. export interface IWebXRLegacyHitResult {
  82978. /**
  82979. * Transformation matrix that can be applied to a node that will put it in the hit point location
  82980. */
  82981. transformationMatrix: Matrix;
  82982. /**
  82983. * The native hit test result
  82984. */
  82985. xrHitResult: XRHitResult | XRHitTestResult;
  82986. }
  82987. /**
  82988. * The currently-working hit-test module.
  82989. * Hit test (or Ray-casting) is used to interact with the real world.
  82990. * For further information read here - https://github.com/immersive-web/hit-test
  82991. */
  82992. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  82993. /**
  82994. * options to use when constructing this feature
  82995. */
  82996. readonly options: IWebXRLegacyHitTestOptions;
  82997. private _direction;
  82998. private _mat;
  82999. private _onSelectEnabled;
  83000. private _origin;
  83001. /**
  83002. * The module's name
  83003. */
  83004. static readonly Name: string;
  83005. /**
  83006. * The (Babylon) version of this module.
  83007. * This is an integer representing the implementation version.
  83008. * This number does not correspond to the WebXR specs version
  83009. */
  83010. static readonly Version: number;
  83011. /**
  83012. * Populated with the last native XR Hit Results
  83013. */
  83014. lastNativeXRHitResults: XRHitResult[];
  83015. /**
  83016. * Triggered when new babylon (transformed) hit test results are available
  83017. */
  83018. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  83019. /**
  83020. * Creates a new instance of the (legacy version) hit test feature
  83021. * @param _xrSessionManager an instance of WebXRSessionManager
  83022. * @param options options to use when constructing this feature
  83023. */
  83024. constructor(_xrSessionManager: WebXRSessionManager,
  83025. /**
  83026. * options to use when constructing this feature
  83027. */
  83028. options?: IWebXRLegacyHitTestOptions);
  83029. /**
  83030. * execute a hit test with an XR Ray
  83031. *
  83032. * @param xrSession a native xrSession that will execute this hit test
  83033. * @param xrRay the ray (position and direction) to use for ray-casting
  83034. * @param referenceSpace native XR reference space to use for the hit-test
  83035. * @param filter filter function that will filter the results
  83036. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  83037. */
  83038. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  83039. /**
  83040. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  83041. * @param event the (select) event to use to select with
  83042. * @param referenceSpace the reference space to use for this hit test
  83043. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  83044. */
  83045. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  83046. /**
  83047. * attach this feature
  83048. * Will usually be called by the features manager
  83049. *
  83050. * @returns true if successful.
  83051. */
  83052. attach(): boolean;
  83053. /**
  83054. * detach this feature.
  83055. * Will usually be called by the features manager
  83056. *
  83057. * @returns true if successful.
  83058. */
  83059. detach(): boolean;
  83060. /**
  83061. * Dispose this feature and all of the resources attached
  83062. */
  83063. dispose(): void;
  83064. protected _onXRFrame(frame: XRFrame): void;
  83065. private _onHitTestResults;
  83066. private _onSelect;
  83067. }
  83068. }
  83069. declare module "babylonjs/XR/features/WebXRHitTest" {
  83070. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  83071. import { Observable } from "babylonjs/Misc/observable";
  83072. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  83073. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  83074. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  83075. /**
  83076. * Options used for hit testing (version 2)
  83077. */
  83078. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  83079. /**
  83080. * Do not create a permanent hit test. Will usually be used when only
  83081. * transient inputs are needed.
  83082. */
  83083. disablePermanentHitTest?: boolean;
  83084. /**
  83085. * Enable transient (for example touch-based) hit test inspections
  83086. */
  83087. enableTransientHitTest?: boolean;
  83088. /**
  83089. * Offset ray for the permanent hit test
  83090. */
  83091. offsetRay?: Vector3;
  83092. /**
  83093. * Offset ray for the transient hit test
  83094. */
  83095. transientOffsetRay?: Vector3;
  83096. /**
  83097. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  83098. */
  83099. useReferenceSpace?: boolean;
  83100. /**
  83101. * Override the default entity type(s) of the hit-test result
  83102. */
  83103. entityTypes?: XRHitTestTrackableType[];
  83104. }
  83105. /**
  83106. * Interface defining the babylon result of hit-test
  83107. */
  83108. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  83109. /**
  83110. * The input source that generated this hit test (if transient)
  83111. */
  83112. inputSource?: XRInputSource;
  83113. /**
  83114. * Is this a transient hit test
  83115. */
  83116. isTransient?: boolean;
  83117. /**
  83118. * Position of the hit test result
  83119. */
  83120. position: Vector3;
  83121. /**
  83122. * Rotation of the hit test result
  83123. */
  83124. rotationQuaternion: Quaternion;
  83125. /**
  83126. * The native hit test result
  83127. */
  83128. xrHitResult: XRHitTestResult;
  83129. }
  83130. /**
  83131. * The currently-working hit-test module.
  83132. * Hit test (or Ray-casting) is used to interact with the real world.
  83133. * For further information read here - https://github.com/immersive-web/hit-test
  83134. *
  83135. * Tested on chrome (mobile) 80.
  83136. */
  83137. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  83138. /**
  83139. * options to use when constructing this feature
  83140. */
  83141. readonly options: IWebXRHitTestOptions;
  83142. private _tmpMat;
  83143. private _tmpPos;
  83144. private _tmpQuat;
  83145. private _transientXrHitTestSource;
  83146. private _xrHitTestSource;
  83147. private initHitTestSource;
  83148. /**
  83149. * The module's name
  83150. */
  83151. static readonly Name: string;
  83152. /**
  83153. * The (Babylon) version of this module.
  83154. * This is an integer representing the implementation version.
  83155. * This number does not correspond to the WebXR specs version
  83156. */
  83157. static readonly Version: number;
  83158. /**
  83159. * When set to true, each hit test will have its own position/rotation objects
  83160. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  83161. * the developers will clone them or copy them as they see fit.
  83162. */
  83163. autoCloneTransformation: boolean;
  83164. /**
  83165. * Triggered when new babylon (transformed) hit test results are available
  83166. * Note - this will be called when results come back from the device. It can be an empty array!!
  83167. */
  83168. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  83169. /**
  83170. * Use this to temporarily pause hit test checks.
  83171. */
  83172. paused: boolean;
  83173. /**
  83174. * Creates a new instance of the hit test feature
  83175. * @param _xrSessionManager an instance of WebXRSessionManager
  83176. * @param options options to use when constructing this feature
  83177. */
  83178. constructor(_xrSessionManager: WebXRSessionManager,
  83179. /**
  83180. * options to use when constructing this feature
  83181. */
  83182. options?: IWebXRHitTestOptions);
  83183. /**
  83184. * attach this feature
  83185. * Will usually be called by the features manager
  83186. *
  83187. * @returns true if successful.
  83188. */
  83189. attach(): boolean;
  83190. /**
  83191. * detach this feature.
  83192. * Will usually be called by the features manager
  83193. *
  83194. * @returns true if successful.
  83195. */
  83196. detach(): boolean;
  83197. /**
  83198. * Dispose this feature and all of the resources attached
  83199. */
  83200. dispose(): void;
  83201. protected _onXRFrame(frame: XRFrame): void;
  83202. private _processWebXRHitTestResult;
  83203. }
  83204. }
  83205. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  83206. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  83207. import { Observable } from "babylonjs/Misc/observable";
  83208. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  83209. import { TransformNode } from "babylonjs/Meshes/transformNode";
  83210. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  83211. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  83212. /**
  83213. * Configuration options of the anchor system
  83214. */
  83215. export interface IWebXRAnchorSystemOptions {
  83216. /**
  83217. * a node that will be used to convert local to world coordinates
  83218. */
  83219. worldParentNode?: TransformNode;
  83220. /**
  83221. * If set to true a reference of the created anchors will be kept until the next session starts
  83222. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  83223. */
  83224. doNotRemoveAnchorsOnSessionEnded?: boolean;
  83225. }
  83226. /**
  83227. * A babylon container for an XR Anchor
  83228. */
  83229. export interface IWebXRAnchor {
  83230. /**
  83231. * A babylon-assigned ID for this anchor
  83232. */
  83233. id: number;
  83234. /**
  83235. * Transformation matrix to apply to an object attached to this anchor
  83236. */
  83237. transformationMatrix: Matrix;
  83238. /**
  83239. * The native anchor object
  83240. */
  83241. xrAnchor: XRAnchor;
  83242. /**
  83243. * if defined, this object will be constantly updated by the anchor's position and rotation
  83244. */
  83245. attachedNode?: TransformNode;
  83246. /**
  83247. * Remove this anchor from the scene
  83248. */
  83249. remove(): void;
  83250. }
  83251. /**
  83252. * An implementation of the anchor system for WebXR.
  83253. * For further information see https://github.com/immersive-web/anchors/
  83254. */
  83255. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  83256. private _options;
  83257. private _lastFrameDetected;
  83258. private _trackedAnchors;
  83259. private _referenceSpaceForFrameAnchors;
  83260. private _futureAnchors;
  83261. /**
  83262. * The module's name
  83263. */
  83264. static readonly Name: string;
  83265. /**
  83266. * The (Babylon) version of this module.
  83267. * This is an integer representing the implementation version.
  83268. * This number does not correspond to the WebXR specs version
  83269. */
  83270. static readonly Version: number;
  83271. /**
  83272. * Observers registered here will be executed when a new anchor was added to the session
  83273. */
  83274. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  83275. /**
  83276. * Observers registered here will be executed when an anchor was removed from the session
  83277. */
  83278. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  83279. /**
  83280. * Observers registered here will be executed when an existing anchor updates
  83281. * This can execute N times every frame
  83282. */
  83283. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  83284. /**
  83285. * Set the reference space to use for anchor creation, when not using a hit test.
  83286. * Will default to the session's reference space if not defined
  83287. */
  83288. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  83289. /**
  83290. * constructs a new anchor system
  83291. * @param _xrSessionManager an instance of WebXRSessionManager
  83292. * @param _options configuration object for this feature
  83293. */
  83294. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  83295. private _tmpVector;
  83296. private _tmpQuaternion;
  83297. private _populateTmpTransformation;
  83298. /**
  83299. * Create a new anchor point using a hit test result at a specific point in the scene
  83300. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  83301. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  83302. *
  83303. * @param hitTestResult The hit test result to use for this anchor creation
  83304. * @param position an optional position offset for this anchor
  83305. * @param rotationQuaternion an optional rotation offset for this anchor
  83306. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  83307. */
  83308. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  83309. /**
  83310. * Add a new anchor at a specific position and rotation
  83311. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  83312. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  83313. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  83314. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  83315. *
  83316. * @param position the position in which to add an anchor
  83317. * @param rotationQuaternion an optional rotation for the anchor transformation
  83318. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  83319. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  83320. */
  83321. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  83322. /**
  83323. * Get the list of anchors currently being tracked by the system
  83324. */
  83325. get anchors(): IWebXRAnchor[];
  83326. /**
  83327. * detach this feature.
  83328. * Will usually be called by the features manager
  83329. *
  83330. * @returns true if successful.
  83331. */
  83332. detach(): boolean;
  83333. /**
  83334. * Dispose this feature and all of the resources attached
  83335. */
  83336. dispose(): void;
  83337. protected _onXRFrame(frame: XRFrame): void;
  83338. /**
  83339. * avoiding using Array.find for global support.
  83340. * @param xrAnchor the plane to find in the array
  83341. */
  83342. private _findIndexInAnchorArray;
  83343. private _updateAnchorWithXRFrame;
  83344. private _createAnchorAtTransformation;
  83345. }
  83346. }
  83347. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  83348. import { TransformNode } from "babylonjs/Meshes/transformNode";
  83349. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  83350. import { Observable } from "babylonjs/Misc/observable";
  83351. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  83352. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  83353. /**
  83354. * Options used in the plane detector module
  83355. */
  83356. export interface IWebXRPlaneDetectorOptions {
  83357. /**
  83358. * The node to use to transform the local results to world coordinates
  83359. */
  83360. worldParentNode?: TransformNode;
  83361. /**
  83362. * If set to true a reference of the created planes will be kept until the next session starts
  83363. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  83364. */
  83365. doNotRemovePlanesOnSessionEnded?: boolean;
  83366. /**
  83367. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  83368. */
  83369. preferredDetectorOptions?: XRGeometryDetectorOptions;
  83370. }
  83371. /**
  83372. * A babylon interface for a WebXR plane.
  83373. * A Plane is actually a polygon, built from N points in space
  83374. *
  83375. * Supported in chrome 79, not supported in canary 81 ATM
  83376. */
  83377. export interface IWebXRPlane {
  83378. /**
  83379. * a babylon-assigned ID for this polygon
  83380. */
  83381. id: number;
  83382. /**
  83383. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  83384. */
  83385. polygonDefinition: Array<Vector3>;
  83386. /**
  83387. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  83388. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  83389. */
  83390. transformationMatrix: Matrix;
  83391. /**
  83392. * the native xr-plane object
  83393. */
  83394. xrPlane: XRPlane;
  83395. }
  83396. /**
  83397. * The plane detector is used to detect planes in the real world when in AR
  83398. * For more information see https://github.com/immersive-web/real-world-geometry/
  83399. */
  83400. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  83401. private _options;
  83402. private _detectedPlanes;
  83403. private _enabled;
  83404. private _lastFrameDetected;
  83405. /**
  83406. * The module's name
  83407. */
  83408. static readonly Name: string;
  83409. /**
  83410. * The (Babylon) version of this module.
  83411. * This is an integer representing the implementation version.
  83412. * This number does not correspond to the WebXR specs version
  83413. */
  83414. static readonly Version: number;
  83415. /**
  83416. * Observers registered here will be executed when a new plane was added to the session
  83417. */
  83418. onPlaneAddedObservable: Observable<IWebXRPlane>;
  83419. /**
  83420. * Observers registered here will be executed when a plane is no longer detected in the session
  83421. */
  83422. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  83423. /**
  83424. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  83425. * This can execute N times every frame
  83426. */
  83427. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  83428. /**
  83429. * construct a new Plane Detector
  83430. * @param _xrSessionManager an instance of xr Session manager
  83431. * @param _options configuration to use when constructing this feature
  83432. */
  83433. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  83434. /**
  83435. * detach this feature.
  83436. * Will usually be called by the features manager
  83437. *
  83438. * @returns true if successful.
  83439. */
  83440. detach(): boolean;
  83441. /**
  83442. * Dispose this feature and all of the resources attached
  83443. */
  83444. dispose(): void;
  83445. /**
  83446. * Check if the needed objects are defined.
  83447. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  83448. */
  83449. isCompatible(): boolean;
  83450. protected _onXRFrame(frame: XRFrame): void;
  83451. private _init;
  83452. private _updatePlaneWithXRPlane;
  83453. /**
  83454. * avoiding using Array.find for global support.
  83455. * @param xrPlane the plane to find in the array
  83456. */
  83457. private _findIndexInPlaneArray;
  83458. }
  83459. }
  83460. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  83461. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  83462. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  83463. import { Observable } from "babylonjs/Misc/observable";
  83464. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  83465. /**
  83466. * Options interface for the background remover plugin
  83467. */
  83468. export interface IWebXRBackgroundRemoverOptions {
  83469. /**
  83470. * Further background meshes to disable when entering AR
  83471. */
  83472. backgroundMeshes?: AbstractMesh[];
  83473. /**
  83474. * flags to configure the removal of the environment helper.
  83475. * If not set, the entire background will be removed. If set, flags should be set as well.
  83476. */
  83477. environmentHelperRemovalFlags?: {
  83478. /**
  83479. * Should the skybox be removed (default false)
  83480. */
  83481. skyBox?: boolean;
  83482. /**
  83483. * Should the ground be removed (default false)
  83484. */
  83485. ground?: boolean;
  83486. };
  83487. /**
  83488. * don't disable the environment helper
  83489. */
  83490. ignoreEnvironmentHelper?: boolean;
  83491. }
  83492. /**
  83493. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  83494. */
  83495. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  83496. /**
  83497. * read-only options to be used in this module
  83498. */
  83499. readonly options: IWebXRBackgroundRemoverOptions;
  83500. /**
  83501. * The module's name
  83502. */
  83503. static readonly Name: string;
  83504. /**
  83505. * The (Babylon) version of this module.
  83506. * This is an integer representing the implementation version.
  83507. * This number does not correspond to the WebXR specs version
  83508. */
  83509. static readonly Version: number;
  83510. /**
  83511. * registered observers will be triggered when the background state changes
  83512. */
  83513. onBackgroundStateChangedObservable: Observable<boolean>;
  83514. /**
  83515. * constructs a new background remover module
  83516. * @param _xrSessionManager the session manager for this module
  83517. * @param options read-only options to be used in this module
  83518. */
  83519. constructor(_xrSessionManager: WebXRSessionManager,
  83520. /**
  83521. * read-only options to be used in this module
  83522. */
  83523. options?: IWebXRBackgroundRemoverOptions);
  83524. /**
  83525. * attach this feature
  83526. * Will usually be called by the features manager
  83527. *
  83528. * @returns true if successful.
  83529. */
  83530. attach(): boolean;
  83531. /**
  83532. * detach this feature.
  83533. * Will usually be called by the features manager
  83534. *
  83535. * @returns true if successful.
  83536. */
  83537. detach(): boolean;
  83538. /**
  83539. * Dispose this feature and all of the resources attached
  83540. */
  83541. dispose(): void;
  83542. protected _onXRFrame(_xrFrame: XRFrame): void;
  83543. private _setBackgroundState;
  83544. }
  83545. }
  83546. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  83547. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  83548. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  83549. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  83550. import { WebXRInput } from "babylonjs/XR/webXRInput";
  83551. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  83552. import { Nullable } from "babylonjs/types";
  83553. /**
  83554. * Options for the controller physics feature
  83555. */
  83556. export class IWebXRControllerPhysicsOptions {
  83557. /**
  83558. * Should the headset get its own impostor
  83559. */
  83560. enableHeadsetImpostor?: boolean;
  83561. /**
  83562. * Optional parameters for the headset impostor
  83563. */
  83564. headsetImpostorParams?: {
  83565. /**
  83566. * The type of impostor to create. Default is sphere
  83567. */
  83568. impostorType: number;
  83569. /**
  83570. * the size of the impostor. Defaults to 10cm
  83571. */
  83572. impostorSize?: number | {
  83573. width: number;
  83574. height: number;
  83575. depth: number;
  83576. };
  83577. /**
  83578. * Friction definitions
  83579. */
  83580. friction?: number;
  83581. /**
  83582. * Restitution
  83583. */
  83584. restitution?: number;
  83585. };
  83586. /**
  83587. * The physics properties of the future impostors
  83588. */
  83589. physicsProperties?: {
  83590. /**
  83591. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  83592. * Note that this requires a physics engine that supports mesh impostors!
  83593. */
  83594. useControllerMesh?: boolean;
  83595. /**
  83596. * The type of impostor to create. Default is sphere
  83597. */
  83598. impostorType?: number;
  83599. /**
  83600. * the size of the impostor. Defaults to 10cm
  83601. */
  83602. impostorSize?: number | {
  83603. width: number;
  83604. height: number;
  83605. depth: number;
  83606. };
  83607. /**
  83608. * Friction definitions
  83609. */
  83610. friction?: number;
  83611. /**
  83612. * Restitution
  83613. */
  83614. restitution?: number;
  83615. };
  83616. /**
  83617. * the xr input to use with this pointer selection
  83618. */
  83619. xrInput: WebXRInput;
  83620. }
  83621. /**
  83622. * Add physics impostor to your webxr controllers,
  83623. * including naive calculation of their linear and angular velocity
  83624. */
  83625. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  83626. private readonly _options;
  83627. private _attachController;
  83628. private _controllers;
  83629. private _debugMode;
  83630. private _delta;
  83631. private _headsetImpostor?;
  83632. private _headsetMesh?;
  83633. private _lastTimestamp;
  83634. private _tmpQuaternion;
  83635. private _tmpVector;
  83636. /**
  83637. * The module's name
  83638. */
  83639. static readonly Name: string;
  83640. /**
  83641. * The (Babylon) version of this module.
  83642. * This is an integer representing the implementation version.
  83643. * This number does not correspond to the webxr specs version
  83644. */
  83645. static readonly Version: number;
  83646. /**
  83647. * Construct a new Controller Physics Feature
  83648. * @param _xrSessionManager the corresponding xr session manager
  83649. * @param _options options to create this feature with
  83650. */
  83651. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  83652. /**
  83653. * @hidden
  83654. * enable debugging - will show console outputs and the impostor mesh
  83655. */
  83656. _enablePhysicsDebug(): void;
  83657. /**
  83658. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  83659. * @param xrController the controller to add
  83660. */
  83661. addController(xrController: WebXRInputSource): void;
  83662. /**
  83663. * attach this feature
  83664. * Will usually be called by the features manager
  83665. *
  83666. * @returns true if successful.
  83667. */
  83668. attach(): boolean;
  83669. /**
  83670. * detach this feature.
  83671. * Will usually be called by the features manager
  83672. *
  83673. * @returns true if successful.
  83674. */
  83675. detach(): boolean;
  83676. /**
  83677. * Get the headset impostor, if enabled
  83678. * @returns the impostor
  83679. */
  83680. getHeadsetImpostor(): PhysicsImpostor | undefined;
  83681. /**
  83682. * Get the physics impostor of a specific controller.
  83683. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  83684. * @param controller the controller or the controller id of which to get the impostor
  83685. * @returns the impostor or null
  83686. */
  83687. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  83688. /**
  83689. * Update the physics properties provided in the constructor
  83690. * @param newProperties the new properties object
  83691. */
  83692. setPhysicsProperties(newProperties: {
  83693. impostorType?: number;
  83694. impostorSize?: number | {
  83695. width: number;
  83696. height: number;
  83697. depth: number;
  83698. };
  83699. friction?: number;
  83700. restitution?: number;
  83701. }): void;
  83702. protected _onXRFrame(_xrFrame: any): void;
  83703. private _detachController;
  83704. }
  83705. }
  83706. declare module "babylonjs/XR/features/WebXRFeaturePointSystem" {
  83707. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  83708. import { Observable } from "babylonjs/Misc/observable";
  83709. import { Vector3 } from "babylonjs/Maths/math.vector";
  83710. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  83711. /**
  83712. * A babylon interface for a "WebXR" feature point.
  83713. * Represents the position and confidence value of a given feature point.
  83714. */
  83715. export interface IWebXRFeaturePoint {
  83716. /**
  83717. * Represents the position of the feature point in world space.
  83718. */
  83719. position: Vector3;
  83720. /**
  83721. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  83722. */
  83723. confidenceValue: number;
  83724. }
  83725. /**
  83726. * The feature point system is used to detect feature points from real world geometry.
  83727. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  83728. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  83729. */
  83730. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  83731. private _enabled;
  83732. private _featurePointCloud;
  83733. /**
  83734. * The module's name
  83735. */
  83736. static readonly Name: string;
  83737. /**
  83738. * The (Babylon) version of this module.
  83739. * This is an integer representing the implementation version.
  83740. * This number does not correspond to the WebXR specs version
  83741. */
  83742. static readonly Version: number;
  83743. /**
  83744. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  83745. * Will notify the observers about which feature points have been added.
  83746. */
  83747. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  83748. /**
  83749. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  83750. * Will notify the observers about which feature points have been updated.
  83751. */
  83752. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  83753. /**
  83754. * The current feature point cloud maintained across frames.
  83755. */
  83756. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  83757. /**
  83758. * construct the feature point system
  83759. * @param _xrSessionManager an instance of xr Session manager
  83760. */
  83761. constructor(_xrSessionManager: WebXRSessionManager);
  83762. /**
  83763. * Detach this feature.
  83764. * Will usually be called by the features manager
  83765. *
  83766. * @returns true if successful.
  83767. */
  83768. detach(): boolean;
  83769. /**
  83770. * Dispose this feature and all of the resources attached
  83771. */
  83772. dispose(): void;
  83773. /**
  83774. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  83775. */
  83776. protected _onXRFrame(frame: XRFrame): void;
  83777. /**
  83778. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  83779. */
  83780. private _init;
  83781. }
  83782. }
  83783. declare module "babylonjs/XR/features/WebXRHandTracking" {
  83784. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  83785. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  83786. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  83787. import { Mesh } from "babylonjs/Meshes/mesh";
  83788. import { WebXRInput } from "babylonjs/XR/webXRInput";
  83789. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  83790. import { Nullable } from "babylonjs/types";
  83791. import { IDisposable } from "babylonjs/scene";
  83792. import { Observable } from "babylonjs/Misc/observable";
  83793. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  83794. /**
  83795. * Configuration interface for the hand tracking feature
  83796. */
  83797. export interface IWebXRHandTrackingOptions {
  83798. /**
  83799. * The xrInput that will be used as source for new hands
  83800. */
  83801. xrInput: WebXRInput;
  83802. /**
  83803. * Configuration object for the joint meshes
  83804. */
  83805. jointMeshes?: {
  83806. /**
  83807. * Should the meshes created be invisible (defaults to false)
  83808. */
  83809. invisible?: boolean;
  83810. /**
  83811. * A source mesh to be used to create instances. Defaults to a sphere.
  83812. * This mesh will be the source for all other (25) meshes.
  83813. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  83814. */
  83815. sourceMesh?: Mesh;
  83816. /**
  83817. * This function will be called after a mesh was created for a specific joint.
  83818. * Using this function you can either manipulate the instance or return a new mesh.
  83819. * When returning a new mesh the instance created before will be disposed
  83820. */
  83821. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  83822. /**
  83823. * Should the source mesh stay visible. Defaults to false
  83824. */
  83825. keepOriginalVisible?: boolean;
  83826. /**
  83827. * Scale factor for all instances (defaults to 2)
  83828. */
  83829. scaleFactor?: number;
  83830. /**
  83831. * Should each instance have its own physics impostor
  83832. */
  83833. enablePhysics?: boolean;
  83834. /**
  83835. * If enabled, override default physics properties
  83836. */
  83837. physicsProps?: {
  83838. friction?: number;
  83839. restitution?: number;
  83840. impostorType?: number;
  83841. };
  83842. /**
  83843. * Should the default hand mesh be disabled. In this case, the spheres will be visible (unless set invisible).
  83844. */
  83845. disableDefaultHandMesh?: boolean;
  83846. /**
  83847. * a rigged hand-mesh that will be updated according to the XRHand data provided. This will override the default hand mesh
  83848. */
  83849. handMeshes?: {
  83850. right: AbstractMesh;
  83851. left: AbstractMesh;
  83852. };
  83853. /**
  83854. * If a hand mesh was provided, this array will define what axis will update which node. This will override the default hand mesh
  83855. */
  83856. rigMapping?: {
  83857. right: string[];
  83858. left: string[];
  83859. };
  83860. };
  83861. }
  83862. /**
  83863. * Parts of the hands divided to writs and finger names
  83864. */
  83865. export const enum HandPart {
  83866. /**
  83867. * HandPart - Wrist
  83868. */
  83869. WRIST = "wrist",
  83870. /**
  83871. * HandPart - The THumb
  83872. */
  83873. THUMB = "thumb",
  83874. /**
  83875. * HandPart - Index finger
  83876. */
  83877. INDEX = "index",
  83878. /**
  83879. * HandPart - Middle finger
  83880. */
  83881. MIDDLE = "middle",
  83882. /**
  83883. * HandPart - Ring finger
  83884. */
  83885. RING = "ring",
  83886. /**
  83887. * HandPart - Little finger
  83888. */
  83889. LITTLE = "little"
  83890. }
  83891. /**
  83892. * Representing a single hand (with its corresponding native XRHand object)
  83893. */
  83894. export class WebXRHand implements IDisposable {
  83895. /** the controller to which the hand correlates */
  83896. readonly xrController: WebXRInputSource;
  83897. /** the meshes to be used to track the hand joints */
  83898. readonly trackedMeshes: AbstractMesh[];
  83899. private _handMesh?;
  83900. private _rigMapping?;
  83901. private _scene;
  83902. private _defaultHandMesh;
  83903. private _transformNodeMapping;
  83904. /**
  83905. * Hand-parts definition (key is HandPart)
  83906. */
  83907. handPartsDefinition: {
  83908. [key: string]: number[];
  83909. };
  83910. /**
  83911. * Observers will be triggered when the mesh for this hand was initialized.
  83912. */
  83913. onHandMeshReadyObservable: Observable<WebXRHand>;
  83914. /**
  83915. * Populate the HandPartsDefinition object.
  83916. * This is called as a side effect since certain browsers don't have XRHand defined.
  83917. */
  83918. private generateHandPartsDefinition;
  83919. /**
  83920. * Construct a new hand object
  83921. * @param xrController the controller to which the hand correlates
  83922. * @param trackedMeshes the meshes to be used to track the hand joints
  83923. * @param _handMesh an optional hand mesh. if not provided, ours will be used
  83924. * @param _rigMapping an optional rig mapping for the hand mesh. if not provided, ours will be used
  83925. * @param disableDefaultHandMesh should the default mesh creation be disabled
  83926. */
  83927. constructor(
  83928. /** the controller to which the hand correlates */
  83929. xrController: WebXRInputSource,
  83930. /** the meshes to be used to track the hand joints */
  83931. trackedMeshes: AbstractMesh[], _handMesh?: AbstractMesh | undefined, _rigMapping?: string[] | undefined, disableDefaultHandMesh?: boolean);
  83932. /**
  83933. * Get the hand mesh. It is possible that the hand mesh is not yet ready!
  83934. */
  83935. get handMesh(): AbstractMesh | undefined;
  83936. /**
  83937. * Update this hand from the latest xr frame
  83938. * @param xrFrame xrFrame to update from
  83939. * @param referenceSpace The current viewer reference space
  83940. * @param scaleFactor optional scale factor for the meshes
  83941. */
  83942. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  83943. /**
  83944. * Get meshes of part of the hand
  83945. * @param part the part of hand to get
  83946. * @returns An array of meshes that correlate to the hand part requested
  83947. */
  83948. getHandPartMeshes(part: HandPart): AbstractMesh[];
  83949. /**
  83950. * Dispose this Hand object
  83951. */
  83952. dispose(): void;
  83953. private _generateDefaultHandMesh;
  83954. }
  83955. /**
  83956. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  83957. */
  83958. export class WebXRHandTracking extends WebXRAbstractFeature {
  83959. /**
  83960. * options to use when constructing this feature
  83961. */
  83962. readonly options: IWebXRHandTrackingOptions;
  83963. private static _idCounter;
  83964. /**
  83965. * The module's name
  83966. */
  83967. static readonly Name: string;
  83968. /**
  83969. * The (Babylon) version of this module.
  83970. * This is an integer representing the implementation version.
  83971. * This number does not correspond to the WebXR specs version
  83972. */
  83973. static readonly Version: number;
  83974. /**
  83975. * This observable will notify registered observers when a new hand object was added and initialized
  83976. */
  83977. onHandAddedObservable: Observable<WebXRHand>;
  83978. /**
  83979. * This observable will notify its observers right before the hand object is disposed
  83980. */
  83981. onHandRemovedObservable: Observable<WebXRHand>;
  83982. private _hands;
  83983. /**
  83984. * Creates a new instance of the hit test feature
  83985. * @param _xrSessionManager an instance of WebXRSessionManager
  83986. * @param options options to use when constructing this feature
  83987. */
  83988. constructor(_xrSessionManager: WebXRSessionManager,
  83989. /**
  83990. * options to use when constructing this feature
  83991. */
  83992. options: IWebXRHandTrackingOptions);
  83993. /**
  83994. * Check if the needed objects are defined.
  83995. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  83996. */
  83997. isCompatible(): boolean;
  83998. /**
  83999. * attach this feature
  84000. * Will usually be called by the features manager
  84001. *
  84002. * @returns true if successful.
  84003. */
  84004. attach(): boolean;
  84005. /**
  84006. * detach this feature.
  84007. * Will usually be called by the features manager
  84008. *
  84009. * @returns true if successful.
  84010. */
  84011. detach(): boolean;
  84012. /**
  84013. * Dispose this feature and all of the resources attached
  84014. */
  84015. dispose(): void;
  84016. /**
  84017. * Get the hand object according to the controller id
  84018. * @param controllerId the controller id to which we want to get the hand
  84019. * @returns null if not found or the WebXRHand object if found
  84020. */
  84021. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  84022. /**
  84023. * Get a hand object according to the requested handedness
  84024. * @param handedness the handedness to request
  84025. * @returns null if not found or the WebXRHand object if found
  84026. */
  84027. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  84028. protected _onXRFrame(_xrFrame: XRFrame): void;
  84029. private _attachHand;
  84030. private _detachHand;
  84031. }
  84032. }
  84033. declare module "babylonjs/XR/features/WebXRMeshDetector" {
  84034. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  84035. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  84036. import { TransformNode } from "babylonjs/Meshes/transformNode";
  84037. import { Matrix } from "babylonjs/Maths/math";
  84038. import { Observable } from "babylonjs/Misc/observable";
  84039. /**
  84040. * Options used in the mesh detector module
  84041. */
  84042. export interface IWebXRMeshDetectorOptions {
  84043. /**
  84044. * The node to use to transform the local results to world coordinates
  84045. */
  84046. worldParentNode?: TransformNode;
  84047. /**
  84048. * If set to true a reference of the created meshes will be kept until the next session starts
  84049. * If not defined, meshes will be removed from the array when the feature is detached or the session ended.
  84050. */
  84051. doNotRemoveMeshesOnSessionEnded?: boolean;
  84052. /**
  84053. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  84054. */
  84055. preferredDetectorOptions?: XRGeometryDetectorOptions;
  84056. /**
  84057. * If set to true, WebXRMeshDetector will convert coordinate systems for meshes.
  84058. * If not defined, mesh conversions from right handed to left handed coordinate systems won't be conducted.
  84059. * Right handed mesh data will be available through IWebXRVertexData.xrMesh.
  84060. */
  84061. convertCoordinateSystems?: boolean;
  84062. }
  84063. /**
  84064. * A babylon interface for a XR mesh's vertex data.
  84065. *
  84066. * Currently not supported by WebXR, available only with BabylonNative
  84067. */
  84068. export interface IWebXRVertexData {
  84069. /**
  84070. * A babylon-assigned ID for this mesh
  84071. */
  84072. id: number;
  84073. /**
  84074. * Data required for constructing a mesh in Babylon.js.
  84075. */
  84076. xrMesh: XRMesh;
  84077. /**
  84078. * The node to use to transform the local results to world coordinates.
  84079. * WorldParentNode will only exist if it was declared in the IWebXRMeshDetectorOptions.
  84080. */
  84081. worldParentNode?: TransformNode;
  84082. /**
  84083. * An array of vertex positions in babylon space. right/left hand system is taken into account.
  84084. * Positions will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  84085. */
  84086. positions?: Float32Array;
  84087. /**
  84088. * An array of indices in babylon space. right/left hand system is taken into account.
  84089. * Indices will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  84090. */
  84091. indices?: Uint32Array;
  84092. /**
  84093. * An array of vertex normals in babylon space. right/left hand system is taken into account.
  84094. * Normals will not be calculated if convertCoordinateSystems is undefined in the IWebXRMeshDetectorOptions.
  84095. * Different platforms may or may not support mesh normals when convertCoordinateSystems is set to true.
  84096. */
  84097. normals?: Float32Array;
  84098. /**
  84099. * A transformation matrix to apply on the mesh that will be built using the meshDefinition.
  84100. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module.
  84101. * TransformationMatrix will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  84102. */
  84103. transformationMatrix?: Matrix;
  84104. }
  84105. /**
  84106. * The mesh detector is used to detect meshes in the real world when in AR
  84107. */
  84108. export class WebXRMeshDetector extends WebXRAbstractFeature {
  84109. private _options;
  84110. private _detectedMeshes;
  84111. /**
  84112. * The module's name
  84113. */
  84114. static readonly Name: string;
  84115. /**
  84116. * The (Babylon) version of this module.
  84117. * This is an integer representing the implementation version.
  84118. * This number does not correspond to the WebXR specs version
  84119. */
  84120. static readonly Version: number;
  84121. /**
  84122. * Observers registered here will be executed when a new mesh was added to the session
  84123. */
  84124. onMeshAddedObservable: Observable<IWebXRVertexData>;
  84125. /**
  84126. * Observers registered here will be executed when a mesh is no longer detected in the session
  84127. */
  84128. onMeshRemovedObservable: Observable<IWebXRVertexData>;
  84129. /**
  84130. * Observers registered here will be executed when an existing mesh updates
  84131. */
  84132. onMeshUpdatedObservable: Observable<IWebXRVertexData>;
  84133. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRMeshDetectorOptions);
  84134. detach(): boolean;
  84135. dispose(): void;
  84136. protected _onXRFrame(frame: XRFrame): void;
  84137. private _init;
  84138. private _updateVertexDataWithXRMesh;
  84139. }
  84140. }
  84141. declare module "babylonjs/XR/features/index" {
  84142. export * from "babylonjs/XR/features/WebXRAbstractFeature";
  84143. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  84144. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  84145. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  84146. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  84147. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  84148. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  84149. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  84150. export * from "babylonjs/XR/features/WebXRHitTest";
  84151. export * from "babylonjs/XR/features/WebXRFeaturePointSystem";
  84152. export * from "babylonjs/XR/features/WebXRHandTracking";
  84153. export * from "babylonjs/XR/features/WebXRMeshDetector";
  84154. }
  84155. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  84156. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  84157. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  84158. import { Scene } from "babylonjs/scene";
  84159. /**
  84160. * The motion controller class for all microsoft mixed reality controllers
  84161. */
  84162. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  84163. protected readonly _mapping: {
  84164. defaultButton: {
  84165. valueNodeName: string;
  84166. unpressedNodeName: string;
  84167. pressedNodeName: string;
  84168. };
  84169. defaultAxis: {
  84170. valueNodeName: string;
  84171. minNodeName: string;
  84172. maxNodeName: string;
  84173. };
  84174. buttons: {
  84175. "xr-standard-trigger": {
  84176. rootNodeName: string;
  84177. componentProperty: string;
  84178. states: string[];
  84179. };
  84180. "xr-standard-squeeze": {
  84181. rootNodeName: string;
  84182. componentProperty: string;
  84183. states: string[];
  84184. };
  84185. "xr-standard-touchpad": {
  84186. rootNodeName: string;
  84187. labelAnchorNodeName: string;
  84188. touchPointNodeName: string;
  84189. };
  84190. "xr-standard-thumbstick": {
  84191. rootNodeName: string;
  84192. componentProperty: string;
  84193. states: string[];
  84194. };
  84195. };
  84196. axes: {
  84197. "xr-standard-touchpad": {
  84198. "x-axis": {
  84199. rootNodeName: string;
  84200. };
  84201. "y-axis": {
  84202. rootNodeName: string;
  84203. };
  84204. };
  84205. "xr-standard-thumbstick": {
  84206. "x-axis": {
  84207. rootNodeName: string;
  84208. };
  84209. "y-axis": {
  84210. rootNodeName: string;
  84211. };
  84212. };
  84213. };
  84214. };
  84215. /**
  84216. * The base url used to load the left and right controller models
  84217. */
  84218. static MODEL_BASE_URL: string;
  84219. /**
  84220. * The name of the left controller model file
  84221. */
  84222. static MODEL_LEFT_FILENAME: string;
  84223. /**
  84224. * The name of the right controller model file
  84225. */
  84226. static MODEL_RIGHT_FILENAME: string;
  84227. profileId: string;
  84228. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  84229. protected _getFilenameAndPath(): {
  84230. filename: string;
  84231. path: string;
  84232. };
  84233. protected _getModelLoadingConstraints(): boolean;
  84234. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  84235. protected _setRootMesh(meshes: AbstractMesh[]): void;
  84236. protected _updateModel(): void;
  84237. }
  84238. }
  84239. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  84240. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  84241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  84242. import { Scene } from "babylonjs/scene";
  84243. /**
  84244. * The motion controller class for oculus touch (quest, rift).
  84245. * This class supports legacy mapping as well the standard xr mapping
  84246. */
  84247. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  84248. private _forceLegacyControllers;
  84249. private _modelRootNode;
  84250. /**
  84251. * The base url used to load the left and right controller models
  84252. */
  84253. static MODEL_BASE_URL: string;
  84254. /**
  84255. * The name of the left controller model file
  84256. */
  84257. static MODEL_LEFT_FILENAME: string;
  84258. /**
  84259. * The name of the right controller model file
  84260. */
  84261. static MODEL_RIGHT_FILENAME: string;
  84262. /**
  84263. * Base Url for the Quest controller model.
  84264. */
  84265. static QUEST_MODEL_BASE_URL: string;
  84266. profileId: string;
  84267. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  84268. protected _getFilenameAndPath(): {
  84269. filename: string;
  84270. path: string;
  84271. };
  84272. protected _getModelLoadingConstraints(): boolean;
  84273. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  84274. protected _setRootMesh(meshes: AbstractMesh[]): void;
  84275. protected _updateModel(): void;
  84276. /**
  84277. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  84278. * between the touch and touch 2.
  84279. */
  84280. private _isQuest;
  84281. }
  84282. }
  84283. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  84284. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  84285. import { Scene } from "babylonjs/scene";
  84286. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  84287. /**
  84288. * The motion controller class for the standard HTC-Vive controllers
  84289. */
  84290. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  84291. private _modelRootNode;
  84292. /**
  84293. * The base url used to load the left and right controller models
  84294. */
  84295. static MODEL_BASE_URL: string;
  84296. /**
  84297. * File name for the controller model.
  84298. */
  84299. static MODEL_FILENAME: string;
  84300. profileId: string;
  84301. /**
  84302. * Create a new Vive motion controller object
  84303. * @param scene the scene to use to create this controller
  84304. * @param gamepadObject the corresponding gamepad object
  84305. * @param handedness the handedness of the controller
  84306. */
  84307. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  84308. protected _getFilenameAndPath(): {
  84309. filename: string;
  84310. path: string;
  84311. };
  84312. protected _getModelLoadingConstraints(): boolean;
  84313. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  84314. protected _setRootMesh(meshes: AbstractMesh[]): void;
  84315. protected _updateModel(): void;
  84316. }
  84317. }
  84318. declare module "babylonjs/XR/motionController/index" {
  84319. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  84320. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  84321. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  84322. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  84323. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  84324. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  84325. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  84326. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  84327. }
  84328. declare module "babylonjs/XR/index" {
  84329. export * from "babylonjs/XR/webXRCamera";
  84330. export * from "babylonjs/XR/webXREnterExitUI";
  84331. export * from "babylonjs/XR/webXRExperienceHelper";
  84332. export * from "babylonjs/XR/webXRInput";
  84333. export * from "babylonjs/XR/webXRInputSource";
  84334. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  84335. export * from "babylonjs/XR/webXRTypes";
  84336. export * from "babylonjs/XR/webXRSessionManager";
  84337. export * from "babylonjs/XR/webXRDefaultExperience";
  84338. export * from "babylonjs/XR/webXRFeaturesManager";
  84339. export * from "babylonjs/XR/features/index";
  84340. export * from "babylonjs/XR/motionController/index";
  84341. }
  84342. declare module "babylonjs/index" {
  84343. export * from "babylonjs/abstractScene";
  84344. export * from "babylonjs/Actions/index";
  84345. export * from "babylonjs/Animations/index";
  84346. export * from "babylonjs/assetContainer";
  84347. export * from "babylonjs/Audio/index";
  84348. export * from "babylonjs/Behaviors/index";
  84349. export * from "babylonjs/Bones/index";
  84350. export * from "babylonjs/Cameras/index";
  84351. export * from "babylonjs/Collisions/index";
  84352. export * from "babylonjs/Culling/index";
  84353. export * from "babylonjs/Debug/index";
  84354. export * from "babylonjs/DeviceInput/index";
  84355. export * from "babylonjs/Engines/index";
  84356. export * from "babylonjs/Events/index";
  84357. export * from "babylonjs/Gamepads/index";
  84358. export * from "babylonjs/Gizmos/index";
  84359. export * from "babylonjs/Helpers/index";
  84360. export * from "babylonjs/Instrumentation/index";
  84361. export * from "babylonjs/Layers/index";
  84362. export * from "babylonjs/LensFlares/index";
  84363. export * from "babylonjs/Lights/index";
  84364. export * from "babylonjs/Loading/index";
  84365. export * from "babylonjs/Materials/index";
  84366. export * from "babylonjs/Maths/index";
  84367. export * from "babylonjs/Meshes/index";
  84368. export * from "babylonjs/Morph/index";
  84369. export * from "babylonjs/Navigation/index";
  84370. export * from "babylonjs/node";
  84371. export * from "babylonjs/Offline/index";
  84372. export * from "babylonjs/Particles/index";
  84373. export * from "babylonjs/Physics/index";
  84374. export * from "babylonjs/PostProcesses/index";
  84375. export * from "babylonjs/Probes/index";
  84376. export * from "babylonjs/Rendering/index";
  84377. export * from "babylonjs/scene";
  84378. export * from "babylonjs/sceneComponent";
  84379. export * from "babylonjs/Sprites/index";
  84380. export * from "babylonjs/States/index";
  84381. export * from "babylonjs/Misc/index";
  84382. export * from "babylonjs/XR/index";
  84383. export * from "babylonjs/types";
  84384. }
  84385. declare module "babylonjs/Animations/pathCursor" {
  84386. import { Vector3 } from "babylonjs/Maths/math.vector";
  84387. import { Path2 } from "babylonjs/Maths/math.path";
  84388. /**
  84389. * A cursor which tracks a point on a path
  84390. */
  84391. export class PathCursor {
  84392. private path;
  84393. /**
  84394. * Stores path cursor callbacks for when an onchange event is triggered
  84395. */
  84396. private _onchange;
  84397. /**
  84398. * The value of the path cursor
  84399. */
  84400. value: number;
  84401. /**
  84402. * The animation array of the path cursor
  84403. */
  84404. animations: Animation[];
  84405. /**
  84406. * Initializes the path cursor
  84407. * @param path The path to track
  84408. */
  84409. constructor(path: Path2);
  84410. /**
  84411. * Gets the cursor point on the path
  84412. * @returns A point on the path cursor at the cursor location
  84413. */
  84414. getPoint(): Vector3;
  84415. /**
  84416. * Moves the cursor ahead by the step amount
  84417. * @param step The amount to move the cursor forward
  84418. * @returns This path cursor
  84419. */
  84420. moveAhead(step?: number): PathCursor;
  84421. /**
  84422. * Moves the cursor behind by the step amount
  84423. * @param step The amount to move the cursor back
  84424. * @returns This path cursor
  84425. */
  84426. moveBack(step?: number): PathCursor;
  84427. /**
  84428. * Moves the cursor by the step amount
  84429. * If the step amount is greater than one, an exception is thrown
  84430. * @param step The amount to move the cursor
  84431. * @returns This path cursor
  84432. */
  84433. move(step: number): PathCursor;
  84434. /**
  84435. * Ensures that the value is limited between zero and one
  84436. * @returns This path cursor
  84437. */
  84438. private ensureLimits;
  84439. /**
  84440. * Runs onchange callbacks on change (used by the animation engine)
  84441. * @returns This path cursor
  84442. */
  84443. private raiseOnChange;
  84444. /**
  84445. * Executes a function on change
  84446. * @param f A path cursor onchange callback
  84447. * @returns This path cursor
  84448. */
  84449. onchange(f: (cursor: PathCursor) => void): PathCursor;
  84450. }
  84451. }
  84452. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  84453. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  84454. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  84455. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  84456. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  84457. }
  84458. declare module "babylonjs/Engines/Processors/Expressions/index" {
  84459. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  84460. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  84461. }
  84462. declare module "babylonjs/Engines/Processors/index" {
  84463. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  84464. export * from "babylonjs/Engines/Processors/Expressions/index";
  84465. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  84466. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  84467. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  84468. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  84469. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  84470. export * from "babylonjs/Engines/Processors/shaderProcessor";
  84471. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  84472. }
  84473. declare module "babylonjs/Legacy/legacy" {
  84474. import * as Babylon from "babylonjs/index";
  84475. export * from "babylonjs/index";
  84476. }
  84477. declare module "babylonjs/Shaders/blur.fragment" {
  84478. /** @hidden */
  84479. export var blurPixelShader: {
  84480. name: string;
  84481. shader: string;
  84482. };
  84483. }
  84484. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  84485. /** @hidden */
  84486. export var pointCloudVertexDeclaration: {
  84487. name: string;
  84488. shader: string;
  84489. };
  84490. }
  84491. declare module "babylonjs" {
  84492. export * from "babylonjs/Legacy/legacy";
  84493. }
  84494. declare module BABYLON {
  84495. /** Alias type for value that can be null */
  84496. export type Nullable<T> = T | null;
  84497. /**
  84498. * Alias type for number that are floats
  84499. * @ignorenaming
  84500. */
  84501. export type float = number;
  84502. /**
  84503. * Alias type for number that are doubles.
  84504. * @ignorenaming
  84505. */
  84506. export type double = number;
  84507. /**
  84508. * Alias type for number that are integer
  84509. * @ignorenaming
  84510. */
  84511. export type int = number;
  84512. /** Alias type for number array or Float32Array */
  84513. export type FloatArray = number[] | Float32Array;
  84514. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  84515. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  84516. /**
  84517. * Alias for types that can be used by a Buffer or VertexBuffer.
  84518. */
  84519. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  84520. /**
  84521. * Alias type for primitive types
  84522. * @ignorenaming
  84523. */
  84524. type Primitive = undefined | null | boolean | string | number | Function;
  84525. /**
  84526. * Type modifier to make all the properties of an object Readonly
  84527. */
  84528. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  84529. /**
  84530. * Type modifier to make all the properties of an object Readonly recursively
  84531. */
  84532. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  84533. /**
  84534. * Type modifier to make object properties readonly.
  84535. */
  84536. export type DeepImmutableObject<T> = {
  84537. readonly [K in keyof T]: DeepImmutable<T[K]>;
  84538. };
  84539. /** @hidden */
  84540. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  84541. }
  84542. }
  84543. declare module BABYLON {
  84544. /**
  84545. * A class serves as a medium between the observable and its observers
  84546. */
  84547. export class EventState {
  84548. /**
  84549. * Create a new EventState
  84550. * @param mask defines the mask associated with this state
  84551. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  84552. * @param target defines the original target of the state
  84553. * @param currentTarget defines the current target of the state
  84554. */
  84555. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  84556. /**
  84557. * Initialize the current event state
  84558. * @param mask defines the mask associated with this state
  84559. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  84560. * @param target defines the original target of the state
  84561. * @param currentTarget defines the current target of the state
  84562. * @returns the current event state
  84563. */
  84564. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  84565. /**
  84566. * An Observer can set this property to true to prevent subsequent observers of being notified
  84567. */
  84568. skipNextObservers: boolean;
  84569. /**
  84570. * Get the mask value that were used to trigger the event corresponding to this EventState object
  84571. */
  84572. mask: number;
  84573. /**
  84574. * The object that originally notified the event
  84575. */
  84576. target?: any;
  84577. /**
  84578. * The current object in the bubbling phase
  84579. */
  84580. currentTarget?: any;
  84581. /**
  84582. * This will be populated with the return value of the last function that was executed.
  84583. * If it is the first function in the callback chain it will be the event data.
  84584. */
  84585. lastReturnValue?: any;
  84586. /**
  84587. * User defined information that will be sent to observers
  84588. */
  84589. userInfo?: any;
  84590. }
  84591. /**
  84592. * Represent an Observer registered to a given Observable object.
  84593. */
  84594. export class Observer<T> {
  84595. /**
  84596. * Defines the callback to call when the observer is notified
  84597. */
  84598. callback: (eventData: T, eventState: EventState) => void;
  84599. /**
  84600. * Defines the mask of the observer (used to filter notifications)
  84601. */
  84602. mask: number;
  84603. /**
  84604. * Defines the current scope used to restore the JS context
  84605. */
  84606. scope: any;
  84607. /** @hidden */
  84608. _willBeUnregistered: boolean;
  84609. /**
  84610. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  84611. */
  84612. unregisterOnNextCall: boolean;
  84613. /**
  84614. * Creates a new observer
  84615. * @param callback defines the callback to call when the observer is notified
  84616. * @param mask defines the mask of the observer (used to filter notifications)
  84617. * @param scope defines the current scope used to restore the JS context
  84618. */
  84619. constructor(
  84620. /**
  84621. * Defines the callback to call when the observer is notified
  84622. */
  84623. callback: (eventData: T, eventState: EventState) => void,
  84624. /**
  84625. * Defines the mask of the observer (used to filter notifications)
  84626. */
  84627. mask: number,
  84628. /**
  84629. * Defines the current scope used to restore the JS context
  84630. */
  84631. scope?: any);
  84632. }
  84633. /**
  84634. * Represent a list of observers registered to multiple Observables object.
  84635. */
  84636. export class MultiObserver<T> {
  84637. private _observers;
  84638. private _observables;
  84639. /**
  84640. * Release associated resources
  84641. */
  84642. dispose(): void;
  84643. /**
  84644. * Raise a callback when one of the observable will notify
  84645. * @param observables defines a list of observables to watch
  84646. * @param callback defines the callback to call on notification
  84647. * @param mask defines the mask used to filter notifications
  84648. * @param scope defines the current scope used to restore the JS context
  84649. * @returns the new MultiObserver
  84650. */
  84651. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  84652. }
  84653. /**
  84654. * The Observable class is a simple implementation of the Observable pattern.
  84655. *
  84656. * 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.
  84657. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  84658. * 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).
  84659. * 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.
  84660. */
  84661. export class Observable<T> {
  84662. private _observers;
  84663. private _eventState;
  84664. private _onObserverAdded;
  84665. /**
  84666. * Gets the list of observers
  84667. */
  84668. get observers(): Array<Observer<T>>;
  84669. /**
  84670. * Creates a new observable
  84671. * @param onObserverAdded defines a callback to call when a new observer is added
  84672. */
  84673. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  84674. /**
  84675. * Create a new Observer with the specified callback
  84676. * @param callback the callback that will be executed for that Observer
  84677. * @param mask the mask used to filter observers
  84678. * @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.
  84679. * @param scope optional scope for the callback to be called from
  84680. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  84681. * @returns the new observer created for the callback
  84682. */
  84683. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  84684. /**
  84685. * Create a new Observer with the specified callback and unregisters after the next notification
  84686. * @param callback the callback that will be executed for that Observer
  84687. * @returns the new observer created for the callback
  84688. */
  84689. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  84690. /**
  84691. * Remove an Observer from the Observable object
  84692. * @param observer the instance of the Observer to remove
  84693. * @returns false if it doesn't belong to this Observable
  84694. */
  84695. remove(observer: Nullable<Observer<T>>): boolean;
  84696. /**
  84697. * Remove a callback from the Observable object
  84698. * @param callback the callback to remove
  84699. * @param scope optional scope. If used only the callbacks with this scope will be removed
  84700. * @returns false if it doesn't belong to this Observable
  84701. */
  84702. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  84703. private _deferUnregister;
  84704. private _remove;
  84705. /**
  84706. * Moves the observable to the top of the observer list making it get called first when notified
  84707. * @param observer the observer to move
  84708. */
  84709. makeObserverTopPriority(observer: Observer<T>): void;
  84710. /**
  84711. * Moves the observable to the bottom of the observer list making it get called last when notified
  84712. * @param observer the observer to move
  84713. */
  84714. makeObserverBottomPriority(observer: Observer<T>): void;
  84715. /**
  84716. * Notify all Observers by calling their respective callback with the given data
  84717. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  84718. * @param eventData defines the data to send to all observers
  84719. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  84720. * @param target defines the original target of the state
  84721. * @param currentTarget defines the current target of the state
  84722. * @param userInfo defines any user info to send to observers
  84723. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  84724. */
  84725. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  84726. /**
  84727. * Calling this will execute each callback, expecting it to be a promise or return a value.
  84728. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  84729. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  84730. * and it is crucial that all callbacks will be executed.
  84731. * The order of the callbacks is kept, callbacks are not executed parallel.
  84732. *
  84733. * @param eventData The data to be sent to each callback
  84734. * @param mask is used to filter observers defaults to -1
  84735. * @param target defines the callback target (see EventState)
  84736. * @param currentTarget defines he current object in the bubbling phase
  84737. * @param userInfo defines any user info to send to observers
  84738. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  84739. */
  84740. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  84741. /**
  84742. * Notify a specific observer
  84743. * @param observer defines the observer to notify
  84744. * @param eventData defines the data to be sent to each callback
  84745. * @param mask is used to filter observers defaults to -1
  84746. */
  84747. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  84748. /**
  84749. * Gets a boolean indicating if the observable has at least one observer
  84750. * @returns true is the Observable has at least one Observer registered
  84751. */
  84752. hasObservers(): boolean;
  84753. /**
  84754. * Clear the list of observers
  84755. */
  84756. clear(): void;
  84757. /**
  84758. * Clone the current observable
  84759. * @returns a new observable
  84760. */
  84761. clone(): Observable<T>;
  84762. /**
  84763. * Does this observable handles observer registered with a given mask
  84764. * @param mask defines the mask to be tested
  84765. * @return whether or not one observer registered with the given mask is handeled
  84766. **/
  84767. hasSpecificMask(mask?: number): boolean;
  84768. }
  84769. }
  84770. declare module BABYLON {
  84771. /**
  84772. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  84773. * Babylon.js
  84774. */
  84775. export class DomManagement {
  84776. /**
  84777. * Checks if the window object exists
  84778. * @returns true if the window object exists
  84779. */
  84780. static IsWindowObjectExist(): boolean;
  84781. /**
  84782. * Checks if the navigator object exists
  84783. * @returns true if the navigator object exists
  84784. */
  84785. static IsNavigatorAvailable(): boolean;
  84786. /**
  84787. * Check if the document object exists
  84788. * @returns true if the document object exists
  84789. */
  84790. static IsDocumentAvailable(): boolean;
  84791. /**
  84792. * Extracts text content from a DOM element hierarchy
  84793. * @param element defines the root element
  84794. * @returns a string
  84795. */
  84796. static GetDOMTextContent(element: HTMLElement): string;
  84797. }
  84798. }
  84799. declare module BABYLON {
  84800. /**
  84801. * Logger used througouht the application to allow configuration of
  84802. * the log level required for the messages.
  84803. */
  84804. export class Logger {
  84805. /**
  84806. * No log
  84807. */
  84808. static readonly NoneLogLevel: number;
  84809. /**
  84810. * Only message logs
  84811. */
  84812. static readonly MessageLogLevel: number;
  84813. /**
  84814. * Only warning logs
  84815. */
  84816. static readonly WarningLogLevel: number;
  84817. /**
  84818. * Only error logs
  84819. */
  84820. static readonly ErrorLogLevel: number;
  84821. /**
  84822. * All logs
  84823. */
  84824. static readonly AllLogLevel: number;
  84825. /**
  84826. * Message to display when a message has been logged too many times
  84827. */
  84828. static MessageLimitReached: string;
  84829. private static _LogCache;
  84830. private static _LogLimitOutputs;
  84831. /**
  84832. * Gets a value indicating the number of loading errors
  84833. * @ignorenaming
  84834. */
  84835. static errorsCount: number;
  84836. /**
  84837. * Callback called when a new log is added
  84838. */
  84839. static OnNewCacheEntry: (entry: string) => void;
  84840. private static _CheckLimit;
  84841. private static _GenerateLimitMessage;
  84842. private static _AddLogEntry;
  84843. private static _FormatMessage;
  84844. private static _LogDisabled;
  84845. private static _LogEnabled;
  84846. private static _WarnDisabled;
  84847. private static _WarnEnabled;
  84848. private static _ErrorDisabled;
  84849. private static _ErrorEnabled;
  84850. /**
  84851. * Log a message to the console
  84852. */
  84853. static Log: (message: string, limit?: number) => void;
  84854. /**
  84855. * Write a warning message to the console
  84856. */
  84857. static Warn: (message: string, limit?: number) => void;
  84858. /**
  84859. * Write an error message to the console
  84860. */
  84861. static Error: (message: string, limit?: number) => void;
  84862. /**
  84863. * Gets current log cache (list of logs)
  84864. */
  84865. static get LogCache(): string;
  84866. /**
  84867. * Clears the log cache
  84868. */
  84869. static ClearLogCache(): void;
  84870. /**
  84871. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  84872. */
  84873. static set LogLevels(level: number);
  84874. }
  84875. }
  84876. declare module BABYLON {
  84877. /** @hidden */
  84878. export class _TypeStore {
  84879. /** @hidden */
  84880. static RegisteredTypes: {
  84881. [key: string]: Object;
  84882. };
  84883. /** @hidden */
  84884. static GetClass(fqdn: string): any;
  84885. }
  84886. }
  84887. declare module BABYLON {
  84888. /**
  84889. * Helper to manipulate strings
  84890. */
  84891. export class StringTools {
  84892. /**
  84893. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  84894. * @param str Source string
  84895. * @param suffix Suffix to search for in the source string
  84896. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  84897. */
  84898. static EndsWith(str: string, suffix: string): boolean;
  84899. /**
  84900. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  84901. * @param str Source string
  84902. * @param suffix Suffix to search for in the source string
  84903. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  84904. */
  84905. static StartsWith(str: string, suffix: string): boolean;
  84906. /**
  84907. * Decodes a buffer into a string
  84908. * @param buffer The buffer to decode
  84909. * @returns The decoded string
  84910. */
  84911. static Decode(buffer: Uint8Array | Uint16Array): string;
  84912. /**
  84913. * Encode a buffer to a base64 string
  84914. * @param buffer defines the buffer to encode
  84915. * @returns the encoded string
  84916. */
  84917. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  84918. /**
  84919. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  84920. * @param num the number to convert and pad
  84921. * @param length the expected length of the string
  84922. * @returns the padded string
  84923. */
  84924. static PadNumber(num: number, length: number): string;
  84925. }
  84926. }
  84927. declare module BABYLON {
  84928. /**
  84929. * Class containing a set of static utilities functions for deep copy.
  84930. */
  84931. export class DeepCopier {
  84932. /**
  84933. * Tries to copy an object by duplicating every property
  84934. * @param source defines the source object
  84935. * @param destination defines the target object
  84936. * @param doNotCopyList defines a list of properties to avoid
  84937. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  84938. */
  84939. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  84940. }
  84941. }
  84942. declare module BABYLON {
  84943. /**
  84944. * Class containing a set of static utilities functions for precision date
  84945. */
  84946. export class PrecisionDate {
  84947. /**
  84948. * Gets either window.performance.now() if supported or Date.now() else
  84949. */
  84950. static get Now(): number;
  84951. }
  84952. }
  84953. declare module BABYLON {
  84954. /** @hidden */
  84955. export class _DevTools {
  84956. static WarnImport(name: string): string;
  84957. }
  84958. }
  84959. declare module BABYLON {
  84960. /**
  84961. * Interface used to define the mechanism to get data from the network
  84962. */
  84963. export interface IWebRequest {
  84964. /**
  84965. * Returns client's response url
  84966. */
  84967. responseURL: string;
  84968. /**
  84969. * Returns client's status
  84970. */
  84971. status: number;
  84972. /**
  84973. * Returns client's status as a text
  84974. */
  84975. statusText: string;
  84976. }
  84977. }
  84978. declare module BABYLON {
  84979. /**
  84980. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  84981. */
  84982. export class WebRequest implements IWebRequest {
  84983. private readonly _xhr;
  84984. /**
  84985. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  84986. * i.e. when loading files, where the server/service expects an Authorization header
  84987. */
  84988. static CustomRequestHeaders: {
  84989. [key: string]: string;
  84990. };
  84991. /**
  84992. * Add callback functions in this array to update all the requests before they get sent to the network
  84993. */
  84994. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  84995. private _injectCustomRequestHeaders;
  84996. /**
  84997. * Gets or sets a function to be called when loading progress changes
  84998. */
  84999. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  85000. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  85001. /**
  85002. * Returns client's state
  85003. */
  85004. get readyState(): number;
  85005. /**
  85006. * Returns client's status
  85007. */
  85008. get status(): number;
  85009. /**
  85010. * Returns client's status as a text
  85011. */
  85012. get statusText(): string;
  85013. /**
  85014. * Returns client's response
  85015. */
  85016. get response(): any;
  85017. /**
  85018. * Returns client's response url
  85019. */
  85020. get responseURL(): string;
  85021. /**
  85022. * Returns client's response as text
  85023. */
  85024. get responseText(): string;
  85025. /**
  85026. * Gets or sets the expected response type
  85027. */
  85028. get responseType(): XMLHttpRequestResponseType;
  85029. set responseType(value: XMLHttpRequestResponseType);
  85030. /** @hidden */
  85031. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  85032. /** @hidden */
  85033. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  85034. /**
  85035. * Cancels any network activity
  85036. */
  85037. abort(): void;
  85038. /**
  85039. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  85040. * @param body defines an optional request body
  85041. */
  85042. send(body?: Document | BodyInit | null): void;
  85043. /**
  85044. * Sets the request method, request URL
  85045. * @param method defines the method to use (GET, POST, etc..)
  85046. * @param url defines the url to connect with
  85047. */
  85048. open(method: string, url: string): void;
  85049. /**
  85050. * Sets the value of a request header.
  85051. * @param name The name of the header whose value is to be set
  85052. * @param value The value to set as the body of the header
  85053. */
  85054. setRequestHeader(name: string, value: string): void;
  85055. /**
  85056. * Get the string containing the text of a particular header's value.
  85057. * @param name The name of the header
  85058. * @returns The string containing the text of the given header name
  85059. */
  85060. getResponseHeader(name: string): Nullable<string>;
  85061. }
  85062. }
  85063. declare module BABYLON {
  85064. /**
  85065. * File request interface
  85066. */
  85067. export interface IFileRequest {
  85068. /**
  85069. * Raised when the request is complete (success or error).
  85070. */
  85071. onCompleteObservable: Observable<IFileRequest>;
  85072. /**
  85073. * Aborts the request for a file.
  85074. */
  85075. abort: () => void;
  85076. }
  85077. }
  85078. declare module BABYLON {
  85079. /**
  85080. * Define options used to create a render target texture
  85081. */
  85082. export class RenderTargetCreationOptions {
  85083. /**
  85084. * Specifies if mipmaps must be created. If undefined, the value from generateMipMaps is taken instead
  85085. */
  85086. createMipMaps?: boolean;
  85087. /**
  85088. * Specifies if mipmaps must be generated
  85089. */
  85090. generateMipMaps?: boolean;
  85091. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  85092. generateDepthBuffer?: boolean;
  85093. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  85094. generateStencilBuffer?: boolean;
  85095. /** Defines texture type (int by default) */
  85096. type?: number;
  85097. /** Defines sampling mode (trilinear by default) */
  85098. samplingMode?: number;
  85099. /** Defines format (RGBA by default) */
  85100. format?: number;
  85101. /** Defines sample count (1 by default) */
  85102. samples?: number;
  85103. }
  85104. }
  85105. declare module BABYLON {
  85106. /** Defines the cross module used constants to avoid circular dependncies */
  85107. export class Constants {
  85108. /** Defines that alpha blending is disabled */
  85109. static readonly ALPHA_DISABLE: number;
  85110. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  85111. static readonly ALPHA_ADD: number;
  85112. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  85113. static readonly ALPHA_COMBINE: number;
  85114. /** Defines that alpha blending is DEST - SRC * DEST */
  85115. static readonly ALPHA_SUBTRACT: number;
  85116. /** Defines that alpha blending is SRC * DEST */
  85117. static readonly ALPHA_MULTIPLY: number;
  85118. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  85119. static readonly ALPHA_MAXIMIZED: number;
  85120. /** Defines that alpha blending is SRC + DEST */
  85121. static readonly ALPHA_ONEONE: number;
  85122. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  85123. static readonly ALPHA_PREMULTIPLIED: number;
  85124. /**
  85125. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  85126. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  85127. */
  85128. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  85129. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  85130. static readonly ALPHA_INTERPOLATE: number;
  85131. /**
  85132. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  85133. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  85134. */
  85135. static readonly ALPHA_SCREENMODE: number;
  85136. /**
  85137. * Defines that alpha blending is SRC + DST
  85138. * Alpha will be set to SRC ALPHA + DST ALPHA
  85139. */
  85140. static readonly ALPHA_ONEONE_ONEONE: number;
  85141. /**
  85142. * Defines that alpha blending is SRC * DST ALPHA + DST
  85143. * Alpha will be set to 0
  85144. */
  85145. static readonly ALPHA_ALPHATOCOLOR: number;
  85146. /**
  85147. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  85148. */
  85149. static readonly ALPHA_REVERSEONEMINUS: number;
  85150. /**
  85151. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  85152. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  85153. */
  85154. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  85155. /**
  85156. * Defines that alpha blending is SRC + DST
  85157. * Alpha will be set to SRC ALPHA
  85158. */
  85159. static readonly ALPHA_ONEONE_ONEZERO: number;
  85160. /**
  85161. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  85162. * Alpha will be set to DST ALPHA
  85163. */
  85164. static readonly ALPHA_EXCLUSION: number;
  85165. /** Defines that alpha blending equation a SUM */
  85166. static readonly ALPHA_EQUATION_ADD: number;
  85167. /** Defines that alpha blending equation a SUBSTRACTION */
  85168. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  85169. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  85170. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  85171. /** Defines that alpha blending equation a MAX operation */
  85172. static readonly ALPHA_EQUATION_MAX: number;
  85173. /** Defines that alpha blending equation a MIN operation */
  85174. static readonly ALPHA_EQUATION_MIN: number;
  85175. /**
  85176. * Defines that alpha blending equation a DARKEN operation:
  85177. * It takes the min of the src and sums the alpha channels.
  85178. */
  85179. static readonly ALPHA_EQUATION_DARKEN: number;
  85180. /** Defines that the ressource is not delayed*/
  85181. static readonly DELAYLOADSTATE_NONE: number;
  85182. /** Defines that the ressource was successfully delay loaded */
  85183. static readonly DELAYLOADSTATE_LOADED: number;
  85184. /** Defines that the ressource is currently delay loading */
  85185. static readonly DELAYLOADSTATE_LOADING: number;
  85186. /** Defines that the ressource is delayed and has not started loading */
  85187. static readonly DELAYLOADSTATE_NOTLOADED: number;
  85188. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  85189. static readonly NEVER: number;
  85190. /** 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 */
  85191. static readonly ALWAYS: number;
  85192. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  85193. static readonly LESS: number;
  85194. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  85195. static readonly EQUAL: number;
  85196. /** 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 */
  85197. static readonly LEQUAL: number;
  85198. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  85199. static readonly GREATER: number;
  85200. /** 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 */
  85201. static readonly GEQUAL: number;
  85202. /** 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 */
  85203. static readonly NOTEQUAL: number;
  85204. /** Passed to stencilOperation to specify that stencil value must be kept */
  85205. static readonly KEEP: number;
  85206. /** Passed to stencilOperation to specify that stencil value must be zero */
  85207. static readonly ZERO: number;
  85208. /** Passed to stencilOperation to specify that stencil value must be replaced */
  85209. static readonly REPLACE: number;
  85210. /** Passed to stencilOperation to specify that stencil value must be incremented */
  85211. static readonly INCR: number;
  85212. /** Passed to stencilOperation to specify that stencil value must be decremented */
  85213. static readonly DECR: number;
  85214. /** Passed to stencilOperation to specify that stencil value must be inverted */
  85215. static readonly INVERT: number;
  85216. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  85217. static readonly INCR_WRAP: number;
  85218. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  85219. static readonly DECR_WRAP: number;
  85220. /** Texture is not repeating outside of 0..1 UVs */
  85221. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  85222. /** Texture is repeating outside of 0..1 UVs */
  85223. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  85224. /** Texture is repeating and mirrored */
  85225. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  85226. /** ALPHA */
  85227. static readonly TEXTUREFORMAT_ALPHA: number;
  85228. /** LUMINANCE */
  85229. static readonly TEXTUREFORMAT_LUMINANCE: number;
  85230. /** LUMINANCE_ALPHA */
  85231. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  85232. /** RGB */
  85233. static readonly TEXTUREFORMAT_RGB: number;
  85234. /** RGBA */
  85235. static readonly TEXTUREFORMAT_RGBA: number;
  85236. /** RED */
  85237. static readonly TEXTUREFORMAT_RED: number;
  85238. /** RED (2nd reference) */
  85239. static readonly TEXTUREFORMAT_R: number;
  85240. /** RG */
  85241. static readonly TEXTUREFORMAT_RG: number;
  85242. /** RED_INTEGER */
  85243. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  85244. /** RED_INTEGER (2nd reference) */
  85245. static readonly TEXTUREFORMAT_R_INTEGER: number;
  85246. /** RG_INTEGER */
  85247. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  85248. /** RGB_INTEGER */
  85249. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  85250. /** RGBA_INTEGER */
  85251. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  85252. /** BGRA */
  85253. static readonly TEXTUREFORMAT_BGRA: number;
  85254. /** Depth 24 bits + Stencil 8 bits */
  85255. static readonly TEXTUREFORMAT_DEPTH24_STENCIL8: number;
  85256. /** Depth 32 bits float */
  85257. static readonly TEXTUREFORMAT_DEPTH32_FLOAT: number;
  85258. /** Compressed BC7 */
  85259. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM: number;
  85260. /** Compressed BC6 unsigned float */
  85261. static readonly TEXTUREFORMAT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT: number;
  85262. /** Compressed BC6 signed float */
  85263. static readonly TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT: number;
  85264. /** Compressed BC3 */
  85265. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5: number;
  85266. /** Compressed BC2 */
  85267. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3: number;
  85268. /** Compressed BC1 */
  85269. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1: number;
  85270. /** UNSIGNED_BYTE */
  85271. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  85272. /** UNSIGNED_BYTE (2nd reference) */
  85273. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  85274. /** FLOAT */
  85275. static readonly TEXTURETYPE_FLOAT: number;
  85276. /** HALF_FLOAT */
  85277. static readonly TEXTURETYPE_HALF_FLOAT: number;
  85278. /** BYTE */
  85279. static readonly TEXTURETYPE_BYTE: number;
  85280. /** SHORT */
  85281. static readonly TEXTURETYPE_SHORT: number;
  85282. /** UNSIGNED_SHORT */
  85283. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  85284. /** INT */
  85285. static readonly TEXTURETYPE_INT: number;
  85286. /** UNSIGNED_INT */
  85287. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  85288. /** UNSIGNED_SHORT_4_4_4_4 */
  85289. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  85290. /** UNSIGNED_SHORT_5_5_5_1 */
  85291. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  85292. /** UNSIGNED_SHORT_5_6_5 */
  85293. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  85294. /** UNSIGNED_INT_2_10_10_10_REV */
  85295. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  85296. /** UNSIGNED_INT_24_8 */
  85297. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  85298. /** UNSIGNED_INT_10F_11F_11F_REV */
  85299. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  85300. /** UNSIGNED_INT_5_9_9_9_REV */
  85301. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  85302. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  85303. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  85304. /** nearest is mag = nearest and min = nearest and no mip */
  85305. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  85306. /** mag = nearest and min = nearest and mip = none */
  85307. static readonly TEXTURE_NEAREST_NEAREST: number;
  85308. /** Bilinear is mag = linear and min = linear and no mip */
  85309. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  85310. /** mag = linear and min = linear and mip = none */
  85311. static readonly TEXTURE_LINEAR_LINEAR: number;
  85312. /** Trilinear is mag = linear and min = linear and mip = linear */
  85313. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  85314. /** Trilinear is mag = linear and min = linear and mip = linear */
  85315. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  85316. /** mag = nearest and min = nearest and mip = nearest */
  85317. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  85318. /** mag = nearest and min = linear and mip = nearest */
  85319. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  85320. /** mag = nearest and min = linear and mip = linear */
  85321. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  85322. /** mag = nearest and min = linear and mip = none */
  85323. static readonly TEXTURE_NEAREST_LINEAR: number;
  85324. /** nearest is mag = nearest and min = nearest and mip = linear */
  85325. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  85326. /** mag = linear and min = nearest and mip = nearest */
  85327. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  85328. /** mag = linear and min = nearest and mip = linear */
  85329. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  85330. /** Bilinear is mag = linear and min = linear and mip = nearest */
  85331. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  85332. /** mag = linear and min = nearest and mip = none */
  85333. static readonly TEXTURE_LINEAR_NEAREST: number;
  85334. /** Explicit coordinates mode */
  85335. static readonly TEXTURE_EXPLICIT_MODE: number;
  85336. /** Spherical coordinates mode */
  85337. static readonly TEXTURE_SPHERICAL_MODE: number;
  85338. /** Planar coordinates mode */
  85339. static readonly TEXTURE_PLANAR_MODE: number;
  85340. /** Cubic coordinates mode */
  85341. static readonly TEXTURE_CUBIC_MODE: number;
  85342. /** Projection coordinates mode */
  85343. static readonly TEXTURE_PROJECTION_MODE: number;
  85344. /** Skybox coordinates mode */
  85345. static readonly TEXTURE_SKYBOX_MODE: number;
  85346. /** Inverse Cubic coordinates mode */
  85347. static readonly TEXTURE_INVCUBIC_MODE: number;
  85348. /** Equirectangular coordinates mode */
  85349. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  85350. /** Equirectangular Fixed coordinates mode */
  85351. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  85352. /** Equirectangular Fixed Mirrored coordinates mode */
  85353. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  85354. /** Offline (baking) quality for texture filtering */
  85355. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  85356. /** High quality for texture filtering */
  85357. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  85358. /** Medium quality for texture filtering */
  85359. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  85360. /** Low quality for texture filtering */
  85361. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  85362. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  85363. static readonly SCALEMODE_FLOOR: number;
  85364. /** Defines that texture rescaling will look for the nearest power of 2 size */
  85365. static readonly SCALEMODE_NEAREST: number;
  85366. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  85367. static readonly SCALEMODE_CEILING: number;
  85368. /**
  85369. * The dirty texture flag value
  85370. */
  85371. static readonly MATERIAL_TextureDirtyFlag: number;
  85372. /**
  85373. * The dirty light flag value
  85374. */
  85375. static readonly MATERIAL_LightDirtyFlag: number;
  85376. /**
  85377. * The dirty fresnel flag value
  85378. */
  85379. static readonly MATERIAL_FresnelDirtyFlag: number;
  85380. /**
  85381. * The dirty attribute flag value
  85382. */
  85383. static readonly MATERIAL_AttributesDirtyFlag: number;
  85384. /**
  85385. * The dirty misc flag value
  85386. */
  85387. static readonly MATERIAL_MiscDirtyFlag: number;
  85388. /**
  85389. * The dirty prepass flag value
  85390. */
  85391. static readonly MATERIAL_PrePassDirtyFlag: number;
  85392. /**
  85393. * The all dirty flag value
  85394. */
  85395. static readonly MATERIAL_AllDirtyFlag: number;
  85396. /**
  85397. * Returns the triangle fill mode
  85398. */
  85399. static readonly MATERIAL_TriangleFillMode: number;
  85400. /**
  85401. * Returns the wireframe mode
  85402. */
  85403. static readonly MATERIAL_WireFrameFillMode: number;
  85404. /**
  85405. * Returns the point fill mode
  85406. */
  85407. static readonly MATERIAL_PointFillMode: number;
  85408. /**
  85409. * Returns the point list draw mode
  85410. */
  85411. static readonly MATERIAL_PointListDrawMode: number;
  85412. /**
  85413. * Returns the line list draw mode
  85414. */
  85415. static readonly MATERIAL_LineListDrawMode: number;
  85416. /**
  85417. * Returns the line loop draw mode
  85418. */
  85419. static readonly MATERIAL_LineLoopDrawMode: number;
  85420. /**
  85421. * Returns the line strip draw mode
  85422. */
  85423. static readonly MATERIAL_LineStripDrawMode: number;
  85424. /**
  85425. * Returns the triangle strip draw mode
  85426. */
  85427. static readonly MATERIAL_TriangleStripDrawMode: number;
  85428. /**
  85429. * Returns the triangle fan draw mode
  85430. */
  85431. static readonly MATERIAL_TriangleFanDrawMode: number;
  85432. /**
  85433. * Stores the clock-wise side orientation
  85434. */
  85435. static readonly MATERIAL_ClockWiseSideOrientation: number;
  85436. /**
  85437. * Stores the counter clock-wise side orientation
  85438. */
  85439. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  85440. /**
  85441. * Nothing
  85442. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85443. */
  85444. static readonly ACTION_NothingTrigger: number;
  85445. /**
  85446. * On pick
  85447. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85448. */
  85449. static readonly ACTION_OnPickTrigger: number;
  85450. /**
  85451. * On left pick
  85452. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85453. */
  85454. static readonly ACTION_OnLeftPickTrigger: number;
  85455. /**
  85456. * On right pick
  85457. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85458. */
  85459. static readonly ACTION_OnRightPickTrigger: number;
  85460. /**
  85461. * On center pick
  85462. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85463. */
  85464. static readonly ACTION_OnCenterPickTrigger: number;
  85465. /**
  85466. * On pick down
  85467. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85468. */
  85469. static readonly ACTION_OnPickDownTrigger: number;
  85470. /**
  85471. * On double pick
  85472. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85473. */
  85474. static readonly ACTION_OnDoublePickTrigger: number;
  85475. /**
  85476. * On pick up
  85477. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85478. */
  85479. static readonly ACTION_OnPickUpTrigger: number;
  85480. /**
  85481. * On pick out.
  85482. * This trigger will only be raised if you also declared a OnPickDown
  85483. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85484. */
  85485. static readonly ACTION_OnPickOutTrigger: number;
  85486. /**
  85487. * On long press
  85488. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85489. */
  85490. static readonly ACTION_OnLongPressTrigger: number;
  85491. /**
  85492. * On pointer over
  85493. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85494. */
  85495. static readonly ACTION_OnPointerOverTrigger: number;
  85496. /**
  85497. * On pointer out
  85498. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85499. */
  85500. static readonly ACTION_OnPointerOutTrigger: number;
  85501. /**
  85502. * On every frame
  85503. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85504. */
  85505. static readonly ACTION_OnEveryFrameTrigger: number;
  85506. /**
  85507. * On intersection enter
  85508. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85509. */
  85510. static readonly ACTION_OnIntersectionEnterTrigger: number;
  85511. /**
  85512. * On intersection exit
  85513. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85514. */
  85515. static readonly ACTION_OnIntersectionExitTrigger: number;
  85516. /**
  85517. * On key down
  85518. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85519. */
  85520. static readonly ACTION_OnKeyDownTrigger: number;
  85521. /**
  85522. * On key up
  85523. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  85524. */
  85525. static readonly ACTION_OnKeyUpTrigger: number;
  85526. /**
  85527. * Billboard mode will only apply to Y axis
  85528. */
  85529. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  85530. /**
  85531. * Billboard mode will apply to all axes
  85532. */
  85533. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  85534. /**
  85535. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  85536. */
  85537. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  85538. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  85539. * Test order :
  85540. * Is the bounding sphere outside the frustum ?
  85541. * If not, are the bounding box vertices outside the frustum ?
  85542. * It not, then the cullable object is in the frustum.
  85543. */
  85544. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  85545. /** Culling strategy : Bounding Sphere Only.
  85546. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  85547. * It's also less accurate than the standard because some not visible objects can still be selected.
  85548. * Test : is the bounding sphere outside the frustum ?
  85549. * If not, then the cullable object is in the frustum.
  85550. */
  85551. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  85552. /** Culling strategy : Optimistic Inclusion.
  85553. * This in an inclusion test first, then the standard exclusion test.
  85554. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  85555. * 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.
  85556. * Anyway, it's as accurate as the standard strategy.
  85557. * Test :
  85558. * Is the cullable object bounding sphere center in the frustum ?
  85559. * If not, apply the default culling strategy.
  85560. */
  85561. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  85562. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  85563. * This in an inclusion test first, then the bounding sphere only exclusion test.
  85564. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  85565. * 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.
  85566. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  85567. * Test :
  85568. * Is the cullable object bounding sphere center in the frustum ?
  85569. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  85570. */
  85571. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  85572. /**
  85573. * No logging while loading
  85574. */
  85575. static readonly SCENELOADER_NO_LOGGING: number;
  85576. /**
  85577. * Minimal logging while loading
  85578. */
  85579. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  85580. /**
  85581. * Summary logging while loading
  85582. */
  85583. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  85584. /**
  85585. * Detailled logging while loading
  85586. */
  85587. static readonly SCENELOADER_DETAILED_LOGGING: number;
  85588. /**
  85589. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  85590. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  85591. */
  85592. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  85593. /**
  85594. * Constant used to retrieve the position texture index in the textures array in the prepass
  85595. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  85596. */
  85597. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  85598. /**
  85599. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  85600. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  85601. */
  85602. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  85603. /**
  85604. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  85605. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  85606. */
  85607. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  85608. /**
  85609. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  85610. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  85611. */
  85612. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  85613. /**
  85614. * Constant used to retrieve depth + normal index in the textures array in the prepass
  85615. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  85616. */
  85617. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  85618. /**
  85619. * Constant used to retrieve albedo index in the textures array in the prepass
  85620. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  85621. */
  85622. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  85623. /**
  85624. * Prefixes used by the engine for custom effects
  85625. */
  85626. static readonly CUSTOMEFFECT_PREFIX_SHADOWGENERATOR: string;
  85627. }
  85628. }
  85629. declare module BABYLON {
  85630. /** @hidden */
  85631. export interface HardwareTextureWrapper {
  85632. underlyingResource: any;
  85633. set(hardwareTexture: any): void;
  85634. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  85635. reset(): void;
  85636. release(): void;
  85637. }
  85638. }
  85639. declare module BABYLON {
  85640. /**
  85641. * This represents the required contract to create a new type of texture loader.
  85642. */
  85643. export interface IInternalTextureLoader {
  85644. /**
  85645. * Defines wether the loader supports cascade loading the different faces.
  85646. */
  85647. supportCascades: boolean;
  85648. /**
  85649. * This returns if the loader support the current file information.
  85650. * @param extension defines the file extension of the file being loaded
  85651. * @param mimeType defines the optional mime type of the file being loaded
  85652. * @returns true if the loader can load the specified file
  85653. */
  85654. canLoad(extension: string, mimeType?: string): boolean;
  85655. /**
  85656. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  85657. * @param data contains the texture data
  85658. * @param texture defines the BabylonJS internal texture
  85659. * @param createPolynomials will be true if polynomials have been requested
  85660. * @param onLoad defines the callback to trigger once the texture is ready
  85661. * @param onError defines the callback to trigger in case of error
  85662. * @param options options to be passed to the loader
  85663. */
  85664. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  85665. /**
  85666. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  85667. * @param data contains the texture data
  85668. * @param texture defines the BabylonJS internal texture
  85669. * @param callback defines the method to call once ready to upload
  85670. * @param options options to be passed to the loader
  85671. */
  85672. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  85673. }
  85674. }
  85675. declare module BABYLON {
  85676. /**
  85677. * @hidden
  85678. */
  85679. export interface IColor4Like {
  85680. r: float;
  85681. g: float;
  85682. b: float;
  85683. a: float;
  85684. }
  85685. /**
  85686. * @hidden
  85687. */
  85688. export interface IColor3Like {
  85689. r: float;
  85690. g: float;
  85691. b: float;
  85692. }
  85693. /**
  85694. * @hidden
  85695. */
  85696. export interface IVector4Like {
  85697. x: float;
  85698. y: float;
  85699. z: float;
  85700. w: float;
  85701. }
  85702. /**
  85703. * @hidden
  85704. */
  85705. export interface IVector3Like {
  85706. x: float;
  85707. y: float;
  85708. z: float;
  85709. }
  85710. /**
  85711. * @hidden
  85712. */
  85713. export interface IVector2Like {
  85714. x: float;
  85715. y: float;
  85716. }
  85717. /**
  85718. * @hidden
  85719. */
  85720. export interface IMatrixLike {
  85721. toArray(): DeepImmutable<Float32Array | Array<number>>;
  85722. updateFlag: int;
  85723. }
  85724. /**
  85725. * @hidden
  85726. */
  85727. export interface IViewportLike {
  85728. x: float;
  85729. y: float;
  85730. width: float;
  85731. height: float;
  85732. }
  85733. /**
  85734. * @hidden
  85735. */
  85736. export interface IPlaneLike {
  85737. normal: IVector3Like;
  85738. d: float;
  85739. normalize(): void;
  85740. }
  85741. }
  85742. declare module BABYLON {
  85743. /**
  85744. * Class used to store and describe the pipeline context associated with an effect
  85745. */
  85746. export interface IPipelineContext {
  85747. /**
  85748. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  85749. */
  85750. isAsync: boolean;
  85751. /**
  85752. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  85753. */
  85754. isReady: boolean;
  85755. /** @hidden */
  85756. _name?: string;
  85757. /** @hidden */
  85758. _getVertexShaderCode(): string | null;
  85759. /** @hidden */
  85760. _getFragmentShaderCode(): string | null;
  85761. /** @hidden */
  85762. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  85763. /** @hidden */
  85764. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  85765. [key: string]: number;
  85766. }, uniformsNames: string[], uniforms: {
  85767. [key: string]: Nullable<WebGLUniformLocation>;
  85768. }, samplerList: string[], samplers: {
  85769. [key: string]: number;
  85770. }, attributesNames: string[], attributes: number[]): void;
  85771. /** Releases the resources associated with the pipeline. */
  85772. dispose(): void;
  85773. /**
  85774. * Sets an integer value on a uniform variable.
  85775. * @param uniformName Name of the variable.
  85776. * @param value Value to be set.
  85777. */
  85778. setInt(uniformName: string, value: number): void;
  85779. /**
  85780. * Sets an int2 value on a uniform variable.
  85781. * @param uniformName Name of the variable.
  85782. * @param x First int in int2.
  85783. * @param y Second int in int2.
  85784. */
  85785. setInt2(uniformName: string, x: number, y: number): void;
  85786. /**
  85787. * Sets an int3 value on a uniform variable.
  85788. * @param uniformName Name of the variable.
  85789. * @param x First int in int3.
  85790. * @param y Second int in int3.
  85791. * @param z Third int in int3.
  85792. */
  85793. setInt3(uniformName: string, x: number, y: number, z: number): void;
  85794. /**
  85795. * Sets an int4 value on a uniform variable.
  85796. * @param uniformName Name of the variable.
  85797. * @param x First int in int4.
  85798. * @param y Second int in int4.
  85799. * @param z Third int in int4.
  85800. * @param w Fourth int in int4.
  85801. */
  85802. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  85803. /**
  85804. * Sets an int array on a uniform variable.
  85805. * @param uniformName Name of the variable.
  85806. * @param array array to be set.
  85807. */
  85808. setIntArray(uniformName: string, array: Int32Array): void;
  85809. /**
  85810. * 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)
  85811. * @param uniformName Name of the variable.
  85812. * @param array array to be set.
  85813. */
  85814. setIntArray2(uniformName: string, array: Int32Array): void;
  85815. /**
  85816. * 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)
  85817. * @param uniformName Name of the variable.
  85818. * @param array array to be set.
  85819. */
  85820. setIntArray3(uniformName: string, array: Int32Array): void;
  85821. /**
  85822. * 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)
  85823. * @param uniformName Name of the variable.
  85824. * @param array array to be set.
  85825. */
  85826. setIntArray4(uniformName: string, array: Int32Array): void;
  85827. /**
  85828. * Sets an array on a uniform variable.
  85829. * @param uniformName Name of the variable.
  85830. * @param array array to be set.
  85831. */
  85832. setArray(uniformName: string, array: number[] | Float32Array): void;
  85833. /**
  85834. * 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)
  85835. * @param uniformName Name of the variable.
  85836. * @param array array to be set.
  85837. */
  85838. setArray2(uniformName: string, array: number[] | Float32Array): void;
  85839. /**
  85840. * 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)
  85841. * @param uniformName Name of the variable.
  85842. * @param array array to be set.
  85843. */
  85844. setArray3(uniformName: string, array: number[] | Float32Array): void;
  85845. /**
  85846. * 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)
  85847. * @param uniformName Name of the variable.
  85848. * @param array array to be set.
  85849. */
  85850. setArray4(uniformName: string, array: number[] | Float32Array): void;
  85851. /**
  85852. * Sets matrices on a uniform variable.
  85853. * @param uniformName Name of the variable.
  85854. * @param matrices matrices to be set.
  85855. */
  85856. setMatrices(uniformName: string, matrices: Float32Array): void;
  85857. /**
  85858. * Sets matrix on a uniform variable.
  85859. * @param uniformName Name of the variable.
  85860. * @param matrix matrix to be set.
  85861. */
  85862. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  85863. /**
  85864. * 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)
  85865. * @param uniformName Name of the variable.
  85866. * @param matrix matrix to be set.
  85867. */
  85868. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  85869. /**
  85870. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  85871. * @param uniformName Name of the variable.
  85872. * @param matrix matrix to be set.
  85873. */
  85874. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  85875. /**
  85876. * Sets a float on a uniform variable.
  85877. * @param uniformName Name of the variable.
  85878. * @param value value to be set.
  85879. */
  85880. setFloat(uniformName: string, value: number): void;
  85881. /**
  85882. * Sets a Vector2 on a uniform variable.
  85883. * @param uniformName Name of the variable.
  85884. * @param vector2 vector2 to be set.
  85885. */
  85886. setVector2(uniformName: string, vector2: IVector2Like): void;
  85887. /**
  85888. * Sets a float2 on a uniform variable.
  85889. * @param uniformName Name of the variable.
  85890. * @param x First float in float2.
  85891. * @param y Second float in float2.
  85892. */
  85893. setFloat2(uniformName: string, x: number, y: number): void;
  85894. /**
  85895. * Sets a Vector3 on a uniform variable.
  85896. * @param uniformName Name of the variable.
  85897. * @param vector3 Value to be set.
  85898. */
  85899. setVector3(uniformName: string, vector3: IVector3Like): void;
  85900. /**
  85901. * Sets a float3 on a uniform variable.
  85902. * @param uniformName Name of the variable.
  85903. * @param x First float in float3.
  85904. * @param y Second float in float3.
  85905. * @param z Third float in float3.
  85906. */
  85907. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  85908. /**
  85909. * Sets a Vector4 on a uniform variable.
  85910. * @param uniformName Name of the variable.
  85911. * @param vector4 Value to be set.
  85912. */
  85913. setVector4(uniformName: string, vector4: IVector4Like): void;
  85914. /**
  85915. * Sets a float4 on a uniform variable.
  85916. * @param uniformName Name of the variable.
  85917. * @param x First float in float4.
  85918. * @param y Second float in float4.
  85919. * @param z Third float in float4.
  85920. * @param w Fourth float in float4.
  85921. */
  85922. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  85923. /**
  85924. * Sets a Color3 on a uniform variable.
  85925. * @param uniformName Name of the variable.
  85926. * @param color3 Value to be set.
  85927. */
  85928. setColor3(uniformName: string, color3: IColor3Like): void;
  85929. /**
  85930. * Sets a Color4 on a uniform variable.
  85931. * @param uniformName Name of the variable.
  85932. * @param color3 Value to be set.
  85933. * @param alpha Alpha value to be set.
  85934. */
  85935. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  85936. /**
  85937. * Sets a Color4 on a uniform variable
  85938. * @param uniformName defines the name of the variable
  85939. * @param color4 defines the value to be set
  85940. */
  85941. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  85942. }
  85943. }
  85944. declare module BABYLON {
  85945. /**
  85946. * Class used to store gfx data (like WebGLBuffer)
  85947. */
  85948. export class DataBuffer {
  85949. /**
  85950. * Gets or sets the number of objects referencing this buffer
  85951. */
  85952. references: number;
  85953. /** Gets or sets the size of the underlying buffer */
  85954. capacity: number;
  85955. /**
  85956. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  85957. */
  85958. is32Bits: boolean;
  85959. /**
  85960. * Gets the underlying buffer
  85961. */
  85962. get underlyingResource(): any;
  85963. }
  85964. }
  85965. declare module BABYLON {
  85966. /** @hidden */
  85967. export interface IShaderProcessor {
  85968. attributeProcessor?: (attribute: string, preProcessors: {
  85969. [key: string]: string;
  85970. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  85971. varyingProcessor?: (varying: string, isFragment: boolean, preProcessors: {
  85972. [key: string]: string;
  85973. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  85974. uniformProcessor?: (uniform: string, isFragment: boolean, preProcessors: {
  85975. [key: string]: string;
  85976. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  85977. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  85978. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  85979. lineProcessor?: (line: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  85980. preProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  85981. postProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine) => string;
  85982. initializeShaders?: (processingContext: Nullable<ShaderProcessingContext>) => void;
  85983. finalizeShaders?: (vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>) => {
  85984. vertexCode: string;
  85985. fragmentCode: string;
  85986. };
  85987. }
  85988. }
  85989. declare module BABYLON {
  85990. /** @hidden */
  85991. export interface ShaderProcessingContext {
  85992. }
  85993. /** @hidden */
  85994. export interface ProcessingOptions {
  85995. defines: string[];
  85996. indexParameters: any;
  85997. isFragment: boolean;
  85998. shouldUseHighPrecisionShader: boolean;
  85999. supportsUniformBuffers: boolean;
  86000. shadersRepository: string;
  86001. includesShadersStore: {
  86002. [key: string]: string;
  86003. };
  86004. processor: Nullable<IShaderProcessor>;
  86005. version: string;
  86006. platformName: string;
  86007. lookForClosingBracketForUniformBuffer?: boolean;
  86008. processingContext: Nullable<ShaderProcessingContext>;
  86009. }
  86010. }
  86011. declare module BABYLON {
  86012. /** @hidden */
  86013. export class ShaderCodeNode {
  86014. line: string;
  86015. children: ShaderCodeNode[];
  86016. additionalDefineKey?: string;
  86017. additionalDefineValue?: string;
  86018. isValid(preprocessors: {
  86019. [key: string]: string;
  86020. }): boolean;
  86021. process(preprocessors: {
  86022. [key: string]: string;
  86023. }, options: ProcessingOptions): string;
  86024. }
  86025. }
  86026. declare module BABYLON {
  86027. /** @hidden */
  86028. export class ShaderCodeCursor {
  86029. private _lines;
  86030. lineIndex: number;
  86031. get currentLine(): string;
  86032. get canRead(): boolean;
  86033. set lines(value: string[]);
  86034. }
  86035. }
  86036. declare module BABYLON {
  86037. /** @hidden */
  86038. export class ShaderCodeConditionNode extends ShaderCodeNode {
  86039. process(preprocessors: {
  86040. [key: string]: string;
  86041. }, options: ProcessingOptions): string;
  86042. }
  86043. }
  86044. declare module BABYLON {
  86045. /** @hidden */
  86046. export class ShaderDefineExpression {
  86047. isTrue(preprocessors: {
  86048. [key: string]: string;
  86049. }): boolean;
  86050. private static _OperatorPriority;
  86051. private static _Stack;
  86052. static postfixToInfix(postfix: string[]): string;
  86053. static infixToPostfix(infix: string): string[];
  86054. }
  86055. }
  86056. declare module BABYLON {
  86057. /** @hidden */
  86058. export class ShaderCodeTestNode extends ShaderCodeNode {
  86059. testExpression: ShaderDefineExpression;
  86060. isValid(preprocessors: {
  86061. [key: string]: string;
  86062. }): boolean;
  86063. }
  86064. }
  86065. declare module BABYLON {
  86066. /** @hidden */
  86067. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  86068. define: string;
  86069. not: boolean;
  86070. constructor(define: string, not?: boolean);
  86071. isTrue(preprocessors: {
  86072. [key: string]: string;
  86073. }): boolean;
  86074. }
  86075. }
  86076. declare module BABYLON {
  86077. /** @hidden */
  86078. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  86079. leftOperand: ShaderDefineExpression;
  86080. rightOperand: ShaderDefineExpression;
  86081. isTrue(preprocessors: {
  86082. [key: string]: string;
  86083. }): boolean;
  86084. }
  86085. }
  86086. declare module BABYLON {
  86087. /** @hidden */
  86088. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  86089. leftOperand: ShaderDefineExpression;
  86090. rightOperand: ShaderDefineExpression;
  86091. isTrue(preprocessors: {
  86092. [key: string]: string;
  86093. }): boolean;
  86094. }
  86095. }
  86096. declare module BABYLON {
  86097. /** @hidden */
  86098. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  86099. define: string;
  86100. operand: string;
  86101. testValue: string;
  86102. constructor(define: string, operand: string, testValue: string);
  86103. isTrue(preprocessors: {
  86104. [key: string]: string;
  86105. }): boolean;
  86106. }
  86107. }
  86108. declare module BABYLON {
  86109. /**
  86110. * Class used to enable access to offline support
  86111. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  86112. */
  86113. export interface IOfflineProvider {
  86114. /**
  86115. * Gets a boolean indicating if scene must be saved in the database
  86116. */
  86117. enableSceneOffline: boolean;
  86118. /**
  86119. * Gets a boolean indicating if textures must be saved in the database
  86120. */
  86121. enableTexturesOffline: boolean;
  86122. /**
  86123. * Open the offline support and make it available
  86124. * @param successCallback defines the callback to call on success
  86125. * @param errorCallback defines the callback to call on error
  86126. */
  86127. open(successCallback: () => void, errorCallback: () => void): void;
  86128. /**
  86129. * Loads an image from the offline support
  86130. * @param url defines the url to load from
  86131. * @param image defines the target DOM image
  86132. */
  86133. loadImage(url: string, image: HTMLImageElement): void;
  86134. /**
  86135. * Loads a file from offline support
  86136. * @param url defines the URL to load from
  86137. * @param sceneLoaded defines a callback to call on success
  86138. * @param progressCallBack defines a callback to call when progress changed
  86139. * @param errorCallback defines a callback to call on error
  86140. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  86141. */
  86142. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  86143. }
  86144. }
  86145. declare module BABYLON {
  86146. /**
  86147. * Class used to help managing file picking and drag'n'drop
  86148. * File Storage
  86149. */
  86150. export class FilesInputStore {
  86151. /**
  86152. * List of files ready to be loaded
  86153. */
  86154. static FilesToLoad: {
  86155. [key: string]: File;
  86156. };
  86157. }
  86158. }
  86159. declare module BABYLON {
  86160. /**
  86161. * Class used to define a retry strategy when error happens while loading assets
  86162. */
  86163. export class RetryStrategy {
  86164. /**
  86165. * Function used to defines an exponential back off strategy
  86166. * @param maxRetries defines the maximum number of retries (3 by default)
  86167. * @param baseInterval defines the interval between retries
  86168. * @returns the strategy function to use
  86169. */
  86170. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  86171. }
  86172. }
  86173. declare module BABYLON {
  86174. /**
  86175. * @ignore
  86176. * Application error to support additional information when loading a file
  86177. */
  86178. export abstract class BaseError extends Error {
  86179. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  86180. }
  86181. }
  86182. declare module BABYLON {
  86183. /** @ignore */
  86184. export class LoadFileError extends BaseError {
  86185. request?: WebRequest;
  86186. file?: File;
  86187. /**
  86188. * Creates a new LoadFileError
  86189. * @param message defines the message of the error
  86190. * @param request defines the optional web request
  86191. * @param file defines the optional file
  86192. */
  86193. constructor(message: string, object?: WebRequest | File);
  86194. }
  86195. /** @ignore */
  86196. export class RequestFileError extends BaseError {
  86197. request: WebRequest;
  86198. /**
  86199. * Creates a new LoadFileError
  86200. * @param message defines the message of the error
  86201. * @param request defines the optional web request
  86202. */
  86203. constructor(message: string, request: WebRequest);
  86204. }
  86205. /** @ignore */
  86206. export class ReadFileError extends BaseError {
  86207. file: File;
  86208. /**
  86209. * Creates a new ReadFileError
  86210. * @param message defines the message of the error
  86211. * @param file defines the optional file
  86212. */
  86213. constructor(message: string, file: File);
  86214. }
  86215. /**
  86216. * @hidden
  86217. */
  86218. export class FileTools {
  86219. /**
  86220. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  86221. */
  86222. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  86223. /**
  86224. * Gets or sets the base URL to use to load assets
  86225. */
  86226. static BaseUrl: string;
  86227. /**
  86228. * Default behaviour for cors in the application.
  86229. * It can be a string if the expected behavior is identical in the entire app.
  86230. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  86231. */
  86232. static CorsBehavior: string | ((url: string | string[]) => string);
  86233. /**
  86234. * Gets or sets a function used to pre-process url before using them to load assets
  86235. */
  86236. static PreprocessUrl: (url: string) => string;
  86237. /**
  86238. * Removes unwanted characters from an url
  86239. * @param url defines the url to clean
  86240. * @returns the cleaned url
  86241. */
  86242. private static _CleanUrl;
  86243. /**
  86244. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  86245. * @param url define the url we are trying
  86246. * @param element define the dom element where to configure the cors policy
  86247. */
  86248. static SetCorsBehavior(url: string | string[], element: {
  86249. crossOrigin: string | null;
  86250. }): void;
  86251. /**
  86252. * Loads an image as an HTMLImageElement.
  86253. * @param input url string, ArrayBuffer, or Blob to load
  86254. * @param onLoad callback called when the image successfully loads
  86255. * @param onError callback called when the image fails to load
  86256. * @param offlineProvider offline provider for caching
  86257. * @param mimeType optional mime type
  86258. * @returns the HTMLImageElement of the loaded image
  86259. */
  86260. 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>;
  86261. /**
  86262. * Reads a file from a File object
  86263. * @param file defines the file to load
  86264. * @param onSuccess defines the callback to call when data is loaded
  86265. * @param onProgress defines the callback to call during loading process
  86266. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  86267. * @param onError defines the callback to call when an error occurs
  86268. * @returns a file request object
  86269. */
  86270. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  86271. /**
  86272. * Loads a file from a url
  86273. * @param url url to load
  86274. * @param onSuccess callback called when the file successfully loads
  86275. * @param onProgress callback called while file is loading (if the server supports this mode)
  86276. * @param offlineProvider defines the offline provider for caching
  86277. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  86278. * @param onError callback called when the file fails to load
  86279. * @returns a file request object
  86280. */
  86281. 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;
  86282. /**
  86283. * Loads a file
  86284. * @param url url to load
  86285. * @param onSuccess callback called when the file successfully loads
  86286. * @param onProgress callback called while file is loading (if the server supports this mode)
  86287. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  86288. * @param onError callback called when the file fails to load
  86289. * @param onOpened callback called when the web request is opened
  86290. * @returns a file request object
  86291. */
  86292. 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;
  86293. /**
  86294. * Checks if the loaded document was accessed via `file:`-Protocol.
  86295. * @returns boolean
  86296. */
  86297. static IsFileURL(): boolean;
  86298. }
  86299. }
  86300. declare module BABYLON {
  86301. /** @hidden */
  86302. export class ShaderProcessor {
  86303. static Initialize(options: ProcessingOptions): void;
  86304. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  86305. static Finalize(vertexCode: string, fragmentCode: string, options: ProcessingOptions): {
  86306. vertexCode: string;
  86307. fragmentCode: string;
  86308. };
  86309. private static _ProcessPrecision;
  86310. private static _ExtractOperation;
  86311. private static _BuildSubExpression;
  86312. private static _BuildExpression;
  86313. private static _MoveCursorWithinIf;
  86314. private static _MoveCursor;
  86315. private static _EvaluatePreProcessors;
  86316. private static _PreparePreProcessors;
  86317. private static _ProcessShaderConversion;
  86318. private static _ProcessIncludes;
  86319. /**
  86320. * Loads a file from a url
  86321. * @param url url to load
  86322. * @param onSuccess callback called when the file successfully loads
  86323. * @param onProgress callback called while file is loading (if the server supports this mode)
  86324. * @param offlineProvider defines the offline provider for caching
  86325. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  86326. * @param onError callback called when the file fails to load
  86327. * @returns a file request object
  86328. * @hidden
  86329. */
  86330. 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;
  86331. }
  86332. }
  86333. declare module BABYLON {
  86334. /**
  86335. * Interface used to define common properties for effect fallbacks
  86336. */
  86337. export interface IEffectFallbacks {
  86338. /**
  86339. * Removes the defines that should be removed when falling back.
  86340. * @param currentDefines defines the current define statements for the shader.
  86341. * @param effect defines the current effect we try to compile
  86342. * @returns The resulting defines with defines of the current rank removed.
  86343. */
  86344. reduce(currentDefines: string, effect: Effect): string;
  86345. /**
  86346. * Removes the fallback from the bound mesh.
  86347. */
  86348. unBindMesh(): void;
  86349. /**
  86350. * Checks to see if more fallbacks are still availible.
  86351. */
  86352. hasMoreFallbacks: boolean;
  86353. }
  86354. }
  86355. declare module BABYLON {
  86356. /**
  86357. * Interface for the size containing width and height
  86358. */
  86359. export interface ISize {
  86360. /**
  86361. * Width
  86362. */
  86363. width: number;
  86364. /**
  86365. * Heighht
  86366. */
  86367. height: number;
  86368. }
  86369. /**
  86370. * Size containing widht and height
  86371. */
  86372. export class Size implements ISize {
  86373. /**
  86374. * Width
  86375. */
  86376. width: number;
  86377. /**
  86378. * Height
  86379. */
  86380. height: number;
  86381. /**
  86382. * Creates a Size object from the given width and height (floats).
  86383. * @param width width of the new size
  86384. * @param height height of the new size
  86385. */
  86386. constructor(width: number, height: number);
  86387. /**
  86388. * Returns a string with the Size width and height
  86389. * @returns a string with the Size width and height
  86390. */
  86391. toString(): string;
  86392. /**
  86393. * "Size"
  86394. * @returns the string "Size"
  86395. */
  86396. getClassName(): string;
  86397. /**
  86398. * Returns the Size hash code.
  86399. * @returns a hash code for a unique width and height
  86400. */
  86401. getHashCode(): number;
  86402. /**
  86403. * Updates the current size from the given one.
  86404. * @param src the given size
  86405. */
  86406. copyFrom(src: Size): void;
  86407. /**
  86408. * Updates in place the current Size from the given floats.
  86409. * @param width width of the new size
  86410. * @param height height of the new size
  86411. * @returns the updated Size.
  86412. */
  86413. copyFromFloats(width: number, height: number): Size;
  86414. /**
  86415. * Updates in place the current Size from the given floats.
  86416. * @param width width to set
  86417. * @param height height to set
  86418. * @returns the updated Size.
  86419. */
  86420. set(width: number, height: number): Size;
  86421. /**
  86422. * Multiplies the width and height by numbers
  86423. * @param w factor to multiple the width by
  86424. * @param h factor to multiple the height by
  86425. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  86426. */
  86427. multiplyByFloats(w: number, h: number): Size;
  86428. /**
  86429. * Clones the size
  86430. * @returns a new Size copied from the given one.
  86431. */
  86432. clone(): Size;
  86433. /**
  86434. * True if the current Size and the given one width and height are strictly equal.
  86435. * @param other the other size to compare against
  86436. * @returns True if the current Size and the given one width and height are strictly equal.
  86437. */
  86438. equals(other: Size): boolean;
  86439. /**
  86440. * The surface of the Size : width * height (float).
  86441. */
  86442. get surface(): number;
  86443. /**
  86444. * Create a new size of zero
  86445. * @returns a new Size set to (0.0, 0.0)
  86446. */
  86447. static Zero(): Size;
  86448. /**
  86449. * Sums the width and height of two sizes
  86450. * @param otherSize size to add to this size
  86451. * @returns a new Size set as the addition result of the current Size and the given one.
  86452. */
  86453. add(otherSize: Size): Size;
  86454. /**
  86455. * Subtracts the width and height of two
  86456. * @param otherSize size to subtract to this size
  86457. * @returns a new Size set as the subtraction result of the given one from the current Size.
  86458. */
  86459. subtract(otherSize: Size): Size;
  86460. /**
  86461. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  86462. * @param start starting size to lerp between
  86463. * @param end end size to lerp between
  86464. * @param amount amount to lerp between the start and end values
  86465. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  86466. */
  86467. static Lerp(start: Size, end: Size, amount: number): Size;
  86468. }
  86469. }
  86470. declare module BABYLON {
  86471. /**
  86472. * Base class of all the textures in babylon.
  86473. * It groups all the common properties required to work with Thin Engine.
  86474. */
  86475. export class ThinTexture {
  86476. protected _wrapU: number;
  86477. /**
  86478. * | Value | Type | Description |
  86479. * | ----- | ------------------ | ----------- |
  86480. * | 0 | CLAMP_ADDRESSMODE | |
  86481. * | 1 | WRAP_ADDRESSMODE | |
  86482. * | 2 | MIRROR_ADDRESSMODE | |
  86483. */
  86484. get wrapU(): number;
  86485. set wrapU(value: number);
  86486. protected _wrapV: number;
  86487. /**
  86488. * | Value | Type | Description |
  86489. * | ----- | ------------------ | ----------- |
  86490. * | 0 | CLAMP_ADDRESSMODE | |
  86491. * | 1 | WRAP_ADDRESSMODE | |
  86492. * | 2 | MIRROR_ADDRESSMODE | |
  86493. */
  86494. get wrapV(): number;
  86495. set wrapV(value: number);
  86496. /**
  86497. * | Value | Type | Description |
  86498. * | ----- | ------------------ | ----------- |
  86499. * | 0 | CLAMP_ADDRESSMODE | |
  86500. * | 1 | WRAP_ADDRESSMODE | |
  86501. * | 2 | MIRROR_ADDRESSMODE | |
  86502. */
  86503. wrapR: number;
  86504. /**
  86505. * With compliant hardware and browser (supporting anisotropic filtering)
  86506. * this defines the level of anisotropic filtering in the texture.
  86507. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  86508. */
  86509. anisotropicFilteringLevel: number;
  86510. /**
  86511. * Define the current state of the loading sequence when in delayed load mode.
  86512. */
  86513. delayLoadState: number;
  86514. /**
  86515. * How a texture is mapped.
  86516. * Unused in thin texture mode.
  86517. */
  86518. get coordinatesMode(): number;
  86519. /**
  86520. * Define if the texture is a cube texture or if false a 2d texture.
  86521. */
  86522. get isCube(): boolean;
  86523. set isCube(value: boolean);
  86524. /**
  86525. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  86526. */
  86527. get is3D(): boolean;
  86528. set is3D(value: boolean);
  86529. /**
  86530. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  86531. */
  86532. get is2DArray(): boolean;
  86533. set is2DArray(value: boolean);
  86534. /**
  86535. * Get the class name of the texture.
  86536. * @returns "ThinTexture"
  86537. */
  86538. getClassName(): string;
  86539. /** @hidden */
  86540. _texture: Nullable<InternalTexture>;
  86541. protected _engine: Nullable<ThinEngine>;
  86542. private _cachedSize;
  86543. private _cachedBaseSize;
  86544. /**
  86545. * Instantiates a new ThinTexture.
  86546. * Base class of all the textures in babylon.
  86547. * This can be used as an internal texture wrapper in ThinEngine to benefit from the cache
  86548. * @param internalTexture Define the internalTexture to wrap
  86549. */
  86550. constructor(internalTexture: Nullable<InternalTexture>);
  86551. /**
  86552. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  86553. * @returns true if fully ready
  86554. */
  86555. isReady(): boolean;
  86556. /**
  86557. * Triggers the load sequence in delayed load mode.
  86558. */
  86559. delayLoad(): void;
  86560. /**
  86561. * Get the underlying lower level texture from Babylon.
  86562. * @returns the insternal texture
  86563. */
  86564. getInternalTexture(): Nullable<InternalTexture>;
  86565. /**
  86566. * Get the size of the texture.
  86567. * @returns the texture size.
  86568. */
  86569. getSize(): ISize;
  86570. /**
  86571. * Get the base size of the texture.
  86572. * It can be different from the size if the texture has been resized for POT for instance
  86573. * @returns the base size
  86574. */
  86575. getBaseSize(): ISize;
  86576. /**
  86577. * Update the sampling mode of the texture.
  86578. * Default is Trilinear mode.
  86579. *
  86580. * | Value | Type | Description |
  86581. * | ----- | ------------------ | ----------- |
  86582. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  86583. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  86584. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  86585. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  86586. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  86587. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  86588. * | 7 | NEAREST_LINEAR | |
  86589. * | 8 | NEAREST_NEAREST | |
  86590. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  86591. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  86592. * | 11 | LINEAR_LINEAR | |
  86593. * | 12 | LINEAR_NEAREST | |
  86594. *
  86595. * > _mag_: magnification filter (close to the viewer)
  86596. * > _min_: minification filter (far from the viewer)
  86597. * > _mip_: filter used between mip map levels
  86598. *@param samplingMode Define the new sampling mode of the texture
  86599. */
  86600. updateSamplingMode(samplingMode: number): void;
  86601. /**
  86602. * Release and destroy the underlying lower level texture aka internalTexture.
  86603. */
  86604. releaseInternalTexture(): void;
  86605. /**
  86606. * Dispose the texture and release its associated resources.
  86607. */
  86608. dispose(): void;
  86609. }
  86610. }
  86611. declare module BABYLON {
  86612. /**
  86613. * Defines an array and its length.
  86614. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  86615. */
  86616. export interface ISmartArrayLike<T> {
  86617. /**
  86618. * The data of the array.
  86619. */
  86620. data: Array<T>;
  86621. /**
  86622. * The active length of the array.
  86623. */
  86624. length: number;
  86625. }
  86626. /**
  86627. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  86628. */
  86629. export class SmartArray<T> implements ISmartArrayLike<T> {
  86630. /**
  86631. * The full set of data from the array.
  86632. */
  86633. data: Array<T>;
  86634. /**
  86635. * The active length of the array.
  86636. */
  86637. length: number;
  86638. protected _id: number;
  86639. /**
  86640. * Instantiates a Smart Array.
  86641. * @param capacity defines the default capacity of the array.
  86642. */
  86643. constructor(capacity: number);
  86644. /**
  86645. * Pushes a value at the end of the active data.
  86646. * @param value defines the object to push in the array.
  86647. */
  86648. push(value: T): void;
  86649. /**
  86650. * Iterates over the active data and apply the lambda to them.
  86651. * @param func defines the action to apply on each value.
  86652. */
  86653. forEach(func: (content: T) => void): void;
  86654. /**
  86655. * Sorts the full sets of data.
  86656. * @param compareFn defines the comparison function to apply.
  86657. */
  86658. sort(compareFn: (a: T, b: T) => number): void;
  86659. /**
  86660. * Resets the active data to an empty array.
  86661. */
  86662. reset(): void;
  86663. /**
  86664. * Releases all the data from the array as well as the array.
  86665. */
  86666. dispose(): void;
  86667. /**
  86668. * Concats the active data with a given array.
  86669. * @param array defines the data to concatenate with.
  86670. */
  86671. concat(array: any): void;
  86672. /**
  86673. * Returns the position of a value in the active data.
  86674. * @param value defines the value to find the index for
  86675. * @returns the index if found in the active data otherwise -1
  86676. */
  86677. indexOf(value: T): number;
  86678. /**
  86679. * Returns whether an element is part of the active data.
  86680. * @param value defines the value to look for
  86681. * @returns true if found in the active data otherwise false
  86682. */
  86683. contains(value: T): boolean;
  86684. private static _GlobalId;
  86685. }
  86686. /**
  86687. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  86688. * The data in this array can only be present once
  86689. */
  86690. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  86691. private _duplicateId;
  86692. /**
  86693. * Pushes a value at the end of the active data.
  86694. * THIS DOES NOT PREVENT DUPPLICATE DATA
  86695. * @param value defines the object to push in the array.
  86696. */
  86697. push(value: T): void;
  86698. /**
  86699. * Pushes a value at the end of the active data.
  86700. * If the data is already present, it won t be added again
  86701. * @param value defines the object to push in the array.
  86702. * @returns true if added false if it was already present
  86703. */
  86704. pushNoDuplicate(value: T): boolean;
  86705. /**
  86706. * Resets the active data to an empty array.
  86707. */
  86708. reset(): void;
  86709. /**
  86710. * Concats the active data with a given array.
  86711. * This ensures no dupplicate will be present in the result.
  86712. * @param array defines the data to concatenate with.
  86713. */
  86714. concatWithNoDuplicate(array: any): void;
  86715. }
  86716. }
  86717. declare module BABYLON {
  86718. /**
  86719. * Class used to evalaute queries containing `and` and `or` operators
  86720. */
  86721. export class AndOrNotEvaluator {
  86722. /**
  86723. * Evaluate a query
  86724. * @param query defines the query to evaluate
  86725. * @param evaluateCallback defines the callback used to filter result
  86726. * @returns true if the query matches
  86727. */
  86728. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  86729. private static _HandleParenthesisContent;
  86730. private static _SimplifyNegation;
  86731. }
  86732. }
  86733. declare module BABYLON {
  86734. /**
  86735. * Class used to store custom tags
  86736. */
  86737. export class Tags {
  86738. /**
  86739. * Adds support for tags on the given object
  86740. * @param obj defines the object to use
  86741. */
  86742. static EnableFor(obj: any): void;
  86743. /**
  86744. * Removes tags support
  86745. * @param obj defines the object to use
  86746. */
  86747. static DisableFor(obj: any): void;
  86748. /**
  86749. * Gets a boolean indicating if the given object has tags
  86750. * @param obj defines the object to use
  86751. * @returns a boolean
  86752. */
  86753. static HasTags(obj: any): boolean;
  86754. /**
  86755. * Gets the tags available on a given object
  86756. * @param obj defines the object to use
  86757. * @param asString defines if the tags must be returned as a string instead of an array of strings
  86758. * @returns the tags
  86759. */
  86760. static GetTags(obj: any, asString?: boolean): any;
  86761. /**
  86762. * Adds tags to an object
  86763. * @param obj defines the object to use
  86764. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  86765. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  86766. */
  86767. static AddTagsTo(obj: any, tagsString: string): void;
  86768. /**
  86769. * @hidden
  86770. */
  86771. static _AddTagTo(obj: any, tag: string): void;
  86772. /**
  86773. * Removes specific tags from a specific object
  86774. * @param obj defines the object to use
  86775. * @param tagsString defines the tags to remove
  86776. */
  86777. static RemoveTagsFrom(obj: any, tagsString: string): void;
  86778. /**
  86779. * @hidden
  86780. */
  86781. static _RemoveTagFrom(obj: any, tag: string): void;
  86782. /**
  86783. * Defines if tags hosted on an object match a given query
  86784. * @param obj defines the object to use
  86785. * @param tagsQuery defines the tag query
  86786. * @returns a boolean
  86787. */
  86788. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  86789. }
  86790. }
  86791. declare module BABYLON {
  86792. /**
  86793. * Scalar computation library
  86794. */
  86795. export class Scalar {
  86796. /**
  86797. * Two pi constants convenient for computation.
  86798. */
  86799. static TwoPi: number;
  86800. /**
  86801. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  86802. * @param a number
  86803. * @param b number
  86804. * @param epsilon (default = 1.401298E-45)
  86805. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  86806. */
  86807. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  86808. /**
  86809. * Returns a string : the upper case translation of the number i to hexadecimal.
  86810. * @param i number
  86811. * @returns the upper case translation of the number i to hexadecimal.
  86812. */
  86813. static ToHex(i: number): string;
  86814. /**
  86815. * Returns -1 if value is negative and +1 is value is positive.
  86816. * @param value the value
  86817. * @returns the value itself if it's equal to zero.
  86818. */
  86819. static Sign(value: number): number;
  86820. /**
  86821. * Returns the value itself if it's between min and max.
  86822. * Returns min if the value is lower than min.
  86823. * Returns max if the value is greater than max.
  86824. * @param value the value to clmap
  86825. * @param min the min value to clamp to (default: 0)
  86826. * @param max the max value to clamp to (default: 1)
  86827. * @returns the clamped value
  86828. */
  86829. static Clamp(value: number, min?: number, max?: number): number;
  86830. /**
  86831. * the log2 of value.
  86832. * @param value the value to compute log2 of
  86833. * @returns the log2 of value.
  86834. */
  86835. static Log2(value: number): number;
  86836. /**
  86837. * the floor part of a log2 value.
  86838. * @param value the value to compute log2 of
  86839. * @returns the log2 of value.
  86840. */
  86841. static ILog2(value: number): number;
  86842. /**
  86843. * Loops the value, so that it is never larger than length and never smaller than 0.
  86844. *
  86845. * This is similar to the modulo operator but it works with floating point numbers.
  86846. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  86847. * With t = 5 and length = 2.5, the result would be 0.0.
  86848. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  86849. * @param value the value
  86850. * @param length the length
  86851. * @returns the looped value
  86852. */
  86853. static Repeat(value: number, length: number): number;
  86854. /**
  86855. * Normalize the value between 0.0 and 1.0 using min and max values
  86856. * @param value value to normalize
  86857. * @param min max to normalize between
  86858. * @param max min to normalize between
  86859. * @returns the normalized value
  86860. */
  86861. static Normalize(value: number, min: number, max: number): number;
  86862. /**
  86863. * Denormalize the value from 0.0 and 1.0 using min and max values
  86864. * @param normalized value to denormalize
  86865. * @param min max to denormalize between
  86866. * @param max min to denormalize between
  86867. * @returns the denormalized value
  86868. */
  86869. static Denormalize(normalized: number, min: number, max: number): number;
  86870. /**
  86871. * Calculates the shortest difference between two given angles given in degrees.
  86872. * @param current current angle in degrees
  86873. * @param target target angle in degrees
  86874. * @returns the delta
  86875. */
  86876. static DeltaAngle(current: number, target: number): number;
  86877. /**
  86878. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  86879. * @param tx value
  86880. * @param length length
  86881. * @returns The returned value will move back and forth between 0 and length
  86882. */
  86883. static PingPong(tx: number, length: number): number;
  86884. /**
  86885. * Interpolates between min and max with smoothing at the limits.
  86886. *
  86887. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  86888. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  86889. * @param from from
  86890. * @param to to
  86891. * @param tx value
  86892. * @returns the smooth stepped value
  86893. */
  86894. static SmoothStep(from: number, to: number, tx: number): number;
  86895. /**
  86896. * Moves a value current towards target.
  86897. *
  86898. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  86899. * Negative values of maxDelta pushes the value away from target.
  86900. * @param current current value
  86901. * @param target target value
  86902. * @param maxDelta max distance to move
  86903. * @returns resulting value
  86904. */
  86905. static MoveTowards(current: number, target: number, maxDelta: number): number;
  86906. /**
  86907. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  86908. *
  86909. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  86910. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  86911. * @param current current value
  86912. * @param target target value
  86913. * @param maxDelta max distance to move
  86914. * @returns resulting angle
  86915. */
  86916. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  86917. /**
  86918. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  86919. * @param start start value
  86920. * @param end target value
  86921. * @param amount amount to lerp between
  86922. * @returns the lerped value
  86923. */
  86924. static Lerp(start: number, end: number, amount: number): number;
  86925. /**
  86926. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  86927. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  86928. * @param start start value
  86929. * @param end target value
  86930. * @param amount amount to lerp between
  86931. * @returns the lerped value
  86932. */
  86933. static LerpAngle(start: number, end: number, amount: number): number;
  86934. /**
  86935. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  86936. * @param a start value
  86937. * @param b target value
  86938. * @param value value between a and b
  86939. * @returns the inverseLerp value
  86940. */
  86941. static InverseLerp(a: number, b: number, value: number): number;
  86942. /**
  86943. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  86944. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  86945. * @param value1 spline value
  86946. * @param tangent1 spline value
  86947. * @param value2 spline value
  86948. * @param tangent2 spline value
  86949. * @param amount input value
  86950. * @returns hermite result
  86951. */
  86952. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  86953. /**
  86954. * Returns a random float number between and min and max values
  86955. * @param min min value of random
  86956. * @param max max value of random
  86957. * @returns random value
  86958. */
  86959. static RandomRange(min: number, max: number): number;
  86960. /**
  86961. * This function returns percentage of a number in a given range.
  86962. *
  86963. * RangeToPercent(40,20,60) will return 0.5 (50%)
  86964. * RangeToPercent(34,0,100) will return 0.34 (34%)
  86965. * @param number to convert to percentage
  86966. * @param min min range
  86967. * @param max max range
  86968. * @returns the percentage
  86969. */
  86970. static RangeToPercent(number: number, min: number, max: number): number;
  86971. /**
  86972. * This function returns number that corresponds to the percentage in a given range.
  86973. *
  86974. * PercentToRange(0.34,0,100) will return 34.
  86975. * @param percent to convert to number
  86976. * @param min min range
  86977. * @param max max range
  86978. * @returns the number
  86979. */
  86980. static PercentToRange(percent: number, min: number, max: number): number;
  86981. /**
  86982. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  86983. * @param angle The angle to normalize in radian.
  86984. * @return The converted angle.
  86985. */
  86986. static NormalizeRadians(angle: number): number;
  86987. }
  86988. }
  86989. declare module BABYLON {
  86990. /**
  86991. * Constant used to convert a value to gamma space
  86992. * @ignorenaming
  86993. */
  86994. export const ToGammaSpace: number;
  86995. /**
  86996. * Constant used to convert a value to linear space
  86997. * @ignorenaming
  86998. */
  86999. export const ToLinearSpace = 2.2;
  87000. /**
  87001. * Constant used to define the minimal number value in Babylon.js
  87002. * @ignorenaming
  87003. */
  87004. let Epsilon: number;
  87005. }
  87006. declare module BABYLON {
  87007. /**
  87008. * Class used to represent a viewport on screen
  87009. */
  87010. export class Viewport {
  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 Viewport object located at (x, y) and sized (width, height)
  87021. * @param x defines viewport left coordinate
  87022. * @param y defines viewport top coordinate
  87023. * @param width defines the viewport width
  87024. * @param height defines the viewport height
  87025. */
  87026. constructor(
  87027. /** viewport left coordinate */
  87028. x: number,
  87029. /** viewport top coordinate */
  87030. y: number,
  87031. /**viewport width */
  87032. width: number,
  87033. /** viewport height */
  87034. height: number);
  87035. /**
  87036. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  87037. * @param renderWidth defines the rendering width
  87038. * @param renderHeight defines the rendering height
  87039. * @returns a new Viewport
  87040. */
  87041. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  87042. /**
  87043. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  87044. * @param renderWidth defines the rendering width
  87045. * @param renderHeight defines the rendering height
  87046. * @param ref defines the target viewport
  87047. * @returns the current viewport
  87048. */
  87049. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  87050. /**
  87051. * Returns a new Viewport copied from the current one
  87052. * @returns a new Viewport
  87053. */
  87054. clone(): Viewport;
  87055. }
  87056. }
  87057. declare module BABYLON {
  87058. /**
  87059. * Class containing a set of static utilities functions for arrays.
  87060. */
  87061. export class ArrayTools {
  87062. /**
  87063. * Returns an array of the given size filled with element built from the given constructor and the paramters
  87064. * @param size the number of element to construct and put in the array
  87065. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  87066. * @returns a new array filled with new objects
  87067. */
  87068. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  87069. }
  87070. }
  87071. declare module BABYLON {
  87072. /**
  87073. * Represents a plane by the equation ax + by + cz + d = 0
  87074. */
  87075. export class Plane {
  87076. private static _TmpMatrix;
  87077. /**
  87078. * Normal of the plane (a,b,c)
  87079. */
  87080. normal: Vector3;
  87081. /**
  87082. * d component of the plane
  87083. */
  87084. d: number;
  87085. /**
  87086. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  87087. * @param a a component of the plane
  87088. * @param b b component of the plane
  87089. * @param c c component of the plane
  87090. * @param d d component of the plane
  87091. */
  87092. constructor(a: number, b: number, c: number, d: number);
  87093. /**
  87094. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  87095. */
  87096. asArray(): number[];
  87097. /**
  87098. * @returns a new plane copied from the current Plane.
  87099. */
  87100. clone(): Plane;
  87101. /**
  87102. * @returns the string "Plane".
  87103. */
  87104. getClassName(): string;
  87105. /**
  87106. * @returns the Plane hash code.
  87107. */
  87108. getHashCode(): number;
  87109. /**
  87110. * Normalize the current Plane in place.
  87111. * @returns the updated Plane.
  87112. */
  87113. normalize(): Plane;
  87114. /**
  87115. * Applies a transformation the plane and returns the result
  87116. * @param transformation the transformation matrix to be applied to the plane
  87117. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  87118. */
  87119. transform(transformation: DeepImmutable<Matrix>): Plane;
  87120. /**
  87121. * Compute the dot product between the point and the plane normal
  87122. * @param point point to calculate the dot product with
  87123. * @returns the dot product (float) of the point coordinates and the plane normal.
  87124. */
  87125. dotCoordinate(point: DeepImmutable<Vector3>): number;
  87126. /**
  87127. * Updates the current Plane from the plane defined by the three given points.
  87128. * @param point1 one of the points used to contruct the plane
  87129. * @param point2 one of the points used to contruct the plane
  87130. * @param point3 one of the points used to contruct the plane
  87131. * @returns the updated Plane.
  87132. */
  87133. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  87134. /**
  87135. * 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).
  87136. * Note that for this function to work as expected you should make sure that:
  87137. * - direction and the plane normal are normalized
  87138. * - epsilon is a number just bigger than -1, something like -0.99 for eg
  87139. * @param direction the direction to check if the plane is facing
  87140. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  87141. * @returns True if the plane is facing the given direction
  87142. */
  87143. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  87144. /**
  87145. * Calculates the distance to a point
  87146. * @param point point to calculate distance to
  87147. * @returns the signed distance (float) from the given point to the Plane.
  87148. */
  87149. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  87150. /**
  87151. * Creates a plane from an array
  87152. * @param array the array to create a plane from
  87153. * @returns a new Plane from the given array.
  87154. */
  87155. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  87156. /**
  87157. * Creates a plane from three points
  87158. * @param point1 point used to create the plane
  87159. * @param point2 point used to create the plane
  87160. * @param point3 point used to create the plane
  87161. * @returns a new Plane defined by the three given points.
  87162. */
  87163. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  87164. /**
  87165. * Creates a plane from an origin point and a normal
  87166. * @param origin origin of the plane to be constructed
  87167. * @param normal normal of the plane to be constructed
  87168. * @returns a new Plane the normal vector to this plane at the given origin point.
  87169. * Note : the vector "normal" is updated because normalized.
  87170. */
  87171. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  87172. /**
  87173. * Calculates the distance from a plane and a point
  87174. * @param origin origin of the plane to be constructed
  87175. * @param normal normal of the plane to be constructed
  87176. * @param point point to calculate distance to
  87177. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  87178. */
  87179. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  87180. }
  87181. }
  87182. declare module BABYLON {
  87183. /** @hidden */
  87184. export class PerformanceConfigurator {
  87185. /** @hidden */
  87186. static MatrixUse64Bits: boolean;
  87187. /** @hidden */
  87188. static MatrixTrackPrecisionChange: boolean;
  87189. /** @hidden */
  87190. static MatrixCurrentType: any;
  87191. /** @hidden */
  87192. static MatrixTrackedMatrices: Array<any> | null;
  87193. /** @hidden */
  87194. static SetMatrixPrecision(use64bits: boolean): void;
  87195. }
  87196. }
  87197. declare module BABYLON {
  87198. /**
  87199. * Class representing a vector containing 2 coordinates
  87200. */
  87201. export class Vector2 {
  87202. /** defines the first coordinate */
  87203. x: number;
  87204. /** defines the second coordinate */
  87205. y: number;
  87206. /**
  87207. * Creates a new Vector2 from the given x and y coordinates
  87208. * @param x defines the first coordinate
  87209. * @param y defines the second coordinate
  87210. */
  87211. constructor(
  87212. /** defines the first coordinate */
  87213. x?: number,
  87214. /** defines the second coordinate */
  87215. y?: number);
  87216. /**
  87217. * Gets a string with the Vector2 coordinates
  87218. * @returns a string with the Vector2 coordinates
  87219. */
  87220. toString(): string;
  87221. /**
  87222. * Gets class name
  87223. * @returns the string "Vector2"
  87224. */
  87225. getClassName(): string;
  87226. /**
  87227. * Gets current vector hash code
  87228. * @returns the Vector2 hash code as a number
  87229. */
  87230. getHashCode(): number;
  87231. /**
  87232. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  87233. * @param array defines the source array
  87234. * @param index defines the offset in source array
  87235. * @returns the current Vector2
  87236. */
  87237. toArray(array: FloatArray, index?: number): Vector2;
  87238. /**
  87239. * Update the current vector from an array
  87240. * @param array defines the destination array
  87241. * @param index defines the offset in the destination array
  87242. * @returns the current Vector3
  87243. */
  87244. fromArray(array: FloatArray, index?: number): Vector2;
  87245. /**
  87246. * Copy the current vector to an array
  87247. * @returns a new array with 2 elements: the Vector2 coordinates.
  87248. */
  87249. asArray(): number[];
  87250. /**
  87251. * Sets the Vector2 coordinates with the given Vector2 coordinates
  87252. * @param source defines the source Vector2
  87253. * @returns the current updated Vector2
  87254. */
  87255. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  87256. /**
  87257. * Sets the Vector2 coordinates with the given floats
  87258. * @param x defines the first coordinate
  87259. * @param y defines the second coordinate
  87260. * @returns the current updated Vector2
  87261. */
  87262. copyFromFloats(x: number, y: number): Vector2;
  87263. /**
  87264. * Sets the Vector2 coordinates with the given floats
  87265. * @param x defines the first coordinate
  87266. * @param y defines the second coordinate
  87267. * @returns the current updated Vector2
  87268. */
  87269. set(x: number, y: number): Vector2;
  87270. /**
  87271. * Add another vector with the current one
  87272. * @param otherVector defines the other vector
  87273. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  87274. */
  87275. add(otherVector: DeepImmutable<Vector2>): Vector2;
  87276. /**
  87277. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  87278. * @param otherVector defines the other vector
  87279. * @param result defines the target vector
  87280. * @returns the unmodified current Vector2
  87281. */
  87282. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  87283. /**
  87284. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  87285. * @param otherVector defines the other vector
  87286. * @returns the current updated Vector2
  87287. */
  87288. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  87289. /**
  87290. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  87291. * @param otherVector defines the other vector
  87292. * @returns a new Vector2
  87293. */
  87294. addVector3(otherVector: Vector3): Vector2;
  87295. /**
  87296. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  87297. * @param otherVector defines the other vector
  87298. * @returns a new Vector2
  87299. */
  87300. subtract(otherVector: Vector2): Vector2;
  87301. /**
  87302. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  87303. * @param otherVector defines the other vector
  87304. * @param result defines the target vector
  87305. * @returns the unmodified current Vector2
  87306. */
  87307. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  87308. /**
  87309. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  87310. * @param otherVector defines the other vector
  87311. * @returns the current updated Vector2
  87312. */
  87313. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  87314. /**
  87315. * Multiplies in place the current Vector2 coordinates by the given ones
  87316. * @param otherVector defines the other vector
  87317. * @returns the current updated Vector2
  87318. */
  87319. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  87320. /**
  87321. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  87322. * @param otherVector defines the other vector
  87323. * @returns a new Vector2
  87324. */
  87325. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  87326. /**
  87327. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  87328. * @param otherVector defines the other vector
  87329. * @param result defines the target vector
  87330. * @returns the unmodified current Vector2
  87331. */
  87332. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  87333. /**
  87334. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  87335. * @param x defines the first coordinate
  87336. * @param y defines the second coordinate
  87337. * @returns a new Vector2
  87338. */
  87339. multiplyByFloats(x: number, y: number): Vector2;
  87340. /**
  87341. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  87342. * @param otherVector defines the other vector
  87343. * @returns a new Vector2
  87344. */
  87345. divide(otherVector: Vector2): Vector2;
  87346. /**
  87347. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  87348. * @param otherVector defines the other vector
  87349. * @param result defines the target vector
  87350. * @returns the unmodified current Vector2
  87351. */
  87352. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  87353. /**
  87354. * Divides the current Vector2 coordinates by the given ones
  87355. * @param otherVector defines the other vector
  87356. * @returns the current updated Vector2
  87357. */
  87358. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  87359. /**
  87360. * Gets a new Vector2 with current Vector2 negated coordinates
  87361. * @returns a new Vector2
  87362. */
  87363. negate(): Vector2;
  87364. /**
  87365. * Negate this vector in place
  87366. * @returns this
  87367. */
  87368. negateInPlace(): Vector2;
  87369. /**
  87370. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  87371. * @param result defines the Vector3 object where to store the result
  87372. * @returns the current Vector2
  87373. */
  87374. negateToRef(result: Vector2): Vector2;
  87375. /**
  87376. * Multiply the Vector2 coordinates by scale
  87377. * @param scale defines the scaling factor
  87378. * @returns the current updated Vector2
  87379. */
  87380. scaleInPlace(scale: number): Vector2;
  87381. /**
  87382. * Returns a new Vector2 scaled by "scale" from the current Vector2
  87383. * @param scale defines the scaling factor
  87384. * @returns a new Vector2
  87385. */
  87386. scale(scale: number): Vector2;
  87387. /**
  87388. * Scale the current Vector2 values by a factor to a given Vector2
  87389. * @param scale defines the scale factor
  87390. * @param result defines the Vector2 object where to store the result
  87391. * @returns the unmodified current Vector2
  87392. */
  87393. scaleToRef(scale: number, result: Vector2): Vector2;
  87394. /**
  87395. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  87396. * @param scale defines the scale factor
  87397. * @param result defines the Vector2 object where to store the result
  87398. * @returns the unmodified current Vector2
  87399. */
  87400. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  87401. /**
  87402. * Gets a boolean if two vectors are equals
  87403. * @param otherVector defines the other vector
  87404. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  87405. */
  87406. equals(otherVector: DeepImmutable<Vector2>): boolean;
  87407. /**
  87408. * Gets a boolean if two vectors are equals (using an epsilon value)
  87409. * @param otherVector defines the other vector
  87410. * @param epsilon defines the minimal distance to consider equality
  87411. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  87412. */
  87413. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  87414. /**
  87415. * Gets a new Vector2 from current Vector2 floored values
  87416. * @returns a new Vector2
  87417. */
  87418. floor(): Vector2;
  87419. /**
  87420. * Gets a new Vector2 from current Vector2 floored values
  87421. * @returns a new Vector2
  87422. */
  87423. fract(): Vector2;
  87424. /**
  87425. * Gets the length of the vector
  87426. * @returns the vector length (float)
  87427. */
  87428. length(): number;
  87429. /**
  87430. * Gets the vector squared length
  87431. * @returns the vector squared length (float)
  87432. */
  87433. lengthSquared(): number;
  87434. /**
  87435. * Normalize the vector
  87436. * @returns the current updated Vector2
  87437. */
  87438. normalize(): Vector2;
  87439. /**
  87440. * Gets a new Vector2 copied from the Vector2
  87441. * @returns a new Vector2
  87442. */
  87443. clone(): Vector2;
  87444. /**
  87445. * Gets a new Vector2(0, 0)
  87446. * @returns a new Vector2
  87447. */
  87448. static Zero(): Vector2;
  87449. /**
  87450. * Gets a new Vector2(1, 1)
  87451. * @returns a new Vector2
  87452. */
  87453. static One(): Vector2;
  87454. /**
  87455. * Gets a new Vector2 set from the given index element of the given array
  87456. * @param array defines the data source
  87457. * @param offset defines the offset in the data source
  87458. * @returns a new Vector2
  87459. */
  87460. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  87461. /**
  87462. * Sets "result" from the given index element of the given array
  87463. * @param array defines the data source
  87464. * @param offset defines the offset in the data source
  87465. * @param result defines the target vector
  87466. */
  87467. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  87468. /**
  87469. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  87470. * @param value1 defines 1st point of control
  87471. * @param value2 defines 2nd point of control
  87472. * @param value3 defines 3rd point of control
  87473. * @param value4 defines 4th point of control
  87474. * @param amount defines the interpolation factor
  87475. * @returns a new Vector2
  87476. */
  87477. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  87478. /**
  87479. * 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".
  87480. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  87481. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  87482. * @param value defines the value to clamp
  87483. * @param min defines the lower limit
  87484. * @param max defines the upper limit
  87485. * @returns a new Vector2
  87486. */
  87487. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  87488. /**
  87489. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  87490. * @param value1 defines the 1st control point
  87491. * @param tangent1 defines the outgoing tangent
  87492. * @param value2 defines the 2nd control point
  87493. * @param tangent2 defines the incoming tangent
  87494. * @param amount defines the interpolation factor
  87495. * @returns a new Vector2
  87496. */
  87497. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  87498. /**
  87499. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  87500. * @param start defines the start vector
  87501. * @param end defines the end vector
  87502. * @param amount defines the interpolation factor
  87503. * @returns a new Vector2
  87504. */
  87505. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  87506. /**
  87507. * Gets the dot product of the vector "left" and the vector "right"
  87508. * @param left defines first vector
  87509. * @param right defines second vector
  87510. * @returns the dot product (float)
  87511. */
  87512. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  87513. /**
  87514. * Returns a new Vector2 equal to the normalized given vector
  87515. * @param vector defines the vector to normalize
  87516. * @returns a new Vector2
  87517. */
  87518. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  87519. /**
  87520. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  87521. * @param left defines 1st vector
  87522. * @param right defines 2nd vector
  87523. * @returns a new Vector2
  87524. */
  87525. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  87526. /**
  87527. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  87528. * @param left defines 1st vector
  87529. * @param right defines 2nd vector
  87530. * @returns a new Vector2
  87531. */
  87532. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  87533. /**
  87534. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  87535. * @param vector defines the vector to transform
  87536. * @param transformation defines the matrix to apply
  87537. * @returns a new Vector2
  87538. */
  87539. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  87540. /**
  87541. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  87542. * @param vector defines the vector to transform
  87543. * @param transformation defines the matrix to apply
  87544. * @param result defines the target vector
  87545. */
  87546. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  87547. /**
  87548. * Determines if a given vector is included in a triangle
  87549. * @param p defines the vector to test
  87550. * @param p0 defines 1st triangle point
  87551. * @param p1 defines 2nd triangle point
  87552. * @param p2 defines 3rd triangle point
  87553. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  87554. */
  87555. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  87556. /**
  87557. * Gets the distance between the vectors "value1" and "value2"
  87558. * @param value1 defines first vector
  87559. * @param value2 defines second vector
  87560. * @returns the distance between vectors
  87561. */
  87562. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  87563. /**
  87564. * Returns the squared distance between the vectors "value1" and "value2"
  87565. * @param value1 defines first vector
  87566. * @param value2 defines second vector
  87567. * @returns the squared distance between vectors
  87568. */
  87569. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  87570. /**
  87571. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  87572. * @param value1 defines first vector
  87573. * @param value2 defines second vector
  87574. * @returns a new Vector2
  87575. */
  87576. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  87577. /**
  87578. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  87579. * @param value1 defines first vector
  87580. * @param value2 defines second vector
  87581. * @param ref defines third vector
  87582. * @returns ref
  87583. */
  87584. static CenterToRef(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, ref: DeepImmutable<Vector2>): Vector2;
  87585. /**
  87586. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  87587. * @param p defines the middle point
  87588. * @param segA defines one point of the segment
  87589. * @param segB defines the other point of the segment
  87590. * @returns the shortest distance
  87591. */
  87592. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  87593. }
  87594. /**
  87595. * Class used to store (x,y,z) vector representation
  87596. * A Vector3 is the main object used in 3D geometry
  87597. * It can represent etiher the coordinates of a point the space, either a direction
  87598. * Reminder: js uses a left handed forward facing system
  87599. */
  87600. export class Vector3 {
  87601. private static _UpReadOnly;
  87602. private static _ZeroReadOnly;
  87603. /** @hidden */
  87604. _x: number;
  87605. /** @hidden */
  87606. _y: number;
  87607. /** @hidden */
  87608. _z: number;
  87609. /** @hidden */
  87610. _isDirty: boolean;
  87611. /** Gets or sets the x coordinate */
  87612. get x(): number;
  87613. set x(value: number);
  87614. /** Gets or sets the y coordinate */
  87615. get y(): number;
  87616. set y(value: number);
  87617. /** Gets or sets the z coordinate */
  87618. get z(): number;
  87619. set z(value: number);
  87620. /**
  87621. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  87622. * @param x defines the first coordinates (on X axis)
  87623. * @param y defines the second coordinates (on Y axis)
  87624. * @param z defines the third coordinates (on Z axis)
  87625. */
  87626. constructor(x?: number, y?: number, z?: number);
  87627. /**
  87628. * Creates a string representation of the Vector3
  87629. * @returns a string with the Vector3 coordinates.
  87630. */
  87631. toString(): string;
  87632. /**
  87633. * Gets the class name
  87634. * @returns the string "Vector3"
  87635. */
  87636. getClassName(): string;
  87637. /**
  87638. * Creates the Vector3 hash code
  87639. * @returns a number which tends to be unique between Vector3 instances
  87640. */
  87641. getHashCode(): number;
  87642. /**
  87643. * Creates an array containing three elements : the coordinates of the Vector3
  87644. * @returns a new array of numbers
  87645. */
  87646. asArray(): number[];
  87647. /**
  87648. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  87649. * @param array defines the destination array
  87650. * @param index defines the offset in the destination array
  87651. * @returns the current Vector3
  87652. */
  87653. toArray(array: FloatArray, index?: number): Vector3;
  87654. /**
  87655. * Update the current vector from an array
  87656. * @param array defines the destination array
  87657. * @param index defines the offset in the destination array
  87658. * @returns the current Vector3
  87659. */
  87660. fromArray(array: FloatArray, index?: number): Vector3;
  87661. /**
  87662. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  87663. * @returns a new Quaternion object, computed from the Vector3 coordinates
  87664. */
  87665. toQuaternion(): Quaternion;
  87666. /**
  87667. * Adds the given vector to the current Vector3
  87668. * @param otherVector defines the second operand
  87669. * @returns the current updated Vector3
  87670. */
  87671. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  87672. /**
  87673. * Adds the given coordinates to the current Vector3
  87674. * @param x defines the x coordinate of the operand
  87675. * @param y defines the y coordinate of the operand
  87676. * @param z defines the z coordinate of the operand
  87677. * @returns the current updated Vector3
  87678. */
  87679. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  87680. /**
  87681. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  87682. * @param otherVector defines the second operand
  87683. * @returns the resulting Vector3
  87684. */
  87685. add(otherVector: DeepImmutable<Vector3>): Vector3;
  87686. /**
  87687. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  87688. * @param otherVector defines the second operand
  87689. * @param result defines the Vector3 object where to store the result
  87690. * @returns the current Vector3
  87691. */
  87692. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  87693. /**
  87694. * Subtract the given vector from the current Vector3
  87695. * @param otherVector defines the second operand
  87696. * @returns the current updated Vector3
  87697. */
  87698. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  87699. /**
  87700. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  87701. * @param otherVector defines the second operand
  87702. * @returns the resulting Vector3
  87703. */
  87704. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  87705. /**
  87706. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  87707. * @param otherVector defines the second operand
  87708. * @param result defines the Vector3 object where to store the result
  87709. * @returns the current Vector3
  87710. */
  87711. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  87712. /**
  87713. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  87714. * @param x defines the x coordinate of the operand
  87715. * @param y defines the y coordinate of the operand
  87716. * @param z defines the z coordinate of the operand
  87717. * @returns the resulting Vector3
  87718. */
  87719. subtractFromFloats(x: number, y: number, z: number): Vector3;
  87720. /**
  87721. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  87722. * @param x defines the x coordinate of the operand
  87723. * @param y defines the y coordinate of the operand
  87724. * @param z defines the z coordinate of the operand
  87725. * @param result defines the Vector3 object where to store the result
  87726. * @returns the current Vector3
  87727. */
  87728. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  87729. /**
  87730. * Gets a new Vector3 set with the current Vector3 negated coordinates
  87731. * @returns a new Vector3
  87732. */
  87733. negate(): Vector3;
  87734. /**
  87735. * Negate this vector in place
  87736. * @returns this
  87737. */
  87738. negateInPlace(): Vector3;
  87739. /**
  87740. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  87741. * @param result defines the Vector3 object where to store the result
  87742. * @returns the current Vector3
  87743. */
  87744. negateToRef(result: Vector3): Vector3;
  87745. /**
  87746. * Multiplies the Vector3 coordinates by the float "scale"
  87747. * @param scale defines the multiplier factor
  87748. * @returns the current updated Vector3
  87749. */
  87750. scaleInPlace(scale: number): Vector3;
  87751. /**
  87752. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  87753. * @param scale defines the multiplier factor
  87754. * @returns a new Vector3
  87755. */
  87756. scale(scale: number): Vector3;
  87757. /**
  87758. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  87759. * @param scale defines the multiplier factor
  87760. * @param result defines the Vector3 object where to store the result
  87761. * @returns the current Vector3
  87762. */
  87763. scaleToRef(scale: number, result: Vector3): Vector3;
  87764. /**
  87765. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  87766. * @param scale defines the scale factor
  87767. * @param result defines the Vector3 object where to store the result
  87768. * @returns the unmodified current Vector3
  87769. */
  87770. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  87771. /**
  87772. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  87773. * @param origin defines the origin of the projection ray
  87774. * @param plane defines the plane to project to
  87775. * @returns the projected vector3
  87776. */
  87777. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  87778. /**
  87779. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  87780. * @param origin defines the origin of the projection ray
  87781. * @param plane defines the plane to project to
  87782. * @param result defines the Vector3 where to store the result
  87783. */
  87784. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  87785. /**
  87786. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  87787. * @param otherVector defines the second operand
  87788. * @returns true if both vectors are equals
  87789. */
  87790. equals(otherVector: DeepImmutable<Vector3>): boolean;
  87791. /**
  87792. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  87793. * @param otherVector defines the second operand
  87794. * @param epsilon defines the minimal distance to define values as equals
  87795. * @returns true if both vectors are distant less than epsilon
  87796. */
  87797. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  87798. /**
  87799. * Returns true if the current Vector3 coordinates equals the given floats
  87800. * @param x defines the x coordinate of the operand
  87801. * @param y defines the y coordinate of the operand
  87802. * @param z defines the z coordinate of the operand
  87803. * @returns true if both vectors are equals
  87804. */
  87805. equalsToFloats(x: number, y: number, z: number): boolean;
  87806. /**
  87807. * Multiplies the current Vector3 coordinates by the given ones
  87808. * @param otherVector defines the second operand
  87809. * @returns the current updated Vector3
  87810. */
  87811. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  87812. /**
  87813. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  87814. * @param otherVector defines the second operand
  87815. * @returns the new Vector3
  87816. */
  87817. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  87818. /**
  87819. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  87820. * @param otherVector defines the second operand
  87821. * @param result defines the Vector3 object where to store the result
  87822. * @returns the current Vector3
  87823. */
  87824. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  87825. /**
  87826. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  87827. * @param x defines the x coordinate of the operand
  87828. * @param y defines the y coordinate of the operand
  87829. * @param z defines the z coordinate of the operand
  87830. * @returns the new Vector3
  87831. */
  87832. multiplyByFloats(x: number, y: number, z: number): Vector3;
  87833. /**
  87834. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  87835. * @param otherVector defines the second operand
  87836. * @returns the new Vector3
  87837. */
  87838. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  87839. /**
  87840. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  87841. * @param otherVector defines the second operand
  87842. * @param result defines the Vector3 object where to store the result
  87843. * @returns the current Vector3
  87844. */
  87845. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  87846. /**
  87847. * Divides the current Vector3 coordinates by the given ones.
  87848. * @param otherVector defines the second operand
  87849. * @returns the current updated Vector3
  87850. */
  87851. divideInPlace(otherVector: Vector3): Vector3;
  87852. /**
  87853. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  87854. * @param other defines the second operand
  87855. * @returns the current updated Vector3
  87856. */
  87857. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  87858. /**
  87859. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  87860. * @param other defines the second operand
  87861. * @returns the current updated Vector3
  87862. */
  87863. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  87864. /**
  87865. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  87866. * @param x defines the x coordinate of the operand
  87867. * @param y defines the y coordinate of the operand
  87868. * @param z defines the z coordinate of the operand
  87869. * @returns the current updated Vector3
  87870. */
  87871. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  87872. /**
  87873. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  87874. * @param x defines the x coordinate of the operand
  87875. * @param y defines the y coordinate of the operand
  87876. * @param z defines the z coordinate of the operand
  87877. * @returns the current updated Vector3
  87878. */
  87879. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  87880. /**
  87881. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  87882. * Check if is non uniform within a certain amount of decimal places to account for this
  87883. * @param epsilon the amount the values can differ
  87884. * @returns if the the vector is non uniform to a certain number of decimal places
  87885. */
  87886. isNonUniformWithinEpsilon(epsilon: number): boolean;
  87887. /**
  87888. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  87889. */
  87890. get isNonUniform(): boolean;
  87891. /**
  87892. * Gets a new Vector3 from current Vector3 floored values
  87893. * @returns a new Vector3
  87894. */
  87895. floor(): Vector3;
  87896. /**
  87897. * Gets a new Vector3 from current Vector3 floored values
  87898. * @returns a new Vector3
  87899. */
  87900. fract(): Vector3;
  87901. /**
  87902. * Gets the length of the Vector3
  87903. * @returns the length of the Vector3
  87904. */
  87905. length(): number;
  87906. /**
  87907. * Gets the squared length of the Vector3
  87908. * @returns squared length of the Vector3
  87909. */
  87910. lengthSquared(): number;
  87911. /**
  87912. * Normalize the current Vector3.
  87913. * Please note that this is an in place operation.
  87914. * @returns the current updated Vector3
  87915. */
  87916. normalize(): Vector3;
  87917. /**
  87918. * Reorders the x y z properties of the vector in place
  87919. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  87920. * @returns the current updated vector
  87921. */
  87922. reorderInPlace(order: string): this;
  87923. /**
  87924. * Rotates the vector around 0,0,0 by a quaternion
  87925. * @param quaternion the rotation quaternion
  87926. * @param result vector to store the result
  87927. * @returns the resulting vector
  87928. */
  87929. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  87930. /**
  87931. * Rotates a vector around a given point
  87932. * @param quaternion the rotation quaternion
  87933. * @param point the point to rotate around
  87934. * @param result vector to store the result
  87935. * @returns the resulting vector
  87936. */
  87937. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  87938. /**
  87939. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  87940. * The cross product is then orthogonal to both current and "other"
  87941. * @param other defines the right operand
  87942. * @returns the cross product
  87943. */
  87944. cross(other: Vector3): Vector3;
  87945. /**
  87946. * Normalize the current Vector3 with the given input length.
  87947. * Please note that this is an in place operation.
  87948. * @param len the length of the vector
  87949. * @returns the current updated Vector3
  87950. */
  87951. normalizeFromLength(len: number): Vector3;
  87952. /**
  87953. * Normalize the current Vector3 to a new vector
  87954. * @returns the new Vector3
  87955. */
  87956. normalizeToNew(): Vector3;
  87957. /**
  87958. * Normalize the current Vector3 to the reference
  87959. * @param reference define the Vector3 to update
  87960. * @returns the updated Vector3
  87961. */
  87962. normalizeToRef(reference: Vector3): Vector3;
  87963. /**
  87964. * Creates a new Vector3 copied from the current Vector3
  87965. * @returns the new Vector3
  87966. */
  87967. clone(): Vector3;
  87968. /**
  87969. * Copies the given vector coordinates to the current Vector3 ones
  87970. * @param source defines the source Vector3
  87971. * @returns the current updated Vector3
  87972. */
  87973. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  87974. /**
  87975. * Copies the given floats to the current Vector3 coordinates
  87976. * @param x defines the x coordinate of the operand
  87977. * @param y defines the y coordinate of the operand
  87978. * @param z defines the z coordinate of the operand
  87979. * @returns the current updated Vector3
  87980. */
  87981. copyFromFloats(x: number, y: number, z: number): Vector3;
  87982. /**
  87983. * Copies the given floats to the current Vector3 coordinates
  87984. * @param x defines the x coordinate of the operand
  87985. * @param y defines the y coordinate of the operand
  87986. * @param z defines the z coordinate of the operand
  87987. * @returns the current updated Vector3
  87988. */
  87989. set(x: number, y: number, z: number): Vector3;
  87990. /**
  87991. * Copies the given float to the current Vector3 coordinates
  87992. * @param v defines the x, y and z coordinates of the operand
  87993. * @returns the current updated Vector3
  87994. */
  87995. setAll(v: number): Vector3;
  87996. /**
  87997. * Get the clip factor between two vectors
  87998. * @param vector0 defines the first operand
  87999. * @param vector1 defines the second operand
  88000. * @param axis defines the axis to use
  88001. * @param size defines the size along the axis
  88002. * @returns the clip factor
  88003. */
  88004. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  88005. /**
  88006. * Get angle between two vectors
  88007. * @param vector0 angle between vector0 and vector1
  88008. * @param vector1 angle between vector0 and vector1
  88009. * @param normal direction of the normal
  88010. * @return the angle between vector0 and vector1
  88011. */
  88012. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  88013. /**
  88014. * Returns a new Vector3 set from the index "offset" of the given array
  88015. * @param array defines the source array
  88016. * @param offset defines the offset in the source array
  88017. * @returns the new Vector3
  88018. */
  88019. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  88020. /**
  88021. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  88022. * @param array defines the source array
  88023. * @param offset defines the offset in the source array
  88024. * @returns the new Vector3
  88025. * @deprecated Please use FromArray instead.
  88026. */
  88027. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  88028. /**
  88029. * Sets the given vector "result" with the element values from the index "offset" of the given array
  88030. * @param array defines the source array
  88031. * @param offset defines the offset in the source array
  88032. * @param result defines the Vector3 where to store the result
  88033. */
  88034. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  88035. /**
  88036. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  88037. * @param array defines the source array
  88038. * @param offset defines the offset in the source array
  88039. * @param result defines the Vector3 where to store the result
  88040. * @deprecated Please use FromArrayToRef instead.
  88041. */
  88042. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  88043. /**
  88044. * Sets the given vector "result" with the given floats.
  88045. * @param x defines the x coordinate of the source
  88046. * @param y defines the y coordinate of the source
  88047. * @param z defines the z coordinate of the source
  88048. * @param result defines the Vector3 where to store the result
  88049. */
  88050. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  88051. /**
  88052. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  88053. * @returns a new empty Vector3
  88054. */
  88055. static Zero(): Vector3;
  88056. /**
  88057. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  88058. * @returns a new unit Vector3
  88059. */
  88060. static One(): Vector3;
  88061. /**
  88062. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  88063. * @returns a new up Vector3
  88064. */
  88065. static Up(): Vector3;
  88066. /**
  88067. * Gets a up Vector3 that must not be updated
  88068. */
  88069. static get UpReadOnly(): DeepImmutable<Vector3>;
  88070. /**
  88071. * Gets a zero Vector3 that must not be updated
  88072. */
  88073. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  88074. /**
  88075. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  88076. * @returns a new down Vector3
  88077. */
  88078. static Down(): Vector3;
  88079. /**
  88080. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  88081. * @param rightHandedSystem is the scene right-handed (negative z)
  88082. * @returns a new forward Vector3
  88083. */
  88084. static Forward(rightHandedSystem?: boolean): Vector3;
  88085. /**
  88086. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  88087. * @param rightHandedSystem is the scene right-handed (negative-z)
  88088. * @returns a new forward Vector3
  88089. */
  88090. static Backward(rightHandedSystem?: boolean): Vector3;
  88091. /**
  88092. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  88093. * @returns a new right Vector3
  88094. */
  88095. static Right(): Vector3;
  88096. /**
  88097. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  88098. * @returns a new left Vector3
  88099. */
  88100. static Left(): Vector3;
  88101. /**
  88102. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  88103. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  88104. * @param vector defines the Vector3 to transform
  88105. * @param transformation defines the transformation matrix
  88106. * @returns the transformed Vector3
  88107. */
  88108. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  88109. /**
  88110. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  88111. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  88112. * @param vector defines the Vector3 to transform
  88113. * @param transformation defines the transformation matrix
  88114. * @param result defines the Vector3 where to store the result
  88115. */
  88116. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  88117. /**
  88118. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  88119. * This method computes tranformed coordinates only, not transformed direction vectors
  88120. * @param x define the x coordinate of the source vector
  88121. * @param y define the y coordinate of the source vector
  88122. * @param z define the z coordinate of the source vector
  88123. * @param transformation defines the transformation matrix
  88124. * @param result defines the Vector3 where to store the result
  88125. */
  88126. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  88127. /**
  88128. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  88129. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  88130. * @param vector defines the Vector3 to transform
  88131. * @param transformation defines the transformation matrix
  88132. * @returns the new Vector3
  88133. */
  88134. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  88135. /**
  88136. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  88137. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  88138. * @param vector defines the Vector3 to transform
  88139. * @param transformation defines the transformation matrix
  88140. * @param result defines the Vector3 where to store the result
  88141. */
  88142. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  88143. /**
  88144. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  88145. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  88146. * @param x define the x coordinate of the source vector
  88147. * @param y define the y coordinate of the source vector
  88148. * @param z define the z coordinate of the source vector
  88149. * @param transformation defines the transformation matrix
  88150. * @param result defines the Vector3 where to store the result
  88151. */
  88152. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  88153. /**
  88154. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  88155. * @param value1 defines the first control point
  88156. * @param value2 defines the second control point
  88157. * @param value3 defines the third control point
  88158. * @param value4 defines the fourth control point
  88159. * @param amount defines the amount on the spline to use
  88160. * @returns the new Vector3
  88161. */
  88162. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  88163. /**
  88164. * 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"
  88165. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  88166. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  88167. * @param value defines the current value
  88168. * @param min defines the lower range value
  88169. * @param max defines the upper range value
  88170. * @returns the new Vector3
  88171. */
  88172. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  88173. /**
  88174. * 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"
  88175. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  88176. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  88177. * @param value defines the current value
  88178. * @param min defines the lower range value
  88179. * @param max defines the upper range value
  88180. * @param result defines the Vector3 where to store the result
  88181. */
  88182. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  88183. /**
  88184. * Checks if a given vector is inside a specific range
  88185. * @param v defines the vector to test
  88186. * @param min defines the minimum range
  88187. * @param max defines the maximum range
  88188. */
  88189. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  88190. /**
  88191. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  88192. * @param value1 defines the first control point
  88193. * @param tangent1 defines the first tangent vector
  88194. * @param value2 defines the second control point
  88195. * @param tangent2 defines the second tangent vector
  88196. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  88197. * @returns the new Vector3
  88198. */
  88199. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  88200. /**
  88201. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  88202. * @param start defines the start value
  88203. * @param end defines the end value
  88204. * @param amount max defines amount between both (between 0 and 1)
  88205. * @returns the new Vector3
  88206. */
  88207. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  88208. /**
  88209. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  88210. * @param start defines the start value
  88211. * @param end defines the end value
  88212. * @param amount max defines amount between both (between 0 and 1)
  88213. * @param result defines the Vector3 where to store the result
  88214. */
  88215. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  88216. /**
  88217. * Returns the dot product (float) between the vectors "left" and "right"
  88218. * @param left defines the left operand
  88219. * @param right defines the right operand
  88220. * @returns the dot product
  88221. */
  88222. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  88223. /**
  88224. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  88225. * The cross product is then orthogonal to both "left" and "right"
  88226. * @param left defines the left operand
  88227. * @param right defines the right operand
  88228. * @returns the cross product
  88229. */
  88230. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  88231. /**
  88232. * Sets the given vector "result" with the cross product of "left" and "right"
  88233. * The cross product is then orthogonal to both "left" and "right"
  88234. * @param left defines the left operand
  88235. * @param right defines the right operand
  88236. * @param result defines the Vector3 where to store the result
  88237. */
  88238. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  88239. /**
  88240. * Returns a new Vector3 as the normalization of the given vector
  88241. * @param vector defines the Vector3 to normalize
  88242. * @returns the new Vector3
  88243. */
  88244. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  88245. /**
  88246. * Sets the given vector "result" with the normalization of the given first vector
  88247. * @param vector defines the Vector3 to normalize
  88248. * @param result defines the Vector3 where to store the result
  88249. */
  88250. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  88251. /**
  88252. * Project a Vector3 onto screen space
  88253. * @param vector defines the Vector3 to project
  88254. * @param world defines the world matrix to use
  88255. * @param transform defines the transform (view x projection) matrix to use
  88256. * @param viewport defines the screen viewport to use
  88257. * @returns the new Vector3
  88258. */
  88259. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  88260. /**
  88261. * Project a Vector3 onto screen space to reference
  88262. * @param vector defines the Vector3 to project
  88263. * @param world defines the world matrix to use
  88264. * @param transform defines the transform (view x projection) matrix to use
  88265. * @param viewport defines the screen viewport to use
  88266. * @param result the vector in which the screen space will be stored
  88267. * @returns the new Vector3
  88268. */
  88269. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  88270. /** @hidden */
  88271. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  88272. /**
  88273. * Unproject from screen space to object space
  88274. * @param source defines the screen space Vector3 to use
  88275. * @param viewportWidth defines the current width of the viewport
  88276. * @param viewportHeight defines the current height of the viewport
  88277. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  88278. * @param transform defines the transform (view x projection) matrix to use
  88279. * @returns the new Vector3
  88280. */
  88281. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  88282. /**
  88283. * Unproject from screen space to object space
  88284. * @param source defines the screen space Vector3 to use
  88285. * @param viewportWidth defines the current width of the viewport
  88286. * @param viewportHeight defines the current height of the viewport
  88287. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  88288. * @param view defines the view matrix to use
  88289. * @param projection defines the projection matrix to use
  88290. * @returns the new Vector3
  88291. */
  88292. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  88293. /**
  88294. * Unproject from screen space to object space
  88295. * @param source defines the screen space Vector3 to use
  88296. * @param viewportWidth defines the current width of the viewport
  88297. * @param viewportHeight defines the current height of the viewport
  88298. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  88299. * @param view defines the view matrix to use
  88300. * @param projection defines the projection matrix to use
  88301. * @param result defines the Vector3 where to store the result
  88302. */
  88303. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  88304. /**
  88305. * Unproject from screen space to object space
  88306. * @param sourceX defines the screen space x coordinate to use
  88307. * @param sourceY defines the screen space y coordinate to use
  88308. * @param sourceZ defines the screen space z coordinate to use
  88309. * @param viewportWidth defines the current width of the viewport
  88310. * @param viewportHeight defines the current height of the viewport
  88311. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  88312. * @param view defines the view matrix to use
  88313. * @param projection defines the projection matrix to use
  88314. * @param result defines the Vector3 where to store the result
  88315. */
  88316. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  88317. /**
  88318. * Gets the minimal coordinate values between two Vector3
  88319. * @param left defines the first operand
  88320. * @param right defines the second operand
  88321. * @returns the new Vector3
  88322. */
  88323. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  88324. /**
  88325. * Gets the maximal coordinate values between two Vector3
  88326. * @param left defines the first operand
  88327. * @param right defines the second operand
  88328. * @returns the new Vector3
  88329. */
  88330. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  88331. /**
  88332. * Returns the distance between the vectors "value1" and "value2"
  88333. * @param value1 defines the first operand
  88334. * @param value2 defines the second operand
  88335. * @returns the distance
  88336. */
  88337. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  88338. /**
  88339. * Returns the squared distance between the vectors "value1" and "value2"
  88340. * @param value1 defines the first operand
  88341. * @param value2 defines the second operand
  88342. * @returns the squared distance
  88343. */
  88344. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  88345. /**
  88346. * Returns a new Vector3 located at the center between "value1" and "value2"
  88347. * @param value1 defines the first operand
  88348. * @param value2 defines the second operand
  88349. * @returns the new Vector3
  88350. */
  88351. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  88352. /**
  88353. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  88354. * @param value1 defines first vector
  88355. * @param value2 defines second vector
  88356. * @param ref defines third vector
  88357. * @returns ref
  88358. */
  88359. static CenterToRef(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, ref: DeepImmutable<Vector3>): Vector3;
  88360. /**
  88361. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  88362. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  88363. * to something in order to rotate it from its local system to the given target system
  88364. * Note: axis1, axis2 and axis3 are normalized during this operation
  88365. * @param axis1 defines the first axis
  88366. * @param axis2 defines the second axis
  88367. * @param axis3 defines the third axis
  88368. * @returns a new Vector3
  88369. */
  88370. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  88371. /**
  88372. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  88373. * @param axis1 defines the first axis
  88374. * @param axis2 defines the second axis
  88375. * @param axis3 defines the third axis
  88376. * @param ref defines the Vector3 where to store the result
  88377. */
  88378. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  88379. }
  88380. /**
  88381. * Vector4 class created for EulerAngle class conversion to Quaternion
  88382. */
  88383. export class Vector4 {
  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. * Creates a Vector4 object from the given floats.
  88394. * @param x x value of the vector
  88395. * @param y y value of the vector
  88396. * @param z z value of the vector
  88397. * @param w w value of the vector
  88398. */
  88399. constructor(
  88400. /** x value of the vector */
  88401. x: number,
  88402. /** y value of the vector */
  88403. y: number,
  88404. /** z value of the vector */
  88405. z: number,
  88406. /** w value of the vector */
  88407. w: number);
  88408. /**
  88409. * Returns the string with the Vector4 coordinates.
  88410. * @returns a string containing all the vector values
  88411. */
  88412. toString(): string;
  88413. /**
  88414. * Returns the string "Vector4".
  88415. * @returns "Vector4"
  88416. */
  88417. getClassName(): string;
  88418. /**
  88419. * Returns the Vector4 hash code.
  88420. * @returns a unique hash code
  88421. */
  88422. getHashCode(): number;
  88423. /**
  88424. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  88425. * @returns the resulting array
  88426. */
  88427. asArray(): number[];
  88428. /**
  88429. * Populates the given array from the given index with the Vector4 coordinates.
  88430. * @param array array to populate
  88431. * @param index index of the array to start at (default: 0)
  88432. * @returns the Vector4.
  88433. */
  88434. toArray(array: FloatArray, index?: number): Vector4;
  88435. /**
  88436. * Update the current vector from an array
  88437. * @param array defines the destination array
  88438. * @param index defines the offset in the destination array
  88439. * @returns the current Vector3
  88440. */
  88441. fromArray(array: FloatArray, index?: number): Vector4;
  88442. /**
  88443. * Adds the given vector to the current Vector4.
  88444. * @param otherVector the vector to add
  88445. * @returns the updated Vector4.
  88446. */
  88447. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  88448. /**
  88449. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  88450. * @param otherVector the vector to add
  88451. * @returns the resulting vector
  88452. */
  88453. add(otherVector: DeepImmutable<Vector4>): Vector4;
  88454. /**
  88455. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  88456. * @param otherVector the vector to add
  88457. * @param result the vector to store the result
  88458. * @returns the current Vector4.
  88459. */
  88460. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  88461. /**
  88462. * Subtract in place the given vector from the current Vector4.
  88463. * @param otherVector the vector to subtract
  88464. * @returns the updated Vector4.
  88465. */
  88466. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  88467. /**
  88468. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  88469. * @param otherVector the vector to add
  88470. * @returns the new vector with the result
  88471. */
  88472. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  88473. /**
  88474. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  88475. * @param otherVector the vector to subtract
  88476. * @param result the vector to store the result
  88477. * @returns the current Vector4.
  88478. */
  88479. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  88480. /**
  88481. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  88482. */
  88483. /**
  88484. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  88485. * @param x value to subtract
  88486. * @param y value to subtract
  88487. * @param z value to subtract
  88488. * @param w value to subtract
  88489. * @returns new vector containing the result
  88490. */
  88491. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  88492. /**
  88493. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  88494. * @param x value to subtract
  88495. * @param y value to subtract
  88496. * @param z value to subtract
  88497. * @param w value to subtract
  88498. * @param result the vector to store the result in
  88499. * @returns the current Vector4.
  88500. */
  88501. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  88502. /**
  88503. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  88504. * @returns a new vector with the negated values
  88505. */
  88506. negate(): Vector4;
  88507. /**
  88508. * Negate this vector in place
  88509. * @returns this
  88510. */
  88511. negateInPlace(): Vector4;
  88512. /**
  88513. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  88514. * @param result defines the Vector3 object where to store the result
  88515. * @returns the current Vector4
  88516. */
  88517. negateToRef(result: Vector4): Vector4;
  88518. /**
  88519. * Multiplies the current Vector4 coordinates by scale (float).
  88520. * @param scale the number to scale with
  88521. * @returns the updated Vector4.
  88522. */
  88523. scaleInPlace(scale: number): Vector4;
  88524. /**
  88525. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  88526. * @param scale the number to scale with
  88527. * @returns a new vector with the result
  88528. */
  88529. scale(scale: number): Vector4;
  88530. /**
  88531. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  88532. * @param scale the number to scale with
  88533. * @param result a vector to store the result in
  88534. * @returns the current Vector4.
  88535. */
  88536. scaleToRef(scale: number, result: Vector4): Vector4;
  88537. /**
  88538. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  88539. * @param scale defines the scale factor
  88540. * @param result defines the Vector4 object where to store the result
  88541. * @returns the unmodified current Vector4
  88542. */
  88543. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  88544. /**
  88545. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  88546. * @param otherVector the vector to compare against
  88547. * @returns true if they are equal
  88548. */
  88549. equals(otherVector: DeepImmutable<Vector4>): boolean;
  88550. /**
  88551. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  88552. * @param otherVector vector to compare against
  88553. * @param epsilon (Default: very small number)
  88554. * @returns true if they are equal
  88555. */
  88556. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  88557. /**
  88558. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  88559. * @param x x value to compare against
  88560. * @param y y value to compare against
  88561. * @param z z value to compare against
  88562. * @param w w value to compare against
  88563. * @returns true if equal
  88564. */
  88565. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  88566. /**
  88567. * Multiplies in place the current Vector4 by the given one.
  88568. * @param otherVector vector to multiple with
  88569. * @returns the updated Vector4.
  88570. */
  88571. multiplyInPlace(otherVector: Vector4): Vector4;
  88572. /**
  88573. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  88574. * @param otherVector vector to multiple with
  88575. * @returns resulting new vector
  88576. */
  88577. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  88578. /**
  88579. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  88580. * @param otherVector vector to multiple with
  88581. * @param result vector to store the result
  88582. * @returns the current Vector4.
  88583. */
  88584. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  88585. /**
  88586. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  88587. * @param x x value multiply with
  88588. * @param y y value multiply with
  88589. * @param z z value multiply with
  88590. * @param w w value multiply with
  88591. * @returns resulting new vector
  88592. */
  88593. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  88594. /**
  88595. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  88596. * @param otherVector vector to devide with
  88597. * @returns resulting new vector
  88598. */
  88599. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  88600. /**
  88601. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  88602. * @param otherVector vector to devide with
  88603. * @param result vector to store the result
  88604. * @returns the current Vector4.
  88605. */
  88606. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  88607. /**
  88608. * Divides the current Vector3 coordinates by the given ones.
  88609. * @param otherVector vector to devide with
  88610. * @returns the updated Vector3.
  88611. */
  88612. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  88613. /**
  88614. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  88615. * @param other defines the second operand
  88616. * @returns the current updated Vector4
  88617. */
  88618. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  88619. /**
  88620. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  88621. * @param other defines the second operand
  88622. * @returns the current updated Vector4
  88623. */
  88624. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  88625. /**
  88626. * Gets a new Vector4 from current Vector4 floored values
  88627. * @returns a new Vector4
  88628. */
  88629. floor(): Vector4;
  88630. /**
  88631. * Gets a new Vector4 from current Vector3 floored values
  88632. * @returns a new Vector4
  88633. */
  88634. fract(): Vector4;
  88635. /**
  88636. * Returns the Vector4 length (float).
  88637. * @returns the length
  88638. */
  88639. length(): number;
  88640. /**
  88641. * Returns the Vector4 squared length (float).
  88642. * @returns the length squared
  88643. */
  88644. lengthSquared(): number;
  88645. /**
  88646. * Normalizes in place the Vector4.
  88647. * @returns the updated Vector4.
  88648. */
  88649. normalize(): Vector4;
  88650. /**
  88651. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  88652. * @returns this converted to a new vector3
  88653. */
  88654. toVector3(): Vector3;
  88655. /**
  88656. * Returns a new Vector4 copied from the current one.
  88657. * @returns the new cloned vector
  88658. */
  88659. clone(): Vector4;
  88660. /**
  88661. * Updates the current Vector4 with the given one coordinates.
  88662. * @param source the source vector to copy from
  88663. * @returns the updated Vector4.
  88664. */
  88665. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  88666. /**
  88667. * Updates the current Vector4 coordinates with the given floats.
  88668. * @param x float to copy from
  88669. * @param y float to copy from
  88670. * @param z float to copy from
  88671. * @param w float to copy from
  88672. * @returns the updated Vector4.
  88673. */
  88674. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  88675. /**
  88676. * Updates the current Vector4 coordinates with the given floats.
  88677. * @param x float to set from
  88678. * @param y float to set from
  88679. * @param z float to set from
  88680. * @param w float to set from
  88681. * @returns the updated Vector4.
  88682. */
  88683. set(x: number, y: number, z: number, w: number): Vector4;
  88684. /**
  88685. * Copies the given float to the current Vector3 coordinates
  88686. * @param v defines the x, y, z and w coordinates of the operand
  88687. * @returns the current updated Vector3
  88688. */
  88689. setAll(v: number): Vector4;
  88690. /**
  88691. * Returns a new Vector4 set from the starting index of the given array.
  88692. * @param array the array to pull values from
  88693. * @param offset the offset into the array to start at
  88694. * @returns the new vector
  88695. */
  88696. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  88697. /**
  88698. * Updates the given vector "result" from the starting index of the given array.
  88699. * @param array the array to pull values from
  88700. * @param offset the offset into the array to start at
  88701. * @param result the vector to store the result in
  88702. */
  88703. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  88704. /**
  88705. * Updates the given vector "result" from the starting index of the given Float32Array.
  88706. * @param array the array to pull values from
  88707. * @param offset the offset into the array to start at
  88708. * @param result the vector to store the result in
  88709. */
  88710. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  88711. /**
  88712. * Updates the given vector "result" coordinates from the given floats.
  88713. * @param x float to set from
  88714. * @param y float to set from
  88715. * @param z float to set from
  88716. * @param w float to set from
  88717. * @param result the vector to the floats in
  88718. */
  88719. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  88720. /**
  88721. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  88722. * @returns the new vector
  88723. */
  88724. static Zero(): Vector4;
  88725. /**
  88726. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  88727. * @returns the new vector
  88728. */
  88729. static One(): Vector4;
  88730. /**
  88731. * Returns a new normalized Vector4 from the given one.
  88732. * @param vector the vector to normalize
  88733. * @returns the vector
  88734. */
  88735. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  88736. /**
  88737. * Updates the given vector "result" from the normalization of the given one.
  88738. * @param vector the vector to normalize
  88739. * @param result the vector to store the result in
  88740. */
  88741. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  88742. /**
  88743. * Returns a vector with the minimum values from the left and right vectors
  88744. * @param left left vector to minimize
  88745. * @param right right vector to minimize
  88746. * @returns a new vector with the minimum of the left and right vector values
  88747. */
  88748. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  88749. /**
  88750. * Returns a vector with the maximum values from the left and right vectors
  88751. * @param left left vector to maximize
  88752. * @param right right vector to maximize
  88753. * @returns a new vector with the maximum of the left and right vector values
  88754. */
  88755. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  88756. /**
  88757. * Returns the distance (float) between the vectors "value1" and "value2".
  88758. * @param value1 value to calulate the distance between
  88759. * @param value2 value to calulate the distance between
  88760. * @return the distance between the two vectors
  88761. */
  88762. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  88763. /**
  88764. * Returns the squared distance (float) between the vectors "value1" and "value2".
  88765. * @param value1 value to calulate the distance between
  88766. * @param value2 value to calulate the distance between
  88767. * @return the distance between the two vectors squared
  88768. */
  88769. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  88770. /**
  88771. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  88772. * @param value1 value to calulate the center between
  88773. * @param value2 value to calulate the center between
  88774. * @return the center between the two vectors
  88775. */
  88776. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  88777. /**
  88778. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  88779. * @param value1 defines first vector
  88780. * @param value2 defines second vector
  88781. * @param ref defines third vector
  88782. * @returns ref
  88783. */
  88784. static CenterToRef(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>, ref: DeepImmutable<Vector4>): Vector4;
  88785. /**
  88786. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  88787. * This methods computes transformed normalized direction vectors only.
  88788. * @param vector the vector to transform
  88789. * @param transformation the transformation matrix to apply
  88790. * @returns the new vector
  88791. */
  88792. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  88793. /**
  88794. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  88795. * This methods computes transformed normalized direction vectors only.
  88796. * @param vector the vector to transform
  88797. * @param transformation the transformation matrix to apply
  88798. * @param result the vector to store the result in
  88799. */
  88800. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  88801. /**
  88802. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  88803. * This methods computes transformed normalized direction vectors only.
  88804. * @param x value to transform
  88805. * @param y value to transform
  88806. * @param z value to transform
  88807. * @param w value to transform
  88808. * @param transformation the transformation matrix to apply
  88809. * @param result the vector to store the results in
  88810. */
  88811. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  88812. /**
  88813. * Creates a new Vector4 from a Vector3
  88814. * @param source defines the source data
  88815. * @param w defines the 4th component (default is 0)
  88816. * @returns a new Vector4
  88817. */
  88818. static FromVector3(source: Vector3, w?: number): Vector4;
  88819. }
  88820. /**
  88821. * Class used to store quaternion data
  88822. * @see https://en.wikipedia.org/wiki/Quaternion
  88823. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  88824. */
  88825. export class Quaternion {
  88826. /** @hidden */
  88827. _x: number;
  88828. /** @hidden */
  88829. _y: number;
  88830. /** @hidden */
  88831. _z: number;
  88832. /** @hidden */
  88833. _w: number;
  88834. /** @hidden */
  88835. _isDirty: boolean;
  88836. /** Gets or sets the x coordinate */
  88837. get x(): number;
  88838. set x(value: number);
  88839. /** Gets or sets the y coordinate */
  88840. get y(): number;
  88841. set y(value: number);
  88842. /** Gets or sets the z coordinate */
  88843. get z(): number;
  88844. set z(value: number);
  88845. /** Gets or sets the w coordinate */
  88846. get w(): number;
  88847. set w(value: number);
  88848. /**
  88849. * Creates a new Quaternion from the given floats
  88850. * @param x defines the first component (0 by default)
  88851. * @param y defines the second component (0 by default)
  88852. * @param z defines the third component (0 by default)
  88853. * @param w defines the fourth component (1.0 by default)
  88854. */
  88855. constructor(x?: number, y?: number, z?: number, w?: number);
  88856. /**
  88857. * Gets a string representation for the current quaternion
  88858. * @returns a string with the Quaternion coordinates
  88859. */
  88860. toString(): string;
  88861. /**
  88862. * Gets the class name of the quaternion
  88863. * @returns the string "Quaternion"
  88864. */
  88865. getClassName(): string;
  88866. /**
  88867. * Gets a hash code for this quaternion
  88868. * @returns the quaternion hash code
  88869. */
  88870. getHashCode(): number;
  88871. /**
  88872. * Copy the quaternion to an array
  88873. * @returns a new array populated with 4 elements from the quaternion coordinates
  88874. */
  88875. asArray(): number[];
  88876. /**
  88877. * Check if two quaternions are equals
  88878. * @param otherQuaternion defines the second operand
  88879. * @return true if the current quaternion and the given one coordinates are strictly equals
  88880. */
  88881. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  88882. /**
  88883. * Gets a boolean if two quaternions are equals (using an epsilon value)
  88884. * @param otherQuaternion defines the other quaternion
  88885. * @param epsilon defines the minimal distance to consider equality
  88886. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  88887. */
  88888. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  88889. /**
  88890. * Clone the current quaternion
  88891. * @returns a new quaternion copied from the current one
  88892. */
  88893. clone(): Quaternion;
  88894. /**
  88895. * Copy a quaternion to the current one
  88896. * @param other defines the other quaternion
  88897. * @returns the updated current quaternion
  88898. */
  88899. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  88900. /**
  88901. * Updates the current quaternion with the given float coordinates
  88902. * @param x defines the x coordinate
  88903. * @param y defines the y coordinate
  88904. * @param z defines the z coordinate
  88905. * @param w defines the w coordinate
  88906. * @returns the updated current quaternion
  88907. */
  88908. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  88909. /**
  88910. * Updates the current quaternion from the given float coordinates
  88911. * @param x defines the x coordinate
  88912. * @param y defines the y coordinate
  88913. * @param z defines the z coordinate
  88914. * @param w defines the w coordinate
  88915. * @returns the updated current quaternion
  88916. */
  88917. set(x: number, y: number, z: number, w: number): Quaternion;
  88918. /**
  88919. * Adds two quaternions
  88920. * @param other defines the second operand
  88921. * @returns a new quaternion as the addition result of the given one and the current quaternion
  88922. */
  88923. add(other: DeepImmutable<Quaternion>): Quaternion;
  88924. /**
  88925. * Add a quaternion to the current one
  88926. * @param other defines the quaternion to add
  88927. * @returns the current quaternion
  88928. */
  88929. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  88930. /**
  88931. * Subtract two quaternions
  88932. * @param other defines the second operand
  88933. * @returns a new quaternion as the subtraction result of the given one from the current one
  88934. */
  88935. subtract(other: Quaternion): Quaternion;
  88936. /**
  88937. * Multiplies the current quaternion by a scale factor
  88938. * @param value defines the scale factor
  88939. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  88940. */
  88941. scale(value: number): Quaternion;
  88942. /**
  88943. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  88944. * @param scale defines the scale factor
  88945. * @param result defines the Quaternion object where to store the result
  88946. * @returns the unmodified current quaternion
  88947. */
  88948. scaleToRef(scale: number, result: Quaternion): Quaternion;
  88949. /**
  88950. * Multiplies in place the current quaternion by a scale factor
  88951. * @param value defines the scale factor
  88952. * @returns the current modified quaternion
  88953. */
  88954. scaleInPlace(value: number): Quaternion;
  88955. /**
  88956. * Scale the current quaternion values by a factor and add the result to a given quaternion
  88957. * @param scale defines the scale factor
  88958. * @param result defines the Quaternion object where to store the result
  88959. * @returns the unmodified current quaternion
  88960. */
  88961. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  88962. /**
  88963. * Multiplies two quaternions
  88964. * @param q1 defines the second operand
  88965. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  88966. */
  88967. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  88968. /**
  88969. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  88970. * @param q1 defines the second operand
  88971. * @param result defines the target quaternion
  88972. * @returns the current quaternion
  88973. */
  88974. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  88975. /**
  88976. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  88977. * @param q1 defines the second operand
  88978. * @returns the currentupdated quaternion
  88979. */
  88980. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  88981. /**
  88982. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  88983. * @param ref defines the target quaternion
  88984. * @returns the current quaternion
  88985. */
  88986. conjugateToRef(ref: Quaternion): Quaternion;
  88987. /**
  88988. * Conjugates in place (1-q) the current quaternion
  88989. * @returns the current updated quaternion
  88990. */
  88991. conjugateInPlace(): Quaternion;
  88992. /**
  88993. * Conjugates in place (1-q) the current quaternion
  88994. * @returns a new quaternion
  88995. */
  88996. conjugate(): Quaternion;
  88997. /**
  88998. * Gets length of current quaternion
  88999. * @returns the quaternion length (float)
  89000. */
  89001. length(): number;
  89002. /**
  89003. * Normalize in place the current quaternion
  89004. * @returns the current updated quaternion
  89005. */
  89006. normalize(): Quaternion;
  89007. /**
  89008. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  89009. * @param order is a reserved parameter and is ignored for now
  89010. * @returns a new Vector3 containing the Euler angles
  89011. */
  89012. toEulerAngles(order?: string): Vector3;
  89013. /**
  89014. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  89015. * @param result defines the vector which will be filled with the Euler angles
  89016. * @returns the current unchanged quaternion
  89017. */
  89018. toEulerAnglesToRef(result: Vector3): Quaternion;
  89019. /**
  89020. * Updates the given rotation matrix with the current quaternion values
  89021. * @param result defines the target matrix
  89022. * @returns the current unchanged quaternion
  89023. */
  89024. toRotationMatrix(result: Matrix): Quaternion;
  89025. /**
  89026. * Updates the current quaternion from the given rotation matrix values
  89027. * @param matrix defines the source matrix
  89028. * @returns the current updated quaternion
  89029. */
  89030. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  89031. /**
  89032. * Creates a new quaternion from a rotation matrix
  89033. * @param matrix defines the source matrix
  89034. * @returns a new quaternion created from the given rotation matrix values
  89035. */
  89036. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  89037. /**
  89038. * Updates the given quaternion with the given rotation matrix values
  89039. * @param matrix defines the source matrix
  89040. * @param result defines the target quaternion
  89041. */
  89042. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  89043. /**
  89044. * Returns the dot product (float) between the quaternions "left" and "right"
  89045. * @param left defines the left operand
  89046. * @param right defines the right operand
  89047. * @returns the dot product
  89048. */
  89049. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  89050. /**
  89051. * Checks if the two quaternions are close to each other
  89052. * @param quat0 defines the first quaternion to check
  89053. * @param quat1 defines the second quaternion to check
  89054. * @returns true if the two quaternions are close to each other
  89055. */
  89056. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  89057. /**
  89058. * Creates an empty quaternion
  89059. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  89060. */
  89061. static Zero(): Quaternion;
  89062. /**
  89063. * Inverse a given quaternion
  89064. * @param q defines the source quaternion
  89065. * @returns a new quaternion as the inverted current quaternion
  89066. */
  89067. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  89068. /**
  89069. * Inverse a given quaternion
  89070. * @param q defines the source quaternion
  89071. * @param result the quaternion the result will be stored in
  89072. * @returns the result quaternion
  89073. */
  89074. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  89075. /**
  89076. * Creates an identity quaternion
  89077. * @returns the identity quaternion
  89078. */
  89079. static Identity(): Quaternion;
  89080. /**
  89081. * Gets a boolean indicating if the given quaternion is identity
  89082. * @param quaternion defines the quaternion to check
  89083. * @returns true if the quaternion is identity
  89084. */
  89085. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  89086. /**
  89087. * Creates a quaternion from a rotation around an axis
  89088. * @param axis defines the axis to use
  89089. * @param angle defines the angle to use
  89090. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  89091. */
  89092. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  89093. /**
  89094. * Creates a rotation around an axis and stores it into the given quaternion
  89095. * @param axis defines the axis to use
  89096. * @param angle defines the angle to use
  89097. * @param result defines the target quaternion
  89098. * @returns the target quaternion
  89099. */
  89100. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  89101. /**
  89102. * Creates a new quaternion from data stored into an array
  89103. * @param array defines the data source
  89104. * @param offset defines the offset in the source array where the data starts
  89105. * @returns a new quaternion
  89106. */
  89107. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  89108. /**
  89109. * Updates the given quaternion "result" from the starting index of the given array.
  89110. * @param array the array to pull values from
  89111. * @param offset the offset into the array to start at
  89112. * @param result the quaternion to store the result in
  89113. */
  89114. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  89115. /**
  89116. * Create a quaternion from Euler rotation angles
  89117. * @param x Pitch
  89118. * @param y Yaw
  89119. * @param z Roll
  89120. * @returns the new Quaternion
  89121. */
  89122. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  89123. /**
  89124. * Updates a quaternion from Euler rotation angles
  89125. * @param x Pitch
  89126. * @param y Yaw
  89127. * @param z Roll
  89128. * @param result the quaternion to store the result
  89129. * @returns the updated quaternion
  89130. */
  89131. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  89132. /**
  89133. * Create a quaternion from Euler rotation vector
  89134. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  89135. * @returns the new Quaternion
  89136. */
  89137. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  89138. /**
  89139. * Updates a quaternion from Euler rotation vector
  89140. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  89141. * @param result the quaternion to store the result
  89142. * @returns the updated quaternion
  89143. */
  89144. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  89145. /**
  89146. * Creates a new quaternion from the given Euler float angles (y, x, z)
  89147. * @param yaw defines the rotation around Y axis
  89148. * @param pitch defines the rotation around X axis
  89149. * @param roll defines the rotation around Z axis
  89150. * @returns the new quaternion
  89151. */
  89152. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  89153. /**
  89154. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  89155. * @param yaw defines the rotation around Y axis
  89156. * @param pitch defines the rotation around X axis
  89157. * @param roll defines the rotation around Z axis
  89158. * @param result defines the target quaternion
  89159. */
  89160. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  89161. /**
  89162. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  89163. * @param alpha defines the rotation around first axis
  89164. * @param beta defines the rotation around second axis
  89165. * @param gamma defines the rotation around third axis
  89166. * @returns the new quaternion
  89167. */
  89168. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  89169. /**
  89170. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  89171. * @param alpha defines the rotation around first axis
  89172. * @param beta defines the rotation around second axis
  89173. * @param gamma defines the rotation around third axis
  89174. * @param result defines the target quaternion
  89175. */
  89176. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  89177. /**
  89178. * 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)
  89179. * @param axis1 defines the first axis
  89180. * @param axis2 defines the second axis
  89181. * @param axis3 defines the third axis
  89182. * @returns the new quaternion
  89183. */
  89184. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  89185. /**
  89186. * 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
  89187. * @param axis1 defines the first axis
  89188. * @param axis2 defines the second axis
  89189. * @param axis3 defines the third axis
  89190. * @param ref defines the target quaternion
  89191. */
  89192. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  89193. /**
  89194. * Interpolates between two quaternions
  89195. * @param left defines first quaternion
  89196. * @param right defines second quaternion
  89197. * @param amount defines the gradient to use
  89198. * @returns the new interpolated quaternion
  89199. */
  89200. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  89201. /**
  89202. * Interpolates between two quaternions and stores it into a target quaternion
  89203. * @param left defines first quaternion
  89204. * @param right defines second quaternion
  89205. * @param amount defines the gradient to use
  89206. * @param result defines the target quaternion
  89207. */
  89208. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  89209. /**
  89210. * Interpolate between two quaternions using Hermite interpolation
  89211. * @param value1 defines first quaternion
  89212. * @param tangent1 defines the incoming tangent
  89213. * @param value2 defines second quaternion
  89214. * @param tangent2 defines the outgoing tangent
  89215. * @param amount defines the target quaternion
  89216. * @returns the new interpolated quaternion
  89217. */
  89218. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  89219. }
  89220. /**
  89221. * Class used to store matrix data (4x4)
  89222. */
  89223. export class Matrix {
  89224. /**
  89225. * Gets the precision of matrix computations
  89226. */
  89227. static get Use64Bits(): boolean;
  89228. private static _updateFlagSeed;
  89229. private static _identityReadOnly;
  89230. private _isIdentity;
  89231. private _isIdentityDirty;
  89232. private _isIdentity3x2;
  89233. private _isIdentity3x2Dirty;
  89234. /**
  89235. * Gets the update flag of the matrix which is an unique number for the matrix.
  89236. * It will be incremented every time the matrix data change.
  89237. * You can use it to speed the comparison between two versions of the same matrix.
  89238. */
  89239. updateFlag: number;
  89240. private readonly _m;
  89241. /**
  89242. * Gets the internal data of the matrix
  89243. */
  89244. get m(): DeepImmutable<Float32Array | Array<number>>;
  89245. /** @hidden */
  89246. _markAsUpdated(): void;
  89247. /** @hidden */
  89248. private _updateIdentityStatus;
  89249. /**
  89250. * Creates an empty matrix (filled with zeros)
  89251. */
  89252. constructor();
  89253. /**
  89254. * Check if the current matrix is identity
  89255. * @returns true is the matrix is the identity matrix
  89256. */
  89257. isIdentity(): boolean;
  89258. /**
  89259. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  89260. * @returns true is the matrix is the identity matrix
  89261. */
  89262. isIdentityAs3x2(): boolean;
  89263. /**
  89264. * Gets the determinant of the matrix
  89265. * @returns the matrix determinant
  89266. */
  89267. determinant(): number;
  89268. /**
  89269. * Returns the matrix as a Float32Array or Array<number>
  89270. * @returns the matrix underlying array
  89271. */
  89272. toArray(): DeepImmutable<Float32Array | Array<number>>;
  89273. /**
  89274. * Returns the matrix as a Float32Array or Array<number>
  89275. * @returns the matrix underlying array.
  89276. */
  89277. asArray(): DeepImmutable<Float32Array | Array<number>>;
  89278. /**
  89279. * Inverts the current matrix in place
  89280. * @returns the current inverted matrix
  89281. */
  89282. invert(): Matrix;
  89283. /**
  89284. * Sets all the matrix elements to zero
  89285. * @returns the current matrix
  89286. */
  89287. reset(): Matrix;
  89288. /**
  89289. * Adds the current matrix with a second one
  89290. * @param other defines the matrix to add
  89291. * @returns a new matrix as the addition of the current matrix and the given one
  89292. */
  89293. add(other: DeepImmutable<Matrix>): Matrix;
  89294. /**
  89295. * Sets the given matrix "result" to the addition of the current matrix and the given one
  89296. * @param other defines the matrix to add
  89297. * @param result defines the target matrix
  89298. * @returns the current matrix
  89299. */
  89300. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  89301. /**
  89302. * Adds in place the given matrix to the current matrix
  89303. * @param other defines the second operand
  89304. * @returns the current updated matrix
  89305. */
  89306. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  89307. /**
  89308. * Sets the given matrix to the current inverted Matrix
  89309. * @param other defines the target matrix
  89310. * @returns the unmodified current matrix
  89311. */
  89312. invertToRef(other: Matrix): Matrix;
  89313. /**
  89314. * add a value at the specified position in the current Matrix
  89315. * @param index the index of the value within the matrix. between 0 and 15.
  89316. * @param value the value to be added
  89317. * @returns the current updated matrix
  89318. */
  89319. addAtIndex(index: number, value: number): Matrix;
  89320. /**
  89321. * mutiply the specified position in the current Matrix by a value
  89322. * @param index the index of the value within the matrix. between 0 and 15.
  89323. * @param value the value to be added
  89324. * @returns the current updated matrix
  89325. */
  89326. multiplyAtIndex(index: number, value: number): Matrix;
  89327. /**
  89328. * Inserts the translation vector (using 3 floats) in the current matrix
  89329. * @param x defines the 1st component of the translation
  89330. * @param y defines the 2nd component of the translation
  89331. * @param z defines the 3rd component of the translation
  89332. * @returns the current updated matrix
  89333. */
  89334. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  89335. /**
  89336. * Adds the translation vector (using 3 floats) in the current matrix
  89337. * @param x defines the 1st component of the translation
  89338. * @param y defines the 2nd component of the translation
  89339. * @param z defines the 3rd component of the translation
  89340. * @returns the current updated matrix
  89341. */
  89342. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  89343. /**
  89344. * Inserts the translation vector in the current matrix
  89345. * @param vector3 defines the translation to insert
  89346. * @returns the current updated matrix
  89347. */
  89348. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  89349. /**
  89350. * Gets the translation value of the current matrix
  89351. * @returns a new Vector3 as the extracted translation from the matrix
  89352. */
  89353. getTranslation(): Vector3;
  89354. /**
  89355. * Fill a Vector3 with the extracted translation from the matrix
  89356. * @param result defines the Vector3 where to store the translation
  89357. * @returns the current matrix
  89358. */
  89359. getTranslationToRef(result: Vector3): Matrix;
  89360. /**
  89361. * Remove rotation and scaling part from the matrix
  89362. * @returns the updated matrix
  89363. */
  89364. removeRotationAndScaling(): Matrix;
  89365. /**
  89366. * Multiply two matrices
  89367. * @param other defines the second operand
  89368. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  89369. */
  89370. multiply(other: DeepImmutable<Matrix>): Matrix;
  89371. /**
  89372. * Copy the current matrix from the given one
  89373. * @param other defines the source matrix
  89374. * @returns the current updated matrix
  89375. */
  89376. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  89377. /**
  89378. * Populates the given array from the starting index with the current matrix values
  89379. * @param array defines the target array
  89380. * @param offset defines the offset in the target array where to start storing values
  89381. * @returns the current matrix
  89382. */
  89383. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  89384. /**
  89385. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  89386. * @param other defines the second operand
  89387. * @param result defines the matrix where to store the multiplication
  89388. * @returns the current matrix
  89389. */
  89390. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  89391. /**
  89392. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  89393. * @param other defines the second operand
  89394. * @param result defines the array where to store the multiplication
  89395. * @param offset defines the offset in the target array where to start storing values
  89396. * @returns the current matrix
  89397. */
  89398. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  89399. /**
  89400. * Check equality between this matrix and a second one
  89401. * @param value defines the second matrix to compare
  89402. * @returns true is the current matrix and the given one values are strictly equal
  89403. */
  89404. equals(value: DeepImmutable<Matrix>): boolean;
  89405. /**
  89406. * Clone the current matrix
  89407. * @returns a new matrix from the current matrix
  89408. */
  89409. clone(): Matrix;
  89410. /**
  89411. * Returns the name of the current matrix class
  89412. * @returns the string "Matrix"
  89413. */
  89414. getClassName(): string;
  89415. /**
  89416. * Gets the hash code of the current matrix
  89417. * @returns the hash code
  89418. */
  89419. getHashCode(): number;
  89420. /**
  89421. * Decomposes the current Matrix into a translation, rotation and scaling components
  89422. * @param scale defines the scale vector3 given as a reference to update
  89423. * @param rotation defines the rotation quaternion given as a reference to update
  89424. * @param translation defines the translation vector3 given as a reference to update
  89425. * @returns true if operation was successful
  89426. */
  89427. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  89428. /**
  89429. * Gets specific row of the matrix
  89430. * @param index defines the number of the row to get
  89431. * @returns the index-th row of the current matrix as a new Vector4
  89432. */
  89433. getRow(index: number): Nullable<Vector4>;
  89434. /**
  89435. * Sets the index-th row of the current matrix to the vector4 values
  89436. * @param index defines the number of the row to set
  89437. * @param row defines the target vector4
  89438. * @returns the updated current matrix
  89439. */
  89440. setRow(index: number, row: Vector4): Matrix;
  89441. /**
  89442. * Compute the transpose of the matrix
  89443. * @returns the new transposed matrix
  89444. */
  89445. transpose(): Matrix;
  89446. /**
  89447. * Compute the transpose of the matrix and store it in a given matrix
  89448. * @param result defines the target matrix
  89449. * @returns the current matrix
  89450. */
  89451. transposeToRef(result: Matrix): Matrix;
  89452. /**
  89453. * Sets the index-th row of the current matrix with the given 4 x float values
  89454. * @param index defines the row index
  89455. * @param x defines the x component to set
  89456. * @param y defines the y component to set
  89457. * @param z defines the z component to set
  89458. * @param w defines the w component to set
  89459. * @returns the updated current matrix
  89460. */
  89461. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  89462. /**
  89463. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  89464. * @param scale defines the scale factor
  89465. * @returns a new matrix
  89466. */
  89467. scale(scale: number): Matrix;
  89468. /**
  89469. * Scale the current matrix values by a factor to a given result matrix
  89470. * @param scale defines the scale factor
  89471. * @param result defines the matrix to store the result
  89472. * @returns the current matrix
  89473. */
  89474. scaleToRef(scale: number, result: Matrix): Matrix;
  89475. /**
  89476. * Scale the current matrix values by a factor and add the result to a given matrix
  89477. * @param scale defines the scale factor
  89478. * @param result defines the Matrix to store the result
  89479. * @returns the current matrix
  89480. */
  89481. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  89482. /**
  89483. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  89484. * @param ref matrix to store the result
  89485. */
  89486. toNormalMatrix(ref: Matrix): void;
  89487. /**
  89488. * Gets only rotation part of the current matrix
  89489. * @returns a new matrix sets to the extracted rotation matrix from the current one
  89490. */
  89491. getRotationMatrix(): Matrix;
  89492. /**
  89493. * Extracts the rotation matrix from the current one and sets it as the given "result"
  89494. * @param result defines the target matrix to store data to
  89495. * @returns the current matrix
  89496. */
  89497. getRotationMatrixToRef(result: Matrix): Matrix;
  89498. /**
  89499. * Toggles model matrix from being right handed to left handed in place and vice versa
  89500. */
  89501. toggleModelMatrixHandInPlace(): void;
  89502. /**
  89503. * Toggles projection matrix from being right handed to left handed in place and vice versa
  89504. */
  89505. toggleProjectionMatrixHandInPlace(): void;
  89506. /**
  89507. * Creates a matrix from an array
  89508. * @param array defines the source array
  89509. * @param offset defines an offset in the source array
  89510. * @returns a new Matrix set from the starting index of the given array
  89511. */
  89512. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  89513. /**
  89514. * Copy the content of an array into a given matrix
  89515. * @param array defines the source array
  89516. * @param offset defines an offset in the source array
  89517. * @param result defines the target matrix
  89518. */
  89519. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  89520. /**
  89521. * Stores an array into a matrix after having multiplied each component by a given factor
  89522. * @param array defines the source array
  89523. * @param offset defines the offset in the source array
  89524. * @param scale defines the scaling factor
  89525. * @param result defines the target matrix
  89526. */
  89527. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  89528. /**
  89529. * Gets an identity matrix that must not be updated
  89530. */
  89531. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  89532. /**
  89533. * Stores a list of values (16) inside a given matrix
  89534. * @param initialM11 defines 1st value of 1st row
  89535. * @param initialM12 defines 2nd value of 1st row
  89536. * @param initialM13 defines 3rd value of 1st row
  89537. * @param initialM14 defines 4th value of 1st row
  89538. * @param initialM21 defines 1st value of 2nd row
  89539. * @param initialM22 defines 2nd value of 2nd row
  89540. * @param initialM23 defines 3rd value of 2nd row
  89541. * @param initialM24 defines 4th value of 2nd row
  89542. * @param initialM31 defines 1st value of 3rd row
  89543. * @param initialM32 defines 2nd value of 3rd row
  89544. * @param initialM33 defines 3rd value of 3rd row
  89545. * @param initialM34 defines 4th value of 3rd row
  89546. * @param initialM41 defines 1st value of 4th row
  89547. * @param initialM42 defines 2nd value of 4th row
  89548. * @param initialM43 defines 3rd value of 4th row
  89549. * @param initialM44 defines 4th value of 4th row
  89550. * @param result defines the target matrix
  89551. */
  89552. 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;
  89553. /**
  89554. * Creates new matrix from a list of values (16)
  89555. * @param initialM11 defines 1st value of 1st row
  89556. * @param initialM12 defines 2nd value of 1st row
  89557. * @param initialM13 defines 3rd value of 1st row
  89558. * @param initialM14 defines 4th value of 1st row
  89559. * @param initialM21 defines 1st value of 2nd row
  89560. * @param initialM22 defines 2nd value of 2nd row
  89561. * @param initialM23 defines 3rd value of 2nd row
  89562. * @param initialM24 defines 4th value of 2nd row
  89563. * @param initialM31 defines 1st value of 3rd row
  89564. * @param initialM32 defines 2nd value of 3rd row
  89565. * @param initialM33 defines 3rd value of 3rd row
  89566. * @param initialM34 defines 4th value of 3rd row
  89567. * @param initialM41 defines 1st value of 4th row
  89568. * @param initialM42 defines 2nd value of 4th row
  89569. * @param initialM43 defines 3rd value of 4th row
  89570. * @param initialM44 defines 4th value of 4th row
  89571. * @returns the new matrix
  89572. */
  89573. 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;
  89574. /**
  89575. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  89576. * @param scale defines the scale vector3
  89577. * @param rotation defines the rotation quaternion
  89578. * @param translation defines the translation vector3
  89579. * @returns a new matrix
  89580. */
  89581. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  89582. /**
  89583. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  89584. * @param scale defines the scale vector3
  89585. * @param rotation defines the rotation quaternion
  89586. * @param translation defines the translation vector3
  89587. * @param result defines the target matrix
  89588. */
  89589. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  89590. /**
  89591. * Creates a new identity matrix
  89592. * @returns a new identity matrix
  89593. */
  89594. static Identity(): Matrix;
  89595. /**
  89596. * Creates a new identity matrix and stores the result in a given matrix
  89597. * @param result defines the target matrix
  89598. */
  89599. static IdentityToRef(result: Matrix): void;
  89600. /**
  89601. * Creates a new zero matrix
  89602. * @returns a new zero matrix
  89603. */
  89604. static Zero(): Matrix;
  89605. /**
  89606. * Creates a new rotation matrix for "angle" radians around the X axis
  89607. * @param angle defines the angle (in radians) to use
  89608. * @return the new matrix
  89609. */
  89610. static RotationX(angle: number): Matrix;
  89611. /**
  89612. * Creates a new matrix as the invert of a given matrix
  89613. * @param source defines the source matrix
  89614. * @returns the new matrix
  89615. */
  89616. static Invert(source: DeepImmutable<Matrix>): Matrix;
  89617. /**
  89618. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  89619. * @param angle defines the angle (in radians) to use
  89620. * @param result defines the target matrix
  89621. */
  89622. static RotationXToRef(angle: number, result: Matrix): void;
  89623. /**
  89624. * Creates a new rotation matrix for "angle" radians around the Y axis
  89625. * @param angle defines the angle (in radians) to use
  89626. * @return the new matrix
  89627. */
  89628. static RotationY(angle: number): Matrix;
  89629. /**
  89630. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  89631. * @param angle defines the angle (in radians) to use
  89632. * @param result defines the target matrix
  89633. */
  89634. static RotationYToRef(angle: number, result: Matrix): void;
  89635. /**
  89636. * Creates a new rotation matrix for "angle" radians around the Z axis
  89637. * @param angle defines the angle (in radians) to use
  89638. * @return the new matrix
  89639. */
  89640. static RotationZ(angle: number): Matrix;
  89641. /**
  89642. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  89643. * @param angle defines the angle (in radians) to use
  89644. * @param result defines the target matrix
  89645. */
  89646. static RotationZToRef(angle: number, result: Matrix): void;
  89647. /**
  89648. * Creates a new rotation matrix for "angle" radians around the given axis
  89649. * @param axis defines the axis to use
  89650. * @param angle defines the angle (in radians) to use
  89651. * @return the new matrix
  89652. */
  89653. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  89654. /**
  89655. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  89656. * @param axis defines the axis to use
  89657. * @param angle defines the angle (in radians) to use
  89658. * @param result defines the target matrix
  89659. */
  89660. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  89661. /**
  89662. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  89663. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  89664. * @param from defines the vector to align
  89665. * @param to defines the vector to align to
  89666. * @param result defines the target matrix
  89667. */
  89668. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  89669. /**
  89670. * Creates a rotation matrix
  89671. * @param yaw defines the yaw angle in radians (Y axis)
  89672. * @param pitch defines the pitch angle in radians (X axis)
  89673. * @param roll defines the roll angle in radians (Z axis)
  89674. * @returns the new rotation matrix
  89675. */
  89676. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  89677. /**
  89678. * Creates a rotation matrix and stores it in a given matrix
  89679. * @param yaw defines the yaw angle in radians (Y axis)
  89680. * @param pitch defines the pitch angle in radians (X axis)
  89681. * @param roll defines the roll angle in radians (Z axis)
  89682. * @param result defines the target matrix
  89683. */
  89684. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  89685. /**
  89686. * Creates a scaling matrix
  89687. * @param x defines the scale factor on X axis
  89688. * @param y defines the scale factor on Y axis
  89689. * @param z defines the scale factor on Z axis
  89690. * @returns the new matrix
  89691. */
  89692. static Scaling(x: number, y: number, z: number): Matrix;
  89693. /**
  89694. * Creates a scaling matrix and stores it in a given matrix
  89695. * @param x defines the scale factor on X axis
  89696. * @param y defines the scale factor on Y axis
  89697. * @param z defines the scale factor on Z axis
  89698. * @param result defines the target matrix
  89699. */
  89700. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  89701. /**
  89702. * Creates a translation matrix
  89703. * @param x defines the translation on X axis
  89704. * @param y defines the translation on Y axis
  89705. * @param z defines the translationon Z axis
  89706. * @returns the new matrix
  89707. */
  89708. static Translation(x: number, y: number, z: number): Matrix;
  89709. /**
  89710. * Creates a translation matrix and stores it in a given matrix
  89711. * @param x defines the translation on X axis
  89712. * @param y defines the translation on Y axis
  89713. * @param z defines the translationon Z axis
  89714. * @param result defines the target matrix
  89715. */
  89716. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  89717. /**
  89718. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  89719. * @param startValue defines the start value
  89720. * @param endValue defines the end value
  89721. * @param gradient defines the gradient factor
  89722. * @returns the new matrix
  89723. */
  89724. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  89725. /**
  89726. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  89727. * @param startValue defines the start value
  89728. * @param endValue defines the end value
  89729. * @param gradient defines the gradient factor
  89730. * @param result defines the Matrix object where to store data
  89731. */
  89732. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  89733. /**
  89734. * Builds a new matrix whose values are computed by:
  89735. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  89736. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  89737. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  89738. * @param startValue defines the first matrix
  89739. * @param endValue defines the second matrix
  89740. * @param gradient defines the gradient between the two matrices
  89741. * @returns the new matrix
  89742. */
  89743. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  89744. /**
  89745. * Update a matrix to values which are computed by:
  89746. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  89747. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  89748. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  89749. * @param startValue defines the first matrix
  89750. * @param endValue defines the second matrix
  89751. * @param gradient defines the gradient between the two matrices
  89752. * @param result defines the target matrix
  89753. */
  89754. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  89755. /**
  89756. * 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"
  89757. * This function works in left handed mode
  89758. * @param eye defines the final position of the entity
  89759. * @param target defines where the entity should look at
  89760. * @param up defines the up vector for the entity
  89761. * @returns the new matrix
  89762. */
  89763. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  89764. /**
  89765. * 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".
  89766. * This function works in left handed mode
  89767. * @param eye defines the final position of the entity
  89768. * @param target defines where the entity should look at
  89769. * @param up defines the up vector for the entity
  89770. * @param result defines the target matrix
  89771. */
  89772. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  89773. /**
  89774. * 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"
  89775. * This function works in right handed mode
  89776. * @param eye defines the final position of the entity
  89777. * @param target defines where the entity should look at
  89778. * @param up defines the up vector for the entity
  89779. * @returns the new matrix
  89780. */
  89781. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  89782. /**
  89783. * 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".
  89784. * This function works in right handed mode
  89785. * @param eye defines the final position of the entity
  89786. * @param target defines where the entity should look at
  89787. * @param up defines the up vector for the entity
  89788. * @param result defines the target matrix
  89789. */
  89790. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  89791. /**
  89792. * Create a left-handed orthographic projection matrix
  89793. * @param width defines the viewport width
  89794. * @param height defines the viewport height
  89795. * @param znear defines the near clip plane
  89796. * @param zfar defines the far clip plane
  89797. * @returns a new matrix as a left-handed orthographic projection matrix
  89798. */
  89799. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  89800. /**
  89801. * Store a left-handed orthographic projection to a given matrix
  89802. * @param width defines the viewport width
  89803. * @param height defines the viewport height
  89804. * @param znear defines the near clip plane
  89805. * @param zfar defines the far clip plane
  89806. * @param result defines the target matrix
  89807. */
  89808. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  89809. /**
  89810. * Create a left-handed orthographic projection matrix
  89811. * @param left defines the viewport left coordinate
  89812. * @param right defines the viewport right coordinate
  89813. * @param bottom defines the viewport bottom coordinate
  89814. * @param top defines the viewport top coordinate
  89815. * @param znear defines the near clip plane
  89816. * @param zfar defines the far clip plane
  89817. * @returns a new matrix as a left-handed orthographic projection matrix
  89818. */
  89819. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  89820. /**
  89821. * Stores a left-handed orthographic projection into a given matrix
  89822. * @param left defines the viewport left coordinate
  89823. * @param right defines the viewport right coordinate
  89824. * @param bottom defines the viewport bottom coordinate
  89825. * @param top defines the viewport top coordinate
  89826. * @param znear defines the near clip plane
  89827. * @param zfar defines the far clip plane
  89828. * @param result defines the target matrix
  89829. */
  89830. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  89831. /**
  89832. * Creates a right-handed orthographic projection matrix
  89833. * @param left defines the viewport left coordinate
  89834. * @param right defines the viewport right coordinate
  89835. * @param bottom defines the viewport bottom coordinate
  89836. * @param top defines the viewport top coordinate
  89837. * @param znear defines the near clip plane
  89838. * @param zfar defines the far clip plane
  89839. * @returns a new matrix as a right-handed orthographic projection matrix
  89840. */
  89841. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  89842. /**
  89843. * Stores a right-handed orthographic projection into a given matrix
  89844. * @param left defines the viewport left coordinate
  89845. * @param right defines the viewport right coordinate
  89846. * @param bottom defines the viewport bottom coordinate
  89847. * @param top defines the viewport top coordinate
  89848. * @param znear defines the near clip plane
  89849. * @param zfar defines the far clip plane
  89850. * @param result defines the target matrix
  89851. */
  89852. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  89853. /**
  89854. * Creates a left-handed perspective projection matrix
  89855. * @param width defines the viewport width
  89856. * @param height defines the viewport height
  89857. * @param znear defines the near clip plane
  89858. * @param zfar defines the far clip plane
  89859. * @returns a new matrix as a left-handed perspective projection matrix
  89860. */
  89861. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  89862. /**
  89863. * Creates a left-handed perspective projection matrix
  89864. * @param fov defines the horizontal field of view
  89865. * @param aspect defines the aspect ratio
  89866. * @param znear defines the near clip plane
  89867. * @param zfar defines the far clip plane
  89868. * @returns a new matrix as a left-handed perspective projection matrix
  89869. */
  89870. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  89871. /**
  89872. * Stores a left-handed perspective projection into a given matrix
  89873. * @param fov defines the horizontal field of view
  89874. * @param aspect defines the aspect ratio
  89875. * @param znear defines the near clip plane
  89876. * @param zfar defines the far clip plane
  89877. * @param result defines the target matrix
  89878. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  89879. */
  89880. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  89881. /**
  89882. * Stores a left-handed perspective projection into a given matrix with depth reversed
  89883. * @param fov defines the horizontal field of view
  89884. * @param aspect defines the aspect ratio
  89885. * @param znear defines the near clip plane
  89886. * @param zfar not used as infinity is used as far clip
  89887. * @param result defines the target matrix
  89888. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  89889. */
  89890. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  89891. /**
  89892. * Creates a right-handed perspective projection matrix
  89893. * @param fov defines the horizontal field of view
  89894. * @param aspect defines the aspect ratio
  89895. * @param znear defines the near clip plane
  89896. * @param zfar defines the far clip plane
  89897. * @returns a new matrix as a right-handed perspective projection matrix
  89898. */
  89899. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  89900. /**
  89901. * Stores a right-handed perspective projection into a given matrix
  89902. * @param fov defines the horizontal field of view
  89903. * @param aspect defines the aspect ratio
  89904. * @param znear defines the near clip plane
  89905. * @param zfar defines the far clip plane
  89906. * @param result defines the target matrix
  89907. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  89908. */
  89909. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  89910. /**
  89911. * Stores a right-handed perspective projection into a given matrix
  89912. * @param fov defines the horizontal field of view
  89913. * @param aspect defines the aspect ratio
  89914. * @param znear defines the near clip plane
  89915. * @param zfar not used as infinity is used as far clip
  89916. * @param result defines the target matrix
  89917. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  89918. */
  89919. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  89920. /**
  89921. * Stores a perspective projection for WebVR info a given matrix
  89922. * @param fov defines the field of view
  89923. * @param znear defines the near clip plane
  89924. * @param zfar defines the far clip plane
  89925. * @param result defines the target matrix
  89926. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  89927. */
  89928. static PerspectiveFovWebVRToRef(fov: {
  89929. upDegrees: number;
  89930. downDegrees: number;
  89931. leftDegrees: number;
  89932. rightDegrees: number;
  89933. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  89934. /**
  89935. * Computes a complete transformation matrix
  89936. * @param viewport defines the viewport to use
  89937. * @param world defines the world matrix
  89938. * @param view defines the view matrix
  89939. * @param projection defines the projection matrix
  89940. * @param zmin defines the near clip plane
  89941. * @param zmax defines the far clip plane
  89942. * @returns the transformation matrix
  89943. */
  89944. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  89945. /**
  89946. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  89947. * @param matrix defines the matrix to use
  89948. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  89949. */
  89950. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  89951. /**
  89952. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  89953. * @param matrix defines the matrix to use
  89954. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  89955. */
  89956. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  89957. /**
  89958. * Compute the transpose of a given matrix
  89959. * @param matrix defines the matrix to transpose
  89960. * @returns the new matrix
  89961. */
  89962. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  89963. /**
  89964. * Compute the transpose of a matrix and store it in a target matrix
  89965. * @param matrix defines the matrix to transpose
  89966. * @param result defines the target matrix
  89967. */
  89968. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  89969. /**
  89970. * Computes a reflection matrix from a plane
  89971. * @param plane defines the reflection plane
  89972. * @returns a new matrix
  89973. */
  89974. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  89975. /**
  89976. * Computes a reflection matrix from a plane
  89977. * @param plane defines the reflection plane
  89978. * @param result defines the target matrix
  89979. */
  89980. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  89981. /**
  89982. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  89983. * @param xaxis defines the value of the 1st axis
  89984. * @param yaxis defines the value of the 2nd axis
  89985. * @param zaxis defines the value of the 3rd axis
  89986. * @param result defines the target matrix
  89987. */
  89988. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  89989. /**
  89990. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  89991. * @param quat defines the quaternion to use
  89992. * @param result defines the target matrix
  89993. */
  89994. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  89995. }
  89996. /**
  89997. * @hidden
  89998. */
  89999. export class TmpVectors {
  90000. static Vector2: Vector2[];
  90001. static Vector3: Vector3[];
  90002. static Vector4: Vector4[];
  90003. static Quaternion: Quaternion[];
  90004. static Matrix: Matrix[];
  90005. }
  90006. }
  90007. declare module BABYLON {
  90008. /**
  90009. * Defines potential orientation for back face culling
  90010. */
  90011. export enum Orientation {
  90012. /**
  90013. * Clockwise
  90014. */
  90015. CW = 0,
  90016. /** Counter clockwise */
  90017. CCW = 1
  90018. }
  90019. /** Class used to represent a Bezier curve */
  90020. export class BezierCurve {
  90021. /**
  90022. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  90023. * @param t defines the time
  90024. * @param x1 defines the left coordinate on X axis
  90025. * @param y1 defines the left coordinate on Y axis
  90026. * @param x2 defines the right coordinate on X axis
  90027. * @param y2 defines the right coordinate on Y axis
  90028. * @returns the interpolated value
  90029. */
  90030. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  90031. }
  90032. /**
  90033. * Defines angle representation
  90034. */
  90035. export class Angle {
  90036. private _radians;
  90037. /**
  90038. * Creates an Angle object of "radians" radians (float).
  90039. * @param radians the angle in radians
  90040. */
  90041. constructor(radians: number);
  90042. /**
  90043. * Get value in degrees
  90044. * @returns the Angle value in degrees (float)
  90045. */
  90046. degrees(): number;
  90047. /**
  90048. * Get value in radians
  90049. * @returns the Angle value in radians (float)
  90050. */
  90051. radians(): number;
  90052. /**
  90053. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  90054. * @param a defines first point as the origin
  90055. * @param b defines point
  90056. * @returns a new Angle
  90057. */
  90058. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  90059. /**
  90060. * Gets a new Angle object from the given float in radians
  90061. * @param radians defines the angle value in radians
  90062. * @returns a new Angle
  90063. */
  90064. static FromRadians(radians: number): Angle;
  90065. /**
  90066. * Gets a new Angle object from the given float in degrees
  90067. * @param degrees defines the angle value in degrees
  90068. * @returns a new Angle
  90069. */
  90070. static FromDegrees(degrees: number): Angle;
  90071. }
  90072. /**
  90073. * This represents an arc in a 2d space.
  90074. */
  90075. export class Arc2 {
  90076. /** Defines the start point of the arc */
  90077. startPoint: Vector2;
  90078. /** Defines the mid point of the arc */
  90079. midPoint: Vector2;
  90080. /** Defines the end point of the arc */
  90081. endPoint: Vector2;
  90082. /**
  90083. * Defines the center point of the arc.
  90084. */
  90085. centerPoint: Vector2;
  90086. /**
  90087. * Defines the radius of the arc.
  90088. */
  90089. radius: number;
  90090. /**
  90091. * Defines the angle of the arc (from mid point to end point).
  90092. */
  90093. angle: Angle;
  90094. /**
  90095. * Defines the start angle of the arc (from start point to middle point).
  90096. */
  90097. startAngle: Angle;
  90098. /**
  90099. * Defines the orientation of the arc (clock wise/counter clock wise).
  90100. */
  90101. orientation: Orientation;
  90102. /**
  90103. * Creates an Arc object from the three given points : start, middle and end.
  90104. * @param startPoint Defines the start point of the arc
  90105. * @param midPoint Defines the midlle point of the arc
  90106. * @param endPoint Defines the end point of the arc
  90107. */
  90108. constructor(
  90109. /** Defines the start point of the arc */
  90110. startPoint: Vector2,
  90111. /** Defines the mid point of the arc */
  90112. midPoint: Vector2,
  90113. /** Defines the end point of the arc */
  90114. endPoint: Vector2);
  90115. }
  90116. /**
  90117. * Represents a 2D path made up of multiple 2D points
  90118. */
  90119. export class Path2 {
  90120. private _points;
  90121. private _length;
  90122. /**
  90123. * If the path start and end point are the same
  90124. */
  90125. closed: boolean;
  90126. /**
  90127. * Creates a Path2 object from the starting 2D coordinates x and y.
  90128. * @param x the starting points x value
  90129. * @param y the starting points y value
  90130. */
  90131. constructor(x: number, y: number);
  90132. /**
  90133. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  90134. * @param x the added points x value
  90135. * @param y the added points y value
  90136. * @returns the updated Path2.
  90137. */
  90138. addLineTo(x: number, y: number): Path2;
  90139. /**
  90140. * 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.
  90141. * @param midX middle point x value
  90142. * @param midY middle point y value
  90143. * @param endX end point x value
  90144. * @param endY end point y value
  90145. * @param numberOfSegments (default: 36)
  90146. * @returns the updated Path2.
  90147. */
  90148. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  90149. /**
  90150. * Closes the Path2.
  90151. * @returns the Path2.
  90152. */
  90153. close(): Path2;
  90154. /**
  90155. * Gets the sum of the distance between each sequential point in the path
  90156. * @returns the Path2 total length (float).
  90157. */
  90158. length(): number;
  90159. /**
  90160. * Gets the points which construct the path
  90161. * @returns the Path2 internal array of points.
  90162. */
  90163. getPoints(): Vector2[];
  90164. /**
  90165. * Retreives the point at the distance aways from the starting point
  90166. * @param normalizedLengthPosition the length along the path to retreive the point from
  90167. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  90168. */
  90169. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  90170. /**
  90171. * Creates a new path starting from an x and y position
  90172. * @param x starting x value
  90173. * @param y starting y value
  90174. * @returns a new Path2 starting at the coordinates (x, y).
  90175. */
  90176. static StartingAt(x: number, y: number): Path2;
  90177. }
  90178. /**
  90179. * Represents a 3D path made up of multiple 3D points
  90180. */
  90181. export class Path3D {
  90182. /**
  90183. * an array of Vector3, the curve axis of the Path3D
  90184. */
  90185. path: Vector3[];
  90186. private _curve;
  90187. private _distances;
  90188. private _tangents;
  90189. private _normals;
  90190. private _binormals;
  90191. private _raw;
  90192. private _alignTangentsWithPath;
  90193. private readonly _pointAtData;
  90194. /**
  90195. * new Path3D(path, normal, raw)
  90196. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  90197. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  90198. * @param path an array of Vector3, the curve axis of the Path3D
  90199. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  90200. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  90201. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  90202. */
  90203. constructor(
  90204. /**
  90205. * an array of Vector3, the curve axis of the Path3D
  90206. */
  90207. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  90208. /**
  90209. * Returns the Path3D array of successive Vector3 designing its curve.
  90210. * @returns the Path3D array of successive Vector3 designing its curve.
  90211. */
  90212. getCurve(): Vector3[];
  90213. /**
  90214. * Returns the Path3D array of successive Vector3 designing its curve.
  90215. * @returns the Path3D array of successive Vector3 designing its curve.
  90216. */
  90217. getPoints(): Vector3[];
  90218. /**
  90219. * @returns the computed length (float) of the path.
  90220. */
  90221. length(): number;
  90222. /**
  90223. * Returns an array populated with tangent vectors on each Path3D curve point.
  90224. * @returns an array populated with tangent vectors on each Path3D curve point.
  90225. */
  90226. getTangents(): Vector3[];
  90227. /**
  90228. * Returns an array populated with normal vectors on each Path3D curve point.
  90229. * @returns an array populated with normal vectors on each Path3D curve point.
  90230. */
  90231. getNormals(): Vector3[];
  90232. /**
  90233. * Returns an array populated with binormal vectors on each Path3D curve point.
  90234. * @returns an array populated with binormal vectors on each Path3D curve point.
  90235. */
  90236. getBinormals(): Vector3[];
  90237. /**
  90238. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  90239. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  90240. */
  90241. getDistances(): number[];
  90242. /**
  90243. * Returns an interpolated point along this path
  90244. * @param position the position of the point along this path, from 0.0 to 1.0
  90245. * @returns a new Vector3 as the point
  90246. */
  90247. getPointAt(position: number): Vector3;
  90248. /**
  90249. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  90250. * @param position the position of the point along this path, from 0.0 to 1.0
  90251. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  90252. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  90253. */
  90254. getTangentAt(position: number, interpolated?: boolean): Vector3;
  90255. /**
  90256. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  90257. * @param position the position of the point along this path, from 0.0 to 1.0
  90258. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  90259. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  90260. */
  90261. getNormalAt(position: number, interpolated?: boolean): Vector3;
  90262. /**
  90263. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  90264. * @param position the position of the point along this path, from 0.0 to 1.0
  90265. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  90266. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  90267. */
  90268. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  90269. /**
  90270. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  90271. * @param position the position of the point along this path, from 0.0 to 1.0
  90272. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  90273. */
  90274. getDistanceAt(position: number): number;
  90275. /**
  90276. * Returns the array index of the previous point of an interpolated point along this path
  90277. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  90278. * @returns the array index
  90279. */
  90280. getPreviousPointIndexAt(position: number): number;
  90281. /**
  90282. * 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)
  90283. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  90284. * @returns the sub position
  90285. */
  90286. getSubPositionAt(position: number): number;
  90287. /**
  90288. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  90289. * @param target the vector of which to get the closest position to
  90290. * @returns the position of the closest virtual point on this path to the target vector
  90291. */
  90292. getClosestPositionTo(target: Vector3): number;
  90293. /**
  90294. * Returns a sub path (slice) of this path
  90295. * @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
  90296. * @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
  90297. * @returns a sub path (slice) of this path
  90298. */
  90299. slice(start?: number, end?: number): Path3D;
  90300. /**
  90301. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  90302. * @param path path which all values are copied into the curves points
  90303. * @param firstNormal which should be projected onto the curve
  90304. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  90305. * @returns the same object updated.
  90306. */
  90307. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  90308. private _compute;
  90309. private _getFirstNonNullVector;
  90310. private _getLastNonNullVector;
  90311. private _normalVector;
  90312. /**
  90313. * Updates the point at data for an interpolated point along this curve
  90314. * @param position the position of the point along this curve, from 0.0 to 1.0
  90315. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  90316. * @returns the (updated) point at data
  90317. */
  90318. private _updatePointAtData;
  90319. /**
  90320. * Updates the point at data from the specified parameters
  90321. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  90322. * @param point the interpolated point
  90323. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  90324. */
  90325. private _setPointAtData;
  90326. /**
  90327. * Updates the point at interpolation matrix for the tangents, normals and binormals
  90328. */
  90329. private _updateInterpolationMatrix;
  90330. }
  90331. /**
  90332. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  90333. * A Curve3 is designed from a series of successive Vector3.
  90334. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  90335. */
  90336. export class Curve3 {
  90337. private _points;
  90338. private _length;
  90339. /**
  90340. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  90341. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  90342. * @param v1 (Vector3) the control point
  90343. * @param v2 (Vector3) the end point of the Quadratic Bezier
  90344. * @param nbPoints (integer) the wanted number of points in the curve
  90345. * @returns the created Curve3
  90346. */
  90347. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  90348. /**
  90349. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  90350. * @param v0 (Vector3) the origin point of the Cubic Bezier
  90351. * @param v1 (Vector3) the first control point
  90352. * @param v2 (Vector3) the second control point
  90353. * @param v3 (Vector3) the end point of the Cubic Bezier
  90354. * @param nbPoints (integer) the wanted number of points in the curve
  90355. * @returns the created Curve3
  90356. */
  90357. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  90358. /**
  90359. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  90360. * @param p1 (Vector3) the origin point of the Hermite Spline
  90361. * @param t1 (Vector3) the tangent vector at the origin point
  90362. * @param p2 (Vector3) the end point of the Hermite Spline
  90363. * @param t2 (Vector3) the tangent vector at the end point
  90364. * @param nbPoints (integer) the wanted number of points in the curve
  90365. * @returns the created Curve3
  90366. */
  90367. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  90368. /**
  90369. * Returns a Curve3 object along a CatmullRom Spline curve :
  90370. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  90371. * @param nbPoints (integer) the wanted number of points between each curve control points
  90372. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  90373. * @returns the created Curve3
  90374. */
  90375. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  90376. /**
  90377. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  90378. * A Curve3 is designed from a series of successive Vector3.
  90379. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  90380. * @param points points which make up the curve
  90381. */
  90382. constructor(points: Vector3[]);
  90383. /**
  90384. * @returns the Curve3 stored array of successive Vector3
  90385. */
  90386. getPoints(): Vector3[];
  90387. /**
  90388. * @returns the computed length (float) of the curve.
  90389. */
  90390. length(): number;
  90391. /**
  90392. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  90393. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  90394. * curveA and curveB keep unchanged.
  90395. * @param curve the curve to continue from this curve
  90396. * @returns the newly constructed curve
  90397. */
  90398. continue(curve: DeepImmutable<Curve3>): Curve3;
  90399. private _computeLength;
  90400. }
  90401. }
  90402. declare module BABYLON {
  90403. /**
  90404. * This represents the main contract an easing function should follow.
  90405. * Easing functions are used throughout the animation system.
  90406. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90407. */
  90408. export interface IEasingFunction {
  90409. /**
  90410. * Given an input gradient between 0 and 1, this returns the corrseponding value
  90411. * of the easing function.
  90412. * The link below provides some of the most common examples of easing functions.
  90413. * @see https://easings.net/
  90414. * @param gradient Defines the value between 0 and 1 we want the easing value for
  90415. * @returns the corresponding value on the curve defined by the easing function
  90416. */
  90417. ease(gradient: number): number;
  90418. }
  90419. /**
  90420. * Base class used for every default easing function.
  90421. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90422. */
  90423. export class EasingFunction implements IEasingFunction {
  90424. /**
  90425. * Interpolation follows the mathematical formula associated with the easing function.
  90426. */
  90427. static readonly EASINGMODE_EASEIN: number;
  90428. /**
  90429. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  90430. */
  90431. static readonly EASINGMODE_EASEOUT: number;
  90432. /**
  90433. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  90434. */
  90435. static readonly EASINGMODE_EASEINOUT: number;
  90436. private _easingMode;
  90437. /**
  90438. * Sets the easing mode of the current function.
  90439. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  90440. */
  90441. setEasingMode(easingMode: number): void;
  90442. /**
  90443. * Gets the current easing mode.
  90444. * @returns the easing mode
  90445. */
  90446. getEasingMode(): number;
  90447. /**
  90448. * @hidden
  90449. */
  90450. easeInCore(gradient: number): number;
  90451. /**
  90452. * Given an input gradient between 0 and 1, this returns the corresponding value
  90453. * of the easing function.
  90454. * @param gradient Defines the value between 0 and 1 we want the easing value for
  90455. * @returns the corresponding value on the curve defined by the easing function
  90456. */
  90457. ease(gradient: number): number;
  90458. }
  90459. /**
  90460. * Easing function with a circle shape (see link below).
  90461. * @see https://easings.net/#easeInCirc
  90462. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90463. */
  90464. export class CircleEase extends EasingFunction implements IEasingFunction {
  90465. /** @hidden */
  90466. easeInCore(gradient: number): number;
  90467. }
  90468. /**
  90469. * Easing function with a ease back shape (see link below).
  90470. * @see https://easings.net/#easeInBack
  90471. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90472. */
  90473. export class BackEase extends EasingFunction implements IEasingFunction {
  90474. /** Defines the amplitude of the function */
  90475. amplitude: number;
  90476. /**
  90477. * Instantiates a back ease easing
  90478. * @see https://easings.net/#easeInBack
  90479. * @param amplitude Defines the amplitude of the function
  90480. */
  90481. constructor(
  90482. /** Defines the amplitude of the function */
  90483. amplitude?: number);
  90484. /** @hidden */
  90485. easeInCore(gradient: number): number;
  90486. }
  90487. /**
  90488. * Easing function with a bouncing shape (see link below).
  90489. * @see https://easings.net/#easeInBounce
  90490. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90491. */
  90492. export class BounceEase extends EasingFunction implements IEasingFunction {
  90493. /** Defines the number of bounces */
  90494. bounces: number;
  90495. /** Defines the amplitude of the bounce */
  90496. bounciness: number;
  90497. /**
  90498. * Instantiates a bounce easing
  90499. * @see https://easings.net/#easeInBounce
  90500. * @param bounces Defines the number of bounces
  90501. * @param bounciness Defines the amplitude of the bounce
  90502. */
  90503. constructor(
  90504. /** Defines the number of bounces */
  90505. bounces?: number,
  90506. /** Defines the amplitude of the bounce */
  90507. bounciness?: number);
  90508. /** @hidden */
  90509. easeInCore(gradient: number): number;
  90510. }
  90511. /**
  90512. * Easing function with a power of 3 shape (see link below).
  90513. * @see https://easings.net/#easeInCubic
  90514. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90515. */
  90516. export class CubicEase extends EasingFunction implements IEasingFunction {
  90517. /** @hidden */
  90518. easeInCore(gradient: number): number;
  90519. }
  90520. /**
  90521. * Easing function with an elastic shape (see link below).
  90522. * @see https://easings.net/#easeInElastic
  90523. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90524. */
  90525. export class ElasticEase extends EasingFunction implements IEasingFunction {
  90526. /** Defines the number of oscillations*/
  90527. oscillations: number;
  90528. /** Defines the amplitude of the oscillations*/
  90529. springiness: number;
  90530. /**
  90531. * Instantiates an elastic easing function
  90532. * @see https://easings.net/#easeInElastic
  90533. * @param oscillations Defines the number of oscillations
  90534. * @param springiness Defines the amplitude of the oscillations
  90535. */
  90536. constructor(
  90537. /** Defines the number of oscillations*/
  90538. oscillations?: number,
  90539. /** Defines the amplitude of the oscillations*/
  90540. springiness?: number);
  90541. /** @hidden */
  90542. easeInCore(gradient: number): number;
  90543. }
  90544. /**
  90545. * Easing function with an exponential shape (see link below).
  90546. * @see https://easings.net/#easeInExpo
  90547. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90548. */
  90549. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  90550. /** Defines the exponent of the function */
  90551. exponent: number;
  90552. /**
  90553. * Instantiates an exponential easing function
  90554. * @see https://easings.net/#easeInExpo
  90555. * @param exponent Defines the exponent of the function
  90556. */
  90557. constructor(
  90558. /** Defines the exponent of the function */
  90559. exponent?: number);
  90560. /** @hidden */
  90561. easeInCore(gradient: number): number;
  90562. }
  90563. /**
  90564. * Easing function with a power shape (see link below).
  90565. * @see https://easings.net/#easeInQuad
  90566. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90567. */
  90568. export class PowerEase extends EasingFunction implements IEasingFunction {
  90569. /** Defines the power of the function */
  90570. power: number;
  90571. /**
  90572. * Instantiates an power base easing function
  90573. * @see https://easings.net/#easeInQuad
  90574. * @param power Defines the power of the function
  90575. */
  90576. constructor(
  90577. /** Defines the power of the function */
  90578. power?: number);
  90579. /** @hidden */
  90580. easeInCore(gradient: number): number;
  90581. }
  90582. /**
  90583. * Easing function with a power of 2 shape (see link below).
  90584. * @see https://easings.net/#easeInQuad
  90585. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90586. */
  90587. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  90588. /** @hidden */
  90589. easeInCore(gradient: number): number;
  90590. }
  90591. /**
  90592. * Easing function with a power of 4 shape (see link below).
  90593. * @see https://easings.net/#easeInQuart
  90594. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90595. */
  90596. export class QuarticEase extends EasingFunction implements IEasingFunction {
  90597. /** @hidden */
  90598. easeInCore(gradient: number): number;
  90599. }
  90600. /**
  90601. * Easing function with a power of 5 shape (see link below).
  90602. * @see https://easings.net/#easeInQuint
  90603. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90604. */
  90605. export class QuinticEase extends EasingFunction implements IEasingFunction {
  90606. /** @hidden */
  90607. easeInCore(gradient: number): number;
  90608. }
  90609. /**
  90610. * Easing function with a sin shape (see link below).
  90611. * @see https://easings.net/#easeInSine
  90612. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90613. */
  90614. export class SineEase extends EasingFunction implements IEasingFunction {
  90615. /** @hidden */
  90616. easeInCore(gradient: number): number;
  90617. }
  90618. /**
  90619. * Easing function with a bezier shape (see link below).
  90620. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  90621. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  90622. */
  90623. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  90624. /** Defines the x component of the start tangent in the bezier curve */
  90625. x1: number;
  90626. /** Defines the y component of the start tangent in the bezier curve */
  90627. y1: number;
  90628. /** Defines the x component of the end tangent in the bezier curve */
  90629. x2: number;
  90630. /** Defines the y component of the end tangent in the bezier curve */
  90631. y2: number;
  90632. /**
  90633. * Instantiates a bezier function
  90634. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  90635. * @param x1 Defines the x component of the start tangent in the bezier curve
  90636. * @param y1 Defines the y component of the start tangent in the bezier curve
  90637. * @param x2 Defines the x component of the end tangent in the bezier curve
  90638. * @param y2 Defines the y component of the end tangent in the bezier curve
  90639. */
  90640. constructor(
  90641. /** Defines the x component of the start tangent in the bezier curve */
  90642. x1?: number,
  90643. /** Defines the y component of the start tangent in the bezier curve */
  90644. y1?: number,
  90645. /** Defines the x component of the end tangent in the bezier curve */
  90646. x2?: number,
  90647. /** Defines the y component of the end tangent in the bezier curve */
  90648. y2?: number);
  90649. /** @hidden */
  90650. easeInCore(gradient: number): number;
  90651. }
  90652. }
  90653. declare module BABYLON {
  90654. /**
  90655. * Class used to hold a RBG color
  90656. */
  90657. export class Color3 {
  90658. /**
  90659. * Defines the red component (between 0 and 1, default is 0)
  90660. */
  90661. r: number;
  90662. /**
  90663. * Defines the green component (between 0 and 1, default is 0)
  90664. */
  90665. g: number;
  90666. /**
  90667. * Defines the blue component (between 0 and 1, default is 0)
  90668. */
  90669. b: number;
  90670. /**
  90671. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  90672. * @param r defines the red component (between 0 and 1, default is 0)
  90673. * @param g defines the green component (between 0 and 1, default is 0)
  90674. * @param b defines the blue component (between 0 and 1, default is 0)
  90675. */
  90676. constructor(
  90677. /**
  90678. * Defines the red component (between 0 and 1, default is 0)
  90679. */
  90680. r?: number,
  90681. /**
  90682. * Defines the green component (between 0 and 1, default is 0)
  90683. */
  90684. g?: number,
  90685. /**
  90686. * Defines the blue component (between 0 and 1, default is 0)
  90687. */
  90688. b?: number);
  90689. /**
  90690. * Creates a string with the Color3 current values
  90691. * @returns the string representation of the Color3 object
  90692. */
  90693. toString(): string;
  90694. /**
  90695. * Returns the string "Color3"
  90696. * @returns "Color3"
  90697. */
  90698. getClassName(): string;
  90699. /**
  90700. * Compute the Color3 hash code
  90701. * @returns an unique number that can be used to hash Color3 objects
  90702. */
  90703. getHashCode(): number;
  90704. /**
  90705. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  90706. * @param array defines the array where to store the r,g,b components
  90707. * @param index defines an optional index in the target array to define where to start storing values
  90708. * @returns the current Color3 object
  90709. */
  90710. toArray(array: FloatArray, index?: number): Color3;
  90711. /**
  90712. * Update the current color with values stored in an array from the starting index of the given array
  90713. * @param array defines the source array
  90714. * @param offset defines an offset in the source array
  90715. * @returns the current Color3 object
  90716. */
  90717. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  90718. /**
  90719. * Returns a new Color4 object from the current Color3 and the given alpha
  90720. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  90721. * @returns a new Color4 object
  90722. */
  90723. toColor4(alpha?: number): Color4;
  90724. /**
  90725. * Returns a new array populated with 3 numeric elements : red, green and blue values
  90726. * @returns the new array
  90727. */
  90728. asArray(): number[];
  90729. /**
  90730. * Returns the luminance value
  90731. * @returns a float value
  90732. */
  90733. toLuminance(): number;
  90734. /**
  90735. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  90736. * @param otherColor defines the second operand
  90737. * @returns the new Color3 object
  90738. */
  90739. multiply(otherColor: DeepImmutable<Color3>): Color3;
  90740. /**
  90741. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  90742. * @param otherColor defines the second operand
  90743. * @param result defines the Color3 object where to store the result
  90744. * @returns the current Color3
  90745. */
  90746. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  90747. /**
  90748. * Determines equality between Color3 objects
  90749. * @param otherColor defines the second operand
  90750. * @returns true if the rgb values are equal to the given ones
  90751. */
  90752. equals(otherColor: DeepImmutable<Color3>): boolean;
  90753. /**
  90754. * Determines equality between the current Color3 object and a set of r,b,g values
  90755. * @param r defines the red component to check
  90756. * @param g defines the green component to check
  90757. * @param b defines the blue component to check
  90758. * @returns true if the rgb values are equal to the given ones
  90759. */
  90760. equalsFloats(r: number, g: number, b: number): boolean;
  90761. /**
  90762. * Multiplies in place each rgb value by scale
  90763. * @param scale defines the scaling factor
  90764. * @returns the updated Color3
  90765. */
  90766. scale(scale: number): Color3;
  90767. /**
  90768. * Multiplies the rgb values by scale and stores the result into "result"
  90769. * @param scale defines the scaling factor
  90770. * @param result defines the Color3 object where to store the result
  90771. * @returns the unmodified current Color3
  90772. */
  90773. scaleToRef(scale: number, result: Color3): Color3;
  90774. /**
  90775. * Scale the current Color3 values by a factor and add the result to a given Color3
  90776. * @param scale defines the scale factor
  90777. * @param result defines color to store the result into
  90778. * @returns the unmodified current Color3
  90779. */
  90780. scaleAndAddToRef(scale: number, result: Color3): Color3;
  90781. /**
  90782. * Clamps the rgb values by the min and max values and stores the result into "result"
  90783. * @param min defines minimum clamping value (default is 0)
  90784. * @param max defines maximum clamping value (default is 1)
  90785. * @param result defines color to store the result into
  90786. * @returns the original Color3
  90787. */
  90788. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  90789. /**
  90790. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  90791. * @param otherColor defines the second operand
  90792. * @returns the new Color3
  90793. */
  90794. add(otherColor: DeepImmutable<Color3>): Color3;
  90795. /**
  90796. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  90797. * @param otherColor defines the second operand
  90798. * @param result defines Color3 object to store the result into
  90799. * @returns the unmodified current Color3
  90800. */
  90801. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  90802. /**
  90803. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  90804. * @param otherColor defines the second operand
  90805. * @returns the new Color3
  90806. */
  90807. subtract(otherColor: DeepImmutable<Color3>): Color3;
  90808. /**
  90809. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  90810. * @param otherColor defines the second operand
  90811. * @param result defines Color3 object to store the result into
  90812. * @returns the unmodified current Color3
  90813. */
  90814. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  90815. /**
  90816. * Copy the current object
  90817. * @returns a new Color3 copied the current one
  90818. */
  90819. clone(): Color3;
  90820. /**
  90821. * Copies the rgb values from the source in the current Color3
  90822. * @param source defines the source Color3 object
  90823. * @returns the updated Color3 object
  90824. */
  90825. copyFrom(source: DeepImmutable<Color3>): Color3;
  90826. /**
  90827. * Updates the Color3 rgb values from the given floats
  90828. * @param r defines the red component to read from
  90829. * @param g defines the green component to read from
  90830. * @param b defines the blue component to read from
  90831. * @returns the current Color3 object
  90832. */
  90833. copyFromFloats(r: number, g: number, b: number): Color3;
  90834. /**
  90835. * Updates the Color3 rgb values from the given floats
  90836. * @param r defines the red component to read from
  90837. * @param g defines the green component to read from
  90838. * @param b defines the blue component to read from
  90839. * @returns the current Color3 object
  90840. */
  90841. set(r: number, g: number, b: number): Color3;
  90842. /**
  90843. * Compute the Color3 hexadecimal code as a string
  90844. * @returns a string containing the hexadecimal representation of the Color3 object
  90845. */
  90846. toHexString(): string;
  90847. /**
  90848. * Computes a new Color3 converted from the current one to linear space
  90849. * @returns a new Color3 object
  90850. */
  90851. toLinearSpace(): Color3;
  90852. /**
  90853. * Converts current color in rgb space to HSV values
  90854. * @returns a new color3 representing the HSV values
  90855. */
  90856. toHSV(): Color3;
  90857. /**
  90858. * Converts current color in rgb space to HSV values
  90859. * @param result defines the Color3 where to store the HSV values
  90860. */
  90861. toHSVToRef(result: Color3): void;
  90862. /**
  90863. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  90864. * @param convertedColor defines the Color3 object where to store the linear space version
  90865. * @returns the unmodified Color3
  90866. */
  90867. toLinearSpaceToRef(convertedColor: Color3): Color3;
  90868. /**
  90869. * Computes a new Color3 converted from the current one to gamma space
  90870. * @returns a new Color3 object
  90871. */
  90872. toGammaSpace(): Color3;
  90873. /**
  90874. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  90875. * @param convertedColor defines the Color3 object where to store the gamma space version
  90876. * @returns the unmodified Color3
  90877. */
  90878. toGammaSpaceToRef(convertedColor: Color3): Color3;
  90879. private static _BlackReadOnly;
  90880. /**
  90881. * Convert Hue, saturation and value to a Color3 (RGB)
  90882. * @param hue defines the hue
  90883. * @param saturation defines the saturation
  90884. * @param value defines the value
  90885. * @param result defines the Color3 where to store the RGB values
  90886. */
  90887. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  90888. /**
  90889. * Creates a new Color3 from the string containing valid hexadecimal values
  90890. * @param hex defines a string containing valid hexadecimal values
  90891. * @returns a new Color3 object
  90892. */
  90893. static FromHexString(hex: string): Color3;
  90894. /**
  90895. * Creates a new Color3 from the starting index of the given array
  90896. * @param array defines the source array
  90897. * @param offset defines an offset in the source array
  90898. * @returns a new Color3 object
  90899. */
  90900. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  90901. /**
  90902. * Creates a new Color3 from the starting index element of the given array
  90903. * @param array defines the source array to read from
  90904. * @param offset defines the offset in the source array
  90905. * @param result defines the target Color3 object
  90906. */
  90907. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  90908. /**
  90909. * Creates a new Color3 from integer values (< 256)
  90910. * @param r defines the red component to read from (value between 0 and 255)
  90911. * @param g defines the green component to read from (value between 0 and 255)
  90912. * @param b defines the blue component to read from (value between 0 and 255)
  90913. * @returns a new Color3 object
  90914. */
  90915. static FromInts(r: number, g: number, b: number): Color3;
  90916. /**
  90917. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  90918. * @param start defines the start Color3 value
  90919. * @param end defines the end Color3 value
  90920. * @param amount defines the gradient value between start and end
  90921. * @returns a new Color3 object
  90922. */
  90923. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  90924. /**
  90925. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  90926. * @param left defines the start value
  90927. * @param right defines the end value
  90928. * @param amount defines the gradient factor
  90929. * @param result defines the Color3 object where to store the result
  90930. */
  90931. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  90932. /**
  90933. * Returns a Color3 value containing a red color
  90934. * @returns a new Color3 object
  90935. */
  90936. static Red(): Color3;
  90937. /**
  90938. * Returns a Color3 value containing a green color
  90939. * @returns a new Color3 object
  90940. */
  90941. static Green(): Color3;
  90942. /**
  90943. * Returns a Color3 value containing a blue color
  90944. * @returns a new Color3 object
  90945. */
  90946. static Blue(): Color3;
  90947. /**
  90948. * Returns a Color3 value containing a black color
  90949. * @returns a new Color3 object
  90950. */
  90951. static Black(): Color3;
  90952. /**
  90953. * Gets a Color3 value containing a black color that must not be updated
  90954. */
  90955. static get BlackReadOnly(): DeepImmutable<Color3>;
  90956. /**
  90957. * Returns a Color3 value containing a white color
  90958. * @returns a new Color3 object
  90959. */
  90960. static White(): Color3;
  90961. /**
  90962. * Returns a Color3 value containing a purple color
  90963. * @returns a new Color3 object
  90964. */
  90965. static Purple(): Color3;
  90966. /**
  90967. * Returns a Color3 value containing a magenta color
  90968. * @returns a new Color3 object
  90969. */
  90970. static Magenta(): Color3;
  90971. /**
  90972. * Returns a Color3 value containing a yellow color
  90973. * @returns a new Color3 object
  90974. */
  90975. static Yellow(): Color3;
  90976. /**
  90977. * Returns a Color3 value containing a gray color
  90978. * @returns a new Color3 object
  90979. */
  90980. static Gray(): Color3;
  90981. /**
  90982. * Returns a Color3 value containing a teal color
  90983. * @returns a new Color3 object
  90984. */
  90985. static Teal(): Color3;
  90986. /**
  90987. * Returns a Color3 value containing a random color
  90988. * @returns a new Color3 object
  90989. */
  90990. static Random(): Color3;
  90991. }
  90992. /**
  90993. * Class used to hold a RBGA color
  90994. */
  90995. export class Color4 {
  90996. /**
  90997. * Defines the red component (between 0 and 1, default is 0)
  90998. */
  90999. r: number;
  91000. /**
  91001. * Defines the green component (between 0 and 1, default is 0)
  91002. */
  91003. g: number;
  91004. /**
  91005. * Defines the blue component (between 0 and 1, default is 0)
  91006. */
  91007. b: number;
  91008. /**
  91009. * Defines the alpha component (between 0 and 1, default is 1)
  91010. */
  91011. a: number;
  91012. /**
  91013. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  91014. * @param r defines the red component (between 0 and 1, default is 0)
  91015. * @param g defines the green component (between 0 and 1, default is 0)
  91016. * @param b defines the blue component (between 0 and 1, default is 0)
  91017. * @param a defines the alpha component (between 0 and 1, default is 1)
  91018. */
  91019. constructor(
  91020. /**
  91021. * Defines the red component (between 0 and 1, default is 0)
  91022. */
  91023. r?: number,
  91024. /**
  91025. * Defines the green component (between 0 and 1, default is 0)
  91026. */
  91027. g?: number,
  91028. /**
  91029. * Defines the blue component (between 0 and 1, default is 0)
  91030. */
  91031. b?: number,
  91032. /**
  91033. * Defines the alpha component (between 0 and 1, default is 1)
  91034. */
  91035. a?: number);
  91036. /**
  91037. * Adds in place the given Color4 values to the current Color4 object
  91038. * @param right defines the second operand
  91039. * @returns the current updated Color4 object
  91040. */
  91041. addInPlace(right: DeepImmutable<Color4>): Color4;
  91042. /**
  91043. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  91044. * @returns the new array
  91045. */
  91046. asArray(): number[];
  91047. /**
  91048. * Stores from the starting index in the given array the Color4 successive values
  91049. * @param array defines the array where to store the r,g,b components
  91050. * @param index defines an optional index in the target array to define where to start storing values
  91051. * @returns the current Color4 object
  91052. */
  91053. toArray(array: number[], index?: number): Color4;
  91054. /**
  91055. * Update the current color with values stored in an array from the starting index of the given array
  91056. * @param array defines the source array
  91057. * @param offset defines an offset in the source array
  91058. * @returns the current Color4 object
  91059. */
  91060. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  91061. /**
  91062. * Determines equality between Color4 objects
  91063. * @param otherColor defines the second operand
  91064. * @returns true if the rgba values are equal to the given ones
  91065. */
  91066. equals(otherColor: DeepImmutable<Color4>): boolean;
  91067. /**
  91068. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  91069. * @param right defines the second operand
  91070. * @returns a new Color4 object
  91071. */
  91072. add(right: DeepImmutable<Color4>): Color4;
  91073. /**
  91074. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  91075. * @param right defines the second operand
  91076. * @returns a new Color4 object
  91077. */
  91078. subtract(right: DeepImmutable<Color4>): Color4;
  91079. /**
  91080. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  91081. * @param right defines the second operand
  91082. * @param result defines the Color4 object where to store the result
  91083. * @returns the current Color4 object
  91084. */
  91085. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  91086. /**
  91087. * Creates a new Color4 with the current Color4 values multiplied by scale
  91088. * @param scale defines the scaling factor to apply
  91089. * @returns a new Color4 object
  91090. */
  91091. scale(scale: number): Color4;
  91092. /**
  91093. * Multiplies the current Color4 values by scale and stores the result in "result"
  91094. * @param scale defines the scaling factor to apply
  91095. * @param result defines the Color4 object where to store the result
  91096. * @returns the current unmodified Color4
  91097. */
  91098. scaleToRef(scale: number, result: Color4): Color4;
  91099. /**
  91100. * Scale the current Color4 values by a factor and add the result to a given Color4
  91101. * @param scale defines the scale factor
  91102. * @param result defines the Color4 object where to store the result
  91103. * @returns the unmodified current Color4
  91104. */
  91105. scaleAndAddToRef(scale: number, result: Color4): Color4;
  91106. /**
  91107. * Clamps the rgb values by the min and max values and stores the result into "result"
  91108. * @param min defines minimum clamping value (default is 0)
  91109. * @param max defines maximum clamping value (default is 1)
  91110. * @param result defines color to store the result into.
  91111. * @returns the cuurent Color4
  91112. */
  91113. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  91114. /**
  91115. * Multipy an Color4 value by another and return a new Color4 object
  91116. * @param color defines the Color4 value to multiply by
  91117. * @returns a new Color4 object
  91118. */
  91119. multiply(color: Color4): Color4;
  91120. /**
  91121. * Multipy a Color4 value by another and push the result in a reference value
  91122. * @param color defines the Color4 value to multiply by
  91123. * @param result defines the Color4 to fill the result in
  91124. * @returns the result Color4
  91125. */
  91126. multiplyToRef(color: Color4, result: Color4): Color4;
  91127. /**
  91128. * Creates a string with the Color4 current values
  91129. * @returns the string representation of the Color4 object
  91130. */
  91131. toString(): string;
  91132. /**
  91133. * Returns the string "Color4"
  91134. * @returns "Color4"
  91135. */
  91136. getClassName(): string;
  91137. /**
  91138. * Compute the Color4 hash code
  91139. * @returns an unique number that can be used to hash Color4 objects
  91140. */
  91141. getHashCode(): number;
  91142. /**
  91143. * Creates a new Color4 copied from the current one
  91144. * @returns a new Color4 object
  91145. */
  91146. clone(): Color4;
  91147. /**
  91148. * Copies the given Color4 values into the current one
  91149. * @param source defines the source Color4 object
  91150. * @returns the current updated Color4 object
  91151. */
  91152. copyFrom(source: Color4): Color4;
  91153. /**
  91154. * Copies the given float values into the current one
  91155. * @param r defines the red component to read from
  91156. * @param g defines the green component to read from
  91157. * @param b defines the blue component to read from
  91158. * @param a defines the alpha component to read from
  91159. * @returns the current updated Color4 object
  91160. */
  91161. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  91162. /**
  91163. * Copies the given float values into the current one
  91164. * @param r defines the red component to read from
  91165. * @param g defines the green component to read from
  91166. * @param b defines the blue component to read from
  91167. * @param a defines the alpha component to read from
  91168. * @returns the current updated Color4 object
  91169. */
  91170. set(r: number, g: number, b: number, a: number): Color4;
  91171. /**
  91172. * Compute the Color4 hexadecimal code as a string
  91173. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  91174. * @returns a string containing the hexadecimal representation of the Color4 object
  91175. */
  91176. toHexString(returnAsColor3?: boolean): string;
  91177. /**
  91178. * Computes a new Color4 converted from the current one to linear space
  91179. * @returns a new Color4 object
  91180. */
  91181. toLinearSpace(): Color4;
  91182. /**
  91183. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  91184. * @param convertedColor defines the Color4 object where to store the linear space version
  91185. * @returns the unmodified Color4
  91186. */
  91187. toLinearSpaceToRef(convertedColor: Color4): Color4;
  91188. /**
  91189. * Computes a new Color4 converted from the current one to gamma space
  91190. * @returns a new Color4 object
  91191. */
  91192. toGammaSpace(): Color4;
  91193. /**
  91194. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  91195. * @param convertedColor defines the Color4 object where to store the gamma space version
  91196. * @returns the unmodified Color4
  91197. */
  91198. toGammaSpaceToRef(convertedColor: Color4): Color4;
  91199. /**
  91200. * Creates a new Color4 from the string containing valid hexadecimal values
  91201. * @param hex defines a string containing valid hexadecimal values
  91202. * @returns a new Color4 object
  91203. */
  91204. static FromHexString(hex: string): Color4;
  91205. /**
  91206. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  91207. * @param left defines the start value
  91208. * @param right defines the end value
  91209. * @param amount defines the gradient factor
  91210. * @returns a new Color4 object
  91211. */
  91212. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  91213. /**
  91214. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  91215. * @param left defines the start value
  91216. * @param right defines the end value
  91217. * @param amount defines the gradient factor
  91218. * @param result defines the Color4 object where to store data
  91219. */
  91220. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  91221. /**
  91222. * Creates a new Color4 from a Color3 and an alpha value
  91223. * @param color3 defines the source Color3 to read from
  91224. * @param alpha defines the alpha component (1.0 by default)
  91225. * @returns a new Color4 object
  91226. */
  91227. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  91228. /**
  91229. * Creates a new Color4 from the starting index element of the given array
  91230. * @param array defines the source array to read from
  91231. * @param offset defines the offset in the source array
  91232. * @returns a new Color4 object
  91233. */
  91234. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  91235. /**
  91236. * Creates a new Color4 from the starting index element of the given array
  91237. * @param array defines the source array to read from
  91238. * @param offset defines the offset in the source array
  91239. * @param result defines the target Color4 object
  91240. */
  91241. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  91242. /**
  91243. * Creates a new Color3 from integer values (< 256)
  91244. * @param r defines the red component to read from (value between 0 and 255)
  91245. * @param g defines the green component to read from (value between 0 and 255)
  91246. * @param b defines the blue component to read from (value between 0 and 255)
  91247. * @param a defines the alpha component to read from (value between 0 and 255)
  91248. * @returns a new Color3 object
  91249. */
  91250. static FromInts(r: number, g: number, b: number, a: number): Color4;
  91251. /**
  91252. * Check the content of a given array and convert it to an array containing RGBA data
  91253. * If the original array was already containing count * 4 values then it is returned directly
  91254. * @param colors defines the array to check
  91255. * @param count defines the number of RGBA data to expect
  91256. * @returns an array containing count * 4 values (RGBA)
  91257. */
  91258. static CheckColors4(colors: number[], count: number): number[];
  91259. }
  91260. /**
  91261. * @hidden
  91262. */
  91263. export class TmpColors {
  91264. static Color3: Color3[];
  91265. static Color4: Color4[];
  91266. }
  91267. }
  91268. declare module BABYLON {
  91269. /**
  91270. * Defines an interface which represents an animation key frame
  91271. */
  91272. export interface IAnimationKey {
  91273. /**
  91274. * Frame of the key frame
  91275. */
  91276. frame: number;
  91277. /**
  91278. * Value at the specifies key frame
  91279. */
  91280. value: any;
  91281. /**
  91282. * The input tangent for the cubic hermite spline
  91283. */
  91284. inTangent?: any;
  91285. /**
  91286. * The output tangent for the cubic hermite spline
  91287. */
  91288. outTangent?: any;
  91289. /**
  91290. * The animation interpolation type
  91291. */
  91292. interpolation?: AnimationKeyInterpolation;
  91293. }
  91294. /**
  91295. * Enum for the animation key frame interpolation type
  91296. */
  91297. export enum AnimationKeyInterpolation {
  91298. /**
  91299. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  91300. */
  91301. STEP = 1
  91302. }
  91303. }
  91304. declare module BABYLON {
  91305. /**
  91306. * Represents the range of an animation
  91307. */
  91308. export class AnimationRange {
  91309. /**The name of the animation range**/
  91310. name: string;
  91311. /**The starting frame of the animation */
  91312. from: number;
  91313. /**The ending frame of the animation*/
  91314. to: number;
  91315. /**
  91316. * Initializes the range of an animation
  91317. * @param name The name of the animation range
  91318. * @param from The starting frame of the animation
  91319. * @param to The ending frame of the animation
  91320. */
  91321. constructor(
  91322. /**The name of the animation range**/
  91323. name: string,
  91324. /**The starting frame of the animation */
  91325. from: number,
  91326. /**The ending frame of the animation*/
  91327. to: number);
  91328. /**
  91329. * Makes a copy of the animation range
  91330. * @returns A copy of the animation range
  91331. */
  91332. clone(): AnimationRange;
  91333. }
  91334. }
  91335. declare module BABYLON {
  91336. /**
  91337. * Composed of a frame, and an action function
  91338. */
  91339. export class AnimationEvent {
  91340. /** The frame for which the event is triggered **/
  91341. frame: number;
  91342. /** The event to perform when triggered **/
  91343. action: (currentFrame: number) => void;
  91344. /** Specifies if the event should be triggered only once**/
  91345. onlyOnce?: boolean | undefined;
  91346. /**
  91347. * Specifies if the animation event is done
  91348. */
  91349. isDone: boolean;
  91350. /**
  91351. * Initializes the animation event
  91352. * @param frame The frame for which the event is triggered
  91353. * @param action The event to perform when triggered
  91354. * @param onlyOnce Specifies if the event should be triggered only once
  91355. */
  91356. constructor(
  91357. /** The frame for which the event is triggered **/
  91358. frame: number,
  91359. /** The event to perform when triggered **/
  91360. action: (currentFrame: number) => void,
  91361. /** Specifies if the event should be triggered only once**/
  91362. onlyOnce?: boolean | undefined);
  91363. /** @hidden */
  91364. _clone(): AnimationEvent;
  91365. }
  91366. }
  91367. declare module BABYLON {
  91368. /**
  91369. * Interface used to define a behavior
  91370. */
  91371. export interface Behavior<T> {
  91372. /** gets or sets behavior's name */
  91373. name: string;
  91374. /**
  91375. * Function called when the behavior needs to be initialized (after attaching it to a target)
  91376. */
  91377. init(): void;
  91378. /**
  91379. * Called when the behavior is attached to a target
  91380. * @param target defines the target where the behavior is attached to
  91381. */
  91382. attach(target: T): void;
  91383. /**
  91384. * Called when the behavior is detached from its target
  91385. */
  91386. detach(): void;
  91387. }
  91388. /**
  91389. * Interface implemented by classes supporting behaviors
  91390. */
  91391. export interface IBehaviorAware<T> {
  91392. /**
  91393. * Attach a behavior
  91394. * @param behavior defines the behavior to attach
  91395. * @returns the current host
  91396. */
  91397. addBehavior(behavior: Behavior<T>): T;
  91398. /**
  91399. * Remove a behavior from the current object
  91400. * @param behavior defines the behavior to detach
  91401. * @returns the current host
  91402. */
  91403. removeBehavior(behavior: Behavior<T>): T;
  91404. /**
  91405. * Gets a behavior using its name to search
  91406. * @param name defines the name to search
  91407. * @returns the behavior or null if not found
  91408. */
  91409. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  91410. }
  91411. }
  91412. declare module BABYLON {
  91413. /**
  91414. * Class used to store data that will be store in GPU memory
  91415. */
  91416. export class Buffer {
  91417. private _engine;
  91418. private _buffer;
  91419. /** @hidden */
  91420. _data: Nullable<DataArray>;
  91421. private _updatable;
  91422. private _instanced;
  91423. private _divisor;
  91424. private _isAlreadyOwned;
  91425. /**
  91426. * Gets the byte stride.
  91427. */
  91428. readonly byteStride: number;
  91429. /**
  91430. * Constructor
  91431. * @param engine the engine
  91432. * @param data the data to use for this buffer
  91433. * @param updatable whether the data is updatable
  91434. * @param stride the stride (optional)
  91435. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  91436. * @param instanced whether the buffer is instanced (optional)
  91437. * @param useBytes set to true if the stride in in bytes (optional)
  91438. * @param divisor sets an optional divisor for instances (1 by default)
  91439. */
  91440. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  91441. /**
  91442. * Create a new VertexBuffer based on the current buffer
  91443. * @param kind defines the vertex buffer kind (position, normal, etc.)
  91444. * @param offset defines offset in the buffer (0 by default)
  91445. * @param size defines the size in floats of attributes (position is 3 for instance)
  91446. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  91447. * @param instanced defines if the vertex buffer contains indexed data
  91448. * @param useBytes defines if the offset and stride are in bytes *
  91449. * @param divisor sets an optional divisor for instances (1 by default)
  91450. * @returns the new vertex buffer
  91451. */
  91452. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  91453. /**
  91454. * Gets a boolean indicating if the Buffer is updatable?
  91455. * @returns true if the buffer is updatable
  91456. */
  91457. isUpdatable(): boolean;
  91458. /**
  91459. * Gets current buffer's data
  91460. * @returns a DataArray or null
  91461. */
  91462. getData(): Nullable<DataArray>;
  91463. /**
  91464. * Gets underlying native buffer
  91465. * @returns underlying native buffer
  91466. */
  91467. getBuffer(): Nullable<DataBuffer>;
  91468. /**
  91469. * Gets the stride in float32 units (i.e. byte stride / 4).
  91470. * May not be an integer if the byte stride is not divisible by 4.
  91471. * @returns the stride in float32 units
  91472. * @deprecated Please use byteStride instead.
  91473. */
  91474. getStrideSize(): number;
  91475. /**
  91476. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  91477. * @param data defines the data to store
  91478. */
  91479. create(data?: Nullable<DataArray>): void;
  91480. /** @hidden */
  91481. _rebuild(): void;
  91482. /**
  91483. * Update current buffer data
  91484. * @param data defines the data to store
  91485. */
  91486. update(data: DataArray): void;
  91487. /**
  91488. * Updates the data directly.
  91489. * @param data the new data
  91490. * @param offset the new offset
  91491. * @param vertexCount the vertex count (optional)
  91492. * @param useBytes set to true if the offset is in bytes
  91493. */
  91494. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  91495. /** @hidden */
  91496. _increaseReferences(): void;
  91497. /**
  91498. * Release all resources
  91499. */
  91500. dispose(): void;
  91501. }
  91502. /**
  91503. * Specialized buffer used to store vertex data
  91504. */
  91505. export class VertexBuffer {
  91506. /** @hidden */
  91507. _buffer: Buffer;
  91508. private _kind;
  91509. private _size;
  91510. private _ownsBuffer;
  91511. private _instanced;
  91512. private _instanceDivisor;
  91513. /**
  91514. * The byte type.
  91515. */
  91516. static readonly BYTE: number;
  91517. /**
  91518. * The unsigned byte type.
  91519. */
  91520. static readonly UNSIGNED_BYTE: number;
  91521. /**
  91522. * The short type.
  91523. */
  91524. static readonly SHORT: number;
  91525. /**
  91526. * The unsigned short type.
  91527. */
  91528. static readonly UNSIGNED_SHORT: number;
  91529. /**
  91530. * The integer type.
  91531. */
  91532. static readonly INT: number;
  91533. /**
  91534. * The unsigned integer type.
  91535. */
  91536. static readonly UNSIGNED_INT: number;
  91537. /**
  91538. * The float type.
  91539. */
  91540. static readonly FLOAT: number;
  91541. /**
  91542. * Gets or sets the instance divisor when in instanced mode
  91543. */
  91544. get instanceDivisor(): number;
  91545. set instanceDivisor(value: number);
  91546. /**
  91547. * Gets the byte stride.
  91548. */
  91549. readonly byteStride: number;
  91550. /**
  91551. * Gets the byte offset.
  91552. */
  91553. readonly byteOffset: number;
  91554. /**
  91555. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  91556. */
  91557. readonly normalized: boolean;
  91558. /**
  91559. * Gets the data type of each component in the array.
  91560. */
  91561. readonly type: number;
  91562. /**
  91563. * Constructor
  91564. * @param engine the engine
  91565. * @param data the data to use for this vertex buffer
  91566. * @param kind the vertex buffer kind
  91567. * @param updatable whether the data is updatable
  91568. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  91569. * @param stride the stride (optional)
  91570. * @param instanced whether the buffer is instanced (optional)
  91571. * @param offset the offset of the data (optional)
  91572. * @param size the number of components (optional)
  91573. * @param type the type of the component (optional)
  91574. * @param normalized whether the data contains normalized data (optional)
  91575. * @param useBytes set to true if stride and offset are in bytes (optional)
  91576. * @param divisor defines the instance divisor to use (1 by default)
  91577. * @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed
  91578. */
  91579. 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);
  91580. /** @hidden */
  91581. _rebuild(): void;
  91582. /**
  91583. * Returns the kind of the VertexBuffer (string)
  91584. * @returns a string
  91585. */
  91586. getKind(): string;
  91587. /**
  91588. * Gets a boolean indicating if the VertexBuffer is updatable?
  91589. * @returns true if the buffer is updatable
  91590. */
  91591. isUpdatable(): boolean;
  91592. /**
  91593. * Gets current buffer's data
  91594. * @returns a DataArray or null
  91595. */
  91596. getData(): Nullable<DataArray>;
  91597. /**
  91598. * Gets underlying native buffer
  91599. * @returns underlying native buffer
  91600. */
  91601. getBuffer(): Nullable<DataBuffer>;
  91602. /**
  91603. * Gets the stride in float32 units (i.e. byte stride / 4).
  91604. * May not be an integer if the byte stride is not divisible by 4.
  91605. * @returns the stride in float32 units
  91606. * @deprecated Please use byteStride instead.
  91607. */
  91608. getStrideSize(): number;
  91609. /**
  91610. * Returns the offset as a multiple of the type byte length.
  91611. * @returns the offset in bytes
  91612. * @deprecated Please use byteOffset instead.
  91613. */
  91614. getOffset(): number;
  91615. /**
  91616. * Returns the number of components per vertex attribute (integer)
  91617. * @returns the size in float
  91618. */
  91619. getSize(): number;
  91620. /**
  91621. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  91622. * @returns true if this buffer is instanced
  91623. */
  91624. getIsInstanced(): boolean;
  91625. /**
  91626. * Returns the instancing divisor, zero for non-instanced (integer).
  91627. * @returns a number
  91628. */
  91629. getInstanceDivisor(): number;
  91630. /**
  91631. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  91632. * @param data defines the data to store
  91633. */
  91634. create(data?: DataArray): void;
  91635. /**
  91636. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  91637. * This function will create a new buffer if the current one is not updatable
  91638. * @param data defines the data to store
  91639. */
  91640. update(data: DataArray): void;
  91641. /**
  91642. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  91643. * Returns the directly updated WebGLBuffer.
  91644. * @param data the new data
  91645. * @param offset the new offset
  91646. * @param useBytes set to true if the offset is in bytes
  91647. */
  91648. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  91649. /**
  91650. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  91651. */
  91652. dispose(): void;
  91653. /**
  91654. * Enumerates each value of this vertex buffer as numbers.
  91655. * @param count the number of values to enumerate
  91656. * @param callback the callback function called for each value
  91657. */
  91658. forEach(count: number, callback: (value: number, index: number) => void): void;
  91659. /**
  91660. * Positions
  91661. */
  91662. static readonly PositionKind: string;
  91663. /**
  91664. * Normals
  91665. */
  91666. static readonly NormalKind: string;
  91667. /**
  91668. * Tangents
  91669. */
  91670. static readonly TangentKind: string;
  91671. /**
  91672. * Texture coordinates
  91673. */
  91674. static readonly UVKind: string;
  91675. /**
  91676. * Texture coordinates 2
  91677. */
  91678. static readonly UV2Kind: string;
  91679. /**
  91680. * Texture coordinates 3
  91681. */
  91682. static readonly UV3Kind: string;
  91683. /**
  91684. * Texture coordinates 4
  91685. */
  91686. static readonly UV4Kind: string;
  91687. /**
  91688. * Texture coordinates 5
  91689. */
  91690. static readonly UV5Kind: string;
  91691. /**
  91692. * Texture coordinates 6
  91693. */
  91694. static readonly UV6Kind: string;
  91695. /**
  91696. * Colors
  91697. */
  91698. static readonly ColorKind: string;
  91699. /**
  91700. * Matrix indices (for bones)
  91701. */
  91702. static readonly MatricesIndicesKind: string;
  91703. /**
  91704. * Matrix weights (for bones)
  91705. */
  91706. static readonly MatricesWeightsKind: string;
  91707. /**
  91708. * Additional matrix indices (for bones)
  91709. */
  91710. static readonly MatricesIndicesExtraKind: string;
  91711. /**
  91712. * Additional matrix weights (for bones)
  91713. */
  91714. static readonly MatricesWeightsExtraKind: string;
  91715. /**
  91716. * Deduces the stride given a kind.
  91717. * @param kind The kind string to deduce
  91718. * @returns The deduced stride
  91719. */
  91720. static DeduceStride(kind: string): number;
  91721. /**
  91722. * Gets the byte length of the given type.
  91723. * @param type the type
  91724. * @returns the number of bytes
  91725. */
  91726. static GetTypeByteLength(type: number): number;
  91727. /**
  91728. * Enumerates each value of the given parameters as numbers.
  91729. * @param data the data to enumerate
  91730. * @param byteOffset the byte offset of the data
  91731. * @param byteStride the byte stride of the data
  91732. * @param componentCount the number of components per element
  91733. * @param componentType the type of the component
  91734. * @param count the number of values to enumerate
  91735. * @param normalized whether the data is normalized
  91736. * @param callback the callback function called for each value
  91737. */
  91738. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  91739. private static _GetFloatValue;
  91740. }
  91741. }
  91742. declare module BABYLON {
  91743. /**
  91744. * @hidden
  91745. */
  91746. export class IntersectionInfo {
  91747. bu: Nullable<number>;
  91748. bv: Nullable<number>;
  91749. distance: number;
  91750. faceId: number;
  91751. subMeshId: number;
  91752. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  91753. }
  91754. }
  91755. declare module BABYLON {
  91756. /**
  91757. * Class used to store bounding sphere information
  91758. */
  91759. export class BoundingSphere {
  91760. /**
  91761. * Gets the center of the bounding sphere in local space
  91762. */
  91763. readonly center: Vector3;
  91764. /**
  91765. * Radius of the bounding sphere in local space
  91766. */
  91767. radius: number;
  91768. /**
  91769. * Gets the center of the bounding sphere in world space
  91770. */
  91771. readonly centerWorld: Vector3;
  91772. /**
  91773. * Radius of the bounding sphere in world space
  91774. */
  91775. radiusWorld: number;
  91776. /**
  91777. * Gets the minimum vector in local space
  91778. */
  91779. readonly minimum: Vector3;
  91780. /**
  91781. * Gets the maximum vector in local space
  91782. */
  91783. readonly maximum: Vector3;
  91784. private _worldMatrix;
  91785. private static readonly TmpVector3;
  91786. /**
  91787. * Creates a new bounding sphere
  91788. * @param min defines the minimum vector (in local space)
  91789. * @param max defines the maximum vector (in local space)
  91790. * @param worldMatrix defines the new world matrix
  91791. */
  91792. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  91793. /**
  91794. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  91795. * @param min defines the new minimum vector (in local space)
  91796. * @param max defines the new maximum vector (in local space)
  91797. * @param worldMatrix defines the new world matrix
  91798. */
  91799. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  91800. /**
  91801. * Scale the current bounding sphere by applying a scale factor
  91802. * @param factor defines the scale factor to apply
  91803. * @returns the current bounding box
  91804. */
  91805. scale(factor: number): BoundingSphere;
  91806. /**
  91807. * Gets the world matrix of the bounding box
  91808. * @returns a matrix
  91809. */
  91810. getWorldMatrix(): DeepImmutable<Matrix>;
  91811. /** @hidden */
  91812. _update(worldMatrix: DeepImmutable<Matrix>): void;
  91813. /**
  91814. * Tests if the bounding sphere is intersecting the frustum planes
  91815. * @param frustumPlanes defines the frustum planes to test
  91816. * @returns true if there is an intersection
  91817. */
  91818. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  91819. /**
  91820. * Tests if the bounding sphere center is in between the frustum planes.
  91821. * Used for optimistic fast inclusion.
  91822. * @param frustumPlanes defines the frustum planes to test
  91823. * @returns true if the sphere center is in between the frustum planes
  91824. */
  91825. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  91826. /**
  91827. * Tests if a point is inside the bounding sphere
  91828. * @param point defines the point to test
  91829. * @returns true if the point is inside the bounding sphere
  91830. */
  91831. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  91832. /**
  91833. * Checks if two sphere intersct
  91834. * @param sphere0 sphere 0
  91835. * @param sphere1 sphere 1
  91836. * @returns true if the speres intersect
  91837. */
  91838. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  91839. }
  91840. }
  91841. declare module BABYLON {
  91842. /**
  91843. * Class used to store bounding box information
  91844. */
  91845. export class BoundingBox implements ICullable {
  91846. /**
  91847. * Gets the 8 vectors representing the bounding box in local space
  91848. */
  91849. readonly vectors: Vector3[];
  91850. /**
  91851. * Gets the center of the bounding box in local space
  91852. */
  91853. readonly center: Vector3;
  91854. /**
  91855. * Gets the center of the bounding box in world space
  91856. */
  91857. readonly centerWorld: Vector3;
  91858. /**
  91859. * Gets the extend size in local space
  91860. */
  91861. readonly extendSize: Vector3;
  91862. /**
  91863. * Gets the extend size in world space
  91864. */
  91865. readonly extendSizeWorld: Vector3;
  91866. /**
  91867. * Gets the OBB (object bounding box) directions
  91868. */
  91869. readonly directions: Vector3[];
  91870. /**
  91871. * Gets the 8 vectors representing the bounding box in world space
  91872. */
  91873. readonly vectorsWorld: Vector3[];
  91874. /**
  91875. * Gets the minimum vector in world space
  91876. */
  91877. readonly minimumWorld: Vector3;
  91878. /**
  91879. * Gets the maximum vector in world space
  91880. */
  91881. readonly maximumWorld: Vector3;
  91882. /**
  91883. * Gets the minimum vector in local space
  91884. */
  91885. readonly minimum: Vector3;
  91886. /**
  91887. * Gets the maximum vector in local space
  91888. */
  91889. readonly maximum: Vector3;
  91890. private _worldMatrix;
  91891. private static readonly TmpVector3;
  91892. /**
  91893. * @hidden
  91894. */
  91895. _tag: number;
  91896. /**
  91897. * Creates a new bounding box
  91898. * @param min defines the minimum vector (in local space)
  91899. * @param max defines the maximum vector (in local space)
  91900. * @param worldMatrix defines the new world matrix
  91901. */
  91902. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  91903. /**
  91904. * Recreates the entire bounding box from scratch as if we call the constructor in place
  91905. * @param min defines the new minimum vector (in local space)
  91906. * @param max defines the new maximum vector (in local space)
  91907. * @param worldMatrix defines the new world matrix
  91908. */
  91909. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  91910. /**
  91911. * Scale the current bounding box by applying a scale factor
  91912. * @param factor defines the scale factor to apply
  91913. * @returns the current bounding box
  91914. */
  91915. scale(factor: number): BoundingBox;
  91916. /**
  91917. * Gets the world matrix of the bounding box
  91918. * @returns a matrix
  91919. */
  91920. getWorldMatrix(): DeepImmutable<Matrix>;
  91921. /** @hidden */
  91922. _update(world: DeepImmutable<Matrix>): void;
  91923. /**
  91924. * Tests if the bounding box is intersecting the frustum planes
  91925. * @param frustumPlanes defines the frustum planes to test
  91926. * @returns true if there is an intersection
  91927. */
  91928. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  91929. /**
  91930. * Tests if the bounding box is entirely inside the frustum planes
  91931. * @param frustumPlanes defines the frustum planes to test
  91932. * @returns true if there is an inclusion
  91933. */
  91934. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  91935. /**
  91936. * Tests if a point is inside the bounding box
  91937. * @param point defines the point to test
  91938. * @returns true if the point is inside the bounding box
  91939. */
  91940. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  91941. /**
  91942. * Tests if the bounding box intersects with a bounding sphere
  91943. * @param sphere defines the sphere to test
  91944. * @returns true if there is an intersection
  91945. */
  91946. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  91947. /**
  91948. * Tests if the bounding box intersects with a box defined by a min and max vectors
  91949. * @param min defines the min vector to use
  91950. * @param max defines the max vector to use
  91951. * @returns true if there is an intersection
  91952. */
  91953. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  91954. /**
  91955. * Tests if two bounding boxes are intersections
  91956. * @param box0 defines the first box to test
  91957. * @param box1 defines the second box to test
  91958. * @returns true if there is an intersection
  91959. */
  91960. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  91961. /**
  91962. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  91963. * @param minPoint defines the minimum vector of the bounding box
  91964. * @param maxPoint defines the maximum vector of the bounding box
  91965. * @param sphereCenter defines the sphere center
  91966. * @param sphereRadius defines the sphere radius
  91967. * @returns true if there is an intersection
  91968. */
  91969. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  91970. /**
  91971. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  91972. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  91973. * @param frustumPlanes defines the frustum planes to test
  91974. * @return true if there is an inclusion
  91975. */
  91976. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  91977. /**
  91978. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  91979. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  91980. * @param frustumPlanes defines the frustum planes to test
  91981. * @return true if there is an intersection
  91982. */
  91983. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  91984. }
  91985. }
  91986. declare module BABYLON {
  91987. /** @hidden */
  91988. export class Collider {
  91989. /** Define if a collision was found */
  91990. collisionFound: boolean;
  91991. /**
  91992. * Define last intersection point in local space
  91993. */
  91994. intersectionPoint: Vector3;
  91995. /**
  91996. * Define last collided mesh
  91997. */
  91998. collidedMesh: Nullable<AbstractMesh>;
  91999. private _collisionPoint;
  92000. private _planeIntersectionPoint;
  92001. private _tempVector;
  92002. private _tempVector2;
  92003. private _tempVector3;
  92004. private _tempVector4;
  92005. private _edge;
  92006. private _baseToVertex;
  92007. private _destinationPoint;
  92008. private _slidePlaneNormal;
  92009. private _displacementVector;
  92010. /** @hidden */
  92011. _radius: Vector3;
  92012. /** @hidden */
  92013. _retry: number;
  92014. private _velocity;
  92015. private _basePoint;
  92016. private _epsilon;
  92017. /** @hidden */
  92018. _velocityWorldLength: number;
  92019. /** @hidden */
  92020. _basePointWorld: Vector3;
  92021. private _velocityWorld;
  92022. private _normalizedVelocity;
  92023. /** @hidden */
  92024. _initialVelocity: Vector3;
  92025. /** @hidden */
  92026. _initialPosition: Vector3;
  92027. private _nearestDistance;
  92028. private _collisionMask;
  92029. get collisionMask(): number;
  92030. set collisionMask(mask: number);
  92031. /**
  92032. * Gets the plane normal used to compute the sliding response (in local space)
  92033. */
  92034. get slidePlaneNormal(): Vector3;
  92035. /** @hidden */
  92036. _initialize(source: Vector3, dir: Vector3, e: number): void;
  92037. /** @hidden */
  92038. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  92039. /** @hidden */
  92040. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  92041. /** @hidden */
  92042. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  92043. /** @hidden */
  92044. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  92045. /** @hidden */
  92046. _getResponse(pos: Vector3, vel: Vector3): void;
  92047. }
  92048. }
  92049. declare module BABYLON {
  92050. /**
  92051. * Interface for cullable objects
  92052. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  92053. */
  92054. export interface ICullable {
  92055. /**
  92056. * Checks if the object or part of the object is in the frustum
  92057. * @param frustumPlanes Camera near/planes
  92058. * @returns true if the object is in frustum otherwise false
  92059. */
  92060. isInFrustum(frustumPlanes: Plane[]): boolean;
  92061. /**
  92062. * Checks if a cullable object (mesh...) is in the camera frustum
  92063. * Unlike isInFrustum this cheks the full bounding box
  92064. * @param frustumPlanes Camera near/planes
  92065. * @returns true if the object is in frustum otherwise false
  92066. */
  92067. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  92068. }
  92069. /**
  92070. * Info for a bounding data of a mesh
  92071. */
  92072. export class BoundingInfo implements ICullable {
  92073. /**
  92074. * Bounding box for the mesh
  92075. */
  92076. readonly boundingBox: BoundingBox;
  92077. /**
  92078. * Bounding sphere for the mesh
  92079. */
  92080. readonly boundingSphere: BoundingSphere;
  92081. private _isLocked;
  92082. private static readonly TmpVector3;
  92083. /**
  92084. * Constructs bounding info
  92085. * @param minimum min vector of the bounding box/sphere
  92086. * @param maximum max vector of the bounding box/sphere
  92087. * @param worldMatrix defines the new world matrix
  92088. */
  92089. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  92090. /**
  92091. * Recreates the entire bounding info from scratch as if we call the constructor in place
  92092. * @param min defines the new minimum vector (in local space)
  92093. * @param max defines the new maximum vector (in local space)
  92094. * @param worldMatrix defines the new world matrix
  92095. */
  92096. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  92097. /**
  92098. * min vector of the bounding box/sphere
  92099. */
  92100. get minimum(): Vector3;
  92101. /**
  92102. * max vector of the bounding box/sphere
  92103. */
  92104. get maximum(): Vector3;
  92105. /**
  92106. * If the info is locked and won't be updated to avoid perf overhead
  92107. */
  92108. get isLocked(): boolean;
  92109. set isLocked(value: boolean);
  92110. /**
  92111. * Updates the bounding sphere and box
  92112. * @param world world matrix to be used to update
  92113. */
  92114. update(world: DeepImmutable<Matrix>): void;
  92115. /**
  92116. * Recreate the bounding info to be centered around a specific point given a specific extend.
  92117. * @param center New center of the bounding info
  92118. * @param extend New extend of the bounding info
  92119. * @returns the current bounding info
  92120. */
  92121. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  92122. /**
  92123. * Scale the current bounding info by applying a scale factor
  92124. * @param factor defines the scale factor to apply
  92125. * @returns the current bounding info
  92126. */
  92127. scale(factor: number): BoundingInfo;
  92128. /**
  92129. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  92130. * @param frustumPlanes defines the frustum to test
  92131. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  92132. * @returns true if the bounding info is in the frustum planes
  92133. */
  92134. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  92135. /**
  92136. * Gets the world distance between the min and max points of the bounding box
  92137. */
  92138. get diagonalLength(): number;
  92139. /**
  92140. * Checks if a cullable object (mesh...) is in the camera frustum
  92141. * Unlike isInFrustum this cheks the full bounding box
  92142. * @param frustumPlanes Camera near/planes
  92143. * @returns true if the object is in frustum otherwise false
  92144. */
  92145. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  92146. /** @hidden */
  92147. _checkCollision(collider: Collider): boolean;
  92148. /**
  92149. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  92150. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  92151. * @param point the point to check intersection with
  92152. * @returns if the point intersects
  92153. */
  92154. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  92155. /**
  92156. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  92157. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  92158. * @param boundingInfo the bounding info to check intersection with
  92159. * @param precise if the intersection should be done using OBB
  92160. * @returns if the bounding info intersects
  92161. */
  92162. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  92163. }
  92164. }
  92165. declare module BABYLON {
  92166. /**
  92167. * Extracts minimum and maximum values from a list of indexed positions
  92168. * @param positions defines the positions to use
  92169. * @param indices defines the indices to the positions
  92170. * @param indexStart defines the start index
  92171. * @param indexCount defines the end index
  92172. * @param bias defines bias value to add to the result
  92173. * @return minimum and maximum values
  92174. */
  92175. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  92176. minimum: Vector3;
  92177. maximum: Vector3;
  92178. };
  92179. /**
  92180. * Extracts minimum and maximum values from a list of positions
  92181. * @param positions defines the positions to use
  92182. * @param start defines the start index in the positions array
  92183. * @param count defines the number of positions to handle
  92184. * @param bias defines bias value to add to the result
  92185. * @param stride defines the stride size to use (distance between two positions in the positions array)
  92186. * @return minimum and maximum values
  92187. */
  92188. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  92189. minimum: Vector3;
  92190. maximum: Vector3;
  92191. };
  92192. }
  92193. declare module BABYLON {
  92194. /**
  92195. * Class used to manipulate GUIDs
  92196. */
  92197. export class GUID {
  92198. /**
  92199. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  92200. * Be aware Math.random() could cause collisions, but:
  92201. * "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"
  92202. * @returns a pseudo random id
  92203. */
  92204. static RandomId(): string;
  92205. }
  92206. }
  92207. declare module BABYLON {
  92208. /**
  92209. * Base class of all the textures in babylon.
  92210. * It groups all the common properties the materials, post process, lights... might need
  92211. * in order to make a correct use of the texture.
  92212. */
  92213. export class BaseTexture extends ThinTexture implements IAnimatable {
  92214. /**
  92215. * Default anisotropic filtering level for the application.
  92216. * It is set to 4 as a good tradeoff between perf and quality.
  92217. */
  92218. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  92219. /**
  92220. * Gets or sets the unique id of the texture
  92221. */
  92222. uniqueId: number;
  92223. /**
  92224. * Define the name of the texture.
  92225. */
  92226. name: string;
  92227. /**
  92228. * Gets or sets an object used to store user defined information.
  92229. */
  92230. metadata: any;
  92231. /**
  92232. * For internal use only. Please do not use.
  92233. */
  92234. reservedDataStore: any;
  92235. private _hasAlpha;
  92236. /**
  92237. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  92238. */
  92239. set hasAlpha(value: boolean);
  92240. get hasAlpha(): boolean;
  92241. /**
  92242. * Defines if the alpha value should be determined via the rgb values.
  92243. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  92244. */
  92245. getAlphaFromRGB: boolean;
  92246. /**
  92247. * Intensity or strength of the texture.
  92248. * It is commonly used by materials to fine tune the intensity of the texture
  92249. */
  92250. level: number;
  92251. /**
  92252. * Define the UV chanel to use starting from 0 and defaulting to 0.
  92253. * This is part of the texture as textures usually maps to one uv set.
  92254. */
  92255. coordinatesIndex: number;
  92256. protected _coordinatesMode: number;
  92257. /**
  92258. * How a texture is mapped.
  92259. *
  92260. * | Value | Type | Description |
  92261. * | ----- | ----------------------------------- | ----------- |
  92262. * | 0 | EXPLICIT_MODE | |
  92263. * | 1 | SPHERICAL_MODE | |
  92264. * | 2 | PLANAR_MODE | |
  92265. * | 3 | CUBIC_MODE | |
  92266. * | 4 | PROJECTION_MODE | |
  92267. * | 5 | SKYBOX_MODE | |
  92268. * | 6 | INVCUBIC_MODE | |
  92269. * | 7 | EQUIRECTANGULAR_MODE | |
  92270. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  92271. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  92272. */
  92273. set coordinatesMode(value: number);
  92274. get coordinatesMode(): number;
  92275. /**
  92276. * | Value | Type | Description |
  92277. * | ----- | ------------------ | ----------- |
  92278. * | 0 | CLAMP_ADDRESSMODE | |
  92279. * | 1 | WRAP_ADDRESSMODE | |
  92280. * | 2 | MIRROR_ADDRESSMODE | |
  92281. */
  92282. get wrapU(): number;
  92283. set wrapU(value: number);
  92284. /**
  92285. * | Value | Type | Description |
  92286. * | ----- | ------------------ | ----------- |
  92287. * | 0 | CLAMP_ADDRESSMODE | |
  92288. * | 1 | WRAP_ADDRESSMODE | |
  92289. * | 2 | MIRROR_ADDRESSMODE | |
  92290. */
  92291. get wrapV(): number;
  92292. set wrapV(value: number);
  92293. /**
  92294. * | Value | Type | Description |
  92295. * | ----- | ------------------ | ----------- |
  92296. * | 0 | CLAMP_ADDRESSMODE | |
  92297. * | 1 | WRAP_ADDRESSMODE | |
  92298. * | 2 | MIRROR_ADDRESSMODE | |
  92299. */
  92300. wrapR: number;
  92301. /**
  92302. * With compliant hardware and browser (supporting anisotropic filtering)
  92303. * this defines the level of anisotropic filtering in the texture.
  92304. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  92305. */
  92306. anisotropicFilteringLevel: number;
  92307. private _isCube;
  92308. /**
  92309. * Define if the texture is a cube texture or if false a 2d texture.
  92310. */
  92311. get isCube(): boolean;
  92312. set isCube(value: boolean);
  92313. /**
  92314. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  92315. */
  92316. get is3D(): boolean;
  92317. set is3D(value: boolean);
  92318. /**
  92319. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  92320. */
  92321. get is2DArray(): boolean;
  92322. set is2DArray(value: boolean);
  92323. private _gammaSpace;
  92324. /**
  92325. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  92326. * HDR texture are usually stored in linear space.
  92327. * This only impacts the PBR and Background materials
  92328. */
  92329. get gammaSpace(): boolean;
  92330. set gammaSpace(gamma: boolean);
  92331. /**
  92332. * Gets or sets whether or not the texture contains RGBD data.
  92333. */
  92334. get isRGBD(): boolean;
  92335. set isRGBD(value: boolean);
  92336. /**
  92337. * Is Z inverted in the texture (useful in a cube texture).
  92338. */
  92339. invertZ: boolean;
  92340. /**
  92341. * Are mip maps generated for this texture or not.
  92342. */
  92343. get noMipmap(): boolean;
  92344. /**
  92345. * @hidden
  92346. */
  92347. lodLevelInAlpha: boolean;
  92348. /**
  92349. * With prefiltered texture, defined the offset used during the prefiltering steps.
  92350. */
  92351. get lodGenerationOffset(): number;
  92352. set lodGenerationOffset(value: number);
  92353. /**
  92354. * With prefiltered texture, defined the scale used during the prefiltering steps.
  92355. */
  92356. get lodGenerationScale(): number;
  92357. set lodGenerationScale(value: number);
  92358. /**
  92359. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  92360. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  92361. * average roughness values.
  92362. */
  92363. get linearSpecularLOD(): boolean;
  92364. set linearSpecularLOD(value: boolean);
  92365. /**
  92366. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  92367. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  92368. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  92369. */
  92370. get irradianceTexture(): Nullable<BaseTexture>;
  92371. set irradianceTexture(value: Nullable<BaseTexture>);
  92372. /**
  92373. * Define if the texture is a render target.
  92374. */
  92375. isRenderTarget: boolean;
  92376. /**
  92377. * Define the unique id of the texture in the scene.
  92378. */
  92379. get uid(): string;
  92380. /** @hidden */
  92381. _prefiltered: boolean;
  92382. /**
  92383. * Return a string representation of the texture.
  92384. * @returns the texture as a string
  92385. */
  92386. toString(): string;
  92387. /**
  92388. * Get the class name of the texture.
  92389. * @returns "BaseTexture"
  92390. */
  92391. getClassName(): string;
  92392. /**
  92393. * Define the list of animation attached to the texture.
  92394. */
  92395. animations: Animation[];
  92396. /**
  92397. * An event triggered when the texture is disposed.
  92398. */
  92399. onDisposeObservable: Observable<BaseTexture>;
  92400. private _onDisposeObserver;
  92401. /**
  92402. * Callback triggered when the texture has been disposed.
  92403. * Kept for back compatibility, you can use the onDisposeObservable instead.
  92404. */
  92405. set onDispose(callback: () => void);
  92406. protected _scene: Nullable<Scene>;
  92407. /** @hidden */
  92408. _texture: Nullable<InternalTexture>;
  92409. private _uid;
  92410. /**
  92411. * Define if the texture is preventinga material to render or not.
  92412. * If not and the texture is not ready, the engine will use a default black texture instead.
  92413. */
  92414. get isBlocking(): boolean;
  92415. /**
  92416. * Instantiates a new BaseTexture.
  92417. * Base class of all the textures in babylon.
  92418. * It groups all the common properties the materials, post process, lights... might need
  92419. * in order to make a correct use of the texture.
  92420. * @param sceneOrEngine Define the scene or engine the texture blongs to
  92421. */
  92422. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  92423. /**
  92424. * Get the scene the texture belongs to.
  92425. * @returns the scene or null if undefined
  92426. */
  92427. getScene(): Nullable<Scene>;
  92428. /** @hidden */
  92429. protected _getEngine(): Nullable<ThinEngine>;
  92430. /**
  92431. * Checks if the texture has the same transform matrix than another texture
  92432. * @param texture texture to check against
  92433. * @returns true if the transforms are the same, else false
  92434. */
  92435. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  92436. /**
  92437. * Get the texture transform matrix used to offset tile the texture for istance.
  92438. * @returns the transformation matrix
  92439. */
  92440. getTextureMatrix(): Matrix;
  92441. /**
  92442. * Get the texture reflection matrix used to rotate/transform the reflection.
  92443. * @returns the reflection matrix
  92444. */
  92445. getReflectionTextureMatrix(): Matrix;
  92446. /**
  92447. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  92448. * @returns true if ready or not blocking
  92449. */
  92450. isReadyOrNotBlocking(): boolean;
  92451. /**
  92452. * Scales the texture if is `canRescale()`
  92453. * @param ratio the resize factor we want to use to rescale
  92454. */
  92455. scale(ratio: number): void;
  92456. /**
  92457. * Get if the texture can rescale.
  92458. */
  92459. get canRescale(): boolean;
  92460. /** @hidden */
  92461. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  92462. /** @hidden */
  92463. _rebuild(): void;
  92464. /**
  92465. * Clones the texture.
  92466. * @returns the cloned texture
  92467. */
  92468. clone(): Nullable<BaseTexture>;
  92469. /**
  92470. * Get the texture underlying type (INT, FLOAT...)
  92471. */
  92472. get textureType(): number;
  92473. /**
  92474. * Get the texture underlying format (RGB, RGBA...)
  92475. */
  92476. get textureFormat(): number;
  92477. /**
  92478. * Indicates that textures need to be re-calculated for all materials
  92479. */
  92480. protected _markAllSubMeshesAsTexturesDirty(): void;
  92481. /**
  92482. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  92483. * This will returns an RGBA array buffer containing either in values (0-255) or
  92484. * float values (0-1) depending of the underlying buffer type.
  92485. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  92486. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  92487. * @param buffer defines a user defined buffer to fill with data (can be null)
  92488. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  92489. * @returns The Array buffer promise containing the pixels data.
  92490. */
  92491. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Nullable<Promise<ArrayBufferView>>;
  92492. /** @hidden */
  92493. get _lodTextureHigh(): Nullable<BaseTexture>;
  92494. /** @hidden */
  92495. get _lodTextureMid(): Nullable<BaseTexture>;
  92496. /** @hidden */
  92497. get _lodTextureLow(): Nullable<BaseTexture>;
  92498. /**
  92499. * Dispose the texture and release its associated resources.
  92500. */
  92501. dispose(): void;
  92502. /**
  92503. * Serialize the texture into a JSON representation that can be parsed later on.
  92504. * @returns the JSON representation of the texture
  92505. */
  92506. serialize(): any;
  92507. /**
  92508. * Helper function to be called back once a list of texture contains only ready textures.
  92509. * @param textures Define the list of textures to wait for
  92510. * @param callback Define the callback triggered once the entire list will be ready
  92511. */
  92512. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  92513. private static _isScene;
  92514. }
  92515. }
  92516. declare module BABYLON {
  92517. /** @hidden */
  92518. export class WebGLDataBuffer extends DataBuffer {
  92519. private _buffer;
  92520. constructor(resource: WebGLBuffer);
  92521. get underlyingResource(): any;
  92522. }
  92523. }
  92524. declare module BABYLON {
  92525. /** @hidden */
  92526. export class WebGLPipelineContext implements IPipelineContext {
  92527. private _valueCache;
  92528. private _uniforms;
  92529. engine: ThinEngine;
  92530. program: Nullable<WebGLProgram>;
  92531. context?: WebGLRenderingContext;
  92532. vertexShader?: WebGLShader;
  92533. fragmentShader?: WebGLShader;
  92534. isParallelCompiled: boolean;
  92535. onCompiled?: () => void;
  92536. transformFeedback?: WebGLTransformFeedback | null;
  92537. vertexCompilationError: Nullable<string>;
  92538. fragmentCompilationError: Nullable<string>;
  92539. programLinkError: Nullable<string>;
  92540. programValidationError: Nullable<string>;
  92541. get isAsync(): boolean;
  92542. get isReady(): boolean;
  92543. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  92544. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  92545. [key: string]: number;
  92546. }, uniformsNames: string[], uniforms: {
  92547. [key: string]: Nullable<WebGLUniformLocation>;
  92548. }, samplerList: string[], samplers: {
  92549. [key: string]: number;
  92550. }, attributesNames: string[], attributes: number[]): void;
  92551. /**
  92552. * Release all associated resources.
  92553. **/
  92554. dispose(): void;
  92555. /** @hidden */
  92556. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  92557. /** @hidden */
  92558. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  92559. /** @hidden */
  92560. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  92561. /** @hidden */
  92562. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  92563. /**
  92564. * Sets an interger value on a uniform variable.
  92565. * @param uniformName Name of the variable.
  92566. * @param value Value to be set.
  92567. */
  92568. setInt(uniformName: string, value: number): void;
  92569. /**
  92570. * Sets a int2 on a uniform variable.
  92571. * @param uniformName Name of the variable.
  92572. * @param x First int in int2.
  92573. * @param y Second int in int2.
  92574. */
  92575. setInt2(uniformName: string, x: number, y: number): void;
  92576. /**
  92577. * Sets a int3 on a uniform variable.
  92578. * @param uniformName Name of the variable.
  92579. * @param x First int in int3.
  92580. * @param y Second int in int3.
  92581. * @param y Third int in int3.
  92582. */
  92583. setInt3(uniformName: string, x: number, y: number, z: number): void;
  92584. /**
  92585. * Sets a int4 on a uniform variable.
  92586. * @param uniformName Name of the variable.
  92587. * @param x First int in int4.
  92588. * @param y Second int in int4.
  92589. * @param y Third int in int4.
  92590. * @param w Fourth int in int4.
  92591. */
  92592. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  92593. /**
  92594. * Sets an int array on a uniform variable.
  92595. * @param uniformName Name of the variable.
  92596. * @param array array to be set.
  92597. */
  92598. setIntArray(uniformName: string, array: Int32Array): void;
  92599. /**
  92600. * 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)
  92601. * @param uniformName Name of the variable.
  92602. * @param array array to be set.
  92603. */
  92604. setIntArray2(uniformName: string, array: Int32Array): void;
  92605. /**
  92606. * 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)
  92607. * @param uniformName Name of the variable.
  92608. * @param array array to be set.
  92609. */
  92610. setIntArray3(uniformName: string, array: Int32Array): void;
  92611. /**
  92612. * 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)
  92613. * @param uniformName Name of the variable.
  92614. * @param array array to be set.
  92615. */
  92616. setIntArray4(uniformName: string, array: Int32Array): void;
  92617. /**
  92618. * Sets an array on a uniform variable.
  92619. * @param uniformName Name of the variable.
  92620. * @param array array to be set.
  92621. */
  92622. setArray(uniformName: string, array: number[]): void;
  92623. /**
  92624. * 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)
  92625. * @param uniformName Name of the variable.
  92626. * @param array array to be set.
  92627. */
  92628. setArray2(uniformName: string, array: number[]): void;
  92629. /**
  92630. * 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)
  92631. * @param uniformName Name of the variable.
  92632. * @param array array to be set.
  92633. * @returns this effect.
  92634. */
  92635. setArray3(uniformName: string, array: number[]): void;
  92636. /**
  92637. * 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)
  92638. * @param uniformName Name of the variable.
  92639. * @param array array to be set.
  92640. */
  92641. setArray4(uniformName: string, array: number[]): void;
  92642. /**
  92643. * Sets matrices on a uniform variable.
  92644. * @param uniformName Name of the variable.
  92645. * @param matrices matrices to be set.
  92646. */
  92647. setMatrices(uniformName: string, matrices: Float32Array): void;
  92648. /**
  92649. * Sets matrix on a uniform variable.
  92650. * @param uniformName Name of the variable.
  92651. * @param matrix matrix to be set.
  92652. */
  92653. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  92654. /**
  92655. * 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)
  92656. * @param uniformName Name of the variable.
  92657. * @param matrix matrix to be set.
  92658. */
  92659. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  92660. /**
  92661. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  92662. * @param uniformName Name of the variable.
  92663. * @param matrix matrix to be set.
  92664. */
  92665. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  92666. /**
  92667. * Sets a float on a uniform variable.
  92668. * @param uniformName Name of the variable.
  92669. * @param value value to be set.
  92670. * @returns this effect.
  92671. */
  92672. setFloat(uniformName: string, value: number): void;
  92673. /**
  92674. * Sets a Vector2 on a uniform variable.
  92675. * @param uniformName Name of the variable.
  92676. * @param vector2 vector2 to be set.
  92677. */
  92678. setVector2(uniformName: string, vector2: IVector2Like): void;
  92679. /**
  92680. * Sets a float2 on a uniform variable.
  92681. * @param uniformName Name of the variable.
  92682. * @param x First float in float2.
  92683. * @param y Second float in float2.
  92684. */
  92685. setFloat2(uniformName: string, x: number, y: number): void;
  92686. /**
  92687. * Sets a Vector3 on a uniform variable.
  92688. * @param uniformName Name of the variable.
  92689. * @param vector3 Value to be set.
  92690. */
  92691. setVector3(uniformName: string, vector3: IVector3Like): void;
  92692. /**
  92693. * Sets a float3 on a uniform variable.
  92694. * @param uniformName Name of the variable.
  92695. * @param x First float in float3.
  92696. * @param y Second float in float3.
  92697. * @param z Third float in float3.
  92698. */
  92699. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  92700. /**
  92701. * Sets a Vector4 on a uniform variable.
  92702. * @param uniformName Name of the variable.
  92703. * @param vector4 Value to be set.
  92704. */
  92705. setVector4(uniformName: string, vector4: IVector4Like): void;
  92706. /**
  92707. * Sets a float4 on a uniform variable.
  92708. * @param uniformName Name of the variable.
  92709. * @param x First float in float4.
  92710. * @param y Second float in float4.
  92711. * @param z Third float in float4.
  92712. * @param w Fourth float in float4.
  92713. * @returns this effect.
  92714. */
  92715. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  92716. /**
  92717. * Sets a Color3 on a uniform variable.
  92718. * @param uniformName Name of the variable.
  92719. * @param color3 Value to be set.
  92720. */
  92721. setColor3(uniformName: string, color3: IColor3Like): void;
  92722. /**
  92723. * Sets a Color4 on a uniform variable.
  92724. * @param uniformName Name of the variable.
  92725. * @param color3 Value to be set.
  92726. * @param alpha Alpha value to be set.
  92727. */
  92728. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  92729. /**
  92730. * Sets a Color4 on a uniform variable
  92731. * @param uniformName defines the name of the variable
  92732. * @param color4 defines the value to be set
  92733. */
  92734. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  92735. _getVertexShaderCode(): string | null;
  92736. _getFragmentShaderCode(): string | null;
  92737. }
  92738. }
  92739. declare module BABYLON {
  92740. interface ThinEngine {
  92741. /**
  92742. * Create an uniform buffer
  92743. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  92744. * @param elements defines the content of the uniform buffer
  92745. * @returns the webGL uniform buffer
  92746. */
  92747. createUniformBuffer(elements: FloatArray): DataBuffer;
  92748. /**
  92749. * Create a dynamic uniform buffer
  92750. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  92751. * @param elements defines the content of the uniform buffer
  92752. * @returns the webGL uniform buffer
  92753. */
  92754. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  92755. /**
  92756. * Update an existing uniform buffer
  92757. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  92758. * @param uniformBuffer defines the target uniform buffer
  92759. * @param elements defines the content to update
  92760. * @param offset defines the offset in the uniform buffer where update should start
  92761. * @param count defines the size of the data to update
  92762. */
  92763. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  92764. /**
  92765. * Bind an uniform buffer to the current webGL context
  92766. * @param buffer defines the buffer to bind
  92767. */
  92768. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  92769. /**
  92770. * Bind a buffer to the current webGL context at a given location
  92771. * @param buffer defines the buffer to bind
  92772. * @param location defines the index where to bind the buffer
  92773. * @param name Name of the uniform variable to bind
  92774. */
  92775. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  92776. /**
  92777. * Bind a specific block at a given index in a specific shader program
  92778. * @param pipelineContext defines the pipeline context to use
  92779. * @param blockName defines the block name
  92780. * @param index defines the index where to bind the block
  92781. */
  92782. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  92783. }
  92784. }
  92785. declare module BABYLON {
  92786. /**
  92787. * Uniform buffer objects.
  92788. *
  92789. * Handles blocks of uniform on the GPU.
  92790. *
  92791. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  92792. *
  92793. * For more information, please refer to :
  92794. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  92795. */
  92796. export class UniformBuffer {
  92797. /** @hidden */
  92798. static _updatedUbosInFrame: {
  92799. [name: string]: number;
  92800. };
  92801. private _engine;
  92802. private _buffer;
  92803. private _buffers;
  92804. private _bufferIndex;
  92805. private _createBufferOnWrite;
  92806. private _data;
  92807. private _bufferData;
  92808. private _dynamic?;
  92809. private _uniformLocations;
  92810. private _uniformSizes;
  92811. private _uniformArraySizes;
  92812. private _uniformLocationPointer;
  92813. private _needSync;
  92814. private _noUBO;
  92815. private _currentEffect;
  92816. private _currentEffectName;
  92817. private _name;
  92818. private _currentFrameId;
  92819. /** @hidden */
  92820. _alreadyBound: boolean;
  92821. private static _MAX_UNIFORM_SIZE;
  92822. private static _tempBuffer;
  92823. private static _tempBufferInt32View;
  92824. /**
  92825. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  92826. * This is dynamic to allow compat with webgl 1 and 2.
  92827. * You will need to pass the name of the uniform as well as the value.
  92828. */
  92829. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  92830. /**
  92831. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  92832. * This is dynamic to allow compat with webgl 1 and 2.
  92833. * You will need to pass the name of the uniform as well as the value.
  92834. */
  92835. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  92836. /**
  92837. * Lambda to Update a single float in a uniform buffer.
  92838. * This is dynamic to allow compat with webgl 1 and 2.
  92839. * You will need to pass the name of the uniform as well as the value.
  92840. */
  92841. updateFloat: (name: string, x: number) => void;
  92842. /**
  92843. * Lambda to Update a vec2 of float in a uniform buffer.
  92844. * This is dynamic to allow compat with webgl 1 and 2.
  92845. * You will need to pass the name of the uniform as well as the value.
  92846. */
  92847. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  92848. /**
  92849. * Lambda to Update a vec3 of float in a uniform buffer.
  92850. * This is dynamic to allow compat with webgl 1 and 2.
  92851. * You will need to pass the name of the uniform as well as the value.
  92852. */
  92853. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  92854. /**
  92855. * Lambda to Update a vec4 of float in a uniform buffer.
  92856. * This is dynamic to allow compat with webgl 1 and 2.
  92857. * You will need to pass the name of the uniform as well as the value.
  92858. */
  92859. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  92860. /**
  92861. * Lambda to Update an array of float in a uniform buffer.
  92862. * This is dynamic to allow compat with webgl 1 and 2.
  92863. * You will need to pass the name of the uniform as well as the value.
  92864. */
  92865. updateFloatArray: (name: string, array: Float32Array) => void;
  92866. /**
  92867. * Lambda to Update an array of number in a uniform buffer.
  92868. * This is dynamic to allow compat with webgl 1 and 2.
  92869. * You will need to pass the name of the uniform as well as the value.
  92870. */
  92871. updateArray: (name: string, array: number[]) => void;
  92872. /**
  92873. * Lambda to Update an array of number in a uniform buffer.
  92874. * This is dynamic to allow compat with webgl 1 and 2.
  92875. * You will need to pass the name of the uniform as well as the value.
  92876. */
  92877. updateIntArray: (name: string, array: Int32Array) => void;
  92878. /**
  92879. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  92880. * This is dynamic to allow compat with webgl 1 and 2.
  92881. * You will need to pass the name of the uniform as well as the value.
  92882. */
  92883. updateMatrix: (name: string, mat: IMatrixLike) => void;
  92884. /**
  92885. * Lambda to Update an array of 4x4 Matrix in a uniform buffer.
  92886. * This is dynamic to allow compat with webgl 1 and 2.
  92887. * You will need to pass the name of the uniform as well as the value.
  92888. */
  92889. updateMatrices: (name: string, mat: Float32Array) => void;
  92890. /**
  92891. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  92892. * This is dynamic to allow compat with webgl 1 and 2.
  92893. * You will need to pass the name of the uniform as well as the value.
  92894. */
  92895. updateVector3: (name: string, vector: Vector3) => void;
  92896. /**
  92897. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  92898. * This is dynamic to allow compat with webgl 1 and 2.
  92899. * You will need to pass the name of the uniform as well as the value.
  92900. */
  92901. updateVector4: (name: string, vector: Vector4) => void;
  92902. /**
  92903. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  92904. * This is dynamic to allow compat with webgl 1 and 2.
  92905. * You will need to pass the name of the uniform as well as the value.
  92906. */
  92907. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  92908. /**
  92909. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  92910. * This is dynamic to allow compat with webgl 1 and 2.
  92911. * You will need to pass the name of the uniform as well as the value.
  92912. */
  92913. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  92914. /**
  92915. * Lambda to Update a int a uniform buffer.
  92916. * This is dynamic to allow compat with webgl 1 and 2.
  92917. * You will need to pass the name of the uniform as well as the value.
  92918. */
  92919. updateInt: (name: string, x: number, suffix?: string) => void;
  92920. /**
  92921. * Lambda to Update a vec2 of int in a uniform buffer.
  92922. * This is dynamic to allow compat with webgl 1 and 2.
  92923. * You will need to pass the name of the uniform as well as the value.
  92924. */
  92925. updateInt2: (name: string, x: number, y: number, suffix?: string) => void;
  92926. /**
  92927. * Lambda to Update a vec3 of int in a uniform buffer.
  92928. * This is dynamic to allow compat with webgl 1 and 2.
  92929. * You will need to pass the name of the uniform as well as the value.
  92930. */
  92931. updateInt3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  92932. /**
  92933. * Lambda to Update a vec4 of int in a uniform buffer.
  92934. * This is dynamic to allow compat with webgl 1 and 2.
  92935. * You will need to pass the name of the uniform as well as the value.
  92936. */
  92937. updateInt4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  92938. /**
  92939. * Instantiates a new Uniform buffer objects.
  92940. *
  92941. * Handles blocks of uniform on the GPU.
  92942. *
  92943. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  92944. *
  92945. * For more information, please refer to :
  92946. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  92947. * @param engine Define the engine the buffer is associated with
  92948. * @param data Define the data contained in the buffer
  92949. * @param dynamic Define if the buffer is updatable
  92950. * @param name to assign to the buffer (debugging purpose)
  92951. */
  92952. constructor(engine: Engine, data?: number[], dynamic?: boolean, name?: string);
  92953. /**
  92954. * Indicates if the buffer is using the WebGL2 UBO implementation,
  92955. * or just falling back on setUniformXXX calls.
  92956. */
  92957. get useUbo(): boolean;
  92958. /**
  92959. * Indicates if the WebGL underlying uniform buffer is in sync
  92960. * with the javascript cache data.
  92961. */
  92962. get isSync(): boolean;
  92963. /**
  92964. * Indicates if the WebGL underlying uniform buffer is dynamic.
  92965. * Also, a dynamic UniformBuffer will disable cache verification and always
  92966. * update the underlying WebGL uniform buffer to the GPU.
  92967. * @returns if Dynamic, otherwise false
  92968. */
  92969. isDynamic(): boolean;
  92970. /**
  92971. * The data cache on JS side.
  92972. * @returns the underlying data as a float array
  92973. */
  92974. getData(): Float32Array;
  92975. /**
  92976. * The underlying WebGL Uniform buffer.
  92977. * @returns the webgl buffer
  92978. */
  92979. getBuffer(): Nullable<DataBuffer>;
  92980. /**
  92981. * std140 layout specifies how to align data within an UBO structure.
  92982. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  92983. * for specs.
  92984. */
  92985. private _fillAlignment;
  92986. /**
  92987. * Adds an uniform in the buffer.
  92988. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  92989. * for the layout to be correct !
  92990. * @param name Name of the uniform, as used in the uniform block in the shader.
  92991. * @param size Data size, or data directly.
  92992. * @param arraySize The number of elements in the array, 0 if not an array.
  92993. */
  92994. addUniform(name: string, size: number | number[], arraySize?: number): void;
  92995. /**
  92996. * Adds a Matrix 4x4 to the uniform buffer.
  92997. * @param name Name of the uniform, as used in the uniform block in the shader.
  92998. * @param mat A 4x4 matrix.
  92999. */
  93000. addMatrix(name: string, mat: Matrix): void;
  93001. /**
  93002. * Adds a vec2 to the uniform buffer.
  93003. * @param name Name of the uniform, as used in the uniform block in the shader.
  93004. * @param x Define the x component value of the vec2
  93005. * @param y Define the y component value of the vec2
  93006. */
  93007. addFloat2(name: string, x: number, y: number): void;
  93008. /**
  93009. * Adds a vec3 to the uniform buffer.
  93010. * @param name Name of the uniform, as used in the uniform block in the shader.
  93011. * @param x Define the x component value of the vec3
  93012. * @param y Define the y component value of the vec3
  93013. * @param z Define the z component value of the vec3
  93014. */
  93015. addFloat3(name: string, x: number, y: number, z: number): void;
  93016. /**
  93017. * Adds a vec3 to the uniform buffer.
  93018. * @param name Name of the uniform, as used in the uniform block in the shader.
  93019. * @param color Define the vec3 from a Color
  93020. */
  93021. addColor3(name: string, color: Color3): void;
  93022. /**
  93023. * Adds a vec4 to the uniform buffer.
  93024. * @param name Name of the uniform, as used in the uniform block in the shader.
  93025. * @param color Define the rgb components from a Color
  93026. * @param alpha Define the a component of the vec4
  93027. */
  93028. addColor4(name: string, color: Color3, alpha: number): void;
  93029. /**
  93030. * Adds a vec3 to the uniform buffer.
  93031. * @param name Name of the uniform, as used in the uniform block in the shader.
  93032. * @param vector Define the vec3 components from a Vector
  93033. */
  93034. addVector3(name: string, vector: Vector3): void;
  93035. /**
  93036. * Adds a Matrix 3x3 to the uniform buffer.
  93037. * @param name Name of the uniform, as used in the uniform block in the shader.
  93038. */
  93039. addMatrix3x3(name: string): void;
  93040. /**
  93041. * Adds a Matrix 2x2 to the uniform buffer.
  93042. * @param name Name of the uniform, as used in the uniform block in the shader.
  93043. */
  93044. addMatrix2x2(name: string): void;
  93045. /**
  93046. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  93047. */
  93048. create(): void;
  93049. /** @hidden */
  93050. _rebuild(): void;
  93051. /** @hidden */
  93052. get _numBuffers(): number;
  93053. /** @hidden */
  93054. get _indexBuffer(): number;
  93055. /** Gets the name of this buffer */
  93056. get name(): string;
  93057. /**
  93058. * Updates the WebGL Uniform Buffer on the GPU.
  93059. * If the `dynamic` flag is set to true, no cache comparison is done.
  93060. * Otherwise, the buffer will be updated only if the cache differs.
  93061. */
  93062. update(): void;
  93063. private _createNewBuffer;
  93064. private _checkNewFrame;
  93065. /**
  93066. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  93067. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  93068. * @param data Define the flattened data
  93069. * @param size Define the size of the data.
  93070. */
  93071. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  93072. /**
  93073. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  93074. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  93075. * @param data Define the flattened data
  93076. * @param size Define the size of the data.
  93077. */
  93078. updateUniformArray(uniformName: string, data: FloatArray, size: number): void;
  93079. private _valueCache;
  93080. private _cacheMatrix;
  93081. private _updateMatrix3x3ForUniform;
  93082. private _updateMatrix3x3ForEffect;
  93083. private _updateMatrix2x2ForEffect;
  93084. private _updateMatrix2x2ForUniform;
  93085. private _updateFloatForEffect;
  93086. private _updateFloatForUniform;
  93087. private _updateFloat2ForEffect;
  93088. private _updateFloat2ForUniform;
  93089. private _updateFloat3ForEffect;
  93090. private _updateFloat3ForUniform;
  93091. private _updateFloat4ForEffect;
  93092. private _updateFloat4ForUniform;
  93093. private _updateFloatArrayForEffect;
  93094. private _updateFloatArrayForUniform;
  93095. private _updateArrayForEffect;
  93096. private _updateArrayForUniform;
  93097. private _updateIntArrayForEffect;
  93098. private _updateIntArrayForUniform;
  93099. private _updateMatrixForEffect;
  93100. private _updateMatrixForUniform;
  93101. private _updateMatricesForEffect;
  93102. private _updateMatricesForUniform;
  93103. private _updateVector3ForEffect;
  93104. private _updateVector3ForUniform;
  93105. private _updateVector4ForEffect;
  93106. private _updateVector4ForUniform;
  93107. private _updateColor3ForEffect;
  93108. private _updateColor3ForUniform;
  93109. private _updateColor4ForEffect;
  93110. private _updateColor4ForUniform;
  93111. private _updateIntForEffect;
  93112. private _updateIntForUniform;
  93113. private _updateInt2ForEffect;
  93114. private _updateInt2ForUniform;
  93115. private _updateInt3ForEffect;
  93116. private _updateInt3ForUniform;
  93117. private _updateInt4ForEffect;
  93118. private _updateInt4ForUniform;
  93119. /**
  93120. * Sets a sampler uniform on the effect.
  93121. * @param name Define the name of the sampler.
  93122. * @param texture Define the texture to set in the sampler
  93123. */
  93124. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  93125. /**
  93126. * Directly updates the value of the uniform in the cache AND on the GPU.
  93127. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  93128. * @param data Define the flattened data
  93129. */
  93130. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  93131. /**
  93132. * Binds this uniform buffer to an effect.
  93133. * @param effect Define the effect to bind the buffer to
  93134. * @param name Name of the uniform block in the shader.
  93135. */
  93136. bindToEffect(effect: Effect, name: string): void;
  93137. /**
  93138. * Disposes the uniform buffer.
  93139. */
  93140. dispose(): void;
  93141. }
  93142. }
  93143. declare module BABYLON {
  93144. /**
  93145. * Manages the defines for the Material
  93146. */
  93147. export class MaterialDefines {
  93148. /** @hidden */
  93149. protected _keys: string[];
  93150. private _isDirty;
  93151. /** @hidden */
  93152. _renderId: number;
  93153. /** @hidden */
  93154. _areLightsDirty: boolean;
  93155. /** @hidden */
  93156. _areLightsDisposed: boolean;
  93157. /** @hidden */
  93158. _areAttributesDirty: boolean;
  93159. /** @hidden */
  93160. _areTexturesDirty: boolean;
  93161. /** @hidden */
  93162. _areFresnelDirty: boolean;
  93163. /** @hidden */
  93164. _areMiscDirty: boolean;
  93165. /** @hidden */
  93166. _arePrePassDirty: boolean;
  93167. /** @hidden */
  93168. _areImageProcessingDirty: boolean;
  93169. /** @hidden */
  93170. _normals: boolean;
  93171. /** @hidden */
  93172. _uvs: boolean;
  93173. /** @hidden */
  93174. _needNormals: boolean;
  93175. /** @hidden */
  93176. _needUVs: boolean;
  93177. [id: string]: any;
  93178. /**
  93179. * Specifies if the material needs to be re-calculated
  93180. */
  93181. get isDirty(): boolean;
  93182. /**
  93183. * Marks the material to indicate that it has been re-calculated
  93184. */
  93185. markAsProcessed(): void;
  93186. /**
  93187. * Marks the material to indicate that it needs to be re-calculated
  93188. */
  93189. markAsUnprocessed(): void;
  93190. /**
  93191. * Marks the material to indicate all of its defines need to be re-calculated
  93192. */
  93193. markAllAsDirty(): void;
  93194. /**
  93195. * Marks the material to indicate that image processing needs to be re-calculated
  93196. */
  93197. markAsImageProcessingDirty(): void;
  93198. /**
  93199. * Marks the material to indicate the lights need to be re-calculated
  93200. * @param disposed Defines whether the light is dirty due to dispose or not
  93201. */
  93202. markAsLightDirty(disposed?: boolean): void;
  93203. /**
  93204. * Marks the attribute state as changed
  93205. */
  93206. markAsAttributesDirty(): void;
  93207. /**
  93208. * Marks the texture state as changed
  93209. */
  93210. markAsTexturesDirty(): void;
  93211. /**
  93212. * Marks the fresnel state as changed
  93213. */
  93214. markAsFresnelDirty(): void;
  93215. /**
  93216. * Marks the misc state as changed
  93217. */
  93218. markAsMiscDirty(): void;
  93219. /**
  93220. * Marks the prepass state as changed
  93221. */
  93222. markAsPrePassDirty(): void;
  93223. /**
  93224. * Rebuilds the material defines
  93225. */
  93226. rebuild(): void;
  93227. /**
  93228. * Specifies if two material defines are equal
  93229. * @param other - A material define instance to compare to
  93230. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  93231. */
  93232. isEqual(other: MaterialDefines): boolean;
  93233. /**
  93234. * Clones this instance's defines to another instance
  93235. * @param other - material defines to clone values to
  93236. */
  93237. cloneTo(other: MaterialDefines): void;
  93238. /**
  93239. * Resets the material define values
  93240. */
  93241. reset(): void;
  93242. /**
  93243. * Converts the material define values to a string
  93244. * @returns - String of material define information
  93245. */
  93246. toString(): string;
  93247. }
  93248. }
  93249. declare module BABYLON {
  93250. /**
  93251. * Enum that determines the text-wrapping mode to use.
  93252. */
  93253. export enum InspectableType {
  93254. /**
  93255. * Checkbox for booleans
  93256. */
  93257. Checkbox = 0,
  93258. /**
  93259. * Sliders for numbers
  93260. */
  93261. Slider = 1,
  93262. /**
  93263. * Vector3
  93264. */
  93265. Vector3 = 2,
  93266. /**
  93267. * Quaternions
  93268. */
  93269. Quaternion = 3,
  93270. /**
  93271. * Color3
  93272. */
  93273. Color3 = 4,
  93274. /**
  93275. * String
  93276. */
  93277. String = 5
  93278. }
  93279. /**
  93280. * Interface used to define custom inspectable properties.
  93281. * This interface is used by the inspector to display custom property grids
  93282. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93283. */
  93284. export interface IInspectable {
  93285. /**
  93286. * Gets the label to display
  93287. */
  93288. label: string;
  93289. /**
  93290. * Gets the name of the property to edit
  93291. */
  93292. propertyName: string;
  93293. /**
  93294. * Gets the type of the editor to use
  93295. */
  93296. type: InspectableType;
  93297. /**
  93298. * Gets the minimum value of the property when using in "slider" mode
  93299. */
  93300. min?: number;
  93301. /**
  93302. * Gets the maximum value of the property when using in "slider" mode
  93303. */
  93304. max?: number;
  93305. /**
  93306. * Gets the setp to use when using in "slider" mode
  93307. */
  93308. step?: number;
  93309. }
  93310. }
  93311. declare module BABYLON {
  93312. /**
  93313. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  93314. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  93315. * 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.
  93316. */
  93317. export abstract class Light extends Node {
  93318. /**
  93319. * Falloff Default: light is falling off following the material specification:
  93320. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  93321. */
  93322. static readonly FALLOFF_DEFAULT: number;
  93323. /**
  93324. * Falloff Physical: light is falling off following the inverse squared distance law.
  93325. */
  93326. static readonly FALLOFF_PHYSICAL: number;
  93327. /**
  93328. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  93329. * to enhance interoperability with other engines.
  93330. */
  93331. static readonly FALLOFF_GLTF: number;
  93332. /**
  93333. * Falloff Standard: light is falling off like in the standard material
  93334. * to enhance interoperability with other materials.
  93335. */
  93336. static readonly FALLOFF_STANDARD: number;
  93337. /**
  93338. * If every light affecting the material is in this lightmapMode,
  93339. * material.lightmapTexture adds or multiplies
  93340. * (depends on material.useLightmapAsShadowmap)
  93341. * after every other light calculations.
  93342. */
  93343. static readonly LIGHTMAP_DEFAULT: number;
  93344. /**
  93345. * material.lightmapTexture as only diffuse lighting from this light
  93346. * adds only specular lighting from this light
  93347. * adds dynamic shadows
  93348. */
  93349. static readonly LIGHTMAP_SPECULAR: number;
  93350. /**
  93351. * material.lightmapTexture as only lighting
  93352. * no light calculation from this light
  93353. * only adds dynamic shadows from this light
  93354. */
  93355. static readonly LIGHTMAP_SHADOWSONLY: number;
  93356. /**
  93357. * Each light type uses the default quantity according to its type:
  93358. * point/spot lights use luminous intensity
  93359. * directional lights use illuminance
  93360. */
  93361. static readonly INTENSITYMODE_AUTOMATIC: number;
  93362. /**
  93363. * lumen (lm)
  93364. */
  93365. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  93366. /**
  93367. * candela (lm/sr)
  93368. */
  93369. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  93370. /**
  93371. * lux (lm/m^2)
  93372. */
  93373. static readonly INTENSITYMODE_ILLUMINANCE: number;
  93374. /**
  93375. * nit (cd/m^2)
  93376. */
  93377. static readonly INTENSITYMODE_LUMINANCE: number;
  93378. /**
  93379. * Light type const id of the point light.
  93380. */
  93381. static readonly LIGHTTYPEID_POINTLIGHT: number;
  93382. /**
  93383. * Light type const id of the directional light.
  93384. */
  93385. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  93386. /**
  93387. * Light type const id of the spot light.
  93388. */
  93389. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  93390. /**
  93391. * Light type const id of the hemispheric light.
  93392. */
  93393. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  93394. /**
  93395. * Diffuse gives the basic color to an object.
  93396. */
  93397. diffuse: Color3;
  93398. /**
  93399. * Specular produces a highlight color on an object.
  93400. * Note: This is note affecting PBR materials.
  93401. */
  93402. specular: Color3;
  93403. /**
  93404. * Defines the falloff type for this light. This lets overrriding how punctual light are
  93405. * falling off base on range or angle.
  93406. * This can be set to any values in Light.FALLOFF_x.
  93407. *
  93408. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  93409. * other types of materials.
  93410. */
  93411. falloffType: number;
  93412. /**
  93413. * Strength of the light.
  93414. * Note: By default it is define in the framework own unit.
  93415. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  93416. */
  93417. intensity: number;
  93418. private _range;
  93419. protected _inverseSquaredRange: number;
  93420. /**
  93421. * Defines how far from the source the light is impacting in scene units.
  93422. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  93423. */
  93424. get range(): number;
  93425. /**
  93426. * Defines how far from the source the light is impacting in scene units.
  93427. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  93428. */
  93429. set range(value: number);
  93430. /**
  93431. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  93432. * of light.
  93433. */
  93434. private _photometricScale;
  93435. private _intensityMode;
  93436. /**
  93437. * Gets the photometric scale used to interpret the intensity.
  93438. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  93439. */
  93440. get intensityMode(): number;
  93441. /**
  93442. * Sets the photometric scale used to interpret the intensity.
  93443. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  93444. */
  93445. set intensityMode(value: number);
  93446. private _radius;
  93447. /**
  93448. * Gets the light radius used by PBR Materials to simulate soft area lights.
  93449. */
  93450. get radius(): number;
  93451. /**
  93452. * sets the light radius used by PBR Materials to simulate soft area lights.
  93453. */
  93454. set radius(value: number);
  93455. private _renderPriority;
  93456. /**
  93457. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  93458. * exceeding the number allowed of the materials.
  93459. */
  93460. renderPriority: number;
  93461. private _shadowEnabled;
  93462. /**
  93463. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  93464. * the current shadow generator.
  93465. */
  93466. get shadowEnabled(): boolean;
  93467. /**
  93468. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  93469. * the current shadow generator.
  93470. */
  93471. set shadowEnabled(value: boolean);
  93472. private _includedOnlyMeshes;
  93473. /**
  93474. * Gets the only meshes impacted by this light.
  93475. */
  93476. get includedOnlyMeshes(): AbstractMesh[];
  93477. /**
  93478. * Sets the only meshes impacted by this light.
  93479. */
  93480. set includedOnlyMeshes(value: AbstractMesh[]);
  93481. private _excludedMeshes;
  93482. /**
  93483. * Gets the meshes not impacted by this light.
  93484. */
  93485. get excludedMeshes(): AbstractMesh[];
  93486. /**
  93487. * Sets the meshes not impacted by this light.
  93488. */
  93489. set excludedMeshes(value: AbstractMesh[]);
  93490. private _excludeWithLayerMask;
  93491. /**
  93492. * Gets the layer id use to find what meshes are not impacted by the light.
  93493. * Inactive if 0
  93494. */
  93495. get excludeWithLayerMask(): number;
  93496. /**
  93497. * Sets the layer id use to find what meshes are not impacted by the light.
  93498. * Inactive if 0
  93499. */
  93500. set excludeWithLayerMask(value: number);
  93501. private _includeOnlyWithLayerMask;
  93502. /**
  93503. * Gets the layer id use to find what meshes are impacted by the light.
  93504. * Inactive if 0
  93505. */
  93506. get includeOnlyWithLayerMask(): number;
  93507. /**
  93508. * Sets the layer id use to find what meshes are impacted by the light.
  93509. * Inactive if 0
  93510. */
  93511. set includeOnlyWithLayerMask(value: number);
  93512. private _lightmapMode;
  93513. /**
  93514. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  93515. */
  93516. get lightmapMode(): number;
  93517. /**
  93518. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  93519. */
  93520. set lightmapMode(value: number);
  93521. /**
  93522. * Shadow generator associted to the light.
  93523. * @hidden Internal use only.
  93524. */
  93525. _shadowGenerator: Nullable<IShadowGenerator>;
  93526. /**
  93527. * @hidden Internal use only.
  93528. */
  93529. _excludedMeshesIds: string[];
  93530. /**
  93531. * @hidden Internal use only.
  93532. */
  93533. _includedOnlyMeshesIds: string[];
  93534. /**
  93535. * The current light unifom buffer.
  93536. * @hidden Internal use only.
  93537. */
  93538. _uniformBuffer: UniformBuffer;
  93539. /** @hidden */
  93540. _renderId: number;
  93541. /**
  93542. * Creates a Light object in the scene.
  93543. * Documentation : https://doc.babylonjs.com/babylon101/lights
  93544. * @param name The firendly name of the light
  93545. * @param scene The scene the light belongs too
  93546. */
  93547. constructor(name: string, scene: Scene);
  93548. protected abstract _buildUniformLayout(): void;
  93549. /**
  93550. * Sets the passed Effect "effect" with the Light information.
  93551. * @param effect The effect to update
  93552. * @param lightIndex The index of the light in the effect to update
  93553. * @returns The light
  93554. */
  93555. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  93556. /**
  93557. * Sets the passed Effect "effect" with the Light textures.
  93558. * @param effect The effect to update
  93559. * @param lightIndex The index of the light in the effect to update
  93560. * @returns The light
  93561. */
  93562. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  93563. /**
  93564. * Binds the lights information from the scene to the effect for the given mesh.
  93565. * @param lightIndex Light index
  93566. * @param scene The scene where the light belongs to
  93567. * @param effect The effect we are binding the data to
  93568. * @param useSpecular Defines if specular is supported
  93569. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  93570. */
  93571. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  93572. /**
  93573. * Sets the passed Effect "effect" with the Light information.
  93574. * @param effect The effect to update
  93575. * @param lightDataUniformName The uniform used to store light data (position or direction)
  93576. * @returns The light
  93577. */
  93578. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  93579. /**
  93580. * Returns the string "Light".
  93581. * @returns the class name
  93582. */
  93583. getClassName(): string;
  93584. /** @hidden */
  93585. readonly _isLight: boolean;
  93586. /**
  93587. * Converts the light information to a readable string for debug purpose.
  93588. * @param fullDetails Supports for multiple levels of logging within scene loading
  93589. * @returns the human readable light info
  93590. */
  93591. toString(fullDetails?: boolean): string;
  93592. /** @hidden */
  93593. protected _syncParentEnabledState(): void;
  93594. /**
  93595. * Set the enabled state of this node.
  93596. * @param value - the new enabled state
  93597. */
  93598. setEnabled(value: boolean): void;
  93599. /**
  93600. * Returns the Light associated shadow generator if any.
  93601. * @return the associated shadow generator.
  93602. */
  93603. getShadowGenerator(): Nullable<IShadowGenerator>;
  93604. /**
  93605. * Returns a Vector3, the absolute light position in the World.
  93606. * @returns the world space position of the light
  93607. */
  93608. getAbsolutePosition(): Vector3;
  93609. /**
  93610. * Specifies if the light will affect the passed mesh.
  93611. * @param mesh The mesh to test against the light
  93612. * @return true the mesh is affected otherwise, false.
  93613. */
  93614. canAffectMesh(mesh: AbstractMesh): boolean;
  93615. /**
  93616. * Sort function to order lights for rendering.
  93617. * @param a First Light object to compare to second.
  93618. * @param b Second Light object to compare first.
  93619. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  93620. */
  93621. static CompareLightsPriority(a: Light, b: Light): number;
  93622. /**
  93623. * Releases resources associated with this node.
  93624. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93625. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93626. */
  93627. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93628. /**
  93629. * Returns the light type ID (integer).
  93630. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  93631. */
  93632. getTypeID(): number;
  93633. /**
  93634. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  93635. * @returns the scaled intensity in intensity mode unit
  93636. */
  93637. getScaledIntensity(): number;
  93638. /**
  93639. * Returns a new Light object, named "name", from the current one.
  93640. * @param name The name of the cloned light
  93641. * @param newParent The parent of this light, if it has one
  93642. * @returns the new created light
  93643. */
  93644. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  93645. /**
  93646. * Serializes the current light into a Serialization object.
  93647. * @returns the serialized object.
  93648. */
  93649. serialize(): any;
  93650. /**
  93651. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  93652. * This new light is named "name" and added to the passed scene.
  93653. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  93654. * @param name The friendly name of the light
  93655. * @param scene The scene the new light will belong to
  93656. * @returns the constructor function
  93657. */
  93658. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  93659. /**
  93660. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  93661. * @param parsedLight The JSON representation of the light
  93662. * @param scene The scene to create the parsed light in
  93663. * @returns the created light after parsing
  93664. */
  93665. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  93666. private _hookArrayForExcluded;
  93667. private _hookArrayForIncludedOnly;
  93668. private _resyncMeshes;
  93669. /**
  93670. * Forces the meshes to update their light related information in their rendering used effects
  93671. * @hidden Internal Use Only
  93672. */
  93673. _markMeshesAsLightDirty(): void;
  93674. /**
  93675. * Recomputes the cached photometric scale if needed.
  93676. */
  93677. private _computePhotometricScale;
  93678. /**
  93679. * Returns the Photometric Scale according to the light type and intensity mode.
  93680. */
  93681. private _getPhotometricScale;
  93682. /**
  93683. * Reorder the light in the scene according to their defined priority.
  93684. * @hidden Internal Use Only
  93685. */
  93686. _reorderLightsInScene(): void;
  93687. /**
  93688. * Prepares the list of defines specific to the light type.
  93689. * @param defines the list of defines
  93690. * @param lightIndex defines the index of the light for the effect
  93691. */
  93692. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  93693. }
  93694. }
  93695. declare module BABYLON {
  93696. /** Defines supported spaces */
  93697. export enum Space {
  93698. /** Local (object) space */
  93699. LOCAL = 0,
  93700. /** World space */
  93701. WORLD = 1,
  93702. /** Bone space */
  93703. BONE = 2
  93704. }
  93705. /** Defines the 3 main axes */
  93706. export class Axis {
  93707. /** X axis */
  93708. static X: Vector3;
  93709. /** Y axis */
  93710. static Y: Vector3;
  93711. /** Z axis */
  93712. static Z: Vector3;
  93713. }
  93714. /**
  93715. * Defines cartesian components.
  93716. */
  93717. export enum Coordinate {
  93718. /** X axis */
  93719. X = 0,
  93720. /** Y axis */
  93721. Y = 1,
  93722. /** Z axis */
  93723. Z = 2
  93724. }
  93725. }
  93726. declare module BABYLON {
  93727. /**
  93728. * Interface describing all the common properties and methods a shadow light needs to implement.
  93729. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  93730. * as well as binding the different shadow properties to the effects.
  93731. */
  93732. export interface IShadowLight extends Light {
  93733. /**
  93734. * The light id in the scene (used in scene.findLighById for instance)
  93735. */
  93736. id: string;
  93737. /**
  93738. * The position the shdow will be casted from.
  93739. */
  93740. position: Vector3;
  93741. /**
  93742. * In 2d mode (needCube being false), the direction used to cast the shadow.
  93743. */
  93744. direction: Vector3;
  93745. /**
  93746. * The transformed position. Position of the light in world space taking parenting in account.
  93747. */
  93748. transformedPosition: Vector3;
  93749. /**
  93750. * The transformed direction. Direction of the light in world space taking parenting in account.
  93751. */
  93752. transformedDirection: Vector3;
  93753. /**
  93754. * The friendly name of the light in the scene.
  93755. */
  93756. name: string;
  93757. /**
  93758. * Defines the shadow projection clipping minimum z value.
  93759. */
  93760. shadowMinZ: number;
  93761. /**
  93762. * Defines the shadow projection clipping maximum z value.
  93763. */
  93764. shadowMaxZ: number;
  93765. /**
  93766. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  93767. * @returns true if the information has been computed, false if it does not need to (no parenting)
  93768. */
  93769. computeTransformedInformation(): boolean;
  93770. /**
  93771. * Gets the scene the light belongs to.
  93772. * @returns The scene
  93773. */
  93774. getScene(): Scene;
  93775. /**
  93776. * Callback defining a custom Projection Matrix Builder.
  93777. * This can be used to override the default projection matrix computation.
  93778. */
  93779. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  93780. /**
  93781. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  93782. * @param matrix The materix to updated with the projection information
  93783. * @param viewMatrix The transform matrix of the light
  93784. * @param renderList The list of mesh to render in the map
  93785. * @returns The current light
  93786. */
  93787. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  93788. /**
  93789. * Gets the current depth scale used in ESM.
  93790. * @returns The scale
  93791. */
  93792. getDepthScale(): number;
  93793. /**
  93794. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  93795. * @returns true if a cube texture needs to be use
  93796. */
  93797. needCube(): boolean;
  93798. /**
  93799. * Detects if the projection matrix requires to be recomputed this frame.
  93800. * @returns true if it requires to be recomputed otherwise, false.
  93801. */
  93802. needProjectionMatrixCompute(): boolean;
  93803. /**
  93804. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  93805. */
  93806. forceProjectionMatrixCompute(): void;
  93807. /**
  93808. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  93809. * @param faceIndex The index of the face we are computed the direction to generate shadow
  93810. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  93811. */
  93812. getShadowDirection(faceIndex?: number): Vector3;
  93813. /**
  93814. * Gets the minZ used for shadow according to both the scene and the light.
  93815. * @param activeCamera The camera we are returning the min for
  93816. * @returns the depth min z
  93817. */
  93818. getDepthMinZ(activeCamera: Camera): number;
  93819. /**
  93820. * Gets the maxZ used for shadow according to both the scene and the light.
  93821. * @param activeCamera The camera we are returning the max for
  93822. * @returns the depth max z
  93823. */
  93824. getDepthMaxZ(activeCamera: Camera): number;
  93825. }
  93826. /**
  93827. * Base implementation IShadowLight
  93828. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  93829. */
  93830. export abstract class ShadowLight extends Light implements IShadowLight {
  93831. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  93832. protected _position: Vector3;
  93833. protected _setPosition(value: Vector3): void;
  93834. /**
  93835. * Sets the position the shadow will be casted from. Also use as the light position for both
  93836. * point and spot lights.
  93837. */
  93838. get position(): Vector3;
  93839. /**
  93840. * Sets the position the shadow will be casted from. Also use as the light position for both
  93841. * point and spot lights.
  93842. */
  93843. set position(value: Vector3);
  93844. protected _direction: Vector3;
  93845. protected _setDirection(value: Vector3): void;
  93846. /**
  93847. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  93848. * Also use as the light direction on spot and directional lights.
  93849. */
  93850. get direction(): Vector3;
  93851. /**
  93852. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  93853. * Also use as the light direction on spot and directional lights.
  93854. */
  93855. set direction(value: Vector3);
  93856. protected _shadowMinZ: number;
  93857. /**
  93858. * Gets the shadow projection clipping minimum z value.
  93859. */
  93860. get shadowMinZ(): number;
  93861. /**
  93862. * Sets the shadow projection clipping minimum z value.
  93863. */
  93864. set shadowMinZ(value: number);
  93865. protected _shadowMaxZ: number;
  93866. /**
  93867. * Sets the shadow projection clipping maximum z value.
  93868. */
  93869. get shadowMaxZ(): number;
  93870. /**
  93871. * Gets the shadow projection clipping maximum z value.
  93872. */
  93873. set shadowMaxZ(value: number);
  93874. /**
  93875. * Callback defining a custom Projection Matrix Builder.
  93876. * This can be used to override the default projection matrix computation.
  93877. */
  93878. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  93879. /**
  93880. * The transformed position. Position of the light in world space taking parenting in account.
  93881. */
  93882. transformedPosition: Vector3;
  93883. /**
  93884. * The transformed direction. Direction of the light in world space taking parenting in account.
  93885. */
  93886. transformedDirection: Vector3;
  93887. private _needProjectionMatrixCompute;
  93888. /**
  93889. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  93890. * @returns true if the information has been computed, false if it does not need to (no parenting)
  93891. */
  93892. computeTransformedInformation(): boolean;
  93893. /**
  93894. * Return the depth scale used for the shadow map.
  93895. * @returns the depth scale.
  93896. */
  93897. getDepthScale(): number;
  93898. /**
  93899. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  93900. * @param faceIndex The index of the face we are computed the direction to generate shadow
  93901. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  93902. */
  93903. getShadowDirection(faceIndex?: number): Vector3;
  93904. /**
  93905. * Returns the ShadowLight absolute position in the World.
  93906. * @returns the position vector in world space
  93907. */
  93908. getAbsolutePosition(): Vector3;
  93909. /**
  93910. * Sets the ShadowLight direction toward the passed target.
  93911. * @param target The point to target in local space
  93912. * @returns the updated ShadowLight direction
  93913. */
  93914. setDirectionToTarget(target: Vector3): Vector3;
  93915. /**
  93916. * Returns the light rotation in euler definition.
  93917. * @returns the x y z rotation in local space.
  93918. */
  93919. getRotation(): Vector3;
  93920. /**
  93921. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  93922. * @returns true if a cube texture needs to be use
  93923. */
  93924. needCube(): boolean;
  93925. /**
  93926. * Detects if the projection matrix requires to be recomputed this frame.
  93927. * @returns true if it requires to be recomputed otherwise, false.
  93928. */
  93929. needProjectionMatrixCompute(): boolean;
  93930. /**
  93931. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  93932. */
  93933. forceProjectionMatrixCompute(): void;
  93934. /** @hidden */
  93935. _initCache(): void;
  93936. /** @hidden */
  93937. _isSynchronized(): boolean;
  93938. /**
  93939. * Computes the world matrix of the node
  93940. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93941. * @returns the world matrix
  93942. */
  93943. computeWorldMatrix(force?: boolean): Matrix;
  93944. /**
  93945. * Gets the minZ used for shadow according to both the scene and the light.
  93946. * @param activeCamera The camera we are returning the min for
  93947. * @returns the depth min z
  93948. */
  93949. getDepthMinZ(activeCamera: Camera): number;
  93950. /**
  93951. * Gets the maxZ used for shadow according to both the scene and the light.
  93952. * @param activeCamera The camera we are returning the max for
  93953. * @returns the depth max z
  93954. */
  93955. getDepthMaxZ(activeCamera: Camera): number;
  93956. /**
  93957. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  93958. * @param matrix The materix to updated with the projection information
  93959. * @param viewMatrix The transform matrix of the light
  93960. * @param renderList The list of mesh to render in the map
  93961. * @returns The current light
  93962. */
  93963. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  93964. }
  93965. }
  93966. declare module BABYLON {
  93967. /**
  93968. * Configuration needed for prepass-capable materials
  93969. */
  93970. export class PrePassConfiguration {
  93971. /**
  93972. * Previous world matrices of meshes carrying this material
  93973. * Used for computing velocity
  93974. */
  93975. previousWorldMatrices: {
  93976. [index: number]: Matrix;
  93977. };
  93978. /**
  93979. * Previous view project matrix
  93980. * Used for computing velocity
  93981. */
  93982. previousViewProjection: Matrix;
  93983. /**
  93984. * Previous bones of meshes carrying this material
  93985. * Used for computing velocity
  93986. */
  93987. previousBones: {
  93988. [index: number]: Float32Array;
  93989. };
  93990. /**
  93991. * Add the required uniforms to the current list.
  93992. * @param uniforms defines the current uniform list.
  93993. */
  93994. static AddUniforms(uniforms: string[]): void;
  93995. /**
  93996. * Add the required samplers to the current list.
  93997. * @param samplers defines the current sampler list.
  93998. */
  93999. static AddSamplers(samplers: string[]): void;
  94000. /**
  94001. * Binds the material data.
  94002. * @param effect defines the effect to update
  94003. * @param scene defines the scene the material belongs to.
  94004. * @param mesh The mesh
  94005. * @param world World matrix of this mesh
  94006. * @param isFrozen Is the material frozen
  94007. */
  94008. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  94009. }
  94010. }
  94011. declare module BABYLON {
  94012. /**
  94013. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  94014. * This is the base of the follow, arc rotate cameras and Free camera
  94015. * @see https://doc.babylonjs.com/features/cameras
  94016. */
  94017. export class TargetCamera extends Camera {
  94018. private static _RigCamTransformMatrix;
  94019. private static _TargetTransformMatrix;
  94020. private static _TargetFocalPoint;
  94021. private _tmpUpVector;
  94022. private _tmpTargetVector;
  94023. /**
  94024. * Define the current direction the camera is moving to
  94025. */
  94026. cameraDirection: Vector3;
  94027. /**
  94028. * Define the current rotation the camera is rotating to
  94029. */
  94030. cameraRotation: Vector2;
  94031. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  94032. ignoreParentScaling: boolean;
  94033. /**
  94034. * When set, the up vector of the camera will be updated by the rotation of the camera
  94035. */
  94036. updateUpVectorFromRotation: boolean;
  94037. private _tmpQuaternion;
  94038. /**
  94039. * Define the current rotation of the camera
  94040. */
  94041. rotation: Vector3;
  94042. /**
  94043. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  94044. */
  94045. rotationQuaternion: Quaternion;
  94046. /**
  94047. * Define the current speed of the camera
  94048. */
  94049. speed: number;
  94050. /**
  94051. * Add constraint to the camera to prevent it to move freely in all directions and
  94052. * around all axis.
  94053. */
  94054. noRotationConstraint: boolean;
  94055. /**
  94056. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  94057. * panning
  94058. */
  94059. invertRotation: boolean;
  94060. /**
  94061. * Speed multiplier for inverse camera panning
  94062. */
  94063. inverseRotationSpeed: number;
  94064. /**
  94065. * Define the current target of the camera as an object or a position.
  94066. */
  94067. lockedTarget: any;
  94068. /** @hidden */
  94069. _currentTarget: Vector3;
  94070. /** @hidden */
  94071. _initialFocalDistance: number;
  94072. /** @hidden */
  94073. _viewMatrix: Matrix;
  94074. /** @hidden */
  94075. _camMatrix: Matrix;
  94076. /** @hidden */
  94077. _cameraTransformMatrix: Matrix;
  94078. /** @hidden */
  94079. _cameraRotationMatrix: Matrix;
  94080. /** @hidden */
  94081. _referencePoint: Vector3;
  94082. /** @hidden */
  94083. _transformedReferencePoint: Vector3;
  94084. /** @hidden */
  94085. _reset: () => void;
  94086. private _defaultUp;
  94087. /**
  94088. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  94089. * This is the base of the follow, arc rotate cameras and Free camera
  94090. * @see https://doc.babylonjs.com/features/cameras
  94091. * @param name Defines the name of the camera in the scene
  94092. * @param position Defines the start position of the camera in the scene
  94093. * @param scene Defines the scene the camera belongs to
  94094. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  94095. */
  94096. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  94097. /**
  94098. * Gets the position in front of the camera at a given distance.
  94099. * @param distance The distance from the camera we want the position to be
  94100. * @returns the position
  94101. */
  94102. getFrontPosition(distance: number): Vector3;
  94103. /** @hidden */
  94104. _getLockedTargetPosition(): Nullable<Vector3>;
  94105. private _storedPosition;
  94106. private _storedRotation;
  94107. private _storedRotationQuaternion;
  94108. /**
  94109. * Store current camera state of the camera (fov, position, rotation, etc..)
  94110. * @returns the camera
  94111. */
  94112. storeState(): Camera;
  94113. /**
  94114. * Restored camera state. You must call storeState() first
  94115. * @returns whether it was successful or not
  94116. * @hidden
  94117. */
  94118. _restoreStateValues(): boolean;
  94119. /** @hidden */
  94120. _initCache(): void;
  94121. /** @hidden */
  94122. _updateCache(ignoreParentClass?: boolean): void;
  94123. /** @hidden */
  94124. _isSynchronizedViewMatrix(): boolean;
  94125. /** @hidden */
  94126. _computeLocalCameraSpeed(): number;
  94127. /**
  94128. * Defines the target the camera should look at.
  94129. * @param target Defines the new target as a Vector or a mesh
  94130. */
  94131. setTarget(target: Vector3): void;
  94132. /**
  94133. * Defines the target point of the camera.
  94134. * The camera looks towards it form the radius distance.
  94135. */
  94136. get target(): Vector3;
  94137. set target(value: Vector3);
  94138. /**
  94139. * Return the current target position of the camera. This value is expressed in local space.
  94140. * @returns the target position
  94141. */
  94142. getTarget(): Vector3;
  94143. /** @hidden */
  94144. _decideIfNeedsToMove(): boolean;
  94145. /** @hidden */
  94146. _updatePosition(): void;
  94147. /** @hidden */
  94148. _checkInputs(): void;
  94149. protected _updateCameraRotationMatrix(): void;
  94150. /**
  94151. * 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)
  94152. * @returns the current camera
  94153. */
  94154. private _rotateUpVectorWithCameraRotationMatrix;
  94155. private _cachedRotationZ;
  94156. private _cachedQuaternionRotationZ;
  94157. /** @hidden */
  94158. _getViewMatrix(): Matrix;
  94159. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  94160. /**
  94161. * @hidden
  94162. */
  94163. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  94164. /**
  94165. * @hidden
  94166. */
  94167. _updateRigCameras(): void;
  94168. private _getRigCamPositionAndTarget;
  94169. /**
  94170. * Gets the current object class name.
  94171. * @return the class name
  94172. */
  94173. getClassName(): string;
  94174. }
  94175. }
  94176. declare module BABYLON {
  94177. /**
  94178. * @ignore
  94179. * This is a list of all the different input types that are available in the application.
  94180. * Fo instance: ArcRotateCameraGamepadInput...
  94181. */
  94182. export var CameraInputTypes: {};
  94183. /**
  94184. * This is the contract to implement in order to create a new input class.
  94185. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  94186. */
  94187. export interface ICameraInput<TCamera extends Camera> {
  94188. /**
  94189. * Defines the camera the input is attached to.
  94190. */
  94191. camera: Nullable<TCamera>;
  94192. /**
  94193. * Gets the class name of the current intput.
  94194. * @returns the class name
  94195. */
  94196. getClassName(): string;
  94197. /**
  94198. * Get the friendly name associated with the input class.
  94199. * @returns the input friendly name
  94200. */
  94201. getSimpleName(): string;
  94202. /**
  94203. * Attach the input controls to a specific dom element to get the input from.
  94204. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94205. */
  94206. attachControl(noPreventDefault?: boolean): void;
  94207. /**
  94208. * Detach the current controls from the specified dom element.
  94209. */
  94210. detachControl(): void;
  94211. /**
  94212. * Update the current camera state depending on the inputs that have been used this frame.
  94213. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94214. */
  94215. checkInputs?: () => void;
  94216. }
  94217. /**
  94218. * Represents a map of input types to input instance or input index to input instance.
  94219. */
  94220. export interface CameraInputsMap<TCamera extends Camera> {
  94221. /**
  94222. * Accessor to the input by input type.
  94223. */
  94224. [name: string]: ICameraInput<TCamera>;
  94225. /**
  94226. * Accessor to the input by input index.
  94227. */
  94228. [idx: number]: ICameraInput<TCamera>;
  94229. }
  94230. /**
  94231. * This represents the input manager used within a camera.
  94232. * It helps dealing with all the different kind of input attached to a camera.
  94233. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  94234. */
  94235. export class CameraInputsManager<TCamera extends Camera> {
  94236. /**
  94237. * Defines the list of inputs attahed to the camera.
  94238. */
  94239. attached: CameraInputsMap<TCamera>;
  94240. /**
  94241. * Defines the dom element the camera is collecting inputs from.
  94242. * This is null if the controls have not been attached.
  94243. */
  94244. attachedToElement: boolean;
  94245. /**
  94246. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94247. */
  94248. noPreventDefault: boolean;
  94249. /**
  94250. * Defined the camera the input manager belongs to.
  94251. */
  94252. camera: TCamera;
  94253. /**
  94254. * Update the current camera state depending on the inputs that have been used this frame.
  94255. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94256. */
  94257. checkInputs: () => void;
  94258. /**
  94259. * Instantiate a new Camera Input Manager.
  94260. * @param camera Defines the camera the input manager blongs to
  94261. */
  94262. constructor(camera: TCamera);
  94263. /**
  94264. * Add an input method to a camera
  94265. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  94266. * @param input camera input method
  94267. */
  94268. add(input: ICameraInput<TCamera>): void;
  94269. /**
  94270. * Remove a specific input method from a camera
  94271. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  94272. * @param inputToRemove camera input method
  94273. */
  94274. remove(inputToRemove: ICameraInput<TCamera>): void;
  94275. /**
  94276. * Remove a specific input type from a camera
  94277. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  94278. * @param inputType the type of the input to remove
  94279. */
  94280. removeByType(inputType: string): void;
  94281. private _addCheckInputs;
  94282. /**
  94283. * Attach the input controls to the currently attached dom element to listen the events from.
  94284. * @param input Defines the input to attach
  94285. */
  94286. attachInput(input: ICameraInput<TCamera>): void;
  94287. /**
  94288. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  94289. * @param element Defines the dom element to collect the events from
  94290. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94291. */
  94292. attachElement(noPreventDefault?: boolean): void;
  94293. /**
  94294. * Detach the current manager inputs controls from a specific dom element.
  94295. * @param element Defines the dom element to collect the events from
  94296. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  94297. */
  94298. detachElement(disconnect?: boolean): void;
  94299. /**
  94300. * Rebuild the dynamic inputCheck function from the current list of
  94301. * defined inputs in the manager.
  94302. */
  94303. rebuildInputCheck(): void;
  94304. /**
  94305. * Remove all attached input methods from a camera
  94306. */
  94307. clear(): void;
  94308. /**
  94309. * Serialize the current input manager attached to a camera.
  94310. * This ensures than once parsed,
  94311. * the input associated to the camera will be identical to the current ones
  94312. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  94313. */
  94314. serialize(serializedCamera: any): void;
  94315. /**
  94316. * Parses an input manager serialized JSON to restore the previous list of inputs
  94317. * and states associated to a camera.
  94318. * @param parsedCamera Defines the JSON to parse
  94319. */
  94320. parse(parsedCamera: any): void;
  94321. }
  94322. }
  94323. declare module BABYLON {
  94324. /**
  94325. * Gather the list of keyboard event types as constants.
  94326. */
  94327. export class KeyboardEventTypes {
  94328. /**
  94329. * The keydown event is fired when a key becomes active (pressed).
  94330. */
  94331. static readonly KEYDOWN: number;
  94332. /**
  94333. * The keyup event is fired when a key has been released.
  94334. */
  94335. static readonly KEYUP: number;
  94336. }
  94337. /**
  94338. * This class is used to store keyboard related info for the onKeyboardObservable event.
  94339. */
  94340. export class KeyboardInfo {
  94341. /**
  94342. * Defines the type of event (KeyboardEventTypes)
  94343. */
  94344. type: number;
  94345. /**
  94346. * Defines the related dom event
  94347. */
  94348. event: KeyboardEvent;
  94349. /**
  94350. * Instantiates a new keyboard info.
  94351. * This class is used to store keyboard related info for the onKeyboardObservable event.
  94352. * @param type Defines the type of event (KeyboardEventTypes)
  94353. * @param event Defines the related dom event
  94354. */
  94355. constructor(
  94356. /**
  94357. * Defines the type of event (KeyboardEventTypes)
  94358. */
  94359. type: number,
  94360. /**
  94361. * Defines the related dom event
  94362. */
  94363. event: KeyboardEvent);
  94364. }
  94365. /**
  94366. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  94367. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  94368. */
  94369. export class KeyboardInfoPre extends KeyboardInfo {
  94370. /**
  94371. * Defines the type of event (KeyboardEventTypes)
  94372. */
  94373. type: number;
  94374. /**
  94375. * Defines the related dom event
  94376. */
  94377. event: KeyboardEvent;
  94378. /**
  94379. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  94380. */
  94381. skipOnPointerObservable: boolean;
  94382. /**
  94383. * Instantiates a new keyboard pre info.
  94384. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  94385. * @param type Defines the type of event (KeyboardEventTypes)
  94386. * @param event Defines the related dom event
  94387. */
  94388. constructor(
  94389. /**
  94390. * Defines the type of event (KeyboardEventTypes)
  94391. */
  94392. type: number,
  94393. /**
  94394. * Defines the related dom event
  94395. */
  94396. event: KeyboardEvent);
  94397. }
  94398. }
  94399. declare module BABYLON {
  94400. /**
  94401. * Manage the keyboard inputs to control the movement of a free camera.
  94402. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  94403. */
  94404. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  94405. /**
  94406. * Defines the camera the input is attached to.
  94407. */
  94408. camera: FreeCamera;
  94409. /**
  94410. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  94411. */
  94412. keysUp: number[];
  94413. /**
  94414. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  94415. */
  94416. keysUpward: number[];
  94417. /**
  94418. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  94419. */
  94420. keysDown: number[];
  94421. /**
  94422. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  94423. */
  94424. keysDownward: number[];
  94425. /**
  94426. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  94427. */
  94428. keysLeft: number[];
  94429. /**
  94430. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  94431. */
  94432. keysRight: number[];
  94433. private _keys;
  94434. private _onCanvasBlurObserver;
  94435. private _onKeyboardObserver;
  94436. private _engine;
  94437. private _scene;
  94438. /**
  94439. * Attach the input controls to a specific dom element to get the input from.
  94440. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94441. */
  94442. attachControl(noPreventDefault?: boolean): void;
  94443. /**
  94444. * Detach the current controls from the specified dom element.
  94445. */
  94446. detachControl(): void;
  94447. /**
  94448. * Update the current camera state depending on the inputs that have been used this frame.
  94449. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94450. */
  94451. checkInputs(): void;
  94452. /**
  94453. * Gets the class name of the current intput.
  94454. * @returns the class name
  94455. */
  94456. getClassName(): string;
  94457. /** @hidden */
  94458. _onLostFocus(): void;
  94459. /**
  94460. * Get the friendly name associated with the input class.
  94461. * @returns the input friendly name
  94462. */
  94463. getSimpleName(): string;
  94464. }
  94465. }
  94466. declare module BABYLON {
  94467. /**
  94468. * Interface used to define Action
  94469. */
  94470. export interface IAction {
  94471. /**
  94472. * Trigger for the action
  94473. */
  94474. trigger: number;
  94475. /** Options of the trigger */
  94476. triggerOptions: any;
  94477. /**
  94478. * Gets the trigger parameters
  94479. * @returns the trigger parameters
  94480. */
  94481. getTriggerParameter(): any;
  94482. /**
  94483. * Internal only - executes current action event
  94484. * @hidden
  94485. */
  94486. _executeCurrent(evt?: ActionEvent): void;
  94487. /**
  94488. * Serialize placeholder for child classes
  94489. * @param parent of child
  94490. * @returns the serialized object
  94491. */
  94492. serialize(parent: any): any;
  94493. /**
  94494. * Internal only
  94495. * @hidden
  94496. */
  94497. _prepare(): void;
  94498. /**
  94499. * Internal only - manager for action
  94500. * @hidden
  94501. */
  94502. _actionManager: Nullable<AbstractActionManager>;
  94503. /**
  94504. * Adds action to chain of actions, may be a DoNothingAction
  94505. * @param action defines the next action to execute
  94506. * @returns The action passed in
  94507. * @see https://www.babylonjs-playground.com/#1T30HR#0
  94508. */
  94509. then(action: IAction): IAction;
  94510. }
  94511. /**
  94512. * The action to be carried out following a trigger
  94513. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  94514. */
  94515. export class Action implements IAction {
  94516. /** the trigger, with or without parameters, for the action */
  94517. triggerOptions: any;
  94518. /**
  94519. * Trigger for the action
  94520. */
  94521. trigger: number;
  94522. /**
  94523. * Internal only - manager for action
  94524. * @hidden
  94525. */
  94526. _actionManager: ActionManager;
  94527. private _nextActiveAction;
  94528. private _child;
  94529. private _condition?;
  94530. private _triggerParameter;
  94531. /**
  94532. * An event triggered prior to action being executed.
  94533. */
  94534. onBeforeExecuteObservable: Observable<Action>;
  94535. /**
  94536. * Creates a new Action
  94537. * @param triggerOptions the trigger, with or without parameters, for the action
  94538. * @param condition an optional determinant of action
  94539. */
  94540. constructor(
  94541. /** the trigger, with or without parameters, for the action */
  94542. triggerOptions: any, condition?: Condition);
  94543. /**
  94544. * Internal only
  94545. * @hidden
  94546. */
  94547. _prepare(): void;
  94548. /**
  94549. * Gets the trigger parameter
  94550. * @returns the trigger parameter
  94551. */
  94552. getTriggerParameter(): any;
  94553. /**
  94554. * Sets the trigger parameter
  94555. * @param value defines the new trigger parameter
  94556. */
  94557. setTriggerParameter(value: any): void;
  94558. /**
  94559. * Internal only - executes current action event
  94560. * @hidden
  94561. */
  94562. _executeCurrent(evt?: ActionEvent): void;
  94563. /**
  94564. * Execute placeholder for child classes
  94565. * @param evt optional action event
  94566. */
  94567. execute(evt?: ActionEvent): void;
  94568. /**
  94569. * Skips to next active action
  94570. */
  94571. skipToNextActiveAction(): void;
  94572. /**
  94573. * Adds action to chain of actions, may be a DoNothingAction
  94574. * @param action defines the next action to execute
  94575. * @returns The action passed in
  94576. * @see https://www.babylonjs-playground.com/#1T30HR#0
  94577. */
  94578. then(action: Action): Action;
  94579. /**
  94580. * Internal only
  94581. * @hidden
  94582. */
  94583. _getProperty(propertyPath: string): string;
  94584. /**
  94585. * Internal only
  94586. * @hidden
  94587. */
  94588. _getEffectiveTarget(target: any, propertyPath: string): any;
  94589. /**
  94590. * Serialize placeholder for child classes
  94591. * @param parent of child
  94592. * @returns the serialized object
  94593. */
  94594. serialize(parent: any): any;
  94595. /**
  94596. * Internal only called by serialize
  94597. * @hidden
  94598. */
  94599. protected _serialize(serializedAction: any, parent?: any): any;
  94600. /**
  94601. * Internal only
  94602. * @hidden
  94603. */
  94604. static _SerializeValueAsString: (value: any) => string;
  94605. /**
  94606. * Internal only
  94607. * @hidden
  94608. */
  94609. static _GetTargetProperty: (target: Scene | Node) => {
  94610. name: string;
  94611. targetType: string;
  94612. value: string;
  94613. };
  94614. }
  94615. }
  94616. declare module BABYLON {
  94617. /**
  94618. * A Condition applied to an Action
  94619. */
  94620. export class Condition {
  94621. /**
  94622. * Internal only - manager for action
  94623. * @hidden
  94624. */
  94625. _actionManager: ActionManager;
  94626. /**
  94627. * Internal only
  94628. * @hidden
  94629. */
  94630. _evaluationId: number;
  94631. /**
  94632. * Internal only
  94633. * @hidden
  94634. */
  94635. _currentResult: boolean;
  94636. /**
  94637. * Creates a new Condition
  94638. * @param actionManager the manager of the action the condition is applied to
  94639. */
  94640. constructor(actionManager: ActionManager);
  94641. /**
  94642. * Check if the current condition is valid
  94643. * @returns a boolean
  94644. */
  94645. isValid(): boolean;
  94646. /**
  94647. * Internal only
  94648. * @hidden
  94649. */
  94650. _getProperty(propertyPath: string): string;
  94651. /**
  94652. * Internal only
  94653. * @hidden
  94654. */
  94655. _getEffectiveTarget(target: any, propertyPath: string): any;
  94656. /**
  94657. * Serialize placeholder for child classes
  94658. * @returns the serialized object
  94659. */
  94660. serialize(): any;
  94661. /**
  94662. * Internal only
  94663. * @hidden
  94664. */
  94665. protected _serialize(serializedCondition: any): any;
  94666. }
  94667. /**
  94668. * Defines specific conditional operators as extensions of Condition
  94669. */
  94670. export class ValueCondition extends Condition {
  94671. /** path to specify the property of the target the conditional operator uses */
  94672. propertyPath: string;
  94673. /** the value compared by the conditional operator against the current value of the property */
  94674. value: any;
  94675. /** the conditional operator, default ValueCondition.IsEqual */
  94676. operator: number;
  94677. /**
  94678. * Internal only
  94679. * @hidden
  94680. */
  94681. private static _IsEqual;
  94682. /**
  94683. * Internal only
  94684. * @hidden
  94685. */
  94686. private static _IsDifferent;
  94687. /**
  94688. * Internal only
  94689. * @hidden
  94690. */
  94691. private static _IsGreater;
  94692. /**
  94693. * Internal only
  94694. * @hidden
  94695. */
  94696. private static _IsLesser;
  94697. /**
  94698. * returns the number for IsEqual
  94699. */
  94700. static get IsEqual(): number;
  94701. /**
  94702. * Returns the number for IsDifferent
  94703. */
  94704. static get IsDifferent(): number;
  94705. /**
  94706. * Returns the number for IsGreater
  94707. */
  94708. static get IsGreater(): number;
  94709. /**
  94710. * Returns the number for IsLesser
  94711. */
  94712. static get IsLesser(): number;
  94713. /**
  94714. * Internal only The action manager for the condition
  94715. * @hidden
  94716. */
  94717. _actionManager: ActionManager;
  94718. /**
  94719. * Internal only
  94720. * @hidden
  94721. */
  94722. private _target;
  94723. /**
  94724. * Internal only
  94725. * @hidden
  94726. */
  94727. private _effectiveTarget;
  94728. /**
  94729. * Internal only
  94730. * @hidden
  94731. */
  94732. private _property;
  94733. /**
  94734. * Creates a new ValueCondition
  94735. * @param actionManager manager for the action the condition applies to
  94736. * @param target for the action
  94737. * @param propertyPath path to specify the property of the target the conditional operator uses
  94738. * @param value the value compared by the conditional operator against the current value of the property
  94739. * @param operator the conditional operator, default ValueCondition.IsEqual
  94740. */
  94741. constructor(actionManager: ActionManager, target: any,
  94742. /** path to specify the property of the target the conditional operator uses */
  94743. propertyPath: string,
  94744. /** the value compared by the conditional operator against the current value of the property */
  94745. value: any,
  94746. /** the conditional operator, default ValueCondition.IsEqual */
  94747. operator?: number);
  94748. /**
  94749. * Compares the given value with the property value for the specified conditional operator
  94750. * @returns the result of the comparison
  94751. */
  94752. isValid(): boolean;
  94753. /**
  94754. * Serialize the ValueCondition into a JSON compatible object
  94755. * @returns serialization object
  94756. */
  94757. serialize(): any;
  94758. /**
  94759. * Gets the name of the conditional operator for the ValueCondition
  94760. * @param operator the conditional operator
  94761. * @returns the name
  94762. */
  94763. static GetOperatorName(operator: number): string;
  94764. }
  94765. /**
  94766. * Defines a predicate condition as an extension of Condition
  94767. */
  94768. export class PredicateCondition extends Condition {
  94769. /** defines the predicate function used to validate the condition */
  94770. predicate: () => boolean;
  94771. /**
  94772. * Internal only - manager for action
  94773. * @hidden
  94774. */
  94775. _actionManager: ActionManager;
  94776. /**
  94777. * Creates a new PredicateCondition
  94778. * @param actionManager manager for the action the condition applies to
  94779. * @param predicate defines the predicate function used to validate the condition
  94780. */
  94781. constructor(actionManager: ActionManager,
  94782. /** defines the predicate function used to validate the condition */
  94783. predicate: () => boolean);
  94784. /**
  94785. * @returns the validity of the predicate condition
  94786. */
  94787. isValid(): boolean;
  94788. }
  94789. /**
  94790. * Defines a state condition as an extension of Condition
  94791. */
  94792. export class StateCondition extends Condition {
  94793. /** Value to compare with target state */
  94794. value: string;
  94795. /**
  94796. * Internal only - manager for action
  94797. * @hidden
  94798. */
  94799. _actionManager: ActionManager;
  94800. /**
  94801. * Internal only
  94802. * @hidden
  94803. */
  94804. private _target;
  94805. /**
  94806. * Creates a new StateCondition
  94807. * @param actionManager manager for the action the condition applies to
  94808. * @param target of the condition
  94809. * @param value to compare with target state
  94810. */
  94811. constructor(actionManager: ActionManager, target: any,
  94812. /** Value to compare with target state */
  94813. value: string);
  94814. /**
  94815. * Gets a boolean indicating if the current condition is met
  94816. * @returns the validity of the state
  94817. */
  94818. isValid(): boolean;
  94819. /**
  94820. * Serialize the StateCondition into a JSON compatible object
  94821. * @returns serialization object
  94822. */
  94823. serialize(): any;
  94824. }
  94825. }
  94826. declare module BABYLON {
  94827. /**
  94828. * This defines an action responsible to toggle a boolean once triggered.
  94829. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  94830. */
  94831. export class SwitchBooleanAction extends Action {
  94832. /**
  94833. * The path to the boolean property in the target object
  94834. */
  94835. propertyPath: string;
  94836. private _target;
  94837. private _effectiveTarget;
  94838. private _property;
  94839. /**
  94840. * Instantiate the action
  94841. * @param triggerOptions defines the trigger options
  94842. * @param target defines the object containing the boolean
  94843. * @param propertyPath defines the path to the boolean property in the target object
  94844. * @param condition defines the trigger related conditions
  94845. */
  94846. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  94847. /** @hidden */
  94848. _prepare(): void;
  94849. /**
  94850. * Execute the action toggle the boolean value.
  94851. */
  94852. execute(): void;
  94853. /**
  94854. * Serializes the actions and its related information.
  94855. * @param parent defines the object to serialize in
  94856. * @returns the serialized object
  94857. */
  94858. serialize(parent: any): any;
  94859. }
  94860. /**
  94861. * This defines an action responsible to set a the state field of the target
  94862. * to a desired value once triggered.
  94863. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  94864. */
  94865. export class SetStateAction extends Action {
  94866. /**
  94867. * The value to store in the state field.
  94868. */
  94869. value: string;
  94870. private _target;
  94871. /**
  94872. * Instantiate the action
  94873. * @param triggerOptions defines the trigger options
  94874. * @param target defines the object containing the state property
  94875. * @param value defines the value to store in the state field
  94876. * @param condition defines the trigger related conditions
  94877. */
  94878. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  94879. /**
  94880. * Execute the action and store the value on the target state property.
  94881. */
  94882. execute(): void;
  94883. /**
  94884. * Serializes the actions and its related information.
  94885. * @param parent defines the object to serialize in
  94886. * @returns the serialized object
  94887. */
  94888. serialize(parent: any): any;
  94889. }
  94890. /**
  94891. * This defines an action responsible to set a property of the target
  94892. * to a desired value once triggered.
  94893. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  94894. */
  94895. export class SetValueAction extends Action {
  94896. /**
  94897. * The path of the property to set in the target.
  94898. */
  94899. propertyPath: string;
  94900. /**
  94901. * The value to set in the property
  94902. */
  94903. value: any;
  94904. private _target;
  94905. private _effectiveTarget;
  94906. private _property;
  94907. /**
  94908. * Instantiate the action
  94909. * @param triggerOptions defines the trigger options
  94910. * @param target defines the object containing the property
  94911. * @param propertyPath defines the path of the property to set in the target
  94912. * @param value defines the value to set in the property
  94913. * @param condition defines the trigger related conditions
  94914. */
  94915. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  94916. /** @hidden */
  94917. _prepare(): void;
  94918. /**
  94919. * Execute the action and set the targetted property to the desired value.
  94920. */
  94921. execute(): void;
  94922. /**
  94923. * Serializes the actions and its related information.
  94924. * @param parent defines the object to serialize in
  94925. * @returns the serialized object
  94926. */
  94927. serialize(parent: any): any;
  94928. }
  94929. /**
  94930. * This defines an action responsible to increment the target value
  94931. * to a desired value once triggered.
  94932. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  94933. */
  94934. export class IncrementValueAction extends Action {
  94935. /**
  94936. * The path of the property to increment in the target.
  94937. */
  94938. propertyPath: string;
  94939. /**
  94940. * The value we should increment the property by.
  94941. */
  94942. value: any;
  94943. private _target;
  94944. private _effectiveTarget;
  94945. private _property;
  94946. /**
  94947. * Instantiate the action
  94948. * @param triggerOptions defines the trigger options
  94949. * @param target defines the object containing the property
  94950. * @param propertyPath defines the path of the property to increment in the target
  94951. * @param value defines the value value we should increment the property by
  94952. * @param condition defines the trigger related conditions
  94953. */
  94954. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  94955. /** @hidden */
  94956. _prepare(): void;
  94957. /**
  94958. * Execute the action and increment the target of the value amount.
  94959. */
  94960. execute(): void;
  94961. /**
  94962. * Serializes the actions and its related information.
  94963. * @param parent defines the object to serialize in
  94964. * @returns the serialized object
  94965. */
  94966. serialize(parent: any): any;
  94967. }
  94968. /**
  94969. * This defines an action responsible to start an animation once triggered.
  94970. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  94971. */
  94972. export class PlayAnimationAction extends Action {
  94973. /**
  94974. * Where the animation should start (animation frame)
  94975. */
  94976. from: number;
  94977. /**
  94978. * Where the animation should stop (animation frame)
  94979. */
  94980. to: number;
  94981. /**
  94982. * Define if the animation should loop or stop after the first play.
  94983. */
  94984. loop?: boolean;
  94985. private _target;
  94986. /**
  94987. * Instantiate the action
  94988. * @param triggerOptions defines the trigger options
  94989. * @param target defines the target animation or animation name
  94990. * @param from defines from where the animation should start (animation frame)
  94991. * @param end defines where the animation should stop (animation frame)
  94992. * @param loop defines if the animation should loop or stop after the first play
  94993. * @param condition defines the trigger related conditions
  94994. */
  94995. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  94996. /** @hidden */
  94997. _prepare(): void;
  94998. /**
  94999. * Execute the action and play the animation.
  95000. */
  95001. execute(): void;
  95002. /**
  95003. * Serializes the actions and its related information.
  95004. * @param parent defines the object to serialize in
  95005. * @returns the serialized object
  95006. */
  95007. serialize(parent: any): any;
  95008. }
  95009. /**
  95010. * This defines an action responsible to stop an animation once triggered.
  95011. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  95012. */
  95013. export class StopAnimationAction extends Action {
  95014. private _target;
  95015. /**
  95016. * Instantiate the action
  95017. * @param triggerOptions defines the trigger options
  95018. * @param target defines the target animation or animation name
  95019. * @param condition defines the trigger related conditions
  95020. */
  95021. constructor(triggerOptions: any, target: any, condition?: Condition);
  95022. /** @hidden */
  95023. _prepare(): void;
  95024. /**
  95025. * Execute the action and stop the animation.
  95026. */
  95027. execute(): void;
  95028. /**
  95029. * Serializes the actions and its related information.
  95030. * @param parent defines the object to serialize in
  95031. * @returns the serialized object
  95032. */
  95033. serialize(parent: any): any;
  95034. }
  95035. /**
  95036. * This defines an action responsible that does nothing once triggered.
  95037. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  95038. */
  95039. export class DoNothingAction extends Action {
  95040. /**
  95041. * Instantiate the action
  95042. * @param triggerOptions defines the trigger options
  95043. * @param condition defines the trigger related conditions
  95044. */
  95045. constructor(triggerOptions?: any, condition?: Condition);
  95046. /**
  95047. * Execute the action and do nothing.
  95048. */
  95049. execute(): void;
  95050. /**
  95051. * Serializes the actions and its related information.
  95052. * @param parent defines the object to serialize in
  95053. * @returns the serialized object
  95054. */
  95055. serialize(parent: any): any;
  95056. }
  95057. /**
  95058. * This defines an action responsible to trigger several actions once triggered.
  95059. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  95060. */
  95061. export class CombineAction extends Action {
  95062. /**
  95063. * The list of aggregated animations to run.
  95064. */
  95065. children: Action[];
  95066. /**
  95067. * Instantiate the action
  95068. * @param triggerOptions defines the trigger options
  95069. * @param children defines the list of aggregated animations to run
  95070. * @param condition defines the trigger related conditions
  95071. */
  95072. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  95073. /** @hidden */
  95074. _prepare(): void;
  95075. /**
  95076. * Execute the action and executes all the aggregated actions.
  95077. */
  95078. execute(evt: ActionEvent): void;
  95079. /**
  95080. * Serializes the actions and its related information.
  95081. * @param parent defines the object to serialize in
  95082. * @returns the serialized object
  95083. */
  95084. serialize(parent: any): any;
  95085. }
  95086. /**
  95087. * This defines an action responsible to run code (external event) once triggered.
  95088. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  95089. */
  95090. export class ExecuteCodeAction extends Action {
  95091. /**
  95092. * The callback function to run.
  95093. */
  95094. func: (evt: ActionEvent) => void;
  95095. /**
  95096. * Instantiate the action
  95097. * @param triggerOptions defines the trigger options
  95098. * @param func defines the callback function to run
  95099. * @param condition defines the trigger related conditions
  95100. */
  95101. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  95102. /**
  95103. * Execute the action and run the attached code.
  95104. */
  95105. execute(evt: ActionEvent): void;
  95106. }
  95107. /**
  95108. * This defines an action responsible to set the parent property of the target once triggered.
  95109. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  95110. */
  95111. export class SetParentAction extends Action {
  95112. private _parent;
  95113. private _target;
  95114. /**
  95115. * Instantiate the action
  95116. * @param triggerOptions defines the trigger options
  95117. * @param target defines the target containing the parent property
  95118. * @param parent defines from where the animation should start (animation frame)
  95119. * @param condition defines the trigger related conditions
  95120. */
  95121. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  95122. /** @hidden */
  95123. _prepare(): void;
  95124. /**
  95125. * Execute the action and set the parent property.
  95126. */
  95127. execute(): void;
  95128. /**
  95129. * Serializes the actions and its related information.
  95130. * @param parent defines the object to serialize in
  95131. * @returns the serialized object
  95132. */
  95133. serialize(parent: any): any;
  95134. }
  95135. }
  95136. declare module BABYLON {
  95137. /**
  95138. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  95139. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  95140. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  95141. */
  95142. export class ActionManager extends AbstractActionManager {
  95143. /**
  95144. * Nothing
  95145. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95146. */
  95147. static readonly NothingTrigger: number;
  95148. /**
  95149. * On pick
  95150. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95151. */
  95152. static readonly OnPickTrigger: number;
  95153. /**
  95154. * On left pick
  95155. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95156. */
  95157. static readonly OnLeftPickTrigger: number;
  95158. /**
  95159. * On right pick
  95160. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95161. */
  95162. static readonly OnRightPickTrigger: number;
  95163. /**
  95164. * On center pick
  95165. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95166. */
  95167. static readonly OnCenterPickTrigger: number;
  95168. /**
  95169. * On pick down
  95170. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95171. */
  95172. static readonly OnPickDownTrigger: number;
  95173. /**
  95174. * On double pick
  95175. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95176. */
  95177. static readonly OnDoublePickTrigger: number;
  95178. /**
  95179. * On pick up
  95180. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95181. */
  95182. static readonly OnPickUpTrigger: number;
  95183. /**
  95184. * On pick out.
  95185. * This trigger will only be raised if you also declared a OnPickDown
  95186. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95187. */
  95188. static readonly OnPickOutTrigger: number;
  95189. /**
  95190. * On long press
  95191. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95192. */
  95193. static readonly OnLongPressTrigger: number;
  95194. /**
  95195. * On pointer over
  95196. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95197. */
  95198. static readonly OnPointerOverTrigger: number;
  95199. /**
  95200. * On pointer out
  95201. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95202. */
  95203. static readonly OnPointerOutTrigger: number;
  95204. /**
  95205. * On every frame
  95206. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95207. */
  95208. static readonly OnEveryFrameTrigger: number;
  95209. /**
  95210. * On intersection enter
  95211. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95212. */
  95213. static readonly OnIntersectionEnterTrigger: number;
  95214. /**
  95215. * On intersection exit
  95216. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95217. */
  95218. static readonly OnIntersectionExitTrigger: number;
  95219. /**
  95220. * On key down
  95221. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95222. */
  95223. static readonly OnKeyDownTrigger: number;
  95224. /**
  95225. * On key up
  95226. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  95227. */
  95228. static readonly OnKeyUpTrigger: number;
  95229. private _scene;
  95230. /**
  95231. * Creates a new action manager
  95232. * @param scene defines the hosting scene
  95233. */
  95234. constructor(scene: Scene);
  95235. /**
  95236. * Releases all associated resources
  95237. */
  95238. dispose(): void;
  95239. /**
  95240. * Gets hosting scene
  95241. * @returns the hosting scene
  95242. */
  95243. getScene(): Scene;
  95244. /**
  95245. * Does this action manager handles actions of any of the given triggers
  95246. * @param triggers defines the triggers to be tested
  95247. * @return a boolean indicating whether one (or more) of the triggers is handled
  95248. */
  95249. hasSpecificTriggers(triggers: number[]): boolean;
  95250. /**
  95251. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  95252. * speed.
  95253. * @param triggerA defines the trigger to be tested
  95254. * @param triggerB defines the trigger to be tested
  95255. * @return a boolean indicating whether one (or more) of the triggers is handled
  95256. */
  95257. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  95258. /**
  95259. * Does this action manager handles actions of a given trigger
  95260. * @param trigger defines the trigger to be tested
  95261. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  95262. * @return whether the trigger is handled
  95263. */
  95264. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  95265. /**
  95266. * Does this action manager has pointer triggers
  95267. */
  95268. get hasPointerTriggers(): boolean;
  95269. /**
  95270. * Does this action manager has pick triggers
  95271. */
  95272. get hasPickTriggers(): boolean;
  95273. /**
  95274. * Registers an action to this action manager
  95275. * @param action defines the action to be registered
  95276. * @return the action amended (prepared) after registration
  95277. */
  95278. registerAction(action: IAction): Nullable<IAction>;
  95279. /**
  95280. * Unregisters an action to this action manager
  95281. * @param action defines the action to be unregistered
  95282. * @return a boolean indicating whether the action has been unregistered
  95283. */
  95284. unregisterAction(action: IAction): Boolean;
  95285. /**
  95286. * Process a specific trigger
  95287. * @param trigger defines the trigger to process
  95288. * @param evt defines the event details to be processed
  95289. */
  95290. processTrigger(trigger: number, evt?: IActionEvent): void;
  95291. /** @hidden */
  95292. _getEffectiveTarget(target: any, propertyPath: string): any;
  95293. /** @hidden */
  95294. _getProperty(propertyPath: string): string;
  95295. /**
  95296. * Serialize this manager to a JSON object
  95297. * @param name defines the property name to store this manager
  95298. * @returns a JSON representation of this manager
  95299. */
  95300. serialize(name: string): any;
  95301. /**
  95302. * Creates a new ActionManager from a JSON data
  95303. * @param parsedActions defines the JSON data to read from
  95304. * @param object defines the hosting mesh
  95305. * @param scene defines the hosting scene
  95306. */
  95307. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  95308. /**
  95309. * Get a trigger name by index
  95310. * @param trigger defines the trigger index
  95311. * @returns a trigger name
  95312. */
  95313. static GetTriggerName(trigger: number): string;
  95314. }
  95315. }
  95316. declare module BABYLON {
  95317. /**
  95318. * Class representing a ray with position and direction
  95319. */
  95320. export class Ray {
  95321. /** origin point */
  95322. origin: Vector3;
  95323. /** direction */
  95324. direction: Vector3;
  95325. /** length of the ray */
  95326. length: number;
  95327. private static readonly _TmpVector3;
  95328. private _tmpRay;
  95329. /**
  95330. * Creates a new ray
  95331. * @param origin origin point
  95332. * @param direction direction
  95333. * @param length length of the ray
  95334. */
  95335. constructor(
  95336. /** origin point */
  95337. origin: Vector3,
  95338. /** direction */
  95339. direction: Vector3,
  95340. /** length of the ray */
  95341. length?: number);
  95342. /**
  95343. * Checks if the ray intersects a box
  95344. * This does not account for the ray lenght by design to improve perfs.
  95345. * @param minimum bound of the box
  95346. * @param maximum bound of the box
  95347. * @param intersectionTreshold extra extend to be added to the box in all direction
  95348. * @returns if the box was hit
  95349. */
  95350. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  95351. /**
  95352. * Checks if the ray intersects a box
  95353. * This does not account for the ray lenght by design to improve perfs.
  95354. * @param box the bounding box to check
  95355. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  95356. * @returns if the box was hit
  95357. */
  95358. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  95359. /**
  95360. * If the ray hits a sphere
  95361. * @param sphere the bounding sphere to check
  95362. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  95363. * @returns true if it hits the sphere
  95364. */
  95365. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  95366. /**
  95367. * If the ray hits a triange
  95368. * @param vertex0 triangle vertex
  95369. * @param vertex1 triangle vertex
  95370. * @param vertex2 triangle vertex
  95371. * @returns intersection information if hit
  95372. */
  95373. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  95374. /**
  95375. * Checks if ray intersects a plane
  95376. * @param plane the plane to check
  95377. * @returns the distance away it was hit
  95378. */
  95379. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  95380. /**
  95381. * Calculate the intercept of a ray on a given axis
  95382. * @param axis to check 'x' | 'y' | 'z'
  95383. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  95384. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  95385. */
  95386. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  95387. /**
  95388. * Checks if ray intersects a mesh
  95389. * @param mesh the mesh to check
  95390. * @param fastCheck defines if the first intersection will be used (and not the closest)
  95391. * @returns picking info of the intersecton
  95392. */
  95393. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  95394. /**
  95395. * Checks if ray intersects a mesh
  95396. * @param meshes the meshes to check
  95397. * @param fastCheck defines if the first intersection will be used (and not the closest)
  95398. * @param results array to store result in
  95399. * @returns Array of picking infos
  95400. */
  95401. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  95402. private _comparePickingInfo;
  95403. private static smallnum;
  95404. private static rayl;
  95405. /**
  95406. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  95407. * @param sega the first point of the segment to test the intersection against
  95408. * @param segb the second point of the segment to test the intersection against
  95409. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  95410. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  95411. */
  95412. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  95413. /**
  95414. * Update the ray from viewport position
  95415. * @param x position
  95416. * @param y y position
  95417. * @param viewportWidth viewport width
  95418. * @param viewportHeight viewport height
  95419. * @param world world matrix
  95420. * @param view view matrix
  95421. * @param projection projection matrix
  95422. * @returns this ray updated
  95423. */
  95424. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  95425. /**
  95426. * Creates a ray with origin and direction of 0,0,0
  95427. * @returns the new ray
  95428. */
  95429. static Zero(): Ray;
  95430. /**
  95431. * Creates a new ray from screen space and viewport
  95432. * @param x position
  95433. * @param y y position
  95434. * @param viewportWidth viewport width
  95435. * @param viewportHeight viewport height
  95436. * @param world world matrix
  95437. * @param view view matrix
  95438. * @param projection projection matrix
  95439. * @returns new ray
  95440. */
  95441. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  95442. /**
  95443. * 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
  95444. * transformed to the given world matrix.
  95445. * @param origin The origin point
  95446. * @param end The end point
  95447. * @param world a matrix to transform the ray to. Default is the identity matrix.
  95448. * @returns the new ray
  95449. */
  95450. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  95451. /**
  95452. * Transforms a ray by a matrix
  95453. * @param ray ray to transform
  95454. * @param matrix matrix to apply
  95455. * @returns the resulting new ray
  95456. */
  95457. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  95458. /**
  95459. * Transforms a ray by a matrix
  95460. * @param ray ray to transform
  95461. * @param matrix matrix to apply
  95462. * @param result ray to store result in
  95463. */
  95464. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  95465. /**
  95466. * Unproject a ray from screen space to object space
  95467. * @param sourceX defines the screen space x coordinate to use
  95468. * @param sourceY defines the screen space y coordinate to use
  95469. * @param viewportWidth defines the current width of the viewport
  95470. * @param viewportHeight defines the current height of the viewport
  95471. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  95472. * @param view defines the view matrix to use
  95473. * @param projection defines the projection matrix to use
  95474. */
  95475. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  95476. }
  95477. /**
  95478. * Type used to define predicate used to select faces when a mesh intersection is detected
  95479. */
  95480. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  95481. interface Scene {
  95482. /** @hidden */
  95483. _tempPickingRay: Nullable<Ray>;
  95484. /** @hidden */
  95485. _cachedRayForTransform: Ray;
  95486. /** @hidden */
  95487. _pickWithRayInverseMatrix: Matrix;
  95488. /** @hidden */
  95489. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  95490. /** @hidden */
  95491. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  95492. /** @hidden */
  95493. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  95494. }
  95495. }
  95496. declare module BABYLON {
  95497. /**
  95498. * Groups all the scene component constants in one place to ease maintenance.
  95499. * @hidden
  95500. */
  95501. export class SceneComponentConstants {
  95502. static readonly NAME_EFFECTLAYER: string;
  95503. static readonly NAME_LAYER: string;
  95504. static readonly NAME_LENSFLARESYSTEM: string;
  95505. static readonly NAME_BOUNDINGBOXRENDERER: string;
  95506. static readonly NAME_PARTICLESYSTEM: string;
  95507. static readonly NAME_GAMEPAD: string;
  95508. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  95509. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  95510. static readonly NAME_PREPASSRENDERER: string;
  95511. static readonly NAME_DEPTHRENDERER: string;
  95512. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  95513. static readonly NAME_SPRITE: string;
  95514. static readonly NAME_SUBSURFACE: string;
  95515. static readonly NAME_OUTLINERENDERER: string;
  95516. static readonly NAME_PROCEDURALTEXTURE: string;
  95517. static readonly NAME_SHADOWGENERATOR: string;
  95518. static readonly NAME_OCTREE: string;
  95519. static readonly NAME_PHYSICSENGINE: string;
  95520. static readonly NAME_AUDIO: string;
  95521. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  95522. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  95523. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  95524. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  95525. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  95526. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  95527. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  95528. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  95529. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  95530. static readonly STEP_BEFORERENDERINGMESH_PREPASS: number;
  95531. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  95532. static readonly STEP_AFTERRENDERINGMESH_PREPASS: number;
  95533. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  95534. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  95535. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  95536. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  95537. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  95538. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  95539. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  95540. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  95541. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  95542. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  95543. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  95544. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  95545. static readonly STEP_AFTERRENDER_AUDIO: number;
  95546. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  95547. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  95548. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  95549. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  95550. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  95551. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  95552. static readonly STEP_POINTERMOVE_SPRITE: number;
  95553. static readonly STEP_POINTERDOWN_SPRITE: number;
  95554. static readonly STEP_POINTERUP_SPRITE: number;
  95555. }
  95556. /**
  95557. * This represents a scene component.
  95558. *
  95559. * This is used to decouple the dependency the scene is having on the different workloads like
  95560. * layers, post processes...
  95561. */
  95562. export interface ISceneComponent {
  95563. /**
  95564. * The name of the component. Each component must have a unique name.
  95565. */
  95566. name: string;
  95567. /**
  95568. * The scene the component belongs to.
  95569. */
  95570. scene: Scene;
  95571. /**
  95572. * Register the component to one instance of a scene.
  95573. */
  95574. register(): void;
  95575. /**
  95576. * Rebuilds the elements related to this component in case of
  95577. * context lost for instance.
  95578. */
  95579. rebuild(): void;
  95580. /**
  95581. * Disposes the component and the associated ressources.
  95582. */
  95583. dispose(): void;
  95584. }
  95585. /**
  95586. * This represents a SERIALIZABLE scene component.
  95587. *
  95588. * This extends Scene Component to add Serialization methods on top.
  95589. */
  95590. export interface ISceneSerializableComponent extends ISceneComponent {
  95591. /**
  95592. * Adds all the elements from the container to the scene
  95593. * @param container the container holding the elements
  95594. */
  95595. addFromContainer(container: AbstractScene): void;
  95596. /**
  95597. * Removes all the elements in the container from the scene
  95598. * @param container contains the elements to remove
  95599. * @param dispose if the removed element should be disposed (default: false)
  95600. */
  95601. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  95602. /**
  95603. * Serializes the component data to the specified json object
  95604. * @param serializationObject The object to serialize to
  95605. */
  95606. serialize(serializationObject: any): void;
  95607. }
  95608. /**
  95609. * Strong typing of a Mesh related stage step action
  95610. */
  95611. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  95612. /**
  95613. * Strong typing of a Evaluate Sub Mesh related stage step action
  95614. */
  95615. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  95616. /**
  95617. * Strong typing of a pre active Mesh related stage step action
  95618. */
  95619. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  95620. /**
  95621. * Strong typing of a Camera related stage step action
  95622. */
  95623. export type CameraStageAction = (camera: Camera) => void;
  95624. /**
  95625. * Strong typing of a Camera Frame buffer related stage step action
  95626. */
  95627. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  95628. /**
  95629. * Strong typing of a Render Target related stage step action
  95630. */
  95631. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  95632. /**
  95633. * Strong typing of a RenderingGroup related stage step action
  95634. */
  95635. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  95636. /**
  95637. * Strong typing of a Mesh Render related stage step action
  95638. */
  95639. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch, effect: Nullable<Effect>) => void;
  95640. /**
  95641. * Strong typing of a simple stage step action
  95642. */
  95643. export type SimpleStageAction = () => void;
  95644. /**
  95645. * Strong typing of a render target action.
  95646. */
  95647. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  95648. /**
  95649. * Strong typing of a pointer move action.
  95650. */
  95651. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  95652. /**
  95653. * Strong typing of a pointer up/down action.
  95654. */
  95655. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  95656. /**
  95657. * Representation of a stage in the scene (Basically a list of ordered steps)
  95658. * @hidden
  95659. */
  95660. export class Stage<T extends Function> extends Array<{
  95661. index: number;
  95662. component: ISceneComponent;
  95663. action: T;
  95664. }> {
  95665. /**
  95666. * Hide ctor from the rest of the world.
  95667. * @param items The items to add.
  95668. */
  95669. private constructor();
  95670. /**
  95671. * Creates a new Stage.
  95672. * @returns A new instance of a Stage
  95673. */
  95674. static Create<T extends Function>(): Stage<T>;
  95675. /**
  95676. * Registers a step in an ordered way in the targeted stage.
  95677. * @param index Defines the position to register the step in
  95678. * @param component Defines the component attached to the step
  95679. * @param action Defines the action to launch during the step
  95680. */
  95681. registerStep(index: number, component: ISceneComponent, action: T): void;
  95682. /**
  95683. * Clears all the steps from the stage.
  95684. */
  95685. clear(): void;
  95686. }
  95687. }
  95688. declare module BABYLON {
  95689. interface Scene {
  95690. /** @hidden */
  95691. _pointerOverSprite: Nullable<Sprite>;
  95692. /** @hidden */
  95693. _pickedDownSprite: Nullable<Sprite>;
  95694. /** @hidden */
  95695. _tempSpritePickingRay: Nullable<Ray>;
  95696. /**
  95697. * All of the sprite managers added to this scene
  95698. * @see https://doc.babylonjs.com/babylon101/sprites
  95699. */
  95700. spriteManagers: Array<ISpriteManager>;
  95701. /**
  95702. * An event triggered when sprites rendering is about to start
  95703. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  95704. */
  95705. onBeforeSpritesRenderingObservable: Observable<Scene>;
  95706. /**
  95707. * An event triggered when sprites rendering is done
  95708. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  95709. */
  95710. onAfterSpritesRenderingObservable: Observable<Scene>;
  95711. /** @hidden */
  95712. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  95713. /** Launch a ray to try to pick a sprite in the scene
  95714. * @param x position on screen
  95715. * @param y position on screen
  95716. * @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
  95717. * @param fastCheck defines if the first intersection will be used (and not the closest)
  95718. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  95719. * @returns a PickingInfo
  95720. */
  95721. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  95722. /** Use the given ray to pick a sprite in the scene
  95723. * @param ray The ray (in world space) to use to pick meshes
  95724. * @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
  95725. * @param fastCheck defines if the first intersection will be used (and not the closest)
  95726. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  95727. * @returns a PickingInfo
  95728. */
  95729. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  95730. /** @hidden */
  95731. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  95732. /** Launch a ray to try to pick sprites in the scene
  95733. * @param x position on screen
  95734. * @param y position on screen
  95735. * @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
  95736. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  95737. * @returns a PickingInfo array
  95738. */
  95739. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  95740. /** Use the given ray to pick sprites in the scene
  95741. * @param ray The ray (in world space) to use to pick meshes
  95742. * @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
  95743. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  95744. * @returns a PickingInfo array
  95745. */
  95746. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  95747. /**
  95748. * Force the sprite under the pointer
  95749. * @param sprite defines the sprite to use
  95750. */
  95751. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  95752. /**
  95753. * Gets the sprite under the pointer
  95754. * @returns a Sprite or null if no sprite is under the pointer
  95755. */
  95756. getPointerOverSprite(): Nullable<Sprite>;
  95757. }
  95758. /**
  95759. * Defines the sprite scene component responsible to manage sprites
  95760. * in a given scene.
  95761. */
  95762. export class SpriteSceneComponent implements ISceneComponent {
  95763. /**
  95764. * The component name helpfull to identify the component in the list of scene components.
  95765. */
  95766. readonly name: string;
  95767. /**
  95768. * The scene the component belongs to.
  95769. */
  95770. scene: Scene;
  95771. /** @hidden */
  95772. private _spritePredicate;
  95773. /**
  95774. * Creates a new instance of the component for the given scene
  95775. * @param scene Defines the scene to register the component in
  95776. */
  95777. constructor(scene: Scene);
  95778. /**
  95779. * Registers the component in a given scene
  95780. */
  95781. register(): void;
  95782. /**
  95783. * Rebuilds the elements related to this component in case of
  95784. * context lost for instance.
  95785. */
  95786. rebuild(): void;
  95787. /**
  95788. * Disposes the component and the associated ressources.
  95789. */
  95790. dispose(): void;
  95791. private _pickSpriteButKeepRay;
  95792. private _pointerMove;
  95793. private _pointerDown;
  95794. private _pointerUp;
  95795. }
  95796. }
  95797. declare module BABYLON {
  95798. /**
  95799. * Class used to provide helper for timing
  95800. */
  95801. export class TimingTools {
  95802. /**
  95803. * Polyfill for setImmediate
  95804. * @param action defines the action to execute after the current execution block
  95805. */
  95806. static SetImmediate(action: () => void): void;
  95807. }
  95808. }
  95809. declare module BABYLON {
  95810. /**
  95811. * Class used to enable instatition of objects by class name
  95812. */
  95813. export class InstantiationTools {
  95814. /**
  95815. * Use this object to register external classes like custom textures or material
  95816. * to allow the laoders to instantiate them
  95817. */
  95818. static RegisteredExternalClasses: {
  95819. [key: string]: Object;
  95820. };
  95821. /**
  95822. * Tries to instantiate a new object from a given class name
  95823. * @param className defines the class name to instantiate
  95824. * @returns the new object or null if the system was not able to do the instantiation
  95825. */
  95826. static Instantiate(className: string): any;
  95827. }
  95828. }
  95829. declare module BABYLON {
  95830. /**
  95831. * Class used to host copy specific utilities
  95832. */
  95833. export class CopyTools {
  95834. /**
  95835. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  95836. * @param texture defines the texture to read pixels from
  95837. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  95838. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  95839. * @returns The base64 encoded string or null
  95840. */
  95841. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Promise<Nullable<string>>;
  95842. }
  95843. }
  95844. declare module BABYLON {
  95845. /**
  95846. * Define options used to create a depth texture
  95847. */
  95848. export class DepthTextureCreationOptions {
  95849. /** Specifies whether or not a stencil should be allocated in the texture */
  95850. generateStencil?: boolean;
  95851. /** Specifies whether or not bilinear filtering is enable on the texture */
  95852. bilinearFiltering?: boolean;
  95853. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  95854. comparisonFunction?: number;
  95855. /** Specifies if the created texture is a cube texture */
  95856. isCube?: boolean;
  95857. /** Specifies the sample count of the depth/stencil texture texture */
  95858. samples?: number;
  95859. }
  95860. }
  95861. declare module BABYLON {
  95862. interface ThinEngine {
  95863. /**
  95864. * Creates a depth stencil cube texture.
  95865. * This is only available in WebGL 2.
  95866. * @param size The size of face edge in the cube texture.
  95867. * @param options The options defining the cube texture.
  95868. * @returns The cube texture
  95869. */
  95870. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  95871. /**
  95872. * Creates a cube texture
  95873. * @param rootUrl defines the url where the files to load is located
  95874. * @param scene defines the current scene
  95875. * @param files defines the list of files to load (1 per face)
  95876. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  95877. * @param onLoad defines an optional callback raised when the texture is loaded
  95878. * @param onError defines an optional callback raised if there is an issue to load the texture
  95879. * @param format defines the format of the data
  95880. * @param forcedExtension defines the extension to use to pick the right loader
  95881. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  95882. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  95883. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  95884. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  95885. * @param loaderOptions options to be passed to the loader
  95886. * @returns the cube texture as an InternalTexture
  95887. */
  95888. 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;
  95889. /**
  95890. * Creates a cube texture
  95891. * @param rootUrl defines the url where the files to load is located
  95892. * @param scene defines the current scene
  95893. * @param files defines the list of files to load (1 per face)
  95894. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  95895. * @param onLoad defines an optional callback raised when the texture is loaded
  95896. * @param onError defines an optional callback raised if there is an issue to load the texture
  95897. * @param format defines the format of the data
  95898. * @param forcedExtension defines the extension to use to pick the right loader
  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): InternalTexture;
  95902. /**
  95903. * Creates a cube texture
  95904. * @param rootUrl defines the url where the files to load is located
  95905. * @param scene defines the current scene
  95906. * @param files defines the list of files to load (1 per face)
  95907. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  95908. * @param onLoad defines an optional callback raised when the texture is loaded
  95909. * @param onError defines an optional callback raised if there is an issue to load the texture
  95910. * @param format defines the format of the data
  95911. * @param forcedExtension defines the extension to use to pick the right loader
  95912. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  95913. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  95914. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  95915. * @returns the cube texture as an InternalTexture
  95916. */
  95917. 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;
  95918. /** @hidden */
  95919. 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;
  95920. /** @hidden */
  95921. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  95922. /** @hidden */
  95923. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  95924. /** @hidden */
  95925. _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;
  95926. /** @hidden */
  95927. _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;
  95928. /**
  95929. * @hidden
  95930. */
  95931. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  95932. }
  95933. }
  95934. declare module BABYLON {
  95935. /**
  95936. * Class for creating a cube texture
  95937. */
  95938. export class CubeTexture extends BaseTexture {
  95939. private _delayedOnLoad;
  95940. /**
  95941. * Observable triggered once the texture has been loaded.
  95942. */
  95943. onLoadObservable: Observable<CubeTexture>;
  95944. /**
  95945. * The url of the texture
  95946. */
  95947. url: string;
  95948. /**
  95949. * Gets or sets the center of the bounding box associated with the cube texture.
  95950. * It must define where the camera used to render the texture was set
  95951. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  95952. */
  95953. boundingBoxPosition: Vector3;
  95954. private _boundingBoxSize;
  95955. /**
  95956. * Gets or sets the size of the bounding box associated with the cube texture
  95957. * When defined, the cubemap will switch to local mode
  95958. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  95959. * @example https://www.babylonjs-playground.com/#RNASML
  95960. */
  95961. set boundingBoxSize(value: Vector3);
  95962. /**
  95963. * Returns the bounding box size
  95964. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  95965. */
  95966. get boundingBoxSize(): Vector3;
  95967. protected _rotationY: number;
  95968. /**
  95969. * Sets texture matrix rotation angle around Y axis in radians.
  95970. */
  95971. set rotationY(value: number);
  95972. /**
  95973. * Gets texture matrix rotation angle around Y axis radians.
  95974. */
  95975. get rotationY(): number;
  95976. /**
  95977. * Are mip maps generated for this texture or not.
  95978. */
  95979. get noMipmap(): boolean;
  95980. private _noMipmap;
  95981. private _files;
  95982. protected _forcedExtension: Nullable<string>;
  95983. private _extensions;
  95984. private _textureMatrix;
  95985. private _format;
  95986. private _createPolynomials;
  95987. private _loaderOptions;
  95988. /**
  95989. * Creates a cube texture from an array of image urls
  95990. * @param files defines an array of image urls
  95991. * @param scene defines the hosting scene
  95992. * @param noMipmap specifies if mip maps are not used
  95993. * @returns a cube texture
  95994. */
  95995. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  95996. /**
  95997. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  95998. * @param url defines the url of the prefiltered texture
  95999. * @param scene defines the scene the texture is attached to
  96000. * @param forcedExtension defines the extension of the file if different from the url
  96001. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  96002. * @return the prefiltered texture
  96003. */
  96004. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  96005. /**
  96006. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  96007. * as prefiltered data.
  96008. * @param rootUrl defines the url of the texture or the root name of the six images
  96009. * @param null defines the scene or engine the texture is attached to
  96010. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  96011. * @param noMipmap defines if mipmaps should be created or not
  96012. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  96013. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  96014. * @param onError defines a callback triggered in case of error during load
  96015. * @param format defines the internal format to use for the texture once loaded
  96016. * @param prefiltered defines whether or not the texture is created from prefiltered data
  96017. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  96018. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  96019. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  96020. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  96021. * @param loaderOptions options to be passed to the loader
  96022. * @return the cube texture
  96023. */
  96024. 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);
  96025. /**
  96026. * Get the current class name of the texture useful for serialization or dynamic coding.
  96027. * @returns "CubeTexture"
  96028. */
  96029. getClassName(): string;
  96030. /**
  96031. * Update the url (and optional buffer) of this texture if url was null during construction.
  96032. * @param url the url of the texture
  96033. * @param forcedExtension defines the extension to use
  96034. * @param onLoad callback called when the texture is loaded (defaults to null)
  96035. * @param prefiltered Defines whether the updated texture is prefiltered or not
  96036. */
  96037. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  96038. /**
  96039. * Delays loading of the cube texture
  96040. * @param forcedExtension defines the extension to use
  96041. */
  96042. delayLoad(forcedExtension?: string): void;
  96043. /**
  96044. * Returns the reflection texture matrix
  96045. * @returns the reflection texture matrix
  96046. */
  96047. getReflectionTextureMatrix(): Matrix;
  96048. /**
  96049. * Sets the reflection texture matrix
  96050. * @param value Reflection texture matrix
  96051. */
  96052. setReflectionTextureMatrix(value: Matrix): void;
  96053. /**
  96054. * Parses text to create a cube texture
  96055. * @param parsedTexture define the serialized text to read from
  96056. * @param scene defines the hosting scene
  96057. * @param rootUrl defines the root url of the cube texture
  96058. * @returns a cube texture
  96059. */
  96060. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  96061. /**
  96062. * Makes a clone, or deep copy, of the cube texture
  96063. * @returns a new cube texture
  96064. */
  96065. clone(): CubeTexture;
  96066. }
  96067. }
  96068. declare module BABYLON {
  96069. /**
  96070. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  96071. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  96072. * 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;
  96073. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  96074. */
  96075. export class ColorCurves {
  96076. private _dirty;
  96077. private _tempColor;
  96078. private _globalCurve;
  96079. private _highlightsCurve;
  96080. private _midtonesCurve;
  96081. private _shadowsCurve;
  96082. private _positiveCurve;
  96083. private _negativeCurve;
  96084. private _globalHue;
  96085. private _globalDensity;
  96086. private _globalSaturation;
  96087. private _globalExposure;
  96088. /**
  96089. * Gets the global Hue value.
  96090. * 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).
  96091. */
  96092. get globalHue(): number;
  96093. /**
  96094. * Sets the global Hue value.
  96095. * 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).
  96096. */
  96097. set globalHue(value: number);
  96098. /**
  96099. * Gets the global Density value.
  96100. * 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.
  96101. * Values less than zero provide a filter of opposite hue.
  96102. */
  96103. get globalDensity(): number;
  96104. /**
  96105. * Sets the global Density value.
  96106. * 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.
  96107. * Values less than zero provide a filter of opposite hue.
  96108. */
  96109. set globalDensity(value: number);
  96110. /**
  96111. * Gets the global Saturation value.
  96112. * 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.
  96113. */
  96114. get globalSaturation(): number;
  96115. /**
  96116. * Sets the global Saturation value.
  96117. * 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.
  96118. */
  96119. set globalSaturation(value: number);
  96120. /**
  96121. * Gets the global Exposure value.
  96122. * 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.
  96123. */
  96124. get globalExposure(): number;
  96125. /**
  96126. * Sets the global Exposure value.
  96127. * 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.
  96128. */
  96129. set globalExposure(value: number);
  96130. private _highlightsHue;
  96131. private _highlightsDensity;
  96132. private _highlightsSaturation;
  96133. private _highlightsExposure;
  96134. /**
  96135. * Gets the highlights Hue value.
  96136. * 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).
  96137. */
  96138. get highlightsHue(): number;
  96139. /**
  96140. * Sets the highlights Hue value.
  96141. * 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).
  96142. */
  96143. set highlightsHue(value: number);
  96144. /**
  96145. * Gets the highlights Density value.
  96146. * 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.
  96147. * Values less than zero provide a filter of opposite hue.
  96148. */
  96149. get highlightsDensity(): number;
  96150. /**
  96151. * Sets the highlights Density value.
  96152. * 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.
  96153. * Values less than zero provide a filter of opposite hue.
  96154. */
  96155. set highlightsDensity(value: number);
  96156. /**
  96157. * Gets the highlights Saturation value.
  96158. * 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.
  96159. */
  96160. get highlightsSaturation(): number;
  96161. /**
  96162. * Sets the highlights Saturation value.
  96163. * 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.
  96164. */
  96165. set highlightsSaturation(value: number);
  96166. /**
  96167. * Gets the highlights Exposure value.
  96168. * 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.
  96169. */
  96170. get highlightsExposure(): number;
  96171. /**
  96172. * Sets the highlights Exposure value.
  96173. * 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.
  96174. */
  96175. set highlightsExposure(value: number);
  96176. private _midtonesHue;
  96177. private _midtonesDensity;
  96178. private _midtonesSaturation;
  96179. private _midtonesExposure;
  96180. /**
  96181. * Gets the midtones Hue value.
  96182. * 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).
  96183. */
  96184. get midtonesHue(): number;
  96185. /**
  96186. * Sets the midtones Hue value.
  96187. * 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).
  96188. */
  96189. set midtonesHue(value: number);
  96190. /**
  96191. * Gets the midtones Density value.
  96192. * 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.
  96193. * Values less than zero provide a filter of opposite hue.
  96194. */
  96195. get midtonesDensity(): number;
  96196. /**
  96197. * Sets the midtones Density value.
  96198. * 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.
  96199. * Values less than zero provide a filter of opposite hue.
  96200. */
  96201. set midtonesDensity(value: number);
  96202. /**
  96203. * Gets the midtones Saturation value.
  96204. * 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.
  96205. */
  96206. get midtonesSaturation(): number;
  96207. /**
  96208. * Sets the midtones Saturation value.
  96209. * 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.
  96210. */
  96211. set midtonesSaturation(value: number);
  96212. /**
  96213. * Gets the midtones Exposure value.
  96214. * 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.
  96215. */
  96216. get midtonesExposure(): number;
  96217. /**
  96218. * Sets the midtones Exposure value.
  96219. * 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.
  96220. */
  96221. set midtonesExposure(value: number);
  96222. private _shadowsHue;
  96223. private _shadowsDensity;
  96224. private _shadowsSaturation;
  96225. private _shadowsExposure;
  96226. /**
  96227. * Gets the shadows Hue value.
  96228. * 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).
  96229. */
  96230. get shadowsHue(): number;
  96231. /**
  96232. * Sets the shadows Hue value.
  96233. * 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).
  96234. */
  96235. set shadowsHue(value: number);
  96236. /**
  96237. * Gets the shadows Density value.
  96238. * 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.
  96239. * Values less than zero provide a filter of opposite hue.
  96240. */
  96241. get shadowsDensity(): number;
  96242. /**
  96243. * Sets the shadows Density value.
  96244. * 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.
  96245. * Values less than zero provide a filter of opposite hue.
  96246. */
  96247. set shadowsDensity(value: number);
  96248. /**
  96249. * Gets the shadows Saturation value.
  96250. * 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.
  96251. */
  96252. get shadowsSaturation(): number;
  96253. /**
  96254. * Sets the shadows Saturation value.
  96255. * 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.
  96256. */
  96257. set shadowsSaturation(value: number);
  96258. /**
  96259. * Gets the shadows Exposure value.
  96260. * 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.
  96261. */
  96262. get shadowsExposure(): number;
  96263. /**
  96264. * Sets the shadows Exposure value.
  96265. * 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.
  96266. */
  96267. set shadowsExposure(value: number);
  96268. /**
  96269. * Returns the class name
  96270. * @returns The class name
  96271. */
  96272. getClassName(): string;
  96273. /**
  96274. * Binds the color curves to the shader.
  96275. * @param colorCurves The color curve to bind
  96276. * @param effect The effect to bind to
  96277. * @param positiveUniform The positive uniform shader parameter
  96278. * @param neutralUniform The neutral uniform shader parameter
  96279. * @param negativeUniform The negative uniform shader parameter
  96280. */
  96281. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  96282. /**
  96283. * Prepare the list of uniforms associated with the ColorCurves effects.
  96284. * @param uniformsList The list of uniforms used in the effect
  96285. */
  96286. static PrepareUniforms(uniformsList: string[]): void;
  96287. /**
  96288. * Returns color grading data based on a hue, density, saturation and exposure value.
  96289. * @param filterHue The hue of the color filter.
  96290. * @param filterDensity The density of the color filter.
  96291. * @param saturation The saturation.
  96292. * @param exposure The exposure.
  96293. * @param result The result data container.
  96294. */
  96295. private getColorGradingDataToRef;
  96296. /**
  96297. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  96298. * @param value The input slider value in range [-100,100].
  96299. * @returns Adjusted value.
  96300. */
  96301. private static applyColorGradingSliderNonlinear;
  96302. /**
  96303. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  96304. * @param hue The hue (H) input.
  96305. * @param saturation The saturation (S) input.
  96306. * @param brightness The brightness (B) input.
  96307. * @result An RGBA color represented as Vector4.
  96308. */
  96309. private static fromHSBToRef;
  96310. /**
  96311. * Returns a value clamped between min and max
  96312. * @param value The value to clamp
  96313. * @param min The minimum of value
  96314. * @param max The maximum of value
  96315. * @returns The clamped value.
  96316. */
  96317. private static clamp;
  96318. /**
  96319. * Clones the current color curve instance.
  96320. * @return The cloned curves
  96321. */
  96322. clone(): ColorCurves;
  96323. /**
  96324. * Serializes the current color curve instance to a json representation.
  96325. * @return a JSON representation
  96326. */
  96327. serialize(): any;
  96328. /**
  96329. * Parses the color curve from a json representation.
  96330. * @param source the JSON source to parse
  96331. * @return The parsed curves
  96332. */
  96333. static Parse(source: any): ColorCurves;
  96334. }
  96335. }
  96336. declare module BABYLON {
  96337. /**
  96338. * Interface to follow in your material defines to integrate easily the
  96339. * Image proccessing functions.
  96340. * @hidden
  96341. */
  96342. export interface IImageProcessingConfigurationDefines {
  96343. IMAGEPROCESSING: boolean;
  96344. VIGNETTE: boolean;
  96345. VIGNETTEBLENDMODEMULTIPLY: boolean;
  96346. VIGNETTEBLENDMODEOPAQUE: boolean;
  96347. TONEMAPPING: boolean;
  96348. TONEMAPPING_ACES: boolean;
  96349. CONTRAST: boolean;
  96350. EXPOSURE: boolean;
  96351. COLORCURVES: boolean;
  96352. COLORGRADING: boolean;
  96353. COLORGRADING3D: boolean;
  96354. SAMPLER3DGREENDEPTH: boolean;
  96355. SAMPLER3DBGRMAP: boolean;
  96356. IMAGEPROCESSINGPOSTPROCESS: boolean;
  96357. }
  96358. /**
  96359. * @hidden
  96360. */
  96361. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  96362. IMAGEPROCESSING: boolean;
  96363. VIGNETTE: boolean;
  96364. VIGNETTEBLENDMODEMULTIPLY: boolean;
  96365. VIGNETTEBLENDMODEOPAQUE: boolean;
  96366. TONEMAPPING: boolean;
  96367. TONEMAPPING_ACES: boolean;
  96368. CONTRAST: boolean;
  96369. COLORCURVES: boolean;
  96370. COLORGRADING: boolean;
  96371. COLORGRADING3D: boolean;
  96372. SAMPLER3DGREENDEPTH: boolean;
  96373. SAMPLER3DBGRMAP: boolean;
  96374. IMAGEPROCESSINGPOSTPROCESS: boolean;
  96375. EXPOSURE: boolean;
  96376. constructor();
  96377. }
  96378. /**
  96379. * This groups together the common properties used for image processing either in direct forward pass
  96380. * or through post processing effect depending on the use of the image processing pipeline in your scene
  96381. * or not.
  96382. */
  96383. export class ImageProcessingConfiguration {
  96384. /**
  96385. * Default tone mapping applied in BabylonJS.
  96386. */
  96387. static readonly TONEMAPPING_STANDARD: number;
  96388. /**
  96389. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  96390. * to other engines rendering to increase portability.
  96391. */
  96392. static readonly TONEMAPPING_ACES: number;
  96393. /**
  96394. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  96395. */
  96396. colorCurves: Nullable<ColorCurves>;
  96397. private _colorCurvesEnabled;
  96398. /**
  96399. * Gets wether the color curves effect is enabled.
  96400. */
  96401. get colorCurvesEnabled(): boolean;
  96402. /**
  96403. * Sets wether the color curves effect is enabled.
  96404. */
  96405. set colorCurvesEnabled(value: boolean);
  96406. private _colorGradingTexture;
  96407. /**
  96408. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  96409. */
  96410. get colorGradingTexture(): Nullable<BaseTexture>;
  96411. /**
  96412. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  96413. */
  96414. set colorGradingTexture(value: Nullable<BaseTexture>);
  96415. private _colorGradingEnabled;
  96416. /**
  96417. * Gets wether the color grading effect is enabled.
  96418. */
  96419. get colorGradingEnabled(): boolean;
  96420. /**
  96421. * Sets wether the color grading effect is enabled.
  96422. */
  96423. set colorGradingEnabled(value: boolean);
  96424. private _colorGradingWithGreenDepth;
  96425. /**
  96426. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  96427. */
  96428. get colorGradingWithGreenDepth(): boolean;
  96429. /**
  96430. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  96431. */
  96432. set colorGradingWithGreenDepth(value: boolean);
  96433. private _colorGradingBGR;
  96434. /**
  96435. * Gets wether the color grading texture contains BGR values.
  96436. */
  96437. get colorGradingBGR(): boolean;
  96438. /**
  96439. * Sets wether the color grading texture contains BGR values.
  96440. */
  96441. set colorGradingBGR(value: boolean);
  96442. /** @hidden */
  96443. _exposure: number;
  96444. /**
  96445. * Gets the Exposure used in the effect.
  96446. */
  96447. get exposure(): number;
  96448. /**
  96449. * Sets the Exposure used in the effect.
  96450. */
  96451. set exposure(value: number);
  96452. private _toneMappingEnabled;
  96453. /**
  96454. * Gets wether the tone mapping effect is enabled.
  96455. */
  96456. get toneMappingEnabled(): boolean;
  96457. /**
  96458. * Sets wether the tone mapping effect is enabled.
  96459. */
  96460. set toneMappingEnabled(value: boolean);
  96461. private _toneMappingType;
  96462. /**
  96463. * Gets the type of tone mapping effect.
  96464. */
  96465. get toneMappingType(): number;
  96466. /**
  96467. * Sets the type of tone mapping effect used in BabylonJS.
  96468. */
  96469. set toneMappingType(value: number);
  96470. protected _contrast: number;
  96471. /**
  96472. * Gets the contrast used in the effect.
  96473. */
  96474. get contrast(): number;
  96475. /**
  96476. * Sets the contrast used in the effect.
  96477. */
  96478. set contrast(value: number);
  96479. /**
  96480. * Vignette stretch size.
  96481. */
  96482. vignetteStretch: number;
  96483. /**
  96484. * Vignette centre X Offset.
  96485. */
  96486. vignetteCentreX: number;
  96487. /**
  96488. * Vignette centre Y Offset.
  96489. */
  96490. vignetteCentreY: number;
  96491. /**
  96492. * Vignette weight or intensity of the vignette effect.
  96493. */
  96494. vignetteWeight: number;
  96495. /**
  96496. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  96497. * if vignetteEnabled is set to true.
  96498. */
  96499. vignetteColor: Color4;
  96500. /**
  96501. * Camera field of view used by the Vignette effect.
  96502. */
  96503. vignetteCameraFov: number;
  96504. private _vignetteBlendMode;
  96505. /**
  96506. * Gets the vignette blend mode allowing different kind of effect.
  96507. */
  96508. get vignetteBlendMode(): number;
  96509. /**
  96510. * Sets the vignette blend mode allowing different kind of effect.
  96511. */
  96512. set vignetteBlendMode(value: number);
  96513. private _vignetteEnabled;
  96514. /**
  96515. * Gets wether the vignette effect is enabled.
  96516. */
  96517. get vignetteEnabled(): boolean;
  96518. /**
  96519. * Sets wether the vignette effect is enabled.
  96520. */
  96521. set vignetteEnabled(value: boolean);
  96522. private _applyByPostProcess;
  96523. /**
  96524. * Gets wether the image processing is applied through a post process or not.
  96525. */
  96526. get applyByPostProcess(): boolean;
  96527. /**
  96528. * Sets wether the image processing is applied through a post process or not.
  96529. */
  96530. set applyByPostProcess(value: boolean);
  96531. private _isEnabled;
  96532. /**
  96533. * Gets wether the image processing is enabled or not.
  96534. */
  96535. get isEnabled(): boolean;
  96536. /**
  96537. * Sets wether the image processing is enabled or not.
  96538. */
  96539. set isEnabled(value: boolean);
  96540. /**
  96541. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  96542. */
  96543. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  96544. /**
  96545. * Method called each time the image processing information changes requires to recompile the effect.
  96546. */
  96547. protected _updateParameters(): void;
  96548. /**
  96549. * Gets the current class name.
  96550. * @return "ImageProcessingConfiguration"
  96551. */
  96552. getClassName(): string;
  96553. /**
  96554. * Prepare the list of uniforms associated with the Image Processing effects.
  96555. * @param uniforms The list of uniforms used in the effect
  96556. * @param defines the list of defines currently in use
  96557. */
  96558. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  96559. /**
  96560. * Prepare the list of samplers associated with the Image Processing effects.
  96561. * @param samplersList The list of uniforms used in the effect
  96562. * @param defines the list of defines currently in use
  96563. */
  96564. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  96565. /**
  96566. * Prepare the list of defines associated to the shader.
  96567. * @param defines the list of defines to complete
  96568. * @param forPostProcess Define if we are currently in post process mode or not
  96569. */
  96570. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  96571. /**
  96572. * Returns true if all the image processing information are ready.
  96573. * @returns True if ready, otherwise, false
  96574. */
  96575. isReady(): boolean;
  96576. /**
  96577. * Binds the image processing to the shader.
  96578. * @param effect The effect to bind to
  96579. * @param overrideAspectRatio Override the aspect ratio of the effect
  96580. */
  96581. bind(effect: Effect, overrideAspectRatio?: number): void;
  96582. /**
  96583. * Clones the current image processing instance.
  96584. * @return The cloned image processing
  96585. */
  96586. clone(): ImageProcessingConfiguration;
  96587. /**
  96588. * Serializes the current image processing instance to a json representation.
  96589. * @return a JSON representation
  96590. */
  96591. serialize(): any;
  96592. /**
  96593. * Parses the image processing from a json representation.
  96594. * @param source the JSON source to parse
  96595. * @return The parsed image processing
  96596. */
  96597. static Parse(source: any): ImageProcessingConfiguration;
  96598. private static _VIGNETTEMODE_MULTIPLY;
  96599. private static _VIGNETTEMODE_OPAQUE;
  96600. /**
  96601. * Used to apply the vignette as a mix with the pixel color.
  96602. */
  96603. static get VIGNETTEMODE_MULTIPLY(): number;
  96604. /**
  96605. * Used to apply the vignette as a replacement of the pixel color.
  96606. */
  96607. static get VIGNETTEMODE_OPAQUE(): number;
  96608. }
  96609. }
  96610. declare module BABYLON {
  96611. /** @hidden */
  96612. export var postprocessVertexShader: {
  96613. name: string;
  96614. shader: string;
  96615. };
  96616. }
  96617. declare module BABYLON {
  96618. /**
  96619. * Type used to define a render target texture size (either with a number or with a rect width and height)
  96620. */
  96621. export type RenderTargetTextureSize = number | {
  96622. width: number;
  96623. height: number;
  96624. layers?: number;
  96625. };
  96626. interface ThinEngine {
  96627. /**
  96628. * Creates a new render target texture
  96629. * @param size defines the size of the texture
  96630. * @param options defines the options used to create the texture
  96631. * @returns a new render target texture stored in an InternalTexture
  96632. */
  96633. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  96634. /**
  96635. * Creates a depth stencil texture.
  96636. * This is only available in WebGL 2 or with the depth texture extension available.
  96637. * @param size The size of face edge in the texture.
  96638. * @param options The options defining the texture.
  96639. * @returns The texture
  96640. */
  96641. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  96642. /** @hidden */
  96643. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  96644. }
  96645. }
  96646. declare module BABYLON {
  96647. /**
  96648. * Defines the kind of connection point for node based material
  96649. */
  96650. export enum NodeMaterialBlockConnectionPointTypes {
  96651. /** Float */
  96652. Float = 1,
  96653. /** Int */
  96654. Int = 2,
  96655. /** Vector2 */
  96656. Vector2 = 4,
  96657. /** Vector3 */
  96658. Vector3 = 8,
  96659. /** Vector4 */
  96660. Vector4 = 16,
  96661. /** Color3 */
  96662. Color3 = 32,
  96663. /** Color4 */
  96664. Color4 = 64,
  96665. /** Matrix */
  96666. Matrix = 128,
  96667. /** Custom object */
  96668. Object = 256,
  96669. /** Detect type based on connection */
  96670. AutoDetect = 1024,
  96671. /** Output type that will be defined by input type */
  96672. BasedOnInput = 2048
  96673. }
  96674. }
  96675. declare module BABYLON {
  96676. /**
  96677. * Enum used to define the target of a block
  96678. */
  96679. export enum NodeMaterialBlockTargets {
  96680. /** Vertex shader */
  96681. Vertex = 1,
  96682. /** Fragment shader */
  96683. Fragment = 2,
  96684. /** Neutral */
  96685. Neutral = 4,
  96686. /** Vertex and Fragment */
  96687. VertexAndFragment = 3
  96688. }
  96689. }
  96690. declare module BABYLON {
  96691. /**
  96692. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  96693. */
  96694. export enum NodeMaterialBlockConnectionPointMode {
  96695. /** Value is an uniform */
  96696. Uniform = 0,
  96697. /** Value is a mesh attribute */
  96698. Attribute = 1,
  96699. /** Value is a varying between vertex and fragment shaders */
  96700. Varying = 2,
  96701. /** Mode is undefined */
  96702. Undefined = 3
  96703. }
  96704. }
  96705. declare module BABYLON {
  96706. /**
  96707. * Enum used to define system values e.g. values automatically provided by the system
  96708. */
  96709. export enum NodeMaterialSystemValues {
  96710. /** World */
  96711. World = 1,
  96712. /** View */
  96713. View = 2,
  96714. /** Projection */
  96715. Projection = 3,
  96716. /** ViewProjection */
  96717. ViewProjection = 4,
  96718. /** WorldView */
  96719. WorldView = 5,
  96720. /** WorldViewProjection */
  96721. WorldViewProjection = 6,
  96722. /** CameraPosition */
  96723. CameraPosition = 7,
  96724. /** Fog Color */
  96725. FogColor = 8,
  96726. /** Delta time */
  96727. DeltaTime = 9
  96728. }
  96729. }
  96730. declare module BABYLON {
  96731. /**
  96732. * Represents a camera frustum
  96733. */
  96734. export class Frustum {
  96735. /**
  96736. * Gets the planes representing the frustum
  96737. * @param transform matrix to be applied to the returned planes
  96738. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  96739. */
  96740. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  96741. /**
  96742. * Gets the near frustum plane transformed by the transform matrix
  96743. * @param transform transformation matrix to be applied to the resulting frustum plane
  96744. * @param frustumPlane the resuling frustum plane
  96745. */
  96746. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  96747. /**
  96748. * Gets the far frustum plane transformed by the transform matrix
  96749. * @param transform transformation matrix to be applied to the resulting frustum plane
  96750. * @param frustumPlane the resuling frustum plane
  96751. */
  96752. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  96753. /**
  96754. * Gets the left frustum plane transformed by the transform matrix
  96755. * @param transform transformation matrix to be applied to the resulting frustum plane
  96756. * @param frustumPlane the resuling frustum plane
  96757. */
  96758. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  96759. /**
  96760. * Gets the right frustum plane transformed by the transform matrix
  96761. * @param transform transformation matrix to be applied to the resulting frustum plane
  96762. * @param frustumPlane the resuling frustum plane
  96763. */
  96764. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  96765. /**
  96766. * Gets the top frustum plane transformed by the transform matrix
  96767. * @param transform transformation matrix to be applied to the resulting frustum plane
  96768. * @param frustumPlane the resuling frustum plane
  96769. */
  96770. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  96771. /**
  96772. * Gets the bottom frustum plane transformed by the transform matrix
  96773. * @param transform transformation matrix to be applied to the resulting frustum plane
  96774. * @param frustumPlane the resuling frustum plane
  96775. */
  96776. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  96777. /**
  96778. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  96779. * @param transform transformation matrix to be applied to the resulting frustum planes
  96780. * @param frustumPlanes the resuling frustum planes
  96781. */
  96782. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  96783. }
  96784. }
  96785. declare module BABYLON {
  96786. /**
  96787. * Contains position and normal vectors for a vertex
  96788. */
  96789. export class PositionNormalVertex {
  96790. /** the position of the vertex (defaut: 0,0,0) */
  96791. position: Vector3;
  96792. /** the normal of the vertex (defaut: 0,1,0) */
  96793. normal: Vector3;
  96794. /**
  96795. * Creates a PositionNormalVertex
  96796. * @param position the position of the vertex (defaut: 0,0,0)
  96797. * @param normal the normal of the vertex (defaut: 0,1,0)
  96798. */
  96799. constructor(
  96800. /** the position of the vertex (defaut: 0,0,0) */
  96801. position?: Vector3,
  96802. /** the normal of the vertex (defaut: 0,1,0) */
  96803. normal?: Vector3);
  96804. /**
  96805. * Clones the PositionNormalVertex
  96806. * @returns the cloned PositionNormalVertex
  96807. */
  96808. clone(): PositionNormalVertex;
  96809. }
  96810. /**
  96811. * Contains position, normal and uv vectors for a vertex
  96812. */
  96813. export class PositionNormalTextureVertex {
  96814. /** the position of the vertex (defaut: 0,0,0) */
  96815. position: Vector3;
  96816. /** the normal of the vertex (defaut: 0,1,0) */
  96817. normal: Vector3;
  96818. /** the uv of the vertex (default: 0,0) */
  96819. uv: Vector2;
  96820. /**
  96821. * Creates a PositionNormalTextureVertex
  96822. * @param position the position of the vertex (defaut: 0,0,0)
  96823. * @param normal the normal of the vertex (defaut: 0,1,0)
  96824. * @param uv the uv of the vertex (default: 0,0)
  96825. */
  96826. constructor(
  96827. /** the position of the vertex (defaut: 0,0,0) */
  96828. position?: Vector3,
  96829. /** the normal of the vertex (defaut: 0,1,0) */
  96830. normal?: Vector3,
  96831. /** the uv of the vertex (default: 0,0) */
  96832. uv?: Vector2);
  96833. /**
  96834. * Clones the PositionNormalTextureVertex
  96835. * @returns the cloned PositionNormalTextureVertex
  96836. */
  96837. clone(): PositionNormalTextureVertex;
  96838. }
  96839. }
  96840. declare module BABYLON {
  96841. /**
  96842. * Enum defining the type of animations supported by InputBlock
  96843. */
  96844. export enum AnimatedInputBlockTypes {
  96845. /** No animation */
  96846. None = 0,
  96847. /** Time based animation. Will only work for floats */
  96848. Time = 1
  96849. }
  96850. }
  96851. declare module BABYLON {
  96852. /**
  96853. * Block used to expose an input value
  96854. */
  96855. export class InputBlock extends NodeMaterialBlock {
  96856. private _mode;
  96857. private _associatedVariableName;
  96858. private _storedValue;
  96859. private _valueCallback;
  96860. private _type;
  96861. private _animationType;
  96862. /** Gets or set a value used to limit the range of float values */
  96863. min: number;
  96864. /** Gets or set a value used to limit the range of float values */
  96865. max: number;
  96866. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  96867. isBoolean: boolean;
  96868. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  96869. matrixMode: number;
  96870. /** @hidden */
  96871. _systemValue: Nullable<NodeMaterialSystemValues>;
  96872. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  96873. isConstant: boolean;
  96874. /** Gets or sets the group to use to display this block in the Inspector */
  96875. groupInInspector: string;
  96876. /** Gets an observable raised when the value is changed */
  96877. onValueChangedObservable: Observable<InputBlock>;
  96878. /** Gets or sets a boolean indicating if content needs to be converted to gamma space (for color3/4 only) */
  96879. convertToGammaSpace: boolean;
  96880. /** Gets or sets a boolean indicating if content needs to be converted to linear space (for color3/4 only) */
  96881. convertToLinearSpace: boolean;
  96882. /**
  96883. * Gets or sets the connection point type (default is float)
  96884. */
  96885. get type(): NodeMaterialBlockConnectionPointTypes;
  96886. /**
  96887. * Creates a new InputBlock
  96888. * @param name defines the block name
  96889. * @param target defines the target of that block (Vertex by default)
  96890. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  96891. */
  96892. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  96893. /**
  96894. * Validates if a name is a reserve word.
  96895. * @param newName the new name to be given to the node.
  96896. * @returns false if the name is a reserve word, else true.
  96897. */
  96898. validateBlockName(newName: string): boolean;
  96899. /**
  96900. * Gets the output component
  96901. */
  96902. get output(): NodeMaterialConnectionPoint;
  96903. /**
  96904. * Set the source of this connection point to a vertex attribute
  96905. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  96906. * @returns the current connection point
  96907. */
  96908. setAsAttribute(attributeName?: string): InputBlock;
  96909. /**
  96910. * Set the source of this connection point to a system value
  96911. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  96912. * @returns the current connection point
  96913. */
  96914. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  96915. /**
  96916. * Gets or sets the value of that point.
  96917. * Please note that this value will be ignored if valueCallback is defined
  96918. */
  96919. get value(): any;
  96920. set value(value: any);
  96921. /**
  96922. * Gets or sets a callback used to get the value of that point.
  96923. * Please note that setting this value will force the connection point to ignore the value property
  96924. */
  96925. get valueCallback(): () => any;
  96926. set valueCallback(value: () => any);
  96927. /**
  96928. * Gets or sets the associated variable name in the shader
  96929. */
  96930. get associatedVariableName(): string;
  96931. set associatedVariableName(value: string);
  96932. /** Gets or sets the type of animation applied to the input */
  96933. get animationType(): AnimatedInputBlockTypes;
  96934. set animationType(value: AnimatedInputBlockTypes);
  96935. /**
  96936. * Gets a boolean indicating that this connection point not defined yet
  96937. */
  96938. get isUndefined(): boolean;
  96939. /**
  96940. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  96941. * In this case the connection point name must be the name of the uniform to use.
  96942. * Can only be set on inputs
  96943. */
  96944. get isUniform(): boolean;
  96945. set isUniform(value: boolean);
  96946. /**
  96947. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  96948. * In this case the connection point name must be the name of the attribute to use
  96949. * Can only be set on inputs
  96950. */
  96951. get isAttribute(): boolean;
  96952. set isAttribute(value: boolean);
  96953. /**
  96954. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  96955. * Can only be set on exit points
  96956. */
  96957. get isVarying(): boolean;
  96958. set isVarying(value: boolean);
  96959. /**
  96960. * Gets a boolean indicating that the current connection point is a system value
  96961. */
  96962. get isSystemValue(): boolean;
  96963. /**
  96964. * Gets or sets the current well known value or null if not defined as a system value
  96965. */
  96966. get systemValue(): Nullable<NodeMaterialSystemValues>;
  96967. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  96968. /**
  96969. * Gets the current class name
  96970. * @returns the class name
  96971. */
  96972. getClassName(): string;
  96973. /**
  96974. * Animate the input if animationType !== None
  96975. * @param scene defines the rendering scene
  96976. */
  96977. animate(scene: Scene): void;
  96978. private _emitDefine;
  96979. initialize(state: NodeMaterialBuildState): void;
  96980. /**
  96981. * Set the input block to its default value (based on its type)
  96982. */
  96983. setDefaultValue(): void;
  96984. private _emitConstant;
  96985. /** @hidden */
  96986. get _noContextSwitch(): boolean;
  96987. private _emit;
  96988. /** @hidden */
  96989. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  96990. /** @hidden */
  96991. _transmit(effect: Effect, scene: Scene): void;
  96992. protected _buildBlock(state: NodeMaterialBuildState): void;
  96993. protected _dumpPropertiesCode(): string;
  96994. dispose(): void;
  96995. serialize(): any;
  96996. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  96997. }
  96998. }
  96999. declare module BABYLON {
  97000. /**
  97001. * Enum used to define the compatibility state between two connection points
  97002. */
  97003. export enum NodeMaterialConnectionPointCompatibilityStates {
  97004. /** Points are compatibles */
  97005. Compatible = 0,
  97006. /** Points are incompatible because of their types */
  97007. TypeIncompatible = 1,
  97008. /** Points are incompatible because of their targets (vertex vs fragment) */
  97009. TargetIncompatible = 2
  97010. }
  97011. /**
  97012. * Defines the direction of a connection point
  97013. */
  97014. export enum NodeMaterialConnectionPointDirection {
  97015. /** Input */
  97016. Input = 0,
  97017. /** Output */
  97018. Output = 1
  97019. }
  97020. /**
  97021. * Defines a connection point for a block
  97022. */
  97023. export class NodeMaterialConnectionPoint {
  97024. /**
  97025. * Checks if two types are equivalent
  97026. * @param type1 type 1 to check
  97027. * @param type2 type 2 to check
  97028. * @returns true if both types are equivalent, else false
  97029. */
  97030. static AreEquivalentTypes(type1: number, type2: number): boolean;
  97031. /** @hidden */
  97032. _ownerBlock: NodeMaterialBlock;
  97033. /** @hidden */
  97034. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  97035. private _endpoints;
  97036. private _associatedVariableName;
  97037. private _direction;
  97038. /** @hidden */
  97039. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  97040. /** @hidden */
  97041. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  97042. /** @hidden */
  97043. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  97044. private _type;
  97045. /** @hidden */
  97046. _enforceAssociatedVariableName: boolean;
  97047. /** Gets the direction of the point */
  97048. get direction(): NodeMaterialConnectionPointDirection;
  97049. /** Indicates that this connection point needs dual validation before being connected to another point */
  97050. needDualDirectionValidation: boolean;
  97051. /**
  97052. * Gets or sets the additional types supported by this connection point
  97053. */
  97054. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  97055. /**
  97056. * Gets or sets the additional types excluded by this connection point
  97057. */
  97058. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  97059. /**
  97060. * Observable triggered when this point is connected
  97061. */
  97062. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  97063. /**
  97064. * Gets or sets the associated variable name in the shader
  97065. */
  97066. get associatedVariableName(): string;
  97067. set associatedVariableName(value: string);
  97068. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  97069. get innerType(): NodeMaterialBlockConnectionPointTypes;
  97070. /**
  97071. * Gets or sets the connection point type (default is float)
  97072. */
  97073. get type(): NodeMaterialBlockConnectionPointTypes;
  97074. set type(value: NodeMaterialBlockConnectionPointTypes);
  97075. /**
  97076. * Gets or sets the connection point name
  97077. */
  97078. name: string;
  97079. /**
  97080. * Gets or sets the connection point name
  97081. */
  97082. displayName: string;
  97083. /**
  97084. * Gets or sets a boolean indicating that this connection point can be omitted
  97085. */
  97086. isOptional: boolean;
  97087. /**
  97088. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  97089. */
  97090. isExposedOnFrame: boolean;
  97091. /**
  97092. * Gets or sets number indicating the position that the port is exposed to on a frame
  97093. */
  97094. exposedPortPosition: number;
  97095. /**
  97096. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  97097. */
  97098. define: string;
  97099. /** @hidden */
  97100. _prioritizeVertex: boolean;
  97101. private _target;
  97102. /** Gets or sets the target of that connection point */
  97103. get target(): NodeMaterialBlockTargets;
  97104. set target(value: NodeMaterialBlockTargets);
  97105. /**
  97106. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  97107. */
  97108. get isConnected(): boolean;
  97109. /**
  97110. * Gets a boolean indicating that the current point is connected to an input block
  97111. */
  97112. get isConnectedToInputBlock(): boolean;
  97113. /**
  97114. * Gets a the connected input block (if any)
  97115. */
  97116. get connectInputBlock(): Nullable<InputBlock>;
  97117. /** Get the other side of the connection (if any) */
  97118. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  97119. /** Get the block that owns this connection point */
  97120. get ownerBlock(): NodeMaterialBlock;
  97121. /** Get the block connected on the other side of this connection (if any) */
  97122. get sourceBlock(): Nullable<NodeMaterialBlock>;
  97123. /** Get the block connected on the endpoints of this connection (if any) */
  97124. get connectedBlocks(): Array<NodeMaterialBlock>;
  97125. /** Gets the list of connected endpoints */
  97126. get endpoints(): NodeMaterialConnectionPoint[];
  97127. /** Gets a boolean indicating if that output point is connected to at least one input */
  97128. get hasEndpoints(): boolean;
  97129. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  97130. get isConnectedInVertexShader(): boolean;
  97131. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  97132. get isConnectedInFragmentShader(): boolean;
  97133. /**
  97134. * Creates a block suitable to be used as an input for this input point.
  97135. * If null is returned, a block based on the point type will be created.
  97136. * @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
  97137. */
  97138. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  97139. /**
  97140. * Creates a new connection point
  97141. * @param name defines the connection point name
  97142. * @param ownerBlock defines the block hosting this connection point
  97143. * @param direction defines the direction of the connection point
  97144. */
  97145. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  97146. /**
  97147. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  97148. * @returns the class name
  97149. */
  97150. getClassName(): string;
  97151. /**
  97152. * Gets a boolean indicating if the current point can be connected to another point
  97153. * @param connectionPoint defines the other connection point
  97154. * @returns a boolean
  97155. */
  97156. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  97157. /**
  97158. * Gets a number indicating if the current point can be connected to another point
  97159. * @param connectionPoint defines the other connection point
  97160. * @returns a number defining the compatibility state
  97161. */
  97162. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  97163. /**
  97164. * Connect this point to another connection point
  97165. * @param connectionPoint defines the other connection point
  97166. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  97167. * @returns the current connection point
  97168. */
  97169. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  97170. /**
  97171. * Disconnect this point from one of his endpoint
  97172. * @param endpoint defines the other connection point
  97173. * @returns the current connection point
  97174. */
  97175. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  97176. /**
  97177. * Serializes this point in a JSON representation
  97178. * @param isInput defines if the connection point is an input (default is true)
  97179. * @returns the serialized point object
  97180. */
  97181. serialize(isInput?: boolean): any;
  97182. /**
  97183. * Release resources
  97184. */
  97185. dispose(): void;
  97186. }
  97187. }
  97188. declare module BABYLON {
  97189. /**
  97190. * Enum used to define the material modes
  97191. */
  97192. export enum NodeMaterialModes {
  97193. /** Regular material */
  97194. Material = 0,
  97195. /** For post process */
  97196. PostProcess = 1,
  97197. /** For particle system */
  97198. Particle = 2,
  97199. /** For procedural texture */
  97200. ProceduralTexture = 3
  97201. }
  97202. }
  97203. declare module BABYLON {
  97204. /** @hidden */
  97205. export var helperFunctions: {
  97206. name: string;
  97207. shader: string;
  97208. };
  97209. }
  97210. declare module BABYLON {
  97211. /**
  97212. * Block used to read a texture from a sampler
  97213. */
  97214. export class TextureBlock extends NodeMaterialBlock {
  97215. private _defineName;
  97216. private _linearDefineName;
  97217. private _gammaDefineName;
  97218. private _tempTextureRead;
  97219. private _samplerName;
  97220. private _transformedUVName;
  97221. private _textureTransformName;
  97222. private _textureInfoName;
  97223. private _mainUVName;
  97224. private _mainUVDefineName;
  97225. private _fragmentOnly;
  97226. /**
  97227. * Gets or sets the texture associated with the node
  97228. */
  97229. texture: Nullable<Texture>;
  97230. /**
  97231. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  97232. */
  97233. convertToGammaSpace: boolean;
  97234. /**
  97235. * Gets or sets a boolean indicating if content needs to be converted to linear space
  97236. */
  97237. convertToLinearSpace: boolean;
  97238. /**
  97239. * Create a new TextureBlock
  97240. * @param name defines the block name
  97241. */
  97242. constructor(name: string, fragmentOnly?: boolean);
  97243. /**
  97244. * Gets the current class name
  97245. * @returns the class name
  97246. */
  97247. getClassName(): string;
  97248. /**
  97249. * Gets the uv input component
  97250. */
  97251. get uv(): NodeMaterialConnectionPoint;
  97252. /**
  97253. * Gets the rgba output component
  97254. */
  97255. get rgba(): NodeMaterialConnectionPoint;
  97256. /**
  97257. * Gets the rgb output component
  97258. */
  97259. get rgb(): NodeMaterialConnectionPoint;
  97260. /**
  97261. * Gets the r output component
  97262. */
  97263. get r(): NodeMaterialConnectionPoint;
  97264. /**
  97265. * Gets the g output component
  97266. */
  97267. get g(): NodeMaterialConnectionPoint;
  97268. /**
  97269. * Gets the b output component
  97270. */
  97271. get b(): NodeMaterialConnectionPoint;
  97272. /**
  97273. * Gets the a output component
  97274. */
  97275. get a(): NodeMaterialConnectionPoint;
  97276. get target(): NodeMaterialBlockTargets;
  97277. autoConfigure(material: NodeMaterial): void;
  97278. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  97279. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  97280. isReady(): boolean;
  97281. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  97282. private get _isMixed();
  97283. private _injectVertexCode;
  97284. private _writeTextureRead;
  97285. private _writeOutput;
  97286. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  97287. protected _dumpPropertiesCode(): string;
  97288. serialize(): any;
  97289. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  97290. }
  97291. }
  97292. declare module BABYLON {
  97293. /** @hidden */
  97294. export var reflectionFunction: {
  97295. name: string;
  97296. shader: string;
  97297. };
  97298. }
  97299. declare module BABYLON {
  97300. /**
  97301. * Base block used to read a reflection texture from a sampler
  97302. */
  97303. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  97304. /** @hidden */
  97305. _define3DName: string;
  97306. /** @hidden */
  97307. _defineCubicName: string;
  97308. /** @hidden */
  97309. _defineExplicitName: string;
  97310. /** @hidden */
  97311. _defineProjectionName: string;
  97312. /** @hidden */
  97313. _defineLocalCubicName: string;
  97314. /** @hidden */
  97315. _defineSphericalName: string;
  97316. /** @hidden */
  97317. _definePlanarName: string;
  97318. /** @hidden */
  97319. _defineEquirectangularName: string;
  97320. /** @hidden */
  97321. _defineMirroredEquirectangularFixedName: string;
  97322. /** @hidden */
  97323. _defineEquirectangularFixedName: string;
  97324. /** @hidden */
  97325. _defineSkyboxName: string;
  97326. /** @hidden */
  97327. _defineOppositeZ: string;
  97328. /** @hidden */
  97329. _cubeSamplerName: string;
  97330. /** @hidden */
  97331. _2DSamplerName: string;
  97332. protected _positionUVWName: string;
  97333. protected _directionWName: string;
  97334. protected _reflectionVectorName: string;
  97335. /** @hidden */
  97336. _reflectionCoordsName: string;
  97337. /** @hidden */
  97338. _reflectionMatrixName: string;
  97339. protected _reflectionColorName: string;
  97340. /**
  97341. * Gets or sets the texture associated with the node
  97342. */
  97343. texture: Nullable<BaseTexture>;
  97344. /**
  97345. * Create a new ReflectionTextureBaseBlock
  97346. * @param name defines the block name
  97347. */
  97348. constructor(name: string);
  97349. /**
  97350. * Gets the current class name
  97351. * @returns the class name
  97352. */
  97353. getClassName(): string;
  97354. /**
  97355. * Gets the world position input component
  97356. */
  97357. abstract get position(): NodeMaterialConnectionPoint;
  97358. /**
  97359. * Gets the world position input component
  97360. */
  97361. abstract get worldPosition(): NodeMaterialConnectionPoint;
  97362. /**
  97363. * Gets the world normal input component
  97364. */
  97365. abstract get worldNormal(): NodeMaterialConnectionPoint;
  97366. /**
  97367. * Gets the world input component
  97368. */
  97369. abstract get world(): NodeMaterialConnectionPoint;
  97370. /**
  97371. * Gets the camera (or eye) position component
  97372. */
  97373. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  97374. /**
  97375. * Gets the view input component
  97376. */
  97377. abstract get view(): NodeMaterialConnectionPoint;
  97378. protected _getTexture(): Nullable<BaseTexture>;
  97379. autoConfigure(material: NodeMaterial): void;
  97380. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  97381. isReady(): boolean;
  97382. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  97383. /**
  97384. * Gets the code to inject in the vertex shader
  97385. * @param state current state of the node material building
  97386. * @returns the shader code
  97387. */
  97388. handleVertexSide(state: NodeMaterialBuildState): string;
  97389. /**
  97390. * Handles the inits for the fragment code path
  97391. * @param state node material build state
  97392. */
  97393. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  97394. /**
  97395. * Generates the reflection coords code for the fragment code path
  97396. * @param worldNormalVarName name of the world normal variable
  97397. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  97398. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  97399. * @returns the shader code
  97400. */
  97401. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  97402. /**
  97403. * Generates the reflection color code for the fragment code path
  97404. * @param lodVarName name of the lod variable
  97405. * @param swizzleLookupTexture swizzle to use for the final color variable
  97406. * @returns the shader code
  97407. */
  97408. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  97409. /**
  97410. * Generates the code corresponding to the connected output points
  97411. * @param state node material build state
  97412. * @param varName name of the variable to output
  97413. * @returns the shader code
  97414. */
  97415. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  97416. protected _buildBlock(state: NodeMaterialBuildState): this;
  97417. protected _dumpPropertiesCode(): string;
  97418. serialize(): any;
  97419. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  97420. }
  97421. }
  97422. declare module BABYLON {
  97423. /**
  97424. * Defines a connection point to be used for points with a custom object type
  97425. */
  97426. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  97427. private _blockType;
  97428. private _blockName;
  97429. private _nameForCheking?;
  97430. /**
  97431. * Creates a new connection point
  97432. * @param name defines the connection point name
  97433. * @param ownerBlock defines the block hosting this connection point
  97434. * @param direction defines the direction of the connection point
  97435. */
  97436. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  97437. /**
  97438. * Gets a number indicating if the current point can be connected to another point
  97439. * @param connectionPoint defines the other connection point
  97440. * @returns a number defining the compatibility state
  97441. */
  97442. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  97443. /**
  97444. * Creates a block suitable to be used as an input for this input point.
  97445. * If null is returned, a block based on the point type will be created.
  97446. * @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
  97447. */
  97448. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  97449. }
  97450. }
  97451. declare module BABYLON {
  97452. /**
  97453. * Enum defining the type of properties that can be edited in the property pages in the NME
  97454. */
  97455. export enum PropertyTypeForEdition {
  97456. /** property is a boolean */
  97457. Boolean = 0,
  97458. /** property is a float */
  97459. Float = 1,
  97460. /** property is a Vector2 */
  97461. Vector2 = 2,
  97462. /** property is a list of values */
  97463. List = 3
  97464. }
  97465. /**
  97466. * Interface that defines an option in a variable of type list
  97467. */
  97468. export interface IEditablePropertyListOption {
  97469. /** label of the option */
  97470. "label": string;
  97471. /** value of the option */
  97472. "value": number;
  97473. }
  97474. /**
  97475. * Interface that defines the options available for an editable property
  97476. */
  97477. export interface IEditablePropertyOption {
  97478. /** min value */
  97479. "min"?: number;
  97480. /** max value */
  97481. "max"?: number;
  97482. /** notifiers: indicates which actions to take when the property is changed */
  97483. "notifiers"?: {
  97484. /** the material should be rebuilt */
  97485. "rebuild"?: boolean;
  97486. /** the preview should be updated */
  97487. "update"?: boolean;
  97488. };
  97489. /** list of the options for a variable of type list */
  97490. "options"?: IEditablePropertyListOption[];
  97491. }
  97492. /**
  97493. * Interface that describes an editable property
  97494. */
  97495. export interface IPropertyDescriptionForEdition {
  97496. /** name of the property */
  97497. "propertyName": string;
  97498. /** display name of the property */
  97499. "displayName": string;
  97500. /** type of the property */
  97501. "type": PropertyTypeForEdition;
  97502. /** group of the property - all properties with the same group value will be displayed in a specific section */
  97503. "groupName": string;
  97504. /** options for the property */
  97505. "options": IEditablePropertyOption;
  97506. }
  97507. /**
  97508. * Decorator that flags a property in a node material block as being editable
  97509. */
  97510. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  97511. }
  97512. declare module BABYLON {
  97513. /**
  97514. * Block used to implement the refraction part of the sub surface module of the PBR material
  97515. */
  97516. export class RefractionBlock extends NodeMaterialBlock {
  97517. /** @hidden */
  97518. _define3DName: string;
  97519. /** @hidden */
  97520. _refractionMatrixName: string;
  97521. /** @hidden */
  97522. _defineLODRefractionAlpha: string;
  97523. /** @hidden */
  97524. _defineLinearSpecularRefraction: string;
  97525. /** @hidden */
  97526. _defineOppositeZ: string;
  97527. /** @hidden */
  97528. _cubeSamplerName: string;
  97529. /** @hidden */
  97530. _2DSamplerName: string;
  97531. /** @hidden */
  97532. _vRefractionMicrosurfaceInfosName: string;
  97533. /** @hidden */
  97534. _vRefractionInfosName: string;
  97535. /** @hidden */
  97536. _vRefractionFilteringInfoName: string;
  97537. private _scene;
  97538. /**
  97539. * The properties below are set by the main PBR block prior to calling methods of this class.
  97540. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  97541. * It's less burden on the user side in the editor part.
  97542. */
  97543. /** @hidden */
  97544. viewConnectionPoint: NodeMaterialConnectionPoint;
  97545. /** @hidden */
  97546. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  97547. /**
  97548. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  97549. * Materials half opaque for instance using refraction could benefit from this control.
  97550. */
  97551. linkRefractionWithTransparency: boolean;
  97552. /**
  97553. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  97554. */
  97555. invertRefractionY: boolean;
  97556. /**
  97557. * Gets or sets the texture associated with the node
  97558. */
  97559. texture: Nullable<BaseTexture>;
  97560. /**
  97561. * Create a new RefractionBlock
  97562. * @param name defines the block name
  97563. */
  97564. constructor(name: string);
  97565. /**
  97566. * Gets the current class name
  97567. * @returns the class name
  97568. */
  97569. getClassName(): string;
  97570. /**
  97571. * Gets the intensity input component
  97572. */
  97573. get intensity(): NodeMaterialConnectionPoint;
  97574. /**
  97575. * Gets the tint at distance input component
  97576. */
  97577. get tintAtDistance(): NodeMaterialConnectionPoint;
  97578. /**
  97579. * Gets the view input component
  97580. */
  97581. get view(): NodeMaterialConnectionPoint;
  97582. /**
  97583. * Gets the refraction object output component
  97584. */
  97585. get refraction(): NodeMaterialConnectionPoint;
  97586. /**
  97587. * Returns true if the block has a texture
  97588. */
  97589. get hasTexture(): boolean;
  97590. protected _getTexture(): Nullable<BaseTexture>;
  97591. autoConfigure(material: NodeMaterial): void;
  97592. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  97593. isReady(): boolean;
  97594. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  97595. /**
  97596. * Gets the main code of the block (fragment side)
  97597. * @param state current state of the node material building
  97598. * @returns the shader code
  97599. */
  97600. getCode(state: NodeMaterialBuildState): string;
  97601. protected _buildBlock(state: NodeMaterialBuildState): this;
  97602. protected _dumpPropertiesCode(): string;
  97603. serialize(): any;
  97604. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  97605. }
  97606. }
  97607. declare module BABYLON {
  97608. /**
  97609. * Base block used as input for post process
  97610. */
  97611. export class CurrentScreenBlock extends NodeMaterialBlock {
  97612. private _samplerName;
  97613. private _linearDefineName;
  97614. private _gammaDefineName;
  97615. private _mainUVName;
  97616. private _tempTextureRead;
  97617. /**
  97618. * Gets or sets the texture associated with the node
  97619. */
  97620. texture: Nullable<BaseTexture>;
  97621. /**
  97622. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  97623. */
  97624. convertToGammaSpace: boolean;
  97625. /**
  97626. * Gets or sets a boolean indicating if content needs to be converted to linear space
  97627. */
  97628. convertToLinearSpace: boolean;
  97629. /**
  97630. * Create a new CurrentScreenBlock
  97631. * @param name defines the block name
  97632. */
  97633. constructor(name: string);
  97634. /**
  97635. * Gets the current class name
  97636. * @returns the class name
  97637. */
  97638. getClassName(): string;
  97639. /**
  97640. * Gets the uv input component
  97641. */
  97642. get uv(): NodeMaterialConnectionPoint;
  97643. /**
  97644. * Gets the rgba output component
  97645. */
  97646. get rgba(): NodeMaterialConnectionPoint;
  97647. /**
  97648. * Gets the rgb output component
  97649. */
  97650. get rgb(): NodeMaterialConnectionPoint;
  97651. /**
  97652. * Gets the r output component
  97653. */
  97654. get r(): NodeMaterialConnectionPoint;
  97655. /**
  97656. * Gets the g output component
  97657. */
  97658. get g(): NodeMaterialConnectionPoint;
  97659. /**
  97660. * Gets the b output component
  97661. */
  97662. get b(): NodeMaterialConnectionPoint;
  97663. /**
  97664. * Gets the a output component
  97665. */
  97666. get a(): NodeMaterialConnectionPoint;
  97667. /**
  97668. * Initialize the block and prepare the context for build
  97669. * @param state defines the state that will be used for the build
  97670. */
  97671. initialize(state: NodeMaterialBuildState): void;
  97672. get target(): NodeMaterialBlockTargets;
  97673. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  97674. isReady(): boolean;
  97675. private _injectVertexCode;
  97676. private _writeTextureRead;
  97677. private _writeOutput;
  97678. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  97679. serialize(): any;
  97680. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  97681. }
  97682. }
  97683. declare module BABYLON {
  97684. /**
  97685. * Base block used for the particle texture
  97686. */
  97687. export class ParticleTextureBlock extends NodeMaterialBlock {
  97688. private _samplerName;
  97689. private _linearDefineName;
  97690. private _gammaDefineName;
  97691. private _tempTextureRead;
  97692. /**
  97693. * Gets or sets the texture associated with the node
  97694. */
  97695. texture: Nullable<BaseTexture>;
  97696. /**
  97697. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  97698. */
  97699. convertToGammaSpace: boolean;
  97700. /**
  97701. * Gets or sets a boolean indicating if content needs to be converted to linear space
  97702. */
  97703. convertToLinearSpace: boolean;
  97704. /**
  97705. * Create a new ParticleTextureBlock
  97706. * @param name defines the block name
  97707. */
  97708. constructor(name: string);
  97709. /**
  97710. * Gets the current class name
  97711. * @returns the class name
  97712. */
  97713. getClassName(): string;
  97714. /**
  97715. * Gets the uv input component
  97716. */
  97717. get uv(): NodeMaterialConnectionPoint;
  97718. /**
  97719. * Gets the rgba output component
  97720. */
  97721. get rgba(): NodeMaterialConnectionPoint;
  97722. /**
  97723. * Gets the rgb output component
  97724. */
  97725. get rgb(): NodeMaterialConnectionPoint;
  97726. /**
  97727. * Gets the r output component
  97728. */
  97729. get r(): NodeMaterialConnectionPoint;
  97730. /**
  97731. * Gets the g output component
  97732. */
  97733. get g(): NodeMaterialConnectionPoint;
  97734. /**
  97735. * Gets the b output component
  97736. */
  97737. get b(): NodeMaterialConnectionPoint;
  97738. /**
  97739. * Gets the a output component
  97740. */
  97741. get a(): NodeMaterialConnectionPoint;
  97742. /**
  97743. * Initialize the block and prepare the context for build
  97744. * @param state defines the state that will be used for the build
  97745. */
  97746. initialize(state: NodeMaterialBuildState): void;
  97747. autoConfigure(material: NodeMaterial): void;
  97748. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  97749. isReady(): boolean;
  97750. private _writeOutput;
  97751. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  97752. serialize(): any;
  97753. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  97754. }
  97755. }
  97756. declare module BABYLON {
  97757. /**
  97758. * Class used to store shared data between 2 NodeMaterialBuildState
  97759. */
  97760. export class NodeMaterialBuildStateSharedData {
  97761. /**
  97762. * Gets the list of emitted varyings
  97763. */
  97764. temps: string[];
  97765. /**
  97766. * Gets the list of emitted varyings
  97767. */
  97768. varyings: string[];
  97769. /**
  97770. * Gets the varying declaration string
  97771. */
  97772. varyingDeclaration: string;
  97773. /**
  97774. * Input blocks
  97775. */
  97776. inputBlocks: InputBlock[];
  97777. /**
  97778. * Input blocks
  97779. */
  97780. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  97781. /**
  97782. * Bindable blocks (Blocks that need to set data to the effect)
  97783. */
  97784. bindableBlocks: NodeMaterialBlock[];
  97785. /**
  97786. * List of blocks that can provide a compilation fallback
  97787. */
  97788. blocksWithFallbacks: NodeMaterialBlock[];
  97789. /**
  97790. * List of blocks that can provide a define update
  97791. */
  97792. blocksWithDefines: NodeMaterialBlock[];
  97793. /**
  97794. * List of blocks that can provide a repeatable content
  97795. */
  97796. repeatableContentBlocks: NodeMaterialBlock[];
  97797. /**
  97798. * List of blocks that can provide a dynamic list of uniforms
  97799. */
  97800. dynamicUniformBlocks: NodeMaterialBlock[];
  97801. /**
  97802. * List of blocks that can block the isReady function for the material
  97803. */
  97804. blockingBlocks: NodeMaterialBlock[];
  97805. /**
  97806. * Gets the list of animated inputs
  97807. */
  97808. animatedInputs: InputBlock[];
  97809. /**
  97810. * Build Id used to avoid multiple recompilations
  97811. */
  97812. buildId: number;
  97813. /** List of emitted variables */
  97814. variableNames: {
  97815. [key: string]: number;
  97816. };
  97817. /** List of emitted defines */
  97818. defineNames: {
  97819. [key: string]: number;
  97820. };
  97821. /** Should emit comments? */
  97822. emitComments: boolean;
  97823. /** Emit build activity */
  97824. verbose: boolean;
  97825. /** Gets or sets the hosting scene */
  97826. scene: Scene;
  97827. /**
  97828. * Gets the compilation hints emitted at compilation time
  97829. */
  97830. hints: {
  97831. needWorldViewMatrix: boolean;
  97832. needWorldViewProjectionMatrix: boolean;
  97833. needAlphaBlending: boolean;
  97834. needAlphaTesting: boolean;
  97835. };
  97836. /**
  97837. * List of compilation checks
  97838. */
  97839. checks: {
  97840. emitVertex: boolean;
  97841. emitFragment: boolean;
  97842. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  97843. };
  97844. /**
  97845. * Is vertex program allowed to be empty?
  97846. */
  97847. allowEmptyVertexProgram: boolean;
  97848. /** Creates a new shared data */
  97849. constructor();
  97850. /**
  97851. * Emits console errors and exceptions if there is a failing check
  97852. */
  97853. emitErrors(): void;
  97854. }
  97855. }
  97856. declare module BABYLON {
  97857. /**
  97858. * Class used to store node based material build state
  97859. */
  97860. export class NodeMaterialBuildState {
  97861. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  97862. supportUniformBuffers: boolean;
  97863. /**
  97864. * Gets the list of emitted attributes
  97865. */
  97866. attributes: string[];
  97867. /**
  97868. * Gets the list of emitted uniforms
  97869. */
  97870. uniforms: string[];
  97871. /**
  97872. * Gets the list of emitted constants
  97873. */
  97874. constants: string[];
  97875. /**
  97876. * Gets the list of emitted samplers
  97877. */
  97878. samplers: string[];
  97879. /**
  97880. * Gets the list of emitted functions
  97881. */
  97882. functions: {
  97883. [key: string]: string;
  97884. };
  97885. /**
  97886. * Gets the list of emitted extensions
  97887. */
  97888. extensions: {
  97889. [key: string]: string;
  97890. };
  97891. /**
  97892. * Gets the target of the compilation state
  97893. */
  97894. target: NodeMaterialBlockTargets;
  97895. /**
  97896. * Gets the list of emitted counters
  97897. */
  97898. counters: {
  97899. [key: string]: number;
  97900. };
  97901. /**
  97902. * Shared data between multiple NodeMaterialBuildState instances
  97903. */
  97904. sharedData: NodeMaterialBuildStateSharedData;
  97905. /** @hidden */
  97906. _vertexState: NodeMaterialBuildState;
  97907. /** @hidden */
  97908. _attributeDeclaration: string;
  97909. /** @hidden */
  97910. _uniformDeclaration: string;
  97911. /** @hidden */
  97912. _constantDeclaration: string;
  97913. /** @hidden */
  97914. _samplerDeclaration: string;
  97915. /** @hidden */
  97916. _varyingTransfer: string;
  97917. /** @hidden */
  97918. _injectAtEnd: string;
  97919. private _repeatableContentAnchorIndex;
  97920. /** @hidden */
  97921. _builtCompilationString: string;
  97922. /**
  97923. * Gets the emitted compilation strings
  97924. */
  97925. compilationString: string;
  97926. /**
  97927. * Finalize the compilation strings
  97928. * @param state defines the current compilation state
  97929. */
  97930. finalize(state: NodeMaterialBuildState): void;
  97931. /** @hidden */
  97932. get _repeatableContentAnchor(): string;
  97933. /** @hidden */
  97934. _getFreeVariableName(prefix: string): string;
  97935. /** @hidden */
  97936. _getFreeDefineName(prefix: string): string;
  97937. /** @hidden */
  97938. _excludeVariableName(name: string): void;
  97939. /** @hidden */
  97940. _emit2DSampler(name: string): void;
  97941. /** @hidden */
  97942. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  97943. /** @hidden */
  97944. _emitExtension(name: string, extension: string, define?: string): void;
  97945. /** @hidden */
  97946. _emitFunction(name: string, code: string, comments: string): void;
  97947. /** @hidden */
  97948. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  97949. replaceStrings?: {
  97950. search: RegExp;
  97951. replace: string;
  97952. }[];
  97953. repeatKey?: string;
  97954. }): string;
  97955. /** @hidden */
  97956. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  97957. repeatKey?: string;
  97958. removeAttributes?: boolean;
  97959. removeUniforms?: boolean;
  97960. removeVaryings?: boolean;
  97961. removeIfDef?: boolean;
  97962. replaceStrings?: {
  97963. search: RegExp;
  97964. replace: string;
  97965. }[];
  97966. }, storeKey?: string): void;
  97967. /** @hidden */
  97968. _registerTempVariable(name: string): boolean;
  97969. /** @hidden */
  97970. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  97971. /** @hidden */
  97972. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  97973. /** @hidden */
  97974. _emitFloat(value: number): string;
  97975. }
  97976. }
  97977. declare module BABYLON {
  97978. /**
  97979. * Helper class used to generate session unique ID
  97980. */
  97981. export class UniqueIdGenerator {
  97982. private static _UniqueIdCounter;
  97983. /**
  97984. * Gets an unique (relatively to the current scene) Id
  97985. */
  97986. static get UniqueId(): number;
  97987. }
  97988. }
  97989. declare module BABYLON {
  97990. /**
  97991. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  97992. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  97993. */
  97994. export class EffectFallbacks implements IEffectFallbacks {
  97995. private _defines;
  97996. private _currentRank;
  97997. private _maxRank;
  97998. private _mesh;
  97999. /**
  98000. * Removes the fallback from the bound mesh.
  98001. */
  98002. unBindMesh(): void;
  98003. /**
  98004. * Adds a fallback on the specified property.
  98005. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  98006. * @param define The name of the define in the shader
  98007. */
  98008. addFallback(rank: number, define: string): void;
  98009. /**
  98010. * Sets the mesh to use CPU skinning when needing to fallback.
  98011. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  98012. * @param mesh The mesh to use the fallbacks.
  98013. */
  98014. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  98015. /**
  98016. * Checks to see if more fallbacks are still availible.
  98017. */
  98018. get hasMoreFallbacks(): boolean;
  98019. /**
  98020. * Removes the defines that should be removed when falling back.
  98021. * @param currentDefines defines the current define statements for the shader.
  98022. * @param effect defines the current effect we try to compile
  98023. * @returns The resulting defines with defines of the current rank removed.
  98024. */
  98025. reduce(currentDefines: string, effect: Effect): string;
  98026. }
  98027. }
  98028. declare module BABYLON {
  98029. /**
  98030. * Defines a block that can be used inside a node based material
  98031. */
  98032. export class NodeMaterialBlock {
  98033. private _buildId;
  98034. private _buildTarget;
  98035. private _target;
  98036. private _isFinalMerger;
  98037. private _isInput;
  98038. private _name;
  98039. protected _isUnique: boolean;
  98040. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  98041. inputsAreExclusive: boolean;
  98042. /** @hidden */
  98043. _codeVariableName: string;
  98044. /** @hidden */
  98045. _inputs: NodeMaterialConnectionPoint[];
  98046. /** @hidden */
  98047. _outputs: NodeMaterialConnectionPoint[];
  98048. /** @hidden */
  98049. _preparationId: number;
  98050. /**
  98051. * Gets the name of the block
  98052. */
  98053. get name(): string;
  98054. /**
  98055. * Sets the name of the block. Will check if the name is valid.
  98056. */
  98057. set name(newName: string);
  98058. /**
  98059. * Gets or sets the unique id of the node
  98060. */
  98061. uniqueId: number;
  98062. /**
  98063. * Gets or sets the comments associated with this block
  98064. */
  98065. comments: string;
  98066. /**
  98067. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  98068. */
  98069. get isUnique(): boolean;
  98070. /**
  98071. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  98072. */
  98073. get isFinalMerger(): boolean;
  98074. /**
  98075. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  98076. */
  98077. get isInput(): boolean;
  98078. /**
  98079. * Gets or sets the build Id
  98080. */
  98081. get buildId(): number;
  98082. set buildId(value: number);
  98083. /**
  98084. * Gets or sets the target of the block
  98085. */
  98086. get target(): NodeMaterialBlockTargets;
  98087. set target(value: NodeMaterialBlockTargets);
  98088. /**
  98089. * Gets the list of input points
  98090. */
  98091. get inputs(): NodeMaterialConnectionPoint[];
  98092. /** Gets the list of output points */
  98093. get outputs(): NodeMaterialConnectionPoint[];
  98094. /**
  98095. * Find an input by its name
  98096. * @param name defines the name of the input to look for
  98097. * @returns the input or null if not found
  98098. */
  98099. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  98100. /**
  98101. * Find an output by its name
  98102. * @param name defines the name of the outputto look for
  98103. * @returns the output or null if not found
  98104. */
  98105. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  98106. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  98107. visibleInInspector: boolean;
  98108. /** Gets or sets a boolean indicating that this input can be edited from a collapsed frame*/
  98109. visibleOnFrame: boolean;
  98110. /**
  98111. * Creates a new NodeMaterialBlock
  98112. * @param name defines the block name
  98113. * @param target defines the target of that block (Vertex by default)
  98114. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  98115. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  98116. */
  98117. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  98118. /**
  98119. * Initialize the block and prepare the context for build
  98120. * @param state defines the state that will be used for the build
  98121. */
  98122. initialize(state: NodeMaterialBuildState): void;
  98123. /**
  98124. * Bind data to effect. Will only be called for blocks with isBindable === true
  98125. * @param effect defines the effect to bind data to
  98126. * @param nodeMaterial defines the hosting NodeMaterial
  98127. * @param mesh defines the mesh that will be rendered
  98128. * @param subMesh defines the submesh that will be rendered
  98129. */
  98130. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  98131. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  98132. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  98133. protected _writeFloat(value: number): string;
  98134. /**
  98135. * Gets the current class name e.g. "NodeMaterialBlock"
  98136. * @returns the class name
  98137. */
  98138. getClassName(): string;
  98139. /**
  98140. * Register a new input. Must be called inside a block constructor
  98141. * @param name defines the connection point name
  98142. * @param type defines the connection point type
  98143. * @param isOptional defines a boolean indicating that this input can be omitted
  98144. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  98145. * @param point an already created connection point. If not provided, create a new one
  98146. * @returns the current block
  98147. */
  98148. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  98149. /**
  98150. * Register a new output. Must be called inside a block constructor
  98151. * @param name defines the connection point name
  98152. * @param type defines the connection point type
  98153. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  98154. * @param point an already created connection point. If not provided, create a new one
  98155. * @returns the current block
  98156. */
  98157. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  98158. /**
  98159. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  98160. * @param forOutput defines an optional connection point to check compatibility with
  98161. * @returns the first available input or null
  98162. */
  98163. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  98164. /**
  98165. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  98166. * @param forBlock defines an optional block to check compatibility with
  98167. * @returns the first available input or null
  98168. */
  98169. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  98170. /**
  98171. * Gets the sibling of the given output
  98172. * @param current defines the current output
  98173. * @returns the next output in the list or null
  98174. */
  98175. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  98176. /**
  98177. * Connect current block with another block
  98178. * @param other defines the block to connect with
  98179. * @param options define the various options to help pick the right connections
  98180. * @returns the current block
  98181. */
  98182. connectTo(other: NodeMaterialBlock, options?: {
  98183. input?: string;
  98184. output?: string;
  98185. outputSwizzle?: string;
  98186. }): this | undefined;
  98187. protected _buildBlock(state: NodeMaterialBuildState): void;
  98188. /**
  98189. * Add uniforms, samplers and uniform buffers at compilation time
  98190. * @param state defines the state to update
  98191. * @param nodeMaterial defines the node material requesting the update
  98192. * @param defines defines the material defines to update
  98193. * @param uniformBuffers defines the list of uniform buffer names
  98194. */
  98195. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  98196. /**
  98197. * Add potential fallbacks if shader compilation fails
  98198. * @param mesh defines the mesh to be rendered
  98199. * @param fallbacks defines the current prioritized list of fallbacks
  98200. */
  98201. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  98202. /**
  98203. * Initialize defines for shader compilation
  98204. * @param mesh defines the mesh to be rendered
  98205. * @param nodeMaterial defines the node material requesting the update
  98206. * @param defines defines the material defines to update
  98207. * @param useInstances specifies that instances should be used
  98208. */
  98209. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  98210. /**
  98211. * Update defines for shader compilation
  98212. * @param mesh defines the mesh to be rendered
  98213. * @param nodeMaterial defines the node material requesting the update
  98214. * @param defines defines the material defines to update
  98215. * @param useInstances specifies that instances should be used
  98216. * @param subMesh defines which submesh to render
  98217. */
  98218. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  98219. /**
  98220. * Lets the block try to connect some inputs automatically
  98221. * @param material defines the hosting NodeMaterial
  98222. */
  98223. autoConfigure(material: NodeMaterial): void;
  98224. /**
  98225. * Function called when a block is declared as repeatable content generator
  98226. * @param vertexShaderState defines the current compilation state for the vertex shader
  98227. * @param fragmentShaderState defines the current compilation state for the fragment shader
  98228. * @param mesh defines the mesh to be rendered
  98229. * @param defines defines the material defines to update
  98230. */
  98231. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  98232. /**
  98233. * Checks if the block is ready
  98234. * @param mesh defines the mesh to be rendered
  98235. * @param nodeMaterial defines the node material requesting the update
  98236. * @param defines defines the material defines to update
  98237. * @param useInstances specifies that instances should be used
  98238. * @returns true if the block is ready
  98239. */
  98240. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  98241. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  98242. private _processBuild;
  98243. /**
  98244. * Validates the new name for the block node.
  98245. * @param newName the new name to be given to the node.
  98246. * @returns false if the name is a reserve word, else true.
  98247. */
  98248. validateBlockName(newName: string): boolean;
  98249. /**
  98250. * Compile the current node and generate the shader code
  98251. * @param state defines the current compilation state (uniforms, samplers, current string)
  98252. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  98253. * @returns true if already built
  98254. */
  98255. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  98256. protected _inputRename(name: string): string;
  98257. protected _outputRename(name: string): string;
  98258. protected _dumpPropertiesCode(): string;
  98259. /** @hidden */
  98260. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  98261. /** @hidden */
  98262. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  98263. /**
  98264. * Clone the current block to a new identical block
  98265. * @param scene defines the hosting scene
  98266. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98267. * @returns a copy of the current block
  98268. */
  98269. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  98270. /**
  98271. * Serializes this block in a JSON representation
  98272. * @returns the serialized block object
  98273. */
  98274. serialize(): any;
  98275. /** @hidden */
  98276. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98277. private _deserializePortDisplayNamesAndExposedOnFrame;
  98278. /**
  98279. * Release resources
  98280. */
  98281. dispose(): void;
  98282. }
  98283. }
  98284. declare module BABYLON {
  98285. /**
  98286. * Base class of materials working in push mode in babylon JS
  98287. * @hidden
  98288. */
  98289. export class PushMaterial extends Material {
  98290. protected _activeEffect: Effect;
  98291. protected _normalMatrix: Matrix;
  98292. constructor(name: string, scene: Scene);
  98293. getEffect(): Effect;
  98294. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  98295. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  98296. /**
  98297. * Binds the given world matrix to the active effect
  98298. *
  98299. * @param world the matrix to bind
  98300. */
  98301. bindOnlyWorldMatrix(world: Matrix): void;
  98302. /**
  98303. * Binds the given normal matrix to the active effect
  98304. *
  98305. * @param normalMatrix the matrix to bind
  98306. */
  98307. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  98308. bind(world: Matrix, mesh?: Mesh): void;
  98309. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  98310. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  98311. }
  98312. }
  98313. declare module BABYLON {
  98314. /**
  98315. * Root class for all node material optimizers
  98316. */
  98317. export class NodeMaterialOptimizer {
  98318. /**
  98319. * Function used to optimize a NodeMaterial graph
  98320. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  98321. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  98322. */
  98323. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  98324. }
  98325. }
  98326. declare module BABYLON {
  98327. /**
  98328. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  98329. */
  98330. export class TransformBlock extends NodeMaterialBlock {
  98331. /**
  98332. * Defines the value to use to complement W value to transform it to a Vector4
  98333. */
  98334. complementW: number;
  98335. /**
  98336. * Defines the value to use to complement z value to transform it to a Vector4
  98337. */
  98338. complementZ: number;
  98339. /**
  98340. * Creates a new TransformBlock
  98341. * @param name defines the block name
  98342. */
  98343. constructor(name: string);
  98344. /**
  98345. * Gets the current class name
  98346. * @returns the class name
  98347. */
  98348. getClassName(): string;
  98349. /**
  98350. * Gets the vector input
  98351. */
  98352. get vector(): NodeMaterialConnectionPoint;
  98353. /**
  98354. * Gets the output component
  98355. */
  98356. get output(): NodeMaterialConnectionPoint;
  98357. /**
  98358. * Gets the xyz output component
  98359. */
  98360. get xyz(): NodeMaterialConnectionPoint;
  98361. /**
  98362. * Gets the matrix transform input
  98363. */
  98364. get transform(): NodeMaterialConnectionPoint;
  98365. protected _buildBlock(state: NodeMaterialBuildState): this;
  98366. /**
  98367. * Update defines for shader compilation
  98368. * @param mesh defines the mesh to be rendered
  98369. * @param nodeMaterial defines the node material requesting the update
  98370. * @param defines defines the material defines to update
  98371. * @param useInstances specifies that instances should be used
  98372. * @param subMesh defines which submesh to render
  98373. */
  98374. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  98375. serialize(): any;
  98376. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98377. protected _dumpPropertiesCode(): string;
  98378. }
  98379. }
  98380. declare module BABYLON {
  98381. /**
  98382. * Block used to output the vertex position
  98383. */
  98384. export class VertexOutputBlock extends NodeMaterialBlock {
  98385. /**
  98386. * Creates a new VertexOutputBlock
  98387. * @param name defines the block name
  98388. */
  98389. constructor(name: string);
  98390. /**
  98391. * Gets the current class name
  98392. * @returns the class name
  98393. */
  98394. getClassName(): string;
  98395. /**
  98396. * Gets the vector input component
  98397. */
  98398. get vector(): NodeMaterialConnectionPoint;
  98399. protected _buildBlock(state: NodeMaterialBuildState): this;
  98400. }
  98401. }
  98402. declare module BABYLON {
  98403. /**
  98404. * Block used to output the final color
  98405. */
  98406. export class FragmentOutputBlock extends NodeMaterialBlock {
  98407. /**
  98408. * Create a new FragmentOutputBlock
  98409. * @param name defines the block name
  98410. */
  98411. constructor(name: string);
  98412. /**
  98413. * Gets the current class name
  98414. * @returns the class name
  98415. */
  98416. getClassName(): string;
  98417. /**
  98418. * Gets the rgba input component
  98419. */
  98420. get rgba(): NodeMaterialConnectionPoint;
  98421. /**
  98422. * Gets the rgb input component
  98423. */
  98424. get rgb(): NodeMaterialConnectionPoint;
  98425. /**
  98426. * Gets the a input component
  98427. */
  98428. get a(): NodeMaterialConnectionPoint;
  98429. protected _buildBlock(state: NodeMaterialBuildState): this;
  98430. }
  98431. }
  98432. declare module BABYLON {
  98433. /**
  98434. * Block used for the particle ramp gradient section
  98435. */
  98436. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  98437. /**
  98438. * Create a new ParticleRampGradientBlock
  98439. * @param name defines the block name
  98440. */
  98441. constructor(name: string);
  98442. /**
  98443. * Gets the current class name
  98444. * @returns the class name
  98445. */
  98446. getClassName(): string;
  98447. /**
  98448. * Gets the color input component
  98449. */
  98450. get color(): NodeMaterialConnectionPoint;
  98451. /**
  98452. * Gets the rampColor output component
  98453. */
  98454. get rampColor(): NodeMaterialConnectionPoint;
  98455. /**
  98456. * Initialize the block and prepare the context for build
  98457. * @param state defines the state that will be used for the build
  98458. */
  98459. initialize(state: NodeMaterialBuildState): void;
  98460. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98461. }
  98462. }
  98463. declare module BABYLON {
  98464. /**
  98465. * Block used for the particle blend multiply section
  98466. */
  98467. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  98468. /**
  98469. * Create a new ParticleBlendMultiplyBlock
  98470. * @param name defines the block name
  98471. */
  98472. constructor(name: string);
  98473. /**
  98474. * Gets the current class name
  98475. * @returns the class name
  98476. */
  98477. getClassName(): string;
  98478. /**
  98479. * Gets the color input component
  98480. */
  98481. get color(): NodeMaterialConnectionPoint;
  98482. /**
  98483. * Gets the alphaTexture input component
  98484. */
  98485. get alphaTexture(): NodeMaterialConnectionPoint;
  98486. /**
  98487. * Gets the alphaColor input component
  98488. */
  98489. get alphaColor(): NodeMaterialConnectionPoint;
  98490. /**
  98491. * Gets the blendColor output component
  98492. */
  98493. get blendColor(): NodeMaterialConnectionPoint;
  98494. /**
  98495. * Initialize the block and prepare the context for build
  98496. * @param state defines the state that will be used for the build
  98497. */
  98498. initialize(state: NodeMaterialBuildState): void;
  98499. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98500. }
  98501. }
  98502. declare module BABYLON {
  98503. /**
  98504. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  98505. */
  98506. export class VectorMergerBlock extends NodeMaterialBlock {
  98507. /**
  98508. * Create a new VectorMergerBlock
  98509. * @param name defines the block name
  98510. */
  98511. constructor(name: string);
  98512. /**
  98513. * Gets the current class name
  98514. * @returns the class name
  98515. */
  98516. getClassName(): string;
  98517. /**
  98518. * Gets the xyz component (input)
  98519. */
  98520. get xyzIn(): NodeMaterialConnectionPoint;
  98521. /**
  98522. * Gets the xy component (input)
  98523. */
  98524. get xyIn(): NodeMaterialConnectionPoint;
  98525. /**
  98526. * Gets the x component (input)
  98527. */
  98528. get x(): NodeMaterialConnectionPoint;
  98529. /**
  98530. * Gets the y component (input)
  98531. */
  98532. get y(): NodeMaterialConnectionPoint;
  98533. /**
  98534. * Gets the z component (input)
  98535. */
  98536. get z(): NodeMaterialConnectionPoint;
  98537. /**
  98538. * Gets the w component (input)
  98539. */
  98540. get w(): NodeMaterialConnectionPoint;
  98541. /**
  98542. * Gets the xyzw component (output)
  98543. */
  98544. get xyzw(): NodeMaterialConnectionPoint;
  98545. /**
  98546. * Gets the xyz component (output)
  98547. */
  98548. get xyzOut(): NodeMaterialConnectionPoint;
  98549. /**
  98550. * Gets the xy component (output)
  98551. */
  98552. get xyOut(): NodeMaterialConnectionPoint;
  98553. /**
  98554. * Gets the xy component (output)
  98555. * @deprecated Please use xyOut instead.
  98556. */
  98557. get xy(): NodeMaterialConnectionPoint;
  98558. /**
  98559. * Gets the xyz component (output)
  98560. * @deprecated Please use xyzOut instead.
  98561. */
  98562. get xyz(): NodeMaterialConnectionPoint;
  98563. protected _buildBlock(state: NodeMaterialBuildState): this;
  98564. }
  98565. }
  98566. declare module BABYLON {
  98567. /**
  98568. * Block used to remap a float from a range to a new one
  98569. */
  98570. export class RemapBlock extends NodeMaterialBlock {
  98571. /**
  98572. * Gets or sets the source range
  98573. */
  98574. sourceRange: Vector2;
  98575. /**
  98576. * Gets or sets the target range
  98577. */
  98578. targetRange: Vector2;
  98579. /**
  98580. * Creates a new RemapBlock
  98581. * @param name defines the block name
  98582. */
  98583. constructor(name: string);
  98584. /**
  98585. * Gets the current class name
  98586. * @returns the class name
  98587. */
  98588. getClassName(): string;
  98589. /**
  98590. * Gets the input component
  98591. */
  98592. get input(): NodeMaterialConnectionPoint;
  98593. /**
  98594. * Gets the source min input component
  98595. */
  98596. get sourceMin(): NodeMaterialConnectionPoint;
  98597. /**
  98598. * Gets the source max input component
  98599. */
  98600. get sourceMax(): NodeMaterialConnectionPoint;
  98601. /**
  98602. * Gets the target min input component
  98603. */
  98604. get targetMin(): NodeMaterialConnectionPoint;
  98605. /**
  98606. * Gets the target max input component
  98607. */
  98608. get targetMax(): NodeMaterialConnectionPoint;
  98609. /**
  98610. * Gets the output component
  98611. */
  98612. get output(): NodeMaterialConnectionPoint;
  98613. protected _buildBlock(state: NodeMaterialBuildState): this;
  98614. protected _dumpPropertiesCode(): string;
  98615. serialize(): any;
  98616. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98617. }
  98618. }
  98619. declare module BABYLON {
  98620. /**
  98621. * Block used to multiply 2 values
  98622. */
  98623. export class MultiplyBlock extends NodeMaterialBlock {
  98624. /**
  98625. * Creates a new MultiplyBlock
  98626. * @param name defines the block name
  98627. */
  98628. constructor(name: string);
  98629. /**
  98630. * Gets the current class name
  98631. * @returns the class name
  98632. */
  98633. getClassName(): string;
  98634. /**
  98635. * Gets the left operand input component
  98636. */
  98637. get left(): NodeMaterialConnectionPoint;
  98638. /**
  98639. * Gets the right operand input component
  98640. */
  98641. get right(): NodeMaterialConnectionPoint;
  98642. /**
  98643. * Gets the output component
  98644. */
  98645. get output(): NodeMaterialConnectionPoint;
  98646. protected _buildBlock(state: NodeMaterialBuildState): this;
  98647. }
  98648. }
  98649. declare module BABYLON {
  98650. /** Interface used by value gradients (color, factor, ...) */
  98651. export interface IValueGradient {
  98652. /**
  98653. * Gets or sets the gradient value (between 0 and 1)
  98654. */
  98655. gradient: number;
  98656. }
  98657. /** Class used to store color4 gradient */
  98658. export class ColorGradient implements IValueGradient {
  98659. /**
  98660. * Gets or sets the gradient value (between 0 and 1)
  98661. */
  98662. gradient: number;
  98663. /**
  98664. * Gets or sets first associated color
  98665. */
  98666. color1: Color4;
  98667. /**
  98668. * Gets or sets second associated color
  98669. */
  98670. color2?: Color4 | undefined;
  98671. /**
  98672. * Creates a new color4 gradient
  98673. * @param gradient gets or sets the gradient value (between 0 and 1)
  98674. * @param color1 gets or sets first associated color
  98675. * @param color2 gets or sets first second color
  98676. */
  98677. constructor(
  98678. /**
  98679. * Gets or sets the gradient value (between 0 and 1)
  98680. */
  98681. gradient: number,
  98682. /**
  98683. * Gets or sets first associated color
  98684. */
  98685. color1: Color4,
  98686. /**
  98687. * Gets or sets second associated color
  98688. */
  98689. color2?: Color4 | undefined);
  98690. /**
  98691. * Will get a color picked randomly between color1 and color2.
  98692. * If color2 is undefined then color1 will be used
  98693. * @param result defines the target Color4 to store the result in
  98694. */
  98695. getColorToRef(result: Color4): void;
  98696. }
  98697. /** Class used to store color 3 gradient */
  98698. export class Color3Gradient implements IValueGradient {
  98699. /**
  98700. * Gets or sets the gradient value (between 0 and 1)
  98701. */
  98702. gradient: number;
  98703. /**
  98704. * Gets or sets the associated color
  98705. */
  98706. color: Color3;
  98707. /**
  98708. * Creates a new color3 gradient
  98709. * @param gradient gets or sets the gradient value (between 0 and 1)
  98710. * @param color gets or sets associated color
  98711. */
  98712. constructor(
  98713. /**
  98714. * Gets or sets the gradient value (between 0 and 1)
  98715. */
  98716. gradient: number,
  98717. /**
  98718. * Gets or sets the associated color
  98719. */
  98720. color: Color3);
  98721. }
  98722. /** Class used to store factor gradient */
  98723. export class FactorGradient implements IValueGradient {
  98724. /**
  98725. * Gets or sets the gradient value (between 0 and 1)
  98726. */
  98727. gradient: number;
  98728. /**
  98729. * Gets or sets first associated factor
  98730. */
  98731. factor1: number;
  98732. /**
  98733. * Gets or sets second associated factor
  98734. */
  98735. factor2?: number | undefined;
  98736. /**
  98737. * Creates a new factor gradient
  98738. * @param gradient gets or sets the gradient value (between 0 and 1)
  98739. * @param factor1 gets or sets first associated factor
  98740. * @param factor2 gets or sets second associated factor
  98741. */
  98742. constructor(
  98743. /**
  98744. * Gets or sets the gradient value (between 0 and 1)
  98745. */
  98746. gradient: number,
  98747. /**
  98748. * Gets or sets first associated factor
  98749. */
  98750. factor1: number,
  98751. /**
  98752. * Gets or sets second associated factor
  98753. */
  98754. factor2?: number | undefined);
  98755. /**
  98756. * Will get a number picked randomly between factor1 and factor2.
  98757. * If factor2 is undefined then factor1 will be used
  98758. * @returns the picked number
  98759. */
  98760. getFactor(): number;
  98761. }
  98762. /**
  98763. * Helper used to simplify some generic gradient tasks
  98764. */
  98765. export class GradientHelper {
  98766. /**
  98767. * Gets the current gradient from an array of IValueGradient
  98768. * @param ratio defines the current ratio to get
  98769. * @param gradients defines the array of IValueGradient
  98770. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  98771. */
  98772. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  98773. }
  98774. }
  98775. declare module BABYLON {
  98776. interface ThinEngine {
  98777. /**
  98778. * Creates a raw texture
  98779. * @param data defines the data to store in the texture
  98780. * @param width defines the width of the texture
  98781. * @param height defines the height of the texture
  98782. * @param format defines the format of the data
  98783. * @param generateMipMaps defines if the engine should generate the mip levels
  98784. * @param invertY defines if data must be stored with Y axis inverted
  98785. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  98786. * @param compression defines the compression used (null by default)
  98787. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  98788. * @returns the raw texture inside an InternalTexture
  98789. */
  98790. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  98791. /**
  98792. * Update a raw texture
  98793. * @param texture defines the texture to update
  98794. * @param data defines the data to store in the texture
  98795. * @param format defines the format of the data
  98796. * @param invertY defines if data must be stored with Y axis inverted
  98797. */
  98798. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  98799. /**
  98800. * Update a raw texture
  98801. * @param texture defines the texture to update
  98802. * @param data defines the data to store in the texture
  98803. * @param format defines the format of the data
  98804. * @param invertY defines if data must be stored with Y axis inverted
  98805. * @param compression defines the compression used (null by default)
  98806. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  98807. */
  98808. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  98809. /**
  98810. * Creates a new raw cube texture
  98811. * @param data defines the array of data to use to create each face
  98812. * @param size defines the size of the textures
  98813. * @param format defines the format of the data
  98814. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  98815. * @param generateMipMaps defines if the engine should generate the mip levels
  98816. * @param invertY defines if data must be stored with Y axis inverted
  98817. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98818. * @param compression defines the compression used (null by default)
  98819. * @returns the cube texture as an InternalTexture
  98820. */
  98821. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  98822. /**
  98823. * Update a raw cube texture
  98824. * @param texture defines the texture to udpdate
  98825. * @param data defines the data to store
  98826. * @param format defines the data format
  98827. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  98828. * @param invertY defines if data must be stored with Y axis inverted
  98829. */
  98830. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  98831. /**
  98832. * Update a raw cube texture
  98833. * @param texture defines the texture to udpdate
  98834. * @param data defines the data to store
  98835. * @param format defines the data format
  98836. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  98837. * @param invertY defines if data must be stored with Y axis inverted
  98838. * @param compression defines the compression used (null by default)
  98839. */
  98840. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  98841. /**
  98842. * Update a raw cube texture
  98843. * @param texture defines the texture to udpdate
  98844. * @param data defines the data to store
  98845. * @param format defines the data format
  98846. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  98847. * @param invertY defines if data must be stored with Y axis inverted
  98848. * @param compression defines the compression used (null by default)
  98849. * @param level defines which level of the texture to update
  98850. */
  98851. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  98852. /**
  98853. * Creates a new raw cube texture from a specified url
  98854. * @param url defines the url where the data is located
  98855. * @param scene defines the current scene
  98856. * @param size defines the size of the textures
  98857. * @param format defines the format of the data
  98858. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  98859. * @param noMipmap defines if the engine should avoid generating the mip levels
  98860. * @param callback defines a callback used to extract texture data from loaded data
  98861. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  98862. * @param onLoad defines a callback called when texture is loaded
  98863. * @param onError defines a callback called if there is an error
  98864. * @returns the cube texture as an InternalTexture
  98865. */
  98866. 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;
  98867. /**
  98868. * Creates a new raw cube texture from a specified url
  98869. * @param url defines the url where the data is located
  98870. * @param scene defines the current scene
  98871. * @param size defines the size of the textures
  98872. * @param format defines the format of the data
  98873. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  98874. * @param noMipmap defines if the engine should avoid generating the mip levels
  98875. * @param callback defines a callback used to extract texture data from loaded data
  98876. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  98877. * @param onLoad defines a callback called when texture is loaded
  98878. * @param onError defines a callback called if there is an error
  98879. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98880. * @param invertY defines if data must be stored with Y axis inverted
  98881. * @returns the cube texture as an InternalTexture
  98882. */
  98883. 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;
  98884. /**
  98885. * Creates a new raw 3D texture
  98886. * @param data defines the data used to create the texture
  98887. * @param width defines the width of the texture
  98888. * @param height defines the height of the texture
  98889. * @param depth defines the depth of the texture
  98890. * @param format defines the format of the texture
  98891. * @param generateMipMaps defines if the engine must generate mip levels
  98892. * @param invertY defines if data must be stored with Y axis inverted
  98893. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98894. * @param compression defines the compressed used (can be null)
  98895. * @param textureType defines the compressed used (can be null)
  98896. * @returns a new raw 3D texture (stored in an InternalTexture)
  98897. */
  98898. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  98899. /**
  98900. * Update a raw 3D texture
  98901. * @param texture defines the texture to update
  98902. * @param data defines the data to store
  98903. * @param format defines the data format
  98904. * @param invertY defines if data must be stored with Y axis inverted
  98905. */
  98906. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  98907. /**
  98908. * Update a raw 3D texture
  98909. * @param texture defines the texture to update
  98910. * @param data defines the data to store
  98911. * @param format defines the data format
  98912. * @param invertY defines if data must be stored with Y axis inverted
  98913. * @param compression defines the used compression (can be null)
  98914. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  98915. */
  98916. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  98917. /**
  98918. * Creates a new raw 2D array texture
  98919. * @param data defines the data used to create the texture
  98920. * @param width defines the width of the texture
  98921. * @param height defines the height of the texture
  98922. * @param depth defines the number of layers of the texture
  98923. * @param format defines the format of the texture
  98924. * @param generateMipMaps defines if the engine must generate mip levels
  98925. * @param invertY defines if data must be stored with Y axis inverted
  98926. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98927. * @param compression defines the compressed used (can be null)
  98928. * @param textureType defines the compressed used (can be null)
  98929. * @returns a new raw 2D array texture (stored in an InternalTexture)
  98930. */
  98931. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  98932. /**
  98933. * Update a raw 2D array texture
  98934. * @param texture defines the texture to update
  98935. * @param data defines the data to store
  98936. * @param format defines the data format
  98937. * @param invertY defines if data must be stored with Y axis inverted
  98938. */
  98939. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  98940. /**
  98941. * Update a raw 2D array texture
  98942. * @param texture defines the texture to update
  98943. * @param data defines the data to store
  98944. * @param format defines the data format
  98945. * @param invertY defines if data must be stored with Y axis inverted
  98946. * @param compression defines the used compression (can be null)
  98947. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  98948. */
  98949. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  98950. }
  98951. }
  98952. declare module BABYLON {
  98953. /**
  98954. * Raw texture can help creating a texture directly from an array of data.
  98955. * This can be super useful if you either get the data from an uncompressed source or
  98956. * if you wish to create your texture pixel by pixel.
  98957. */
  98958. export class RawTexture extends Texture {
  98959. /**
  98960. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  98961. */
  98962. format: number;
  98963. /**
  98964. * Instantiates a new RawTexture.
  98965. * Raw texture can help creating a texture directly from an array of data.
  98966. * This can be super useful if you either get the data from an uncompressed source or
  98967. * if you wish to create your texture pixel by pixel.
  98968. * @param data define the array of data to use to create the texture
  98969. * @param width define the width of the texture
  98970. * @param height define the height of the texture
  98971. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  98972. * @param sceneOrEngine defines the scene or engine the texture will belong to
  98973. * @param generateMipMaps define whether mip maps should be generated or not
  98974. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  98975. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  98976. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  98977. */
  98978. constructor(data: ArrayBufferView, width: number, height: number,
  98979. /**
  98980. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  98981. */
  98982. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  98983. /**
  98984. * Updates the texture underlying data.
  98985. * @param data Define the new data of the texture
  98986. */
  98987. update(data: ArrayBufferView): void;
  98988. /**
  98989. * Creates a luminance texture from some data.
  98990. * @param data Define the texture data
  98991. * @param width Define the width of the texture
  98992. * @param height Define the height of the texture
  98993. * @param sceneOrEngine defines the scene or engine the texture will belong to
  98994. * @param generateMipMaps Define whether or not to create mip maps for the texture
  98995. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  98996. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  98997. * @returns the luminance texture
  98998. */
  98999. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  99000. /**
  99001. * Creates a luminance alpha texture from some data.
  99002. * @param data Define the texture data
  99003. * @param width Define the width of the texture
  99004. * @param height Define the height of the texture
  99005. * @param sceneOrEngine defines the scene or engine the texture will belong to
  99006. * @param generateMipMaps Define whether or not to create mip maps for the texture
  99007. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  99008. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  99009. * @returns the luminance alpha texture
  99010. */
  99011. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  99012. /**
  99013. * Creates an alpha texture from some data.
  99014. * @param data Define the texture data
  99015. * @param width Define the width of the texture
  99016. * @param height Define the height of the texture
  99017. * @param sceneOrEngine defines the scene or engine the texture will belong to
  99018. * @param generateMipMaps Define whether or not to create mip maps for the texture
  99019. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  99020. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  99021. * @returns the alpha texture
  99022. */
  99023. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  99024. /**
  99025. * Creates a RGB texture from some data.
  99026. * @param data Define the texture data
  99027. * @param width Define the width of the texture
  99028. * @param height Define the height of the texture
  99029. * @param sceneOrEngine defines the scene or engine the texture will belong to
  99030. * @param generateMipMaps Define whether or not to create mip maps for the texture
  99031. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  99032. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  99033. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  99034. * @returns the RGB alpha texture
  99035. */
  99036. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  99037. /**
  99038. * Creates a RGBA texture from some data.
  99039. * @param data Define the texture data
  99040. * @param width Define the width of the texture
  99041. * @param height Define the height of the texture
  99042. * @param sceneOrEngine defines the scene or engine the texture will belong to
  99043. * @param generateMipMaps Define whether or not to create mip maps for the texture
  99044. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  99045. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  99046. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  99047. * @returns the RGBA texture
  99048. */
  99049. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  99050. /**
  99051. * Creates a R texture from some data.
  99052. * @param data Define the texture data
  99053. * @param width Define the width of the texture
  99054. * @param height Define the height of the texture
  99055. * @param sceneOrEngine defines the scene or engine the texture will belong to
  99056. * @param generateMipMaps Define whether or not to create mip maps for the texture
  99057. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  99058. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  99059. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  99060. * @returns the R texture
  99061. */
  99062. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  99063. }
  99064. }
  99065. declare module BABYLON {
  99066. interface ThinEngine {
  99067. /**
  99068. * Update a dynamic index buffer
  99069. * @param indexBuffer defines the target index buffer
  99070. * @param indices defines the data to update
  99071. * @param offset defines the offset in the target index buffer where update should start
  99072. */
  99073. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  99074. /**
  99075. * Updates a dynamic vertex buffer.
  99076. * @param vertexBuffer the vertex buffer to update
  99077. * @param data the data used to update the vertex buffer
  99078. * @param byteOffset the byte offset of the data
  99079. * @param byteLength the byte length of the data
  99080. */
  99081. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  99082. }
  99083. }
  99084. declare module BABYLON {
  99085. interface AbstractScene {
  99086. /**
  99087. * The list of procedural textures added to the scene
  99088. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  99089. */
  99090. proceduralTextures: Array<ProceduralTexture>;
  99091. }
  99092. /**
  99093. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  99094. * in a given scene.
  99095. */
  99096. export class ProceduralTextureSceneComponent implements ISceneComponent {
  99097. /**
  99098. * The component name helpfull to identify the component in the list of scene components.
  99099. */
  99100. readonly name: string;
  99101. /**
  99102. * The scene the component belongs to.
  99103. */
  99104. scene: Scene;
  99105. /**
  99106. * Creates a new instance of the component for the given scene
  99107. * @param scene Defines the scene to register the component in
  99108. */
  99109. constructor(scene: Scene);
  99110. /**
  99111. * Registers the component in a given scene
  99112. */
  99113. register(): void;
  99114. /**
  99115. * Rebuilds the elements related to this component in case of
  99116. * context lost for instance.
  99117. */
  99118. rebuild(): void;
  99119. /**
  99120. * Disposes the component and the associated ressources.
  99121. */
  99122. dispose(): void;
  99123. private _beforeClear;
  99124. }
  99125. }
  99126. declare module BABYLON {
  99127. interface ThinEngine {
  99128. /**
  99129. * Creates a new render target cube texture
  99130. * @param size defines the size of the texture
  99131. * @param options defines the options used to create the texture
  99132. * @returns a new render target cube texture stored in an InternalTexture
  99133. */
  99134. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  99135. }
  99136. }
  99137. declare module BABYLON {
  99138. /** @hidden */
  99139. export var proceduralVertexShader: {
  99140. name: string;
  99141. shader: string;
  99142. };
  99143. }
  99144. declare module BABYLON {
  99145. /**
  99146. * 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.
  99147. * This is the base class of any Procedural texture and contains most of the shareable code.
  99148. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  99149. */
  99150. export class ProceduralTexture extends Texture {
  99151. /**
  99152. * Define if the texture is enabled or not (disabled texture will not render)
  99153. */
  99154. isEnabled: boolean;
  99155. /**
  99156. * Define if the texture must be cleared before rendering (default is true)
  99157. */
  99158. autoClear: boolean;
  99159. /**
  99160. * Callback called when the texture is generated
  99161. */
  99162. onGenerated: () => void;
  99163. /**
  99164. * Event raised when the texture is generated
  99165. */
  99166. onGeneratedObservable: Observable<ProceduralTexture>;
  99167. /**
  99168. * Event raised before the texture is generated
  99169. */
  99170. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  99171. /**
  99172. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  99173. */
  99174. nodeMaterialSource: Nullable<NodeMaterial>;
  99175. /** @hidden */
  99176. _generateMipMaps: boolean;
  99177. /** @hidden **/
  99178. _effect: Effect;
  99179. /** @hidden */
  99180. _textures: {
  99181. [key: string]: Texture;
  99182. };
  99183. /** @hidden */
  99184. protected _fallbackTexture: Nullable<Texture>;
  99185. private _size;
  99186. private _textureType;
  99187. private _currentRefreshId;
  99188. private _frameId;
  99189. private _refreshRate;
  99190. private _vertexBuffers;
  99191. private _indexBuffer;
  99192. private _uniforms;
  99193. private _samplers;
  99194. private _fragment;
  99195. private _floats;
  99196. private _ints;
  99197. private _floatsArrays;
  99198. private _colors3;
  99199. private _colors4;
  99200. private _vectors2;
  99201. private _vectors3;
  99202. private _matrices;
  99203. private _fallbackTextureUsed;
  99204. private _fullEngine;
  99205. private _cachedDefines;
  99206. private _contentUpdateId;
  99207. private _contentData;
  99208. /**
  99209. * Instantiates a new procedural texture.
  99210. * 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.
  99211. * This is the base class of any Procedural texture and contains most of the shareable code.
  99212. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  99213. * @param name Define the name of the texture
  99214. * @param size Define the size of the texture to create
  99215. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  99216. * @param scene Define the scene the texture belongs to
  99217. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  99218. * @param generateMipMaps Define if the texture should creates mip maps or not
  99219. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  99220. * @param textureType The FBO internal texture type
  99221. */
  99222. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  99223. /**
  99224. * The effect that is created when initializing the post process.
  99225. * @returns The created effect corresponding the the postprocess.
  99226. */
  99227. getEffect(): Effect;
  99228. /**
  99229. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  99230. * @returns an ArrayBufferView promise (Uint8Array or Float32Array)
  99231. */
  99232. getContent(): Nullable<Promise<ArrayBufferView>>;
  99233. private _createIndexBuffer;
  99234. /** @hidden */
  99235. _rebuild(): void;
  99236. /**
  99237. * Resets the texture in order to recreate its associated resources.
  99238. * This can be called in case of context loss
  99239. */
  99240. reset(): void;
  99241. protected _getDefines(): string;
  99242. /**
  99243. * Is the texture ready to be used ? (rendered at least once)
  99244. * @returns true if ready, otherwise, false.
  99245. */
  99246. isReady(): boolean;
  99247. /**
  99248. * Resets the refresh counter of the texture and start bak from scratch.
  99249. * Could be useful to regenerate the texture if it is setup to render only once.
  99250. */
  99251. resetRefreshCounter(): void;
  99252. /**
  99253. * Set the fragment shader to use in order to render the texture.
  99254. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  99255. */
  99256. setFragment(fragment: any): void;
  99257. /**
  99258. * Define the refresh rate of the texture or the rendering frequency.
  99259. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  99260. */
  99261. get refreshRate(): number;
  99262. set refreshRate(value: number);
  99263. /** @hidden */
  99264. _shouldRender(): boolean;
  99265. /**
  99266. * Get the size the texture is rendering at.
  99267. * @returns the size (on cube texture it is always squared)
  99268. */
  99269. getRenderSize(): RenderTargetTextureSize;
  99270. /**
  99271. * Resize the texture to new value.
  99272. * @param size Define the new size the texture should have
  99273. * @param generateMipMaps Define whether the new texture should create mip maps
  99274. */
  99275. resize(size: number, generateMipMaps: boolean): void;
  99276. private _checkUniform;
  99277. /**
  99278. * Set a texture in the shader program used to render.
  99279. * @param name Define the name of the uniform samplers as defined in the shader
  99280. * @param texture Define the texture to bind to this sampler
  99281. * @return the texture itself allowing "fluent" like uniform updates
  99282. */
  99283. setTexture(name: string, texture: Texture): ProceduralTexture;
  99284. /**
  99285. * Set a float in the shader.
  99286. * @param name Define the name of the uniform as defined in the shader
  99287. * @param value Define the value to give to the uniform
  99288. * @return the texture itself allowing "fluent" like uniform updates
  99289. */
  99290. setFloat(name: string, value: number): ProceduralTexture;
  99291. /**
  99292. * Set a int in the shader.
  99293. * @param name Define the name of the uniform as defined in the shader
  99294. * @param value Define the value to give to the uniform
  99295. * @return the texture itself allowing "fluent" like uniform updates
  99296. */
  99297. setInt(name: string, value: number): ProceduralTexture;
  99298. /**
  99299. * Set an array of floats in the shader.
  99300. * @param name Define the name of the uniform as defined in the shader
  99301. * @param value Define the value to give to the uniform
  99302. * @return the texture itself allowing "fluent" like uniform updates
  99303. */
  99304. setFloats(name: string, value: number[]): ProceduralTexture;
  99305. /**
  99306. * Set a vec3 in the shader from a Color3.
  99307. * @param name Define the name of the uniform as defined in the shader
  99308. * @param value Define the value to give to the uniform
  99309. * @return the texture itself allowing "fluent" like uniform updates
  99310. */
  99311. setColor3(name: string, value: Color3): ProceduralTexture;
  99312. /**
  99313. * Set a vec4 in the shader from a Color4.
  99314. * @param name Define the name of the uniform as defined in the shader
  99315. * @param value Define the value to give to the uniform
  99316. * @return the texture itself allowing "fluent" like uniform updates
  99317. */
  99318. setColor4(name: string, value: Color4): ProceduralTexture;
  99319. /**
  99320. * Set a vec2 in the shader from a Vector2.
  99321. * @param name Define the name of the uniform as defined in the shader
  99322. * @param value Define the value to give to the uniform
  99323. * @return the texture itself allowing "fluent" like uniform updates
  99324. */
  99325. setVector2(name: string, value: Vector2): ProceduralTexture;
  99326. /**
  99327. * Set a vec3 in the shader from a Vector3.
  99328. * @param name Define the name of the uniform as defined in the shader
  99329. * @param value Define the value to give to the uniform
  99330. * @return the texture itself allowing "fluent" like uniform updates
  99331. */
  99332. setVector3(name: string, value: Vector3): ProceduralTexture;
  99333. /**
  99334. * Set a mat4 in the shader from a MAtrix.
  99335. * @param name Define the name of the uniform as defined in the shader
  99336. * @param value Define the value to give to the uniform
  99337. * @return the texture itself allowing "fluent" like uniform updates
  99338. */
  99339. setMatrix(name: string, value: Matrix): ProceduralTexture;
  99340. /**
  99341. * Render the texture to its associated render target.
  99342. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  99343. */
  99344. render(useCameraPostProcess?: boolean): void;
  99345. /**
  99346. * Clone the texture.
  99347. * @returns the cloned texture
  99348. */
  99349. clone(): ProceduralTexture;
  99350. /**
  99351. * Dispose the texture and release its asoociated resources.
  99352. */
  99353. dispose(): void;
  99354. }
  99355. }
  99356. declare module BABYLON {
  99357. /**
  99358. * This represents the base class for particle system in Babylon.
  99359. * 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.
  99360. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  99361. * @example https://doc.babylonjs.com/babylon101/particles
  99362. */
  99363. export class BaseParticleSystem {
  99364. /**
  99365. * Source color is added to the destination color without alpha affecting the result
  99366. */
  99367. static BLENDMODE_ONEONE: number;
  99368. /**
  99369. * Blend current color and particle color using particle’s alpha
  99370. */
  99371. static BLENDMODE_STANDARD: number;
  99372. /**
  99373. * Add current color and particle color multiplied by particle’s alpha
  99374. */
  99375. static BLENDMODE_ADD: number;
  99376. /**
  99377. * Multiply current color with particle color
  99378. */
  99379. static BLENDMODE_MULTIPLY: number;
  99380. /**
  99381. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  99382. */
  99383. static BLENDMODE_MULTIPLYADD: number;
  99384. /**
  99385. * List of animations used by the particle system.
  99386. */
  99387. animations: Animation[];
  99388. /**
  99389. * Gets or sets the unique id of the particle system
  99390. */
  99391. uniqueId: number;
  99392. /**
  99393. * The id of the Particle system.
  99394. */
  99395. id: string;
  99396. /**
  99397. * The friendly name of the Particle system.
  99398. */
  99399. name: string;
  99400. /**
  99401. * Snippet ID if the particle system was created from the snippet server
  99402. */
  99403. snippetId: string;
  99404. /**
  99405. * The rendering group used by the Particle system to chose when to render.
  99406. */
  99407. renderingGroupId: number;
  99408. /**
  99409. * The emitter represents the Mesh or position we are attaching the particle system to.
  99410. */
  99411. emitter: Nullable<AbstractMesh | Vector3>;
  99412. /**
  99413. * The maximum number of particles to emit per frame
  99414. */
  99415. emitRate: number;
  99416. /**
  99417. * If you want to launch only a few particles at once, that can be done, as well.
  99418. */
  99419. manualEmitCount: number;
  99420. /**
  99421. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  99422. */
  99423. updateSpeed: number;
  99424. /**
  99425. * The amount of time the particle system is running (depends of the overall update speed).
  99426. */
  99427. targetStopDuration: number;
  99428. /**
  99429. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  99430. */
  99431. disposeOnStop: boolean;
  99432. /**
  99433. * Minimum power of emitting particles.
  99434. */
  99435. minEmitPower: number;
  99436. /**
  99437. * Maximum power of emitting particles.
  99438. */
  99439. maxEmitPower: number;
  99440. /**
  99441. * Minimum life time of emitting particles.
  99442. */
  99443. minLifeTime: number;
  99444. /**
  99445. * Maximum life time of emitting particles.
  99446. */
  99447. maxLifeTime: number;
  99448. /**
  99449. * Minimum Size of emitting particles.
  99450. */
  99451. minSize: number;
  99452. /**
  99453. * Maximum Size of emitting particles.
  99454. */
  99455. maxSize: number;
  99456. /**
  99457. * Minimum scale of emitting particles on X axis.
  99458. */
  99459. minScaleX: number;
  99460. /**
  99461. * Maximum scale of emitting particles on X axis.
  99462. */
  99463. maxScaleX: number;
  99464. /**
  99465. * Minimum scale of emitting particles on Y axis.
  99466. */
  99467. minScaleY: number;
  99468. /**
  99469. * Maximum scale of emitting particles on Y axis.
  99470. */
  99471. maxScaleY: number;
  99472. /**
  99473. * Gets or sets the minimal initial rotation in radians.
  99474. */
  99475. minInitialRotation: number;
  99476. /**
  99477. * Gets or sets the maximal initial rotation in radians.
  99478. */
  99479. maxInitialRotation: number;
  99480. /**
  99481. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  99482. */
  99483. minAngularSpeed: number;
  99484. /**
  99485. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  99486. */
  99487. maxAngularSpeed: number;
  99488. /**
  99489. * The texture used to render each particle. (this can be a spritesheet)
  99490. */
  99491. particleTexture: Nullable<BaseTexture>;
  99492. /**
  99493. * The layer mask we are rendering the particles through.
  99494. */
  99495. layerMask: number;
  99496. /**
  99497. * This can help using your own shader to render the particle system.
  99498. * The according effect will be created
  99499. */
  99500. customShader: any;
  99501. /**
  99502. * By default particle system starts as soon as they are created. This prevents the
  99503. * automatic start to happen and let you decide when to start emitting particles.
  99504. */
  99505. preventAutoStart: boolean;
  99506. private _noiseTexture;
  99507. /**
  99508. * Gets or sets a texture used to add random noise to particle positions
  99509. */
  99510. get noiseTexture(): Nullable<ProceduralTexture>;
  99511. set noiseTexture(value: Nullable<ProceduralTexture>);
  99512. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  99513. noiseStrength: Vector3;
  99514. /**
  99515. * Callback triggered when the particle animation is ending.
  99516. */
  99517. onAnimationEnd: Nullable<() => void>;
  99518. /**
  99519. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  99520. */
  99521. blendMode: number;
  99522. /**
  99523. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  99524. * to override the particles.
  99525. */
  99526. forceDepthWrite: boolean;
  99527. /** 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 */
  99528. preWarmCycles: number;
  99529. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  99530. preWarmStepOffset: number;
  99531. /**
  99532. * 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)
  99533. */
  99534. spriteCellChangeSpeed: number;
  99535. /**
  99536. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  99537. */
  99538. startSpriteCellID: number;
  99539. /**
  99540. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  99541. */
  99542. endSpriteCellID: number;
  99543. /**
  99544. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  99545. */
  99546. spriteCellWidth: number;
  99547. /**
  99548. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  99549. */
  99550. spriteCellHeight: number;
  99551. /**
  99552. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  99553. */
  99554. spriteRandomStartCell: boolean;
  99555. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  99556. translationPivot: Vector2;
  99557. /** @hidden */
  99558. protected _isAnimationSheetEnabled: boolean;
  99559. /**
  99560. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  99561. */
  99562. beginAnimationOnStart: boolean;
  99563. /**
  99564. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  99565. */
  99566. beginAnimationFrom: number;
  99567. /**
  99568. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  99569. */
  99570. beginAnimationTo: number;
  99571. /**
  99572. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  99573. */
  99574. beginAnimationLoop: boolean;
  99575. /**
  99576. * Gets or sets a world offset applied to all particles
  99577. */
  99578. worldOffset: Vector3;
  99579. /**
  99580. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  99581. */
  99582. get isAnimationSheetEnabled(): boolean;
  99583. set isAnimationSheetEnabled(value: boolean);
  99584. /**
  99585. * Get hosting scene
  99586. * @returns the scene
  99587. */
  99588. getScene(): Nullable<Scene>;
  99589. /**
  99590. * You can use gravity if you want to give an orientation to your particles.
  99591. */
  99592. gravity: Vector3;
  99593. protected _colorGradients: Nullable<Array<ColorGradient>>;
  99594. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  99595. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  99596. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  99597. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  99598. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  99599. protected _dragGradients: Nullable<Array<FactorGradient>>;
  99600. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  99601. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  99602. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  99603. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  99604. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  99605. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  99606. /**
  99607. * Defines the delay in milliseconds before starting the system (0 by default)
  99608. */
  99609. startDelay: number;
  99610. /**
  99611. * Gets the current list of drag gradients.
  99612. * You must use addDragGradient and removeDragGradient to udpate this list
  99613. * @returns the list of drag gradients
  99614. */
  99615. getDragGradients(): Nullable<Array<FactorGradient>>;
  99616. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  99617. limitVelocityDamping: number;
  99618. /**
  99619. * Gets the current list of limit velocity gradients.
  99620. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  99621. * @returns the list of limit velocity gradients
  99622. */
  99623. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  99624. /**
  99625. * Gets the current list of color gradients.
  99626. * You must use addColorGradient and removeColorGradient to udpate this list
  99627. * @returns the list of color gradients
  99628. */
  99629. getColorGradients(): Nullable<Array<ColorGradient>>;
  99630. /**
  99631. * Gets the current list of size gradients.
  99632. * You must use addSizeGradient and removeSizeGradient to udpate this list
  99633. * @returns the list of size gradients
  99634. */
  99635. getSizeGradients(): Nullable<Array<FactorGradient>>;
  99636. /**
  99637. * Gets the current list of color remap gradients.
  99638. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  99639. * @returns the list of color remap gradients
  99640. */
  99641. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  99642. /**
  99643. * Gets the current list of alpha remap gradients.
  99644. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  99645. * @returns the list of alpha remap gradients
  99646. */
  99647. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  99648. /**
  99649. * Gets the current list of life time gradients.
  99650. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  99651. * @returns the list of life time gradients
  99652. */
  99653. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  99654. /**
  99655. * Gets the current list of angular speed gradients.
  99656. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  99657. * @returns the list of angular speed gradients
  99658. */
  99659. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  99660. /**
  99661. * Gets the current list of velocity gradients.
  99662. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  99663. * @returns the list of velocity gradients
  99664. */
  99665. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  99666. /**
  99667. * Gets the current list of start size gradients.
  99668. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  99669. * @returns the list of start size gradients
  99670. */
  99671. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  99672. /**
  99673. * Gets the current list of emit rate gradients.
  99674. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  99675. * @returns the list of emit rate gradients
  99676. */
  99677. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  99678. /**
  99679. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  99680. * This only works when particleEmitterTyps is a BoxParticleEmitter
  99681. */
  99682. get direction1(): Vector3;
  99683. set direction1(value: Vector3);
  99684. /**
  99685. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  99686. * This only works when particleEmitterTyps is a BoxParticleEmitter
  99687. */
  99688. get direction2(): Vector3;
  99689. set direction2(value: Vector3);
  99690. /**
  99691. * 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.
  99692. * This only works when particleEmitterTyps is a BoxParticleEmitter
  99693. */
  99694. get minEmitBox(): Vector3;
  99695. set minEmitBox(value: Vector3);
  99696. /**
  99697. * 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.
  99698. * This only works when particleEmitterTyps is a BoxParticleEmitter
  99699. */
  99700. get maxEmitBox(): Vector3;
  99701. set maxEmitBox(value: Vector3);
  99702. /**
  99703. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  99704. */
  99705. color1: Color4;
  99706. /**
  99707. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  99708. */
  99709. color2: Color4;
  99710. /**
  99711. * Color the particle will have at the end of its lifetime
  99712. */
  99713. colorDead: Color4;
  99714. /**
  99715. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  99716. */
  99717. textureMask: Color4;
  99718. /**
  99719. * The particle emitter type defines the emitter used by the particle system.
  99720. * It can be for example box, sphere, or cone...
  99721. */
  99722. particleEmitterType: IParticleEmitterType;
  99723. /** @hidden */
  99724. _isSubEmitter: boolean;
  99725. /**
  99726. * Gets or sets the billboard mode to use when isBillboardBased = true.
  99727. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  99728. */
  99729. billboardMode: number;
  99730. protected _isBillboardBased: boolean;
  99731. /**
  99732. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  99733. */
  99734. get isBillboardBased(): boolean;
  99735. set isBillboardBased(value: boolean);
  99736. /**
  99737. * The scene the particle system belongs to.
  99738. */
  99739. protected _scene: Nullable<Scene>;
  99740. /**
  99741. * The engine the particle system belongs to.
  99742. */
  99743. protected _engine: ThinEngine;
  99744. /**
  99745. * Local cache of defines for image processing.
  99746. */
  99747. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  99748. /**
  99749. * Default configuration related to image processing available in the standard Material.
  99750. */
  99751. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  99752. /**
  99753. * Gets the image processing configuration used either in this material.
  99754. */
  99755. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  99756. /**
  99757. * Sets the Default image processing configuration used either in the this material.
  99758. *
  99759. * If sets to null, the scene one is in use.
  99760. */
  99761. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  99762. /**
  99763. * Attaches a new image processing configuration to the Standard Material.
  99764. * @param configuration
  99765. */
  99766. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99767. /** @hidden */
  99768. protected _reset(): void;
  99769. /** @hidden */
  99770. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  99771. /**
  99772. * Instantiates a particle system.
  99773. * 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.
  99774. * @param name The name of the particle system
  99775. */
  99776. constructor(name: string);
  99777. /**
  99778. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  99779. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  99780. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  99781. * @returns the emitter
  99782. */
  99783. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  99784. /**
  99785. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  99786. * @param radius The radius of the hemisphere to emit from
  99787. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  99788. * @returns the emitter
  99789. */
  99790. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  99791. /**
  99792. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  99793. * @param radius The radius of the sphere to emit from
  99794. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  99795. * @returns the emitter
  99796. */
  99797. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  99798. /**
  99799. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  99800. * @param radius The radius of the sphere to emit from
  99801. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  99802. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  99803. * @returns the emitter
  99804. */
  99805. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  99806. /**
  99807. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  99808. * @param radius The radius of the emission cylinder
  99809. * @param height The height of the emission cylinder
  99810. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  99811. * @param directionRandomizer How much to randomize the particle direction [0-1]
  99812. * @returns the emitter
  99813. */
  99814. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  99815. /**
  99816. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  99817. * @param radius The radius of the cylinder to emit from
  99818. * @param height The height of the emission cylinder
  99819. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  99820. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  99821. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  99822. * @returns the emitter
  99823. */
  99824. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  99825. /**
  99826. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  99827. * @param radius The radius of the cone to emit from
  99828. * @param angle The base angle of the cone
  99829. * @returns the emitter
  99830. */
  99831. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  99832. /**
  99833. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  99834. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  99835. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  99836. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  99837. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  99838. * @returns the emitter
  99839. */
  99840. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  99841. }
  99842. }
  99843. declare module BABYLON {
  99844. /**
  99845. * Type of sub emitter
  99846. */
  99847. export enum SubEmitterType {
  99848. /**
  99849. * Attached to the particle over it's lifetime
  99850. */
  99851. ATTACHED = 0,
  99852. /**
  99853. * Created when the particle dies
  99854. */
  99855. END = 1
  99856. }
  99857. /**
  99858. * Sub emitter class used to emit particles from an existing particle
  99859. */
  99860. export class SubEmitter {
  99861. /**
  99862. * the particle system to be used by the sub emitter
  99863. */
  99864. particleSystem: ParticleSystem;
  99865. /**
  99866. * Type of the submitter (Default: END)
  99867. */
  99868. type: SubEmitterType;
  99869. /**
  99870. * 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)
  99871. * Note: This only is supported when using an emitter of type Mesh
  99872. */
  99873. inheritDirection: boolean;
  99874. /**
  99875. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  99876. */
  99877. inheritedVelocityAmount: number;
  99878. /**
  99879. * Creates a sub emitter
  99880. * @param particleSystem the particle system to be used by the sub emitter
  99881. */
  99882. constructor(
  99883. /**
  99884. * the particle system to be used by the sub emitter
  99885. */
  99886. particleSystem: ParticleSystem);
  99887. /**
  99888. * Clones the sub emitter
  99889. * @returns the cloned sub emitter
  99890. */
  99891. clone(): SubEmitter;
  99892. /**
  99893. * Serialize current object to a JSON object
  99894. * @returns the serialized object
  99895. */
  99896. serialize(): any;
  99897. /** @hidden */
  99898. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  99899. /**
  99900. * Creates a new SubEmitter from a serialized JSON version
  99901. * @param serializationObject defines the JSON object to read from
  99902. * @param sceneOrEngine defines the hosting scene or the hosting engine
  99903. * @param rootUrl defines the rootUrl for data loading
  99904. * @returns a new SubEmitter
  99905. */
  99906. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  99907. /** Release associated resources */
  99908. dispose(): void;
  99909. }
  99910. }
  99911. declare module BABYLON {
  99912. /** @hidden */
  99913. export var clipPlaneFragmentDeclaration: {
  99914. name: string;
  99915. shader: string;
  99916. };
  99917. }
  99918. declare module BABYLON {
  99919. /** @hidden */
  99920. export var imageProcessingDeclaration: {
  99921. name: string;
  99922. shader: string;
  99923. };
  99924. }
  99925. declare module BABYLON {
  99926. /** @hidden */
  99927. export var imageProcessingFunctions: {
  99928. name: string;
  99929. shader: string;
  99930. };
  99931. }
  99932. declare module BABYLON {
  99933. /** @hidden */
  99934. export var clipPlaneFragment: {
  99935. name: string;
  99936. shader: string;
  99937. };
  99938. }
  99939. declare module BABYLON {
  99940. /** @hidden */
  99941. export var particlesPixelShader: {
  99942. name: string;
  99943. shader: string;
  99944. };
  99945. }
  99946. declare module BABYLON {
  99947. /** @hidden */
  99948. export var clipPlaneVertexDeclaration: {
  99949. name: string;
  99950. shader: string;
  99951. };
  99952. }
  99953. declare module BABYLON {
  99954. /** @hidden */
  99955. export var clipPlaneVertex: {
  99956. name: string;
  99957. shader: string;
  99958. };
  99959. }
  99960. declare module BABYLON {
  99961. /** @hidden */
  99962. export var particlesVertexShader: {
  99963. name: string;
  99964. shader: string;
  99965. };
  99966. }
  99967. declare module BABYLON {
  99968. /**
  99969. * Interface used to define entities containing multiple clip planes
  99970. */
  99971. export interface IClipPlanesHolder {
  99972. /**
  99973. * Gets or sets the active clipplane 1
  99974. */
  99975. clipPlane: Nullable<Plane>;
  99976. /**
  99977. * Gets or sets the active clipplane 2
  99978. */
  99979. clipPlane2: Nullable<Plane>;
  99980. /**
  99981. * Gets or sets the active clipplane 3
  99982. */
  99983. clipPlane3: Nullable<Plane>;
  99984. /**
  99985. * Gets or sets the active clipplane 4
  99986. */
  99987. clipPlane4: Nullable<Plane>;
  99988. /**
  99989. * Gets or sets the active clipplane 5
  99990. */
  99991. clipPlane5: Nullable<Plane>;
  99992. /**
  99993. * Gets or sets the active clipplane 6
  99994. */
  99995. clipPlane6: Nullable<Plane>;
  99996. }
  99997. }
  99998. declare module BABYLON {
  99999. /**
  100000. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  100001. *
  100002. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  100003. *
  100004. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  100005. */
  100006. export class ThinMaterialHelper {
  100007. /**
  100008. * Binds the clip plane information from the holder to the effect.
  100009. * @param effect The effect we are binding the data to
  100010. * @param holder The entity containing the clip plane information
  100011. */
  100012. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  100013. }
  100014. }
  100015. declare module BABYLON {
  100016. interface ThinEngine {
  100017. /**
  100018. * Sets alpha constants used by some alpha blending modes
  100019. * @param r defines the red component
  100020. * @param g defines the green component
  100021. * @param b defines the blue component
  100022. * @param a defines the alpha component
  100023. */
  100024. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  100025. /**
  100026. * Sets the current alpha mode
  100027. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  100028. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  100029. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  100030. */
  100031. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  100032. /**
  100033. * Gets the current alpha mode
  100034. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  100035. * @returns the current alpha mode
  100036. */
  100037. getAlphaMode(): number;
  100038. /**
  100039. * Sets the current alpha equation
  100040. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  100041. */
  100042. setAlphaEquation(equation: number): void;
  100043. /**
  100044. * Gets the current alpha equation.
  100045. * @returns the current alpha equation
  100046. */
  100047. getAlphaEquation(): number;
  100048. }
  100049. }
  100050. declare module BABYLON {
  100051. /**
  100052. * This represents a particle system in Babylon.
  100053. * 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.
  100054. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  100055. * @example https://doc.babylonjs.com/babylon101/particles
  100056. */
  100057. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  100058. /**
  100059. * Billboard mode will only apply to Y axis
  100060. */
  100061. static readonly BILLBOARDMODE_Y: number;
  100062. /**
  100063. * Billboard mode will apply to all axes
  100064. */
  100065. static readonly BILLBOARDMODE_ALL: number;
  100066. /**
  100067. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  100068. */
  100069. static readonly BILLBOARDMODE_STRETCHED: number;
  100070. /**
  100071. * This function can be defined to provide custom update for active particles.
  100072. * This function will be called instead of regular update (age, position, color, etc.).
  100073. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  100074. */
  100075. updateFunction: (particles: Particle[]) => void;
  100076. private _emitterWorldMatrix;
  100077. /**
  100078. * This function can be defined to specify initial direction for every new particle.
  100079. * It by default use the emitterType defined function
  100080. */
  100081. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  100082. /**
  100083. * This function can be defined to specify initial position for every new particle.
  100084. * It by default use the emitterType defined function
  100085. */
  100086. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  100087. /**
  100088. * @hidden
  100089. */
  100090. _inheritedVelocityOffset: Vector3;
  100091. /**
  100092. * An event triggered when the system is disposed
  100093. */
  100094. onDisposeObservable: Observable<IParticleSystem>;
  100095. /**
  100096. * An event triggered when the system is stopped
  100097. */
  100098. onStoppedObservable: Observable<IParticleSystem>;
  100099. private _onDisposeObserver;
  100100. /**
  100101. * Sets a callback that will be triggered when the system is disposed
  100102. */
  100103. set onDispose(callback: () => void);
  100104. private _particles;
  100105. private _epsilon;
  100106. private _capacity;
  100107. private _stockParticles;
  100108. private _newPartsExcess;
  100109. private _vertexData;
  100110. private _vertexBuffer;
  100111. private _vertexBuffers;
  100112. private _spriteBuffer;
  100113. private _indexBuffer;
  100114. private _effect;
  100115. private _customEffect;
  100116. private _cachedDefines;
  100117. private _scaledColorStep;
  100118. private _colorDiff;
  100119. private _scaledDirection;
  100120. private _scaledGravity;
  100121. private _currentRenderId;
  100122. private _alive;
  100123. private _useInstancing;
  100124. private _vertexArrayObject;
  100125. private _started;
  100126. private _stopped;
  100127. private _actualFrame;
  100128. private _scaledUpdateSpeed;
  100129. private _vertexBufferSize;
  100130. /** @hidden */
  100131. _currentEmitRateGradient: Nullable<FactorGradient>;
  100132. /** @hidden */
  100133. _currentEmitRate1: number;
  100134. /** @hidden */
  100135. _currentEmitRate2: number;
  100136. /** @hidden */
  100137. _currentStartSizeGradient: Nullable<FactorGradient>;
  100138. /** @hidden */
  100139. _currentStartSize1: number;
  100140. /** @hidden */
  100141. _currentStartSize2: number;
  100142. private readonly _rawTextureWidth;
  100143. private _rampGradientsTexture;
  100144. private _useRampGradients;
  100145. /** Gets or sets a matrix to use to compute projection */
  100146. defaultProjectionMatrix: Matrix;
  100147. /** Gets or sets a matrix to use to compute view */
  100148. defaultViewMatrix: Matrix;
  100149. /** Gets or sets a boolean indicating that ramp gradients must be used
  100150. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  100151. */
  100152. get useRampGradients(): boolean;
  100153. set useRampGradients(value: boolean);
  100154. /**
  100155. * 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.
  100156. * 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: [])
  100157. */
  100158. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  100159. private _subEmitters;
  100160. /**
  100161. * @hidden
  100162. * If the particle systems emitter should be disposed when the particle system is disposed
  100163. */
  100164. _disposeEmitterOnDispose: boolean;
  100165. /**
  100166. * The current active Sub-systems, this property is used by the root particle system only.
  100167. */
  100168. activeSubSystems: Array<ParticleSystem>;
  100169. /**
  100170. * Specifies if the particles are updated in emitter local space or world space
  100171. */
  100172. isLocal: boolean;
  100173. private _rootParticleSystem;
  100174. /**
  100175. * Gets the current list of active particles
  100176. */
  100177. get particles(): Particle[];
  100178. /**
  100179. * Gets the number of particles active at the same time.
  100180. * @returns The number of active particles.
  100181. */
  100182. getActiveCount(): number;
  100183. /**
  100184. * Returns the string "ParticleSystem"
  100185. * @returns a string containing the class name
  100186. */
  100187. getClassName(): string;
  100188. /**
  100189. * Gets a boolean indicating that the system is stopping
  100190. * @returns true if the system is currently stopping
  100191. */
  100192. isStopping(): boolean;
  100193. /**
  100194. * Gets the custom effect used to render the particles
  100195. * @param blendMode Blend mode for which the effect should be retrieved
  100196. * @returns The effect
  100197. */
  100198. getCustomEffect(blendMode?: number): Nullable<Effect>;
  100199. /**
  100200. * Sets the custom effect used to render the particles
  100201. * @param effect The effect to set
  100202. * @param blendMode Blend mode for which the effect should be set
  100203. */
  100204. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  100205. /** @hidden */
  100206. private _onBeforeDrawParticlesObservable;
  100207. /**
  100208. * Observable that will be called just before the particles are drawn
  100209. */
  100210. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  100211. /**
  100212. * Gets the name of the particle vertex shader
  100213. */
  100214. get vertexShaderName(): string;
  100215. /**
  100216. * Instantiates a particle system.
  100217. * 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.
  100218. * @param name The name of the particle system
  100219. * @param capacity The max number of particles alive at the same time
  100220. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  100221. * @param customEffect a custom effect used to change the way particles are rendered by default
  100222. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  100223. * @param epsilon Offset used to render the particles
  100224. */
  100225. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  100226. private _addFactorGradient;
  100227. private _removeFactorGradient;
  100228. /**
  100229. * Adds a new life time gradient
  100230. * @param gradient defines the gradient to use (between 0 and 1)
  100231. * @param factor defines the life time factor to affect to the specified gradient
  100232. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  100233. * @returns the current particle system
  100234. */
  100235. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  100236. /**
  100237. * Remove a specific life time gradient
  100238. * @param gradient defines the gradient to remove
  100239. * @returns the current particle system
  100240. */
  100241. removeLifeTimeGradient(gradient: number): IParticleSystem;
  100242. /**
  100243. * Adds a new size gradient
  100244. * @param gradient defines the gradient to use (between 0 and 1)
  100245. * @param factor defines the size factor to affect to the specified gradient
  100246. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  100247. * @returns the current particle system
  100248. */
  100249. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  100250. /**
  100251. * Remove a specific size gradient
  100252. * @param gradient defines the gradient to remove
  100253. * @returns the current particle system
  100254. */
  100255. removeSizeGradient(gradient: number): IParticleSystem;
  100256. /**
  100257. * Adds a new color remap gradient
  100258. * @param gradient defines the gradient to use (between 0 and 1)
  100259. * @param min defines the color remap minimal range
  100260. * @param max defines the color remap maximal range
  100261. * @returns the current particle system
  100262. */
  100263. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  100264. /**
  100265. * Remove a specific color remap gradient
  100266. * @param gradient defines the gradient to remove
  100267. * @returns the current particle system
  100268. */
  100269. removeColorRemapGradient(gradient: number): IParticleSystem;
  100270. /**
  100271. * Adds a new alpha remap gradient
  100272. * @param gradient defines the gradient to use (between 0 and 1)
  100273. * @param min defines the alpha remap minimal range
  100274. * @param max defines the alpha remap maximal range
  100275. * @returns the current particle system
  100276. */
  100277. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  100278. /**
  100279. * Remove a specific alpha remap gradient
  100280. * @param gradient defines the gradient to remove
  100281. * @returns the current particle system
  100282. */
  100283. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  100284. /**
  100285. * Adds a new angular speed gradient
  100286. * @param gradient defines the gradient to use (between 0 and 1)
  100287. * @param factor defines the angular speed to affect to the specified gradient
  100288. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  100289. * @returns the current particle system
  100290. */
  100291. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  100292. /**
  100293. * Remove a specific angular speed gradient
  100294. * @param gradient defines the gradient to remove
  100295. * @returns the current particle system
  100296. */
  100297. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  100298. /**
  100299. * Adds a new velocity gradient
  100300. * @param gradient defines the gradient to use (between 0 and 1)
  100301. * @param factor defines the velocity to affect to the specified gradient
  100302. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  100303. * @returns the current particle system
  100304. */
  100305. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  100306. /**
  100307. * Remove a specific velocity gradient
  100308. * @param gradient defines the gradient to remove
  100309. * @returns the current particle system
  100310. */
  100311. removeVelocityGradient(gradient: number): IParticleSystem;
  100312. /**
  100313. * Adds a new limit velocity gradient
  100314. * @param gradient defines the gradient to use (between 0 and 1)
  100315. * @param factor defines the limit velocity value to affect to the specified gradient
  100316. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  100317. * @returns the current particle system
  100318. */
  100319. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  100320. /**
  100321. * Remove a specific limit velocity gradient
  100322. * @param gradient defines the gradient to remove
  100323. * @returns the current particle system
  100324. */
  100325. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  100326. /**
  100327. * Adds a new drag gradient
  100328. * @param gradient defines the gradient to use (between 0 and 1)
  100329. * @param factor defines the drag value to affect to the specified gradient
  100330. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  100331. * @returns the current particle system
  100332. */
  100333. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  100334. /**
  100335. * Remove a specific drag gradient
  100336. * @param gradient defines the gradient to remove
  100337. * @returns the current particle system
  100338. */
  100339. removeDragGradient(gradient: number): IParticleSystem;
  100340. /**
  100341. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  100342. * @param gradient defines the gradient to use (between 0 and 1)
  100343. * @param factor defines the emit rate value to affect to the specified gradient
  100344. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  100345. * @returns the current particle system
  100346. */
  100347. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  100348. /**
  100349. * Remove a specific emit rate gradient
  100350. * @param gradient defines the gradient to remove
  100351. * @returns the current particle system
  100352. */
  100353. removeEmitRateGradient(gradient: number): IParticleSystem;
  100354. /**
  100355. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  100356. * @param gradient defines the gradient to use (between 0 and 1)
  100357. * @param factor defines the start size value to affect to the specified gradient
  100358. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  100359. * @returns the current particle system
  100360. */
  100361. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  100362. /**
  100363. * Remove a specific start size gradient
  100364. * @param gradient defines the gradient to remove
  100365. * @returns the current particle system
  100366. */
  100367. removeStartSizeGradient(gradient: number): IParticleSystem;
  100368. private _createRampGradientTexture;
  100369. /**
  100370. * Gets the current list of ramp gradients.
  100371. * You must use addRampGradient and removeRampGradient to udpate this list
  100372. * @returns the list of ramp gradients
  100373. */
  100374. getRampGradients(): Nullable<Array<Color3Gradient>>;
  100375. /** Force the system to rebuild all gradients that need to be resync */
  100376. forceRefreshGradients(): void;
  100377. private _syncRampGradientTexture;
  100378. /**
  100379. * Adds a new ramp gradient used to remap particle colors
  100380. * @param gradient defines the gradient to use (between 0 and 1)
  100381. * @param color defines the color to affect to the specified gradient
  100382. * @returns the current particle system
  100383. */
  100384. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  100385. /**
  100386. * Remove a specific ramp gradient
  100387. * @param gradient defines the gradient to remove
  100388. * @returns the current particle system
  100389. */
  100390. removeRampGradient(gradient: number): ParticleSystem;
  100391. /**
  100392. * Adds a new color gradient
  100393. * @param gradient defines the gradient to use (between 0 and 1)
  100394. * @param color1 defines the color to affect to the specified gradient
  100395. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  100396. * @returns this particle system
  100397. */
  100398. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  100399. /**
  100400. * Remove a specific color gradient
  100401. * @param gradient defines the gradient to remove
  100402. * @returns this particle system
  100403. */
  100404. removeColorGradient(gradient: number): IParticleSystem;
  100405. private _fetchR;
  100406. protected _reset(): void;
  100407. private _resetEffect;
  100408. private _createVertexBuffers;
  100409. private _createIndexBuffer;
  100410. /**
  100411. * Gets the maximum number of particles active at the same time.
  100412. * @returns The max number of active particles.
  100413. */
  100414. getCapacity(): number;
  100415. /**
  100416. * Gets whether there are still active particles in the system.
  100417. * @returns True if it is alive, otherwise false.
  100418. */
  100419. isAlive(): boolean;
  100420. /**
  100421. * Gets if the system has been started. (Note: this will still be true after stop is called)
  100422. * @returns True if it has been started, otherwise false.
  100423. */
  100424. isStarted(): boolean;
  100425. private _prepareSubEmitterInternalArray;
  100426. /**
  100427. * Starts the particle system and begins to emit
  100428. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  100429. */
  100430. start(delay?: number): void;
  100431. /**
  100432. * Stops the particle system.
  100433. * @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.
  100434. */
  100435. stop(stopSubEmitters?: boolean): void;
  100436. /**
  100437. * Remove all active particles
  100438. */
  100439. reset(): void;
  100440. /**
  100441. * @hidden (for internal use only)
  100442. */
  100443. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  100444. /**
  100445. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  100446. * Its lifetime will start back at 0.
  100447. */
  100448. recycleParticle: (particle: Particle) => void;
  100449. private _stopSubEmitters;
  100450. private _createParticle;
  100451. private _removeFromRoot;
  100452. private _emitFromParticle;
  100453. private _update;
  100454. /** @hidden */
  100455. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  100456. /** @hidden */
  100457. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  100458. /**
  100459. * Fill the defines array according to the current settings of the particle system
  100460. * @param defines Array to be updated
  100461. * @param blendMode blend mode to take into account when updating the array
  100462. */
  100463. fillDefines(defines: Array<string>, blendMode: number): void;
  100464. /**
  100465. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  100466. * @param uniforms Uniforms array to fill
  100467. * @param attributes Attributes array to fill
  100468. * @param samplers Samplers array to fill
  100469. */
  100470. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  100471. /** @hidden */
  100472. private _getEffect;
  100473. /**
  100474. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  100475. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  100476. */
  100477. animate(preWarmOnly?: boolean): void;
  100478. private _appendParticleVertices;
  100479. /**
  100480. * Rebuilds the particle system.
  100481. */
  100482. rebuild(): void;
  100483. /**
  100484. * Is this system ready to be used/rendered
  100485. * @return true if the system is ready
  100486. */
  100487. isReady(): boolean;
  100488. private _render;
  100489. /**
  100490. * Renders the particle system in its current state.
  100491. * @returns the current number of particles
  100492. */
  100493. render(): number;
  100494. /**
  100495. * Disposes the particle system and free the associated resources
  100496. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  100497. */
  100498. dispose(disposeTexture?: boolean): void;
  100499. /**
  100500. * Clones the particle system.
  100501. * @param name The name of the cloned object
  100502. * @param newEmitter The new emitter to use
  100503. * @returns the cloned particle system
  100504. */
  100505. clone(name: string, newEmitter: any): ParticleSystem;
  100506. /**
  100507. * Serializes the particle system to a JSON object
  100508. * @param serializeTexture defines if the texture must be serialized as well
  100509. * @returns the JSON object
  100510. */
  100511. serialize(serializeTexture?: boolean): any;
  100512. /** @hidden */
  100513. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  100514. /** @hidden */
  100515. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  100516. /**
  100517. * Parses a JSON object to create a particle system.
  100518. * @param parsedParticleSystem The JSON object to parse
  100519. * @param sceneOrEngine The scene or the engine to create the particle system in
  100520. * @param rootUrl The root url to use to load external dependencies like texture
  100521. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  100522. * @returns the Parsed particle system
  100523. */
  100524. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  100525. }
  100526. }
  100527. declare module BABYLON {
  100528. /**
  100529. * A particle represents one of the element emitted by a particle system.
  100530. * This is mainly define by its coordinates, direction, velocity and age.
  100531. */
  100532. export class Particle {
  100533. /**
  100534. * The particle system the particle belongs to.
  100535. */
  100536. particleSystem: ParticleSystem;
  100537. private static _Count;
  100538. /**
  100539. * Unique ID of the particle
  100540. */
  100541. id: number;
  100542. /**
  100543. * The world position of the particle in the scene.
  100544. */
  100545. position: Vector3;
  100546. /**
  100547. * The world direction of the particle in the scene.
  100548. */
  100549. direction: Vector3;
  100550. /**
  100551. * The color of the particle.
  100552. */
  100553. color: Color4;
  100554. /**
  100555. * The color change of the particle per step.
  100556. */
  100557. colorStep: Color4;
  100558. /**
  100559. * Defines how long will the life of the particle be.
  100560. */
  100561. lifeTime: number;
  100562. /**
  100563. * The current age of the particle.
  100564. */
  100565. age: number;
  100566. /**
  100567. * The current size of the particle.
  100568. */
  100569. size: number;
  100570. /**
  100571. * The current scale of the particle.
  100572. */
  100573. scale: Vector2;
  100574. /**
  100575. * The current angle of the particle.
  100576. */
  100577. angle: number;
  100578. /**
  100579. * Defines how fast is the angle changing.
  100580. */
  100581. angularSpeed: number;
  100582. /**
  100583. * Defines the cell index used by the particle to be rendered from a sprite.
  100584. */
  100585. cellIndex: number;
  100586. /**
  100587. * The information required to support color remapping
  100588. */
  100589. remapData: Vector4;
  100590. /** @hidden */
  100591. _randomCellOffset?: number;
  100592. /** @hidden */
  100593. _initialDirection: Nullable<Vector3>;
  100594. /** @hidden */
  100595. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  100596. /** @hidden */
  100597. _initialStartSpriteCellID: number;
  100598. /** @hidden */
  100599. _initialEndSpriteCellID: number;
  100600. /** @hidden */
  100601. _currentColorGradient: Nullable<ColorGradient>;
  100602. /** @hidden */
  100603. _currentColor1: Color4;
  100604. /** @hidden */
  100605. _currentColor2: Color4;
  100606. /** @hidden */
  100607. _currentSizeGradient: Nullable<FactorGradient>;
  100608. /** @hidden */
  100609. _currentSize1: number;
  100610. /** @hidden */
  100611. _currentSize2: number;
  100612. /** @hidden */
  100613. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  100614. /** @hidden */
  100615. _currentAngularSpeed1: number;
  100616. /** @hidden */
  100617. _currentAngularSpeed2: number;
  100618. /** @hidden */
  100619. _currentVelocityGradient: Nullable<FactorGradient>;
  100620. /** @hidden */
  100621. _currentVelocity1: number;
  100622. /** @hidden */
  100623. _currentVelocity2: number;
  100624. /** @hidden */
  100625. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  100626. /** @hidden */
  100627. _currentLimitVelocity1: number;
  100628. /** @hidden */
  100629. _currentLimitVelocity2: number;
  100630. /** @hidden */
  100631. _currentDragGradient: Nullable<FactorGradient>;
  100632. /** @hidden */
  100633. _currentDrag1: number;
  100634. /** @hidden */
  100635. _currentDrag2: number;
  100636. /** @hidden */
  100637. _randomNoiseCoordinates1: Vector3;
  100638. /** @hidden */
  100639. _randomNoiseCoordinates2: Vector3;
  100640. /** @hidden */
  100641. _localPosition?: Vector3;
  100642. /**
  100643. * Creates a new instance Particle
  100644. * @param particleSystem the particle system the particle belongs to
  100645. */
  100646. constructor(
  100647. /**
  100648. * The particle system the particle belongs to.
  100649. */
  100650. particleSystem: ParticleSystem);
  100651. private updateCellInfoFromSystem;
  100652. /**
  100653. * Defines how the sprite cell index is updated for the particle
  100654. */
  100655. updateCellIndex(): void;
  100656. /** @hidden */
  100657. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  100658. /** @hidden */
  100659. _inheritParticleInfoToSubEmitters(): void;
  100660. /** @hidden */
  100661. _reset(): void;
  100662. /**
  100663. * Copy the properties of particle to another one.
  100664. * @param other the particle to copy the information to.
  100665. */
  100666. copyTo(other: Particle): void;
  100667. }
  100668. }
  100669. declare module BABYLON {
  100670. /**
  100671. * Particle emitter represents a volume emitting particles.
  100672. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  100673. */
  100674. export interface IParticleEmitterType {
  100675. /**
  100676. * Called by the particle System when the direction is computed for the created particle.
  100677. * @param worldMatrix is the world matrix of the particle system
  100678. * @param directionToUpdate is the direction vector to update with the result
  100679. * @param particle is the particle we are computed the direction for
  100680. * @param isLocal defines if the direction should be set in local space
  100681. */
  100682. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  100683. /**
  100684. * Called by the particle System when the position is computed for the created particle.
  100685. * @param worldMatrix is the world matrix of the particle system
  100686. * @param positionToUpdate is the position vector to update with the result
  100687. * @param particle is the particle we are computed the position for
  100688. * @param isLocal defines if the position should be set in local space
  100689. */
  100690. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  100691. /**
  100692. * Clones the current emitter and returns a copy of it
  100693. * @returns the new emitter
  100694. */
  100695. clone(): IParticleEmitterType;
  100696. /**
  100697. * Called by the GPUParticleSystem to setup the update shader
  100698. * @param effect defines the update shader
  100699. */
  100700. applyToShader(effect: Effect): void;
  100701. /**
  100702. * Returns a string to use to update the GPU particles update shader
  100703. * @returns the effect defines string
  100704. */
  100705. getEffectDefines(): string;
  100706. /**
  100707. * Returns a string representing the class name
  100708. * @returns a string containing the class name
  100709. */
  100710. getClassName(): string;
  100711. /**
  100712. * Serializes the particle system to a JSON object.
  100713. * @returns the JSON object
  100714. */
  100715. serialize(): any;
  100716. /**
  100717. * Parse properties from a JSON object
  100718. * @param serializationObject defines the JSON object
  100719. * @param scene defines the hosting scene
  100720. */
  100721. parse(serializationObject: any, scene: Nullable<Scene>): void;
  100722. }
  100723. }
  100724. declare module BABYLON {
  100725. /**
  100726. * Particle emitter emitting particles from the inside of a box.
  100727. * It emits the particles randomly between 2 given directions.
  100728. */
  100729. export class BoxParticleEmitter implements IParticleEmitterType {
  100730. /**
  100731. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  100732. */
  100733. direction1: Vector3;
  100734. /**
  100735. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  100736. */
  100737. direction2: Vector3;
  100738. /**
  100739. * 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.
  100740. */
  100741. minEmitBox: Vector3;
  100742. /**
  100743. * 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.
  100744. */
  100745. maxEmitBox: Vector3;
  100746. /**
  100747. * Creates a new instance BoxParticleEmitter
  100748. */
  100749. constructor();
  100750. /**
  100751. * Called by the particle System when the direction is computed for the created particle.
  100752. * @param worldMatrix is the world matrix of the particle system
  100753. * @param directionToUpdate is the direction vector to update with the result
  100754. * @param particle is the particle we are computed the direction for
  100755. * @param isLocal defines if the direction should be set in local space
  100756. */
  100757. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  100758. /**
  100759. * Called by the particle System when the position is computed for the created particle.
  100760. * @param worldMatrix is the world matrix of the particle system
  100761. * @param positionToUpdate is the position vector to update with the result
  100762. * @param particle is the particle we are computed the position for
  100763. * @param isLocal defines if the position should be set in local space
  100764. */
  100765. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  100766. /**
  100767. * Clones the current emitter and returns a copy of it
  100768. * @returns the new emitter
  100769. */
  100770. clone(): BoxParticleEmitter;
  100771. /**
  100772. * Called by the GPUParticleSystem to setup the update shader
  100773. * @param effect defines the update shader
  100774. */
  100775. applyToShader(effect: Effect): void;
  100776. /**
  100777. * Returns a string to use to update the GPU particles update shader
  100778. * @returns a string containng the defines string
  100779. */
  100780. getEffectDefines(): string;
  100781. /**
  100782. * Returns the string "BoxParticleEmitter"
  100783. * @returns a string containing the class name
  100784. */
  100785. getClassName(): string;
  100786. /**
  100787. * Serializes the particle system to a JSON object.
  100788. * @returns the JSON object
  100789. */
  100790. serialize(): any;
  100791. /**
  100792. * Parse properties from a JSON object
  100793. * @param serializationObject defines the JSON object
  100794. */
  100795. parse(serializationObject: any): void;
  100796. }
  100797. }
  100798. declare module BABYLON {
  100799. /**
  100800. * Particle emitter emitting particles from the inside of a cone.
  100801. * It emits the particles alongside the cone volume from the base to the particle.
  100802. * The emission direction might be randomized.
  100803. */
  100804. export class ConeParticleEmitter implements IParticleEmitterType {
  100805. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  100806. directionRandomizer: number;
  100807. private _radius;
  100808. private _angle;
  100809. private _height;
  100810. /**
  100811. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  100812. */
  100813. radiusRange: number;
  100814. /**
  100815. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  100816. */
  100817. heightRange: number;
  100818. /**
  100819. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  100820. */
  100821. emitFromSpawnPointOnly: boolean;
  100822. /**
  100823. * Gets or sets the radius of the emission cone
  100824. */
  100825. get radius(): number;
  100826. set radius(value: number);
  100827. /**
  100828. * Gets or sets the angle of the emission cone
  100829. */
  100830. get angle(): number;
  100831. set angle(value: number);
  100832. private _buildHeight;
  100833. /**
  100834. * Creates a new instance ConeParticleEmitter
  100835. * @param radius the radius of the emission cone (1 by default)
  100836. * @param angle the cone base angle (PI by default)
  100837. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  100838. */
  100839. constructor(radius?: number, angle?: number,
  100840. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  100841. directionRandomizer?: number);
  100842. /**
  100843. * Called by the particle System when the direction is computed for the created particle.
  100844. * @param worldMatrix is the world matrix of the particle system
  100845. * @param directionToUpdate is the direction vector to update with the result
  100846. * @param particle is the particle we are computed the direction for
  100847. * @param isLocal defines if the direction should be set in local space
  100848. */
  100849. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  100850. /**
  100851. * Called by the particle System when the position is computed for the created particle.
  100852. * @param worldMatrix is the world matrix of the particle system
  100853. * @param positionToUpdate is the position vector to update with the result
  100854. * @param particle is the particle we are computed the position for
  100855. * @param isLocal defines if the position should be set in local space
  100856. */
  100857. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  100858. /**
  100859. * Clones the current emitter and returns a copy of it
  100860. * @returns the new emitter
  100861. */
  100862. clone(): ConeParticleEmitter;
  100863. /**
  100864. * Called by the GPUParticleSystem to setup the update shader
  100865. * @param effect defines the update shader
  100866. */
  100867. applyToShader(effect: Effect): void;
  100868. /**
  100869. * Returns a string to use to update the GPU particles update shader
  100870. * @returns a string containng the defines string
  100871. */
  100872. getEffectDefines(): string;
  100873. /**
  100874. * Returns the string "ConeParticleEmitter"
  100875. * @returns a string containing the class name
  100876. */
  100877. getClassName(): string;
  100878. /**
  100879. * Serializes the particle system to a JSON object.
  100880. * @returns the JSON object
  100881. */
  100882. serialize(): any;
  100883. /**
  100884. * Parse properties from a JSON object
  100885. * @param serializationObject defines the JSON object
  100886. */
  100887. parse(serializationObject: any): void;
  100888. }
  100889. }
  100890. declare module BABYLON {
  100891. /**
  100892. * Particle emitter emitting particles from the inside of a cylinder.
  100893. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  100894. */
  100895. export class CylinderParticleEmitter implements IParticleEmitterType {
  100896. /**
  100897. * The radius of the emission cylinder.
  100898. */
  100899. radius: number;
  100900. /**
  100901. * The height of the emission cylinder.
  100902. */
  100903. height: number;
  100904. /**
  100905. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  100906. */
  100907. radiusRange: number;
  100908. /**
  100909. * How much to randomize the particle direction [0-1].
  100910. */
  100911. directionRandomizer: number;
  100912. /**
  100913. * Creates a new instance CylinderParticleEmitter
  100914. * @param radius the radius of the emission cylinder (1 by default)
  100915. * @param height the height of the emission cylinder (1 by default)
  100916. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  100917. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  100918. */
  100919. constructor(
  100920. /**
  100921. * The radius of the emission cylinder.
  100922. */
  100923. radius?: number,
  100924. /**
  100925. * The height of the emission cylinder.
  100926. */
  100927. height?: number,
  100928. /**
  100929. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  100930. */
  100931. radiusRange?: number,
  100932. /**
  100933. * How much to randomize the particle direction [0-1].
  100934. */
  100935. directionRandomizer?: number);
  100936. /**
  100937. * Called by the particle System when the direction is computed for the created particle.
  100938. * @param worldMatrix is the world matrix of the particle system
  100939. * @param directionToUpdate is the direction vector to update with the result
  100940. * @param particle is the particle we are computed the direction for
  100941. * @param isLocal defines if the direction should be set in local space
  100942. */
  100943. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  100944. /**
  100945. * Called by the particle System when the position is computed for the created particle.
  100946. * @param worldMatrix is the world matrix of the particle system
  100947. * @param positionToUpdate is the position vector to update with the result
  100948. * @param particle is the particle we are computed the position for
  100949. * @param isLocal defines if the position should be set in local space
  100950. */
  100951. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  100952. /**
  100953. * Clones the current emitter and returns a copy of it
  100954. * @returns the new emitter
  100955. */
  100956. clone(): CylinderParticleEmitter;
  100957. /**
  100958. * Called by the GPUParticleSystem to setup the update shader
  100959. * @param effect defines the update shader
  100960. */
  100961. applyToShader(effect: Effect): void;
  100962. /**
  100963. * Returns a string to use to update the GPU particles update shader
  100964. * @returns a string containng the defines string
  100965. */
  100966. getEffectDefines(): string;
  100967. /**
  100968. * Returns the string "CylinderParticleEmitter"
  100969. * @returns a string containing the class name
  100970. */
  100971. getClassName(): string;
  100972. /**
  100973. * Serializes the particle system to a JSON object.
  100974. * @returns the JSON object
  100975. */
  100976. serialize(): any;
  100977. /**
  100978. * Parse properties from a JSON object
  100979. * @param serializationObject defines the JSON object
  100980. */
  100981. parse(serializationObject: any): void;
  100982. }
  100983. /**
  100984. * Particle emitter emitting particles from the inside of a cylinder.
  100985. * It emits the particles randomly between two vectors.
  100986. */
  100987. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  100988. /**
  100989. * The min limit of the emission direction.
  100990. */
  100991. direction1: Vector3;
  100992. /**
  100993. * The max limit of the emission direction.
  100994. */
  100995. direction2: Vector3;
  100996. /**
  100997. * Creates a new instance CylinderDirectedParticleEmitter
  100998. * @param radius the radius of the emission cylinder (1 by default)
  100999. * @param height the height of the emission cylinder (1 by default)
  101000. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  101001. * @param direction1 the min limit of the emission direction (up vector by default)
  101002. * @param direction2 the max limit of the emission direction (up vector by default)
  101003. */
  101004. constructor(radius?: number, height?: number, radiusRange?: number,
  101005. /**
  101006. * The min limit of the emission direction.
  101007. */
  101008. direction1?: Vector3,
  101009. /**
  101010. * The max limit of the emission direction.
  101011. */
  101012. direction2?: Vector3);
  101013. /**
  101014. * Called by the particle System when the direction is computed for the created particle.
  101015. * @param worldMatrix is the world matrix of the particle system
  101016. * @param directionToUpdate is the direction vector to update with the result
  101017. * @param particle is the particle we are computed the direction for
  101018. */
  101019. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  101020. /**
  101021. * Clones the current emitter and returns a copy of it
  101022. * @returns the new emitter
  101023. */
  101024. clone(): CylinderDirectedParticleEmitter;
  101025. /**
  101026. * Called by the GPUParticleSystem to setup the update shader
  101027. * @param effect defines the update shader
  101028. */
  101029. applyToShader(effect: Effect): void;
  101030. /**
  101031. * Returns a string to use to update the GPU particles update shader
  101032. * @returns a string containng the defines string
  101033. */
  101034. getEffectDefines(): string;
  101035. /**
  101036. * Returns the string "CylinderDirectedParticleEmitter"
  101037. * @returns a string containing the class name
  101038. */
  101039. getClassName(): string;
  101040. /**
  101041. * Serializes the particle system to a JSON object.
  101042. * @returns the JSON object
  101043. */
  101044. serialize(): any;
  101045. /**
  101046. * Parse properties from a JSON object
  101047. * @param serializationObject defines the JSON object
  101048. */
  101049. parse(serializationObject: any): void;
  101050. }
  101051. }
  101052. declare module BABYLON {
  101053. /**
  101054. * Particle emitter emitting particles from the inside of a hemisphere.
  101055. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  101056. */
  101057. export class HemisphericParticleEmitter implements IParticleEmitterType {
  101058. /**
  101059. * The radius of the emission hemisphere.
  101060. */
  101061. radius: number;
  101062. /**
  101063. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  101064. */
  101065. radiusRange: number;
  101066. /**
  101067. * How much to randomize the particle direction [0-1].
  101068. */
  101069. directionRandomizer: number;
  101070. /**
  101071. * Creates a new instance HemisphericParticleEmitter
  101072. * @param radius the radius of the emission hemisphere (1 by default)
  101073. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  101074. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  101075. */
  101076. constructor(
  101077. /**
  101078. * The radius of the emission hemisphere.
  101079. */
  101080. radius?: number,
  101081. /**
  101082. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  101083. */
  101084. radiusRange?: number,
  101085. /**
  101086. * How much to randomize the particle direction [0-1].
  101087. */
  101088. directionRandomizer?: number);
  101089. /**
  101090. * Called by the particle System when the direction is computed for the created particle.
  101091. * @param worldMatrix is the world matrix of the particle system
  101092. * @param directionToUpdate is the direction vector to update with the result
  101093. * @param particle is the particle we are computed the direction for
  101094. * @param isLocal defines if the direction should be set in local space
  101095. */
  101096. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101097. /**
  101098. * Called by the particle System when the position is computed for the created particle.
  101099. * @param worldMatrix is the world matrix of the particle system
  101100. * @param positionToUpdate is the position vector to update with the result
  101101. * @param particle is the particle we are computed the position for
  101102. * @param isLocal defines if the position should be set in local space
  101103. */
  101104. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101105. /**
  101106. * Clones the current emitter and returns a copy of it
  101107. * @returns the new emitter
  101108. */
  101109. clone(): HemisphericParticleEmitter;
  101110. /**
  101111. * Called by the GPUParticleSystem to setup the update shader
  101112. * @param effect defines the update shader
  101113. */
  101114. applyToShader(effect: Effect): void;
  101115. /**
  101116. * Returns a string to use to update the GPU particles update shader
  101117. * @returns a string containng the defines string
  101118. */
  101119. getEffectDefines(): string;
  101120. /**
  101121. * Returns the string "HemisphericParticleEmitter"
  101122. * @returns a string containing the class name
  101123. */
  101124. getClassName(): string;
  101125. /**
  101126. * Serializes the particle system to a JSON object.
  101127. * @returns the JSON object
  101128. */
  101129. serialize(): any;
  101130. /**
  101131. * Parse properties from a JSON object
  101132. * @param serializationObject defines the JSON object
  101133. */
  101134. parse(serializationObject: any): void;
  101135. }
  101136. }
  101137. declare module BABYLON {
  101138. /**
  101139. * Particle emitter emitting particles from a point.
  101140. * It emits the particles randomly between 2 given directions.
  101141. */
  101142. export class PointParticleEmitter implements IParticleEmitterType {
  101143. /**
  101144. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  101145. */
  101146. direction1: Vector3;
  101147. /**
  101148. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  101149. */
  101150. direction2: Vector3;
  101151. /**
  101152. * Creates a new instance PointParticleEmitter
  101153. */
  101154. constructor();
  101155. /**
  101156. * Called by the particle System when the direction is computed for the created particle.
  101157. * @param worldMatrix is the world matrix of the particle system
  101158. * @param directionToUpdate is the direction vector to update with the result
  101159. * @param particle is the particle we are computed the direction for
  101160. * @param isLocal defines if the direction should be set in local space
  101161. */
  101162. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101163. /**
  101164. * Called by the particle System when the position is computed for the created particle.
  101165. * @param worldMatrix is the world matrix of the particle system
  101166. * @param positionToUpdate is the position vector to update with the result
  101167. * @param particle is the particle we are computed the position for
  101168. * @param isLocal defines if the position should be set in local space
  101169. */
  101170. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101171. /**
  101172. * Clones the current emitter and returns a copy of it
  101173. * @returns the new emitter
  101174. */
  101175. clone(): PointParticleEmitter;
  101176. /**
  101177. * Called by the GPUParticleSystem to setup the update shader
  101178. * @param effect defines the update shader
  101179. */
  101180. applyToShader(effect: Effect): void;
  101181. /**
  101182. * Returns a string to use to update the GPU particles update shader
  101183. * @returns a string containng the defines string
  101184. */
  101185. getEffectDefines(): string;
  101186. /**
  101187. * Returns the string "PointParticleEmitter"
  101188. * @returns a string containing the class name
  101189. */
  101190. getClassName(): string;
  101191. /**
  101192. * Serializes the particle system to a JSON object.
  101193. * @returns the JSON object
  101194. */
  101195. serialize(): any;
  101196. /**
  101197. * Parse properties from a JSON object
  101198. * @param serializationObject defines the JSON object
  101199. */
  101200. parse(serializationObject: any): void;
  101201. }
  101202. }
  101203. declare module BABYLON {
  101204. /**
  101205. * Particle emitter emitting particles from the inside of a sphere.
  101206. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  101207. */
  101208. export class SphereParticleEmitter implements IParticleEmitterType {
  101209. /**
  101210. * The radius of the emission sphere.
  101211. */
  101212. radius: number;
  101213. /**
  101214. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  101215. */
  101216. radiusRange: number;
  101217. /**
  101218. * How much to randomize the particle direction [0-1].
  101219. */
  101220. directionRandomizer: number;
  101221. /**
  101222. * Creates a new instance SphereParticleEmitter
  101223. * @param radius the radius of the emission sphere (1 by default)
  101224. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  101225. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  101226. */
  101227. constructor(
  101228. /**
  101229. * The radius of the emission sphere.
  101230. */
  101231. radius?: number,
  101232. /**
  101233. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  101234. */
  101235. radiusRange?: number,
  101236. /**
  101237. * How much to randomize the particle direction [0-1].
  101238. */
  101239. directionRandomizer?: number);
  101240. /**
  101241. * Called by the particle System when the direction is computed for the created particle.
  101242. * @param worldMatrix is the world matrix of the particle system
  101243. * @param directionToUpdate is the direction vector to update with the result
  101244. * @param particle is the particle we are computed the direction for
  101245. * @param isLocal defines if the direction should be set in local space
  101246. */
  101247. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101248. /**
  101249. * Called by the particle System when the position is computed for the created particle.
  101250. * @param worldMatrix is the world matrix of the particle system
  101251. * @param positionToUpdate is the position vector to update with the result
  101252. * @param particle is the particle we are computed the position for
  101253. * @param isLocal defines if the position should be set in local space
  101254. */
  101255. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101256. /**
  101257. * Clones the current emitter and returns a copy of it
  101258. * @returns the new emitter
  101259. */
  101260. clone(): SphereParticleEmitter;
  101261. /**
  101262. * Called by the GPUParticleSystem to setup the update shader
  101263. * @param effect defines the update shader
  101264. */
  101265. applyToShader(effect: Effect): void;
  101266. /**
  101267. * Returns a string to use to update the GPU particles update shader
  101268. * @returns a string containng the defines string
  101269. */
  101270. getEffectDefines(): string;
  101271. /**
  101272. * Returns the string "SphereParticleEmitter"
  101273. * @returns a string containing the class name
  101274. */
  101275. getClassName(): string;
  101276. /**
  101277. * Serializes the particle system to a JSON object.
  101278. * @returns the JSON object
  101279. */
  101280. serialize(): any;
  101281. /**
  101282. * Parse properties from a JSON object
  101283. * @param serializationObject defines the JSON object
  101284. */
  101285. parse(serializationObject: any): void;
  101286. }
  101287. /**
  101288. * Particle emitter emitting particles from the inside of a sphere.
  101289. * It emits the particles randomly between two vectors.
  101290. */
  101291. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  101292. /**
  101293. * The min limit of the emission direction.
  101294. */
  101295. direction1: Vector3;
  101296. /**
  101297. * The max limit of the emission direction.
  101298. */
  101299. direction2: Vector3;
  101300. /**
  101301. * Creates a new instance SphereDirectedParticleEmitter
  101302. * @param radius the radius of the emission sphere (1 by default)
  101303. * @param direction1 the min limit of the emission direction (up vector by default)
  101304. * @param direction2 the max limit of the emission direction (up vector by default)
  101305. */
  101306. constructor(radius?: number,
  101307. /**
  101308. * The min limit of the emission direction.
  101309. */
  101310. direction1?: Vector3,
  101311. /**
  101312. * The max limit of the emission direction.
  101313. */
  101314. direction2?: Vector3);
  101315. /**
  101316. * Called by the particle System when the direction is computed for the created particle.
  101317. * @param worldMatrix is the world matrix of the particle system
  101318. * @param directionToUpdate is the direction vector to update with the result
  101319. * @param particle is the particle we are computed the direction for
  101320. */
  101321. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  101322. /**
  101323. * Clones the current emitter and returns a copy of it
  101324. * @returns the new emitter
  101325. */
  101326. clone(): SphereDirectedParticleEmitter;
  101327. /**
  101328. * Called by the GPUParticleSystem to setup the update shader
  101329. * @param effect defines the update shader
  101330. */
  101331. applyToShader(effect: Effect): void;
  101332. /**
  101333. * Returns a string to use to update the GPU particles update shader
  101334. * @returns a string containng the defines string
  101335. */
  101336. getEffectDefines(): string;
  101337. /**
  101338. * Returns the string "SphereDirectedParticleEmitter"
  101339. * @returns a string containing the class name
  101340. */
  101341. getClassName(): string;
  101342. /**
  101343. * Serializes the particle system to a JSON object.
  101344. * @returns the JSON object
  101345. */
  101346. serialize(): any;
  101347. /**
  101348. * Parse properties from a JSON object
  101349. * @param serializationObject defines the JSON object
  101350. */
  101351. parse(serializationObject: any): void;
  101352. }
  101353. }
  101354. declare module BABYLON {
  101355. /**
  101356. * Particle emitter emitting particles from a custom list of positions.
  101357. */
  101358. export class CustomParticleEmitter implements IParticleEmitterType {
  101359. /**
  101360. * Gets or sets the position generator that will create the inital position of each particle.
  101361. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  101362. */
  101363. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  101364. /**
  101365. * Gets or sets the destination generator that will create the final destination of each particle.
  101366. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  101367. */
  101368. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  101369. /**
  101370. * Creates a new instance CustomParticleEmitter
  101371. */
  101372. constructor();
  101373. /**
  101374. * Called by the particle System when the direction is computed for the created particle.
  101375. * @param worldMatrix is the world matrix of the particle system
  101376. * @param directionToUpdate is the direction vector to update with the result
  101377. * @param particle is the particle we are computed the direction for
  101378. * @param isLocal defines if the direction should be set in local space
  101379. */
  101380. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101381. /**
  101382. * Called by the particle System when the position is computed for the created particle.
  101383. * @param worldMatrix is the world matrix of the particle system
  101384. * @param positionToUpdate is the position vector to update with the result
  101385. * @param particle is the particle we are computed the position for
  101386. * @param isLocal defines if the position should be set in local space
  101387. */
  101388. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101389. /**
  101390. * Clones the current emitter and returns a copy of it
  101391. * @returns the new emitter
  101392. */
  101393. clone(): CustomParticleEmitter;
  101394. /**
  101395. * Called by the GPUParticleSystem to setup the update shader
  101396. * @param effect defines the update shader
  101397. */
  101398. applyToShader(effect: Effect): void;
  101399. /**
  101400. * Returns a string to use to update the GPU particles update shader
  101401. * @returns a string containng the defines string
  101402. */
  101403. getEffectDefines(): string;
  101404. /**
  101405. * Returns the string "PointParticleEmitter"
  101406. * @returns a string containing the class name
  101407. */
  101408. getClassName(): string;
  101409. /**
  101410. * Serializes the particle system to a JSON object.
  101411. * @returns the JSON object
  101412. */
  101413. serialize(): any;
  101414. /**
  101415. * Parse properties from a JSON object
  101416. * @param serializationObject defines the JSON object
  101417. */
  101418. parse(serializationObject: any): void;
  101419. }
  101420. }
  101421. declare module BABYLON {
  101422. /**
  101423. * Particle emitter emitting particles from the inside of a box.
  101424. * It emits the particles randomly between 2 given directions.
  101425. */
  101426. export class MeshParticleEmitter implements IParticleEmitterType {
  101427. private _indices;
  101428. private _positions;
  101429. private _normals;
  101430. private _storedNormal;
  101431. private _mesh;
  101432. /**
  101433. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  101434. */
  101435. direction1: Vector3;
  101436. /**
  101437. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  101438. */
  101439. direction2: Vector3;
  101440. /**
  101441. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  101442. */
  101443. useMeshNormalsForDirection: boolean;
  101444. /** Defines the mesh to use as source */
  101445. get mesh(): Nullable<AbstractMesh>;
  101446. set mesh(value: Nullable<AbstractMesh>);
  101447. /**
  101448. * Creates a new instance MeshParticleEmitter
  101449. * @param mesh defines the mesh to use as source
  101450. */
  101451. constructor(mesh?: Nullable<AbstractMesh>);
  101452. /**
  101453. * Called by the particle System when the direction is computed for the created particle.
  101454. * @param worldMatrix is the world matrix of the particle system
  101455. * @param directionToUpdate is the direction vector to update with the result
  101456. * @param particle is the particle we are computed the direction for
  101457. * @param isLocal defines if the direction should be set in local space
  101458. */
  101459. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101460. /**
  101461. * Called by the particle System when the position is computed for the created particle.
  101462. * @param worldMatrix is the world matrix of the particle system
  101463. * @param positionToUpdate is the position vector to update with the result
  101464. * @param particle is the particle we are computed the position for
  101465. * @param isLocal defines if the position should be set in local space
  101466. */
  101467. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  101468. /**
  101469. * Clones the current emitter and returns a copy of it
  101470. * @returns the new emitter
  101471. */
  101472. clone(): MeshParticleEmitter;
  101473. /**
  101474. * Called by the GPUParticleSystem to setup the update shader
  101475. * @param effect defines the update shader
  101476. */
  101477. applyToShader(effect: Effect): void;
  101478. /**
  101479. * Returns a string to use to update the GPU particles update shader
  101480. * @returns a string containng the defines string
  101481. */
  101482. getEffectDefines(): string;
  101483. /**
  101484. * Returns the string "BoxParticleEmitter"
  101485. * @returns a string containing the class name
  101486. */
  101487. getClassName(): string;
  101488. /**
  101489. * Serializes the particle system to a JSON object.
  101490. * @returns the JSON object
  101491. */
  101492. serialize(): any;
  101493. /**
  101494. * Parse properties from a JSON object
  101495. * @param serializationObject defines the JSON object
  101496. * @param scene defines the hosting scene
  101497. */
  101498. parse(serializationObject: any, scene: Nullable<Scene>): void;
  101499. }
  101500. }
  101501. declare module BABYLON {
  101502. /**
  101503. * Interface representing a particle system in Babylon.js.
  101504. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  101505. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  101506. */
  101507. export interface IParticleSystem {
  101508. /**
  101509. * List of animations used by the particle system.
  101510. */
  101511. animations: Animation[];
  101512. /**
  101513. * The id of the Particle system.
  101514. */
  101515. id: string;
  101516. /**
  101517. * The name of the Particle system.
  101518. */
  101519. name: string;
  101520. /**
  101521. * The emitter represents the Mesh or position we are attaching the particle system to.
  101522. */
  101523. emitter: Nullable<AbstractMesh | Vector3>;
  101524. /**
  101525. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  101526. */
  101527. isBillboardBased: boolean;
  101528. /**
  101529. * The rendering group used by the Particle system to chose when to render.
  101530. */
  101531. renderingGroupId: number;
  101532. /**
  101533. * The layer mask we are rendering the particles through.
  101534. */
  101535. layerMask: number;
  101536. /**
  101537. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  101538. */
  101539. updateSpeed: number;
  101540. /**
  101541. * The amount of time the particle system is running (depends of the overall update speed).
  101542. */
  101543. targetStopDuration: number;
  101544. /**
  101545. * The texture used to render each particle. (this can be a spritesheet)
  101546. */
  101547. particleTexture: Nullable<BaseTexture>;
  101548. /**
  101549. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  101550. */
  101551. blendMode: number;
  101552. /**
  101553. * Minimum life time of emitting particles.
  101554. */
  101555. minLifeTime: number;
  101556. /**
  101557. * Maximum life time of emitting particles.
  101558. */
  101559. maxLifeTime: number;
  101560. /**
  101561. * Minimum Size of emitting particles.
  101562. */
  101563. minSize: number;
  101564. /**
  101565. * Maximum Size of emitting particles.
  101566. */
  101567. maxSize: number;
  101568. /**
  101569. * Minimum scale of emitting particles on X axis.
  101570. */
  101571. minScaleX: number;
  101572. /**
  101573. * Maximum scale of emitting particles on X axis.
  101574. */
  101575. maxScaleX: number;
  101576. /**
  101577. * Minimum scale of emitting particles on Y axis.
  101578. */
  101579. minScaleY: number;
  101580. /**
  101581. * Maximum scale of emitting particles on Y axis.
  101582. */
  101583. maxScaleY: number;
  101584. /**
  101585. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  101586. */
  101587. color1: Color4;
  101588. /**
  101589. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  101590. */
  101591. color2: Color4;
  101592. /**
  101593. * Color the particle will have at the end of its lifetime.
  101594. */
  101595. colorDead: Color4;
  101596. /**
  101597. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  101598. */
  101599. emitRate: number;
  101600. /**
  101601. * You can use gravity if you want to give an orientation to your particles.
  101602. */
  101603. gravity: Vector3;
  101604. /**
  101605. * Minimum power of emitting particles.
  101606. */
  101607. minEmitPower: number;
  101608. /**
  101609. * Maximum power of emitting particles.
  101610. */
  101611. maxEmitPower: number;
  101612. /**
  101613. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  101614. */
  101615. minAngularSpeed: number;
  101616. /**
  101617. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  101618. */
  101619. maxAngularSpeed: number;
  101620. /**
  101621. * Gets or sets the minimal initial rotation in radians.
  101622. */
  101623. minInitialRotation: number;
  101624. /**
  101625. * Gets or sets the maximal initial rotation in radians.
  101626. */
  101627. maxInitialRotation: number;
  101628. /**
  101629. * The particle emitter type defines the emitter used by the particle system.
  101630. * It can be for example box, sphere, or cone...
  101631. */
  101632. particleEmitterType: Nullable<IParticleEmitterType>;
  101633. /**
  101634. * Defines the delay in milliseconds before starting the system (0 by default)
  101635. */
  101636. startDelay: number;
  101637. /**
  101638. * 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
  101639. */
  101640. preWarmCycles: number;
  101641. /**
  101642. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  101643. */
  101644. preWarmStepOffset: number;
  101645. /**
  101646. * 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)
  101647. */
  101648. spriteCellChangeSpeed: number;
  101649. /**
  101650. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  101651. */
  101652. startSpriteCellID: number;
  101653. /**
  101654. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  101655. */
  101656. endSpriteCellID: number;
  101657. /**
  101658. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  101659. */
  101660. spriteCellWidth: number;
  101661. /**
  101662. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  101663. */
  101664. spriteCellHeight: number;
  101665. /**
  101666. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  101667. */
  101668. spriteRandomStartCell: boolean;
  101669. /**
  101670. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  101671. */
  101672. isAnimationSheetEnabled: boolean;
  101673. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  101674. translationPivot: Vector2;
  101675. /**
  101676. * Gets or sets a texture used to add random noise to particle positions
  101677. */
  101678. noiseTexture: Nullable<BaseTexture>;
  101679. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  101680. noiseStrength: Vector3;
  101681. /**
  101682. * Gets or sets the billboard mode to use when isBillboardBased = true.
  101683. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  101684. */
  101685. billboardMode: number;
  101686. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  101687. limitVelocityDamping: number;
  101688. /**
  101689. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  101690. */
  101691. beginAnimationOnStart: boolean;
  101692. /**
  101693. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  101694. */
  101695. beginAnimationFrom: number;
  101696. /**
  101697. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  101698. */
  101699. beginAnimationTo: number;
  101700. /**
  101701. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  101702. */
  101703. beginAnimationLoop: boolean;
  101704. /**
  101705. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  101706. */
  101707. disposeOnStop: boolean;
  101708. /**
  101709. * Specifies if the particles are updated in emitter local space or world space
  101710. */
  101711. isLocal: boolean;
  101712. /** Snippet ID if the particle system was created from the snippet server */
  101713. snippetId: string;
  101714. /** Gets or sets a matrix to use to compute projection */
  101715. defaultProjectionMatrix: Matrix;
  101716. /**
  101717. * Gets the maximum number of particles active at the same time.
  101718. * @returns The max number of active particles.
  101719. */
  101720. getCapacity(): number;
  101721. /**
  101722. * Gets the number of particles active at the same time.
  101723. * @returns The number of active particles.
  101724. */
  101725. getActiveCount(): number;
  101726. /**
  101727. * Gets if the system has been started. (Note: this will still be true after stop is called)
  101728. * @returns True if it has been started, otherwise false.
  101729. */
  101730. isStarted(): boolean;
  101731. /**
  101732. * Animates the particle system for this frame.
  101733. */
  101734. animate(): void;
  101735. /**
  101736. * Renders the particle system in its current state.
  101737. * @returns the current number of particles
  101738. */
  101739. render(): number;
  101740. /**
  101741. * Dispose the particle system and frees its associated resources.
  101742. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  101743. */
  101744. dispose(disposeTexture?: boolean): void;
  101745. /**
  101746. * An event triggered when the system is disposed
  101747. */
  101748. onDisposeObservable: Observable<IParticleSystem>;
  101749. /**
  101750. * An event triggered when the system is stopped
  101751. */
  101752. onStoppedObservable: Observable<IParticleSystem>;
  101753. /**
  101754. * Clones the particle system.
  101755. * @param name The name of the cloned object
  101756. * @param newEmitter The new emitter to use
  101757. * @returns the cloned particle system
  101758. */
  101759. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  101760. /**
  101761. * Serializes the particle system to a JSON object
  101762. * @param serializeTexture defines if the texture must be serialized as well
  101763. * @returns the JSON object
  101764. */
  101765. serialize(serializeTexture: boolean): any;
  101766. /**
  101767. * Rebuild the particle system
  101768. */
  101769. rebuild(): void;
  101770. /** Force the system to rebuild all gradients that need to be resync */
  101771. forceRefreshGradients(): void;
  101772. /**
  101773. * Starts the particle system and begins to emit
  101774. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  101775. */
  101776. start(delay?: number): void;
  101777. /**
  101778. * Stops the particle system.
  101779. */
  101780. stop(): void;
  101781. /**
  101782. * Remove all active particles
  101783. */
  101784. reset(): void;
  101785. /**
  101786. * Gets a boolean indicating that the system is stopping
  101787. * @returns true if the system is currently stopping
  101788. */
  101789. isStopping(): boolean;
  101790. /**
  101791. * Is this system ready to be used/rendered
  101792. * @return true if the system is ready
  101793. */
  101794. isReady(): boolean;
  101795. /**
  101796. * Returns the string "ParticleSystem"
  101797. * @returns a string containing the class name
  101798. */
  101799. getClassName(): string;
  101800. /**
  101801. * Gets the custom effect used to render the particles
  101802. * @param blendMode Blend mode for which the effect should be retrieved
  101803. * @returns The effect
  101804. */
  101805. getCustomEffect(blendMode: number): Nullable<Effect>;
  101806. /**
  101807. * Sets the custom effect used to render the particles
  101808. * @param effect The effect to set
  101809. * @param blendMode Blend mode for which the effect should be set
  101810. */
  101811. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  101812. /**
  101813. * Fill the defines array according to the current settings of the particle system
  101814. * @param defines Array to be updated
  101815. * @param blendMode blend mode to take into account when updating the array
  101816. */
  101817. fillDefines(defines: Array<string>, blendMode: number): void;
  101818. /**
  101819. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  101820. * @param uniforms Uniforms array to fill
  101821. * @param attributes Attributes array to fill
  101822. * @param samplers Samplers array to fill
  101823. */
  101824. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  101825. /**
  101826. * Observable that will be called just before the particles are drawn
  101827. */
  101828. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  101829. /**
  101830. * Gets the name of the particle vertex shader
  101831. */
  101832. vertexShaderName: string;
  101833. /**
  101834. * Adds a new color gradient
  101835. * @param gradient defines the gradient to use (between 0 and 1)
  101836. * @param color1 defines the color to affect to the specified gradient
  101837. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  101838. * @returns the current particle system
  101839. */
  101840. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  101841. /**
  101842. * Remove a specific color gradient
  101843. * @param gradient defines the gradient to remove
  101844. * @returns the current particle system
  101845. */
  101846. removeColorGradient(gradient: number): IParticleSystem;
  101847. /**
  101848. * Adds a new size gradient
  101849. * @param gradient defines the gradient to use (between 0 and 1)
  101850. * @param factor defines the size factor to affect to the specified gradient
  101851. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  101852. * @returns the current particle system
  101853. */
  101854. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  101855. /**
  101856. * Remove a specific size gradient
  101857. * @param gradient defines the gradient to remove
  101858. * @returns the current particle system
  101859. */
  101860. removeSizeGradient(gradient: number): IParticleSystem;
  101861. /**
  101862. * Gets the current list of color gradients.
  101863. * You must use addColorGradient and removeColorGradient to udpate this list
  101864. * @returns the list of color gradients
  101865. */
  101866. getColorGradients(): Nullable<Array<ColorGradient>>;
  101867. /**
  101868. * Gets the current list of size gradients.
  101869. * You must use addSizeGradient and removeSizeGradient to udpate this list
  101870. * @returns the list of size gradients
  101871. */
  101872. getSizeGradients(): Nullable<Array<FactorGradient>>;
  101873. /**
  101874. * Gets the current list of angular speed gradients.
  101875. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  101876. * @returns the list of angular speed gradients
  101877. */
  101878. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  101879. /**
  101880. * Adds a new angular speed gradient
  101881. * @param gradient defines the gradient to use (between 0 and 1)
  101882. * @param factor defines the angular speed to affect to the specified gradient
  101883. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  101884. * @returns the current particle system
  101885. */
  101886. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  101887. /**
  101888. * Remove a specific angular speed gradient
  101889. * @param gradient defines the gradient to remove
  101890. * @returns the current particle system
  101891. */
  101892. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  101893. /**
  101894. * Gets the current list of velocity gradients.
  101895. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  101896. * @returns the list of velocity gradients
  101897. */
  101898. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  101899. /**
  101900. * Adds a new velocity gradient
  101901. * @param gradient defines the gradient to use (between 0 and 1)
  101902. * @param factor defines the velocity to affect to the specified gradient
  101903. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  101904. * @returns the current particle system
  101905. */
  101906. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  101907. /**
  101908. * Remove a specific velocity gradient
  101909. * @param gradient defines the gradient to remove
  101910. * @returns the current particle system
  101911. */
  101912. removeVelocityGradient(gradient: number): IParticleSystem;
  101913. /**
  101914. * Gets the current list of limit velocity gradients.
  101915. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  101916. * @returns the list of limit velocity gradients
  101917. */
  101918. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  101919. /**
  101920. * Adds a new limit velocity gradient
  101921. * @param gradient defines the gradient to use (between 0 and 1)
  101922. * @param factor defines the limit velocity to affect to the specified gradient
  101923. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  101924. * @returns the current particle system
  101925. */
  101926. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  101927. /**
  101928. * Remove a specific limit velocity gradient
  101929. * @param gradient defines the gradient to remove
  101930. * @returns the current particle system
  101931. */
  101932. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  101933. /**
  101934. * Adds a new drag gradient
  101935. * @param gradient defines the gradient to use (between 0 and 1)
  101936. * @param factor defines the drag to affect to the specified gradient
  101937. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  101938. * @returns the current particle system
  101939. */
  101940. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  101941. /**
  101942. * Remove a specific drag gradient
  101943. * @param gradient defines the gradient to remove
  101944. * @returns the current particle system
  101945. */
  101946. removeDragGradient(gradient: number): IParticleSystem;
  101947. /**
  101948. * Gets the current list of drag gradients.
  101949. * You must use addDragGradient and removeDragGradient to udpate this list
  101950. * @returns the list of drag gradients
  101951. */
  101952. getDragGradients(): Nullable<Array<FactorGradient>>;
  101953. /**
  101954. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  101955. * @param gradient defines the gradient to use (between 0 and 1)
  101956. * @param factor defines the emit rate to affect to the specified gradient
  101957. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  101958. * @returns the current particle system
  101959. */
  101960. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  101961. /**
  101962. * Remove a specific emit rate gradient
  101963. * @param gradient defines the gradient to remove
  101964. * @returns the current particle system
  101965. */
  101966. removeEmitRateGradient(gradient: number): IParticleSystem;
  101967. /**
  101968. * Gets the current list of emit rate gradients.
  101969. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  101970. * @returns the list of emit rate gradients
  101971. */
  101972. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  101973. /**
  101974. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  101975. * @param gradient defines the gradient to use (between 0 and 1)
  101976. * @param factor defines the start size to affect to the specified gradient
  101977. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  101978. * @returns the current particle system
  101979. */
  101980. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  101981. /**
  101982. * Remove a specific start size gradient
  101983. * @param gradient defines the gradient to remove
  101984. * @returns the current particle system
  101985. */
  101986. removeStartSizeGradient(gradient: number): IParticleSystem;
  101987. /**
  101988. * Gets the current list of start size gradients.
  101989. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  101990. * @returns the list of start size gradients
  101991. */
  101992. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  101993. /**
  101994. * Adds a new life time gradient
  101995. * @param gradient defines the gradient to use (between 0 and 1)
  101996. * @param factor defines the life time factor to affect to the specified gradient
  101997. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  101998. * @returns the current particle system
  101999. */
  102000. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  102001. /**
  102002. * Remove a specific life time gradient
  102003. * @param gradient defines the gradient to remove
  102004. * @returns the current particle system
  102005. */
  102006. removeLifeTimeGradient(gradient: number): IParticleSystem;
  102007. /**
  102008. * Gets the current list of life time gradients.
  102009. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  102010. * @returns the list of life time gradients
  102011. */
  102012. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  102013. /**
  102014. * Gets the current list of color gradients.
  102015. * You must use addColorGradient and removeColorGradient to udpate this list
  102016. * @returns the list of color gradients
  102017. */
  102018. getColorGradients(): Nullable<Array<ColorGradient>>;
  102019. /**
  102020. * Adds a new ramp gradient used to remap particle colors
  102021. * @param gradient defines the gradient to use (between 0 and 1)
  102022. * @param color defines the color to affect to the specified gradient
  102023. * @returns the current particle system
  102024. */
  102025. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  102026. /**
  102027. * Gets the current list of ramp gradients.
  102028. * You must use addRampGradient and removeRampGradient to udpate this list
  102029. * @returns the list of ramp gradients
  102030. */
  102031. getRampGradients(): Nullable<Array<Color3Gradient>>;
  102032. /** Gets or sets a boolean indicating that ramp gradients must be used
  102033. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  102034. */
  102035. useRampGradients: boolean;
  102036. /**
  102037. * Adds a new color remap gradient
  102038. * @param gradient defines the gradient to use (between 0 and 1)
  102039. * @param min defines the color remap minimal range
  102040. * @param max defines the color remap maximal range
  102041. * @returns the current particle system
  102042. */
  102043. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  102044. /**
  102045. * Gets the current list of color remap gradients.
  102046. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  102047. * @returns the list of color remap gradients
  102048. */
  102049. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  102050. /**
  102051. * Adds a new alpha remap gradient
  102052. * @param gradient defines the gradient to use (between 0 and 1)
  102053. * @param min defines the alpha remap minimal range
  102054. * @param max defines the alpha remap maximal range
  102055. * @returns the current particle system
  102056. */
  102057. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  102058. /**
  102059. * Gets the current list of alpha remap gradients.
  102060. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  102061. * @returns the list of alpha remap gradients
  102062. */
  102063. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  102064. /**
  102065. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  102066. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  102067. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  102068. * @returns the emitter
  102069. */
  102070. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  102071. /**
  102072. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  102073. * @param radius The radius of the hemisphere to emit from
  102074. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  102075. * @returns the emitter
  102076. */
  102077. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  102078. /**
  102079. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  102080. * @param radius The radius of the sphere to emit from
  102081. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  102082. * @returns the emitter
  102083. */
  102084. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  102085. /**
  102086. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  102087. * @param radius The radius of the sphere to emit from
  102088. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  102089. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  102090. * @returns the emitter
  102091. */
  102092. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  102093. /**
  102094. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  102095. * @param radius The radius of the emission cylinder
  102096. * @param height The height of the emission cylinder
  102097. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  102098. * @param directionRandomizer How much to randomize the particle direction [0-1]
  102099. * @returns the emitter
  102100. */
  102101. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  102102. /**
  102103. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  102104. * @param radius The radius of the cylinder to emit from
  102105. * @param height The height of the emission cylinder
  102106. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  102107. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  102108. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  102109. * @returns the emitter
  102110. */
  102111. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  102112. /**
  102113. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  102114. * @param radius The radius of the cone to emit from
  102115. * @param angle The base angle of the cone
  102116. * @returns the emitter
  102117. */
  102118. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  102119. /**
  102120. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  102121. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  102122. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  102123. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  102124. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  102125. * @returns the emitter
  102126. */
  102127. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  102128. /**
  102129. * Get hosting scene
  102130. * @returns the scene
  102131. */
  102132. getScene(): Nullable<Scene>;
  102133. }
  102134. }
  102135. declare module BABYLON {
  102136. /**
  102137. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  102138. */
  102139. export class ColorSplitterBlock extends NodeMaterialBlock {
  102140. /**
  102141. * Create a new ColorSplitterBlock
  102142. * @param name defines the block name
  102143. */
  102144. constructor(name: string);
  102145. /**
  102146. * Gets the current class name
  102147. * @returns the class name
  102148. */
  102149. getClassName(): string;
  102150. /**
  102151. * Gets the rgba component (input)
  102152. */
  102153. get rgba(): NodeMaterialConnectionPoint;
  102154. /**
  102155. * Gets the rgb component (input)
  102156. */
  102157. get rgbIn(): NodeMaterialConnectionPoint;
  102158. /**
  102159. * Gets the rgb component (output)
  102160. */
  102161. get rgbOut(): NodeMaterialConnectionPoint;
  102162. /**
  102163. * Gets the r component (output)
  102164. */
  102165. get r(): NodeMaterialConnectionPoint;
  102166. /**
  102167. * Gets the g component (output)
  102168. */
  102169. get g(): NodeMaterialConnectionPoint;
  102170. /**
  102171. * Gets the b component (output)
  102172. */
  102173. get b(): NodeMaterialConnectionPoint;
  102174. /**
  102175. * Gets the a component (output)
  102176. */
  102177. get a(): NodeMaterialConnectionPoint;
  102178. protected _inputRename(name: string): string;
  102179. protected _outputRename(name: string): string;
  102180. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102181. }
  102182. }
  102183. declare module BABYLON {
  102184. /**
  102185. * Operations supported by the Trigonometry block
  102186. */
  102187. export enum TrigonometryBlockOperations {
  102188. /** Cos */
  102189. Cos = 0,
  102190. /** Sin */
  102191. Sin = 1,
  102192. /** Abs */
  102193. Abs = 2,
  102194. /** Exp */
  102195. Exp = 3,
  102196. /** Exp2 */
  102197. Exp2 = 4,
  102198. /** Round */
  102199. Round = 5,
  102200. /** Floor */
  102201. Floor = 6,
  102202. /** Ceiling */
  102203. Ceiling = 7,
  102204. /** Square root */
  102205. Sqrt = 8,
  102206. /** Log */
  102207. Log = 9,
  102208. /** Tangent */
  102209. Tan = 10,
  102210. /** Arc tangent */
  102211. ArcTan = 11,
  102212. /** Arc cosinus */
  102213. ArcCos = 12,
  102214. /** Arc sinus */
  102215. ArcSin = 13,
  102216. /** Fraction */
  102217. Fract = 14,
  102218. /** Sign */
  102219. Sign = 15,
  102220. /** To radians (from degrees) */
  102221. Radians = 16,
  102222. /** To degrees (from radians) */
  102223. Degrees = 17
  102224. }
  102225. /**
  102226. * Block used to apply trigonometry operation to floats
  102227. */
  102228. export class TrigonometryBlock extends NodeMaterialBlock {
  102229. /**
  102230. * Gets or sets the operation applied by the block
  102231. */
  102232. operation: TrigonometryBlockOperations;
  102233. /**
  102234. * Creates a new TrigonometryBlock
  102235. * @param name defines the block name
  102236. */
  102237. constructor(name: string);
  102238. /**
  102239. * Gets the current class name
  102240. * @returns the class name
  102241. */
  102242. getClassName(): string;
  102243. /**
  102244. * Gets the input component
  102245. */
  102246. get input(): NodeMaterialConnectionPoint;
  102247. /**
  102248. * Gets the output component
  102249. */
  102250. get output(): NodeMaterialConnectionPoint;
  102251. protected _buildBlock(state: NodeMaterialBuildState): this;
  102252. serialize(): any;
  102253. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102254. protected _dumpPropertiesCode(): string;
  102255. }
  102256. }
  102257. declare module BABYLON {
  102258. /**
  102259. * Interface used to configure the node material editor
  102260. */
  102261. export interface INodeMaterialEditorOptions {
  102262. /** Define the URl to load node editor script */
  102263. editorURL?: string;
  102264. }
  102265. /** @hidden */
  102266. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  102267. NORMAL: boolean;
  102268. TANGENT: boolean;
  102269. UV1: boolean;
  102270. /** BONES */
  102271. NUM_BONE_INFLUENCERS: number;
  102272. BonesPerMesh: number;
  102273. BONETEXTURE: boolean;
  102274. /** MORPH TARGETS */
  102275. MORPHTARGETS: boolean;
  102276. MORPHTARGETS_NORMAL: boolean;
  102277. MORPHTARGETS_TANGENT: boolean;
  102278. MORPHTARGETS_UV: boolean;
  102279. NUM_MORPH_INFLUENCERS: number;
  102280. /** IMAGE PROCESSING */
  102281. IMAGEPROCESSING: boolean;
  102282. VIGNETTE: boolean;
  102283. VIGNETTEBLENDMODEMULTIPLY: boolean;
  102284. VIGNETTEBLENDMODEOPAQUE: boolean;
  102285. TONEMAPPING: boolean;
  102286. TONEMAPPING_ACES: boolean;
  102287. CONTRAST: boolean;
  102288. EXPOSURE: boolean;
  102289. COLORCURVES: boolean;
  102290. COLORGRADING: boolean;
  102291. COLORGRADING3D: boolean;
  102292. SAMPLER3DGREENDEPTH: boolean;
  102293. SAMPLER3DBGRMAP: boolean;
  102294. IMAGEPROCESSINGPOSTPROCESS: boolean;
  102295. /** MISC. */
  102296. BUMPDIRECTUV: number;
  102297. constructor();
  102298. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  102299. }
  102300. /**
  102301. * Class used to configure NodeMaterial
  102302. */
  102303. export interface INodeMaterialOptions {
  102304. /**
  102305. * Defines if blocks should emit comments
  102306. */
  102307. emitComments: boolean;
  102308. }
  102309. /**
  102310. * Class used to create a node based material built by assembling shader blocks
  102311. */
  102312. export class NodeMaterial extends PushMaterial {
  102313. private static _BuildIdGenerator;
  102314. private _options;
  102315. private _vertexCompilationState;
  102316. private _fragmentCompilationState;
  102317. private _sharedData;
  102318. private _buildId;
  102319. private _buildWasSuccessful;
  102320. private _cachedWorldViewMatrix;
  102321. private _cachedWorldViewProjectionMatrix;
  102322. private _optimizers;
  102323. private _animationFrame;
  102324. /** Define the Url to load node editor script */
  102325. static EditorURL: string;
  102326. /** Define the Url to load snippets */
  102327. static SnippetUrl: string;
  102328. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  102329. static IgnoreTexturesAtLoadTime: boolean;
  102330. private BJSNODEMATERIALEDITOR;
  102331. /** Get the inspector from bundle or global */
  102332. private _getGlobalNodeMaterialEditor;
  102333. /**
  102334. * Snippet ID if the material was created from the snippet server
  102335. */
  102336. snippetId: string;
  102337. /**
  102338. * Gets or sets data used by visual editor
  102339. * @see https://nme.babylonjs.com
  102340. */
  102341. editorData: any;
  102342. /**
  102343. * 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)
  102344. */
  102345. ignoreAlpha: boolean;
  102346. /**
  102347. * Defines the maximum number of lights that can be used in the material
  102348. */
  102349. maxSimultaneousLights: number;
  102350. /**
  102351. * Observable raised when the material is built
  102352. */
  102353. onBuildObservable: Observable<NodeMaterial>;
  102354. /**
  102355. * Gets or sets the root nodes of the material vertex shader
  102356. */
  102357. _vertexOutputNodes: NodeMaterialBlock[];
  102358. /**
  102359. * Gets or sets the root nodes of the material fragment (pixel) shader
  102360. */
  102361. _fragmentOutputNodes: NodeMaterialBlock[];
  102362. /** Gets or sets options to control the node material overall behavior */
  102363. get options(): INodeMaterialOptions;
  102364. set options(options: INodeMaterialOptions);
  102365. /**
  102366. * Default configuration related to image processing available in the standard Material.
  102367. */
  102368. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102369. /**
  102370. * Gets the image processing configuration used either in this material.
  102371. */
  102372. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  102373. /**
  102374. * Sets the Default image processing configuration used either in the this material.
  102375. *
  102376. * If sets to null, the scene one is in use.
  102377. */
  102378. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  102379. /**
  102380. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  102381. */
  102382. attachedBlocks: NodeMaterialBlock[];
  102383. /**
  102384. * Specifies the mode of the node material
  102385. * @hidden
  102386. */
  102387. _mode: NodeMaterialModes;
  102388. /**
  102389. * Gets the mode property
  102390. */
  102391. get mode(): NodeMaterialModes;
  102392. /**
  102393. * A free comment about the material
  102394. */
  102395. comment: string;
  102396. /**
  102397. * Create a new node based material
  102398. * @param name defines the material name
  102399. * @param scene defines the hosting scene
  102400. * @param options defines creation option
  102401. */
  102402. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  102403. /**
  102404. * Gets the current class name of the material e.g. "NodeMaterial"
  102405. * @returns the class name
  102406. */
  102407. getClassName(): string;
  102408. /**
  102409. * Keep track of the image processing observer to allow dispose and replace.
  102410. */
  102411. private _imageProcessingObserver;
  102412. /**
  102413. * Attaches a new image processing configuration to the Standard Material.
  102414. * @param configuration
  102415. */
  102416. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102417. /**
  102418. * Get a block by its name
  102419. * @param name defines the name of the block to retrieve
  102420. * @returns the required block or null if not found
  102421. */
  102422. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  102423. /**
  102424. * Get a block by its name
  102425. * @param predicate defines the predicate used to find the good candidate
  102426. * @returns the required block or null if not found
  102427. */
  102428. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  102429. /**
  102430. * Get an input block by its name
  102431. * @param predicate defines the predicate used to find the good candidate
  102432. * @returns the required input block or null if not found
  102433. */
  102434. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  102435. /**
  102436. * Gets the list of input blocks attached to this material
  102437. * @returns an array of InputBlocks
  102438. */
  102439. getInputBlocks(): InputBlock[];
  102440. /**
  102441. * Adds a new optimizer to the list of optimizers
  102442. * @param optimizer defines the optimizers to add
  102443. * @returns the current material
  102444. */
  102445. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  102446. /**
  102447. * Remove an optimizer from the list of optimizers
  102448. * @param optimizer defines the optimizers to remove
  102449. * @returns the current material
  102450. */
  102451. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  102452. /**
  102453. * Add a new block to the list of output nodes
  102454. * @param node defines the node to add
  102455. * @returns the current material
  102456. */
  102457. addOutputNode(node: NodeMaterialBlock): this;
  102458. /**
  102459. * Remove a block from the list of root nodes
  102460. * @param node defines the node to remove
  102461. * @returns the current material
  102462. */
  102463. removeOutputNode(node: NodeMaterialBlock): this;
  102464. private _addVertexOutputNode;
  102465. private _removeVertexOutputNode;
  102466. private _addFragmentOutputNode;
  102467. private _removeFragmentOutputNode;
  102468. /**
  102469. * Specifies if the material will require alpha blending
  102470. * @returns a boolean specifying if alpha blending is needed
  102471. */
  102472. needAlphaBlending(): boolean;
  102473. /**
  102474. * Specifies if this material should be rendered in alpha test mode
  102475. * @returns a boolean specifying if an alpha test is needed.
  102476. */
  102477. needAlphaTesting(): boolean;
  102478. private _initializeBlock;
  102479. private _resetDualBlocks;
  102480. /**
  102481. * Remove a block from the current node material
  102482. * @param block defines the block to remove
  102483. */
  102484. removeBlock(block: NodeMaterialBlock): void;
  102485. /**
  102486. * Build the material and generates the inner effect
  102487. * @param verbose defines if the build should log activity
  102488. */
  102489. build(verbose?: boolean): void;
  102490. /**
  102491. * Runs an otpimization phase to try to improve the shader code
  102492. */
  102493. optimize(): void;
  102494. private _prepareDefinesForAttributes;
  102495. /**
  102496. * Create a post process from the material
  102497. * @param camera The camera to apply the render pass to.
  102498. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  102499. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102500. * @param engine The engine which the post process will be applied. (default: current engine)
  102501. * @param reusable If the post process can be reused on the same frame. (default: false)
  102502. * @param textureType Type of textures used when performing the post process. (default: 0)
  102503. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  102504. * @returns the post process created
  102505. */
  102506. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  102507. /**
  102508. * Create the post process effect from the material
  102509. * @param postProcess The post process to create the effect for
  102510. */
  102511. createEffectForPostProcess(postProcess: PostProcess): void;
  102512. private _createEffectForPostProcess;
  102513. /**
  102514. * Create a new procedural texture based on this node material
  102515. * @param size defines the size of the texture
  102516. * @param scene defines the hosting scene
  102517. * @returns the new procedural texture attached to this node material
  102518. */
  102519. createProceduralTexture(size: number | {
  102520. width: number;
  102521. height: number;
  102522. layers?: number;
  102523. }, scene: Scene): Nullable<ProceduralTexture>;
  102524. private _createEffectForParticles;
  102525. private _checkInternals;
  102526. /**
  102527. * Create the effect to be used as the custom effect for a particle system
  102528. * @param particleSystem Particle system to create the effect for
  102529. * @param onCompiled defines a function to call when the effect creation is successful
  102530. * @param onError defines a function to call when the effect creation has failed
  102531. */
  102532. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  102533. private _processDefines;
  102534. /**
  102535. * Get if the submesh is ready to be used and all its information available.
  102536. * Child classes can use it to update shaders
  102537. * @param mesh defines the mesh to check
  102538. * @param subMesh defines which submesh to check
  102539. * @param useInstances specifies that instances should be used
  102540. * @returns a boolean indicating that the submesh is ready or not
  102541. */
  102542. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102543. /**
  102544. * Get a string representing the shaders built by the current node graph
  102545. */
  102546. get compiledShaders(): string;
  102547. /**
  102548. * Binds the world matrix to the material
  102549. * @param world defines the world transformation matrix
  102550. */
  102551. bindOnlyWorldMatrix(world: Matrix): void;
  102552. /**
  102553. * Binds the submesh to this material by preparing the effect and shader to draw
  102554. * @param world defines the world transformation matrix
  102555. * @param mesh defines the mesh containing the submesh
  102556. * @param subMesh defines the submesh to bind the material to
  102557. */
  102558. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102559. /**
  102560. * Gets the active textures from the material
  102561. * @returns an array of textures
  102562. */
  102563. getActiveTextures(): BaseTexture[];
  102564. /**
  102565. * Gets the list of texture blocks
  102566. * @returns an array of texture blocks
  102567. */
  102568. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  102569. /**
  102570. * Specifies if the material uses a texture
  102571. * @param texture defines the texture to check against the material
  102572. * @returns a boolean specifying if the material uses the texture
  102573. */
  102574. hasTexture(texture: BaseTexture): boolean;
  102575. /**
  102576. * Disposes the material
  102577. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  102578. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  102579. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  102580. */
  102581. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  102582. /** Creates the node editor window. */
  102583. private _createNodeEditor;
  102584. /**
  102585. * Launch the node material editor
  102586. * @param config Define the configuration of the editor
  102587. * @return a promise fulfilled when the node editor is visible
  102588. */
  102589. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  102590. /**
  102591. * Clear the current material
  102592. */
  102593. clear(): void;
  102594. /**
  102595. * Clear the current material and set it to a default state
  102596. */
  102597. setToDefault(): void;
  102598. /**
  102599. * Clear the current material and set it to a default state for post process
  102600. */
  102601. setToDefaultPostProcess(): void;
  102602. /**
  102603. * Clear the current material and set it to a default state for procedural texture
  102604. */
  102605. setToDefaultProceduralTexture(): void;
  102606. /**
  102607. * Clear the current material and set it to a default state for particle
  102608. */
  102609. setToDefaultParticle(): void;
  102610. /**
  102611. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  102612. * @param url defines the url to load from
  102613. * @returns a promise that will fullfil when the material is fully loaded
  102614. */
  102615. loadAsync(url: string): Promise<void>;
  102616. private _gatherBlocks;
  102617. /**
  102618. * Generate a string containing the code declaration required to create an equivalent of this material
  102619. * @returns a string
  102620. */
  102621. generateCode(): string;
  102622. /**
  102623. * Serializes this material in a JSON representation
  102624. * @returns the serialized material object
  102625. */
  102626. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  102627. private _restoreConnections;
  102628. /**
  102629. * Clear the current graph and load a new one from a serialization object
  102630. * @param source defines the JSON representation of the material
  102631. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102632. * @param merge defines whether or not the source must be merged or replace the current content
  102633. */
  102634. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  102635. /**
  102636. * Makes a duplicate of the current material.
  102637. * @param name - name to use for the new material.
  102638. */
  102639. clone(name: string): NodeMaterial;
  102640. /**
  102641. * Creates a node material from parsed material data
  102642. * @param source defines the JSON representation of the material
  102643. * @param scene defines the hosting scene
  102644. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102645. * @returns a new node material
  102646. */
  102647. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  102648. /**
  102649. * Creates a node material from a snippet saved in a remote file
  102650. * @param name defines the name of the material to create
  102651. * @param url defines the url to load from
  102652. * @param scene defines the hosting scene
  102653. * @returns a promise that will resolve to the new node material
  102654. */
  102655. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  102656. /**
  102657. * Creates a node material from a snippet saved by the node material editor
  102658. * @param snippetId defines the snippet to load
  102659. * @param scene defines the hosting scene
  102660. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102661. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  102662. * @returns a promise that will resolve to the new node material
  102663. */
  102664. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  102665. /**
  102666. * Creates a new node material set to default basic configuration
  102667. * @param name defines the name of the material
  102668. * @param scene defines the hosting scene
  102669. * @returns a new NodeMaterial
  102670. */
  102671. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  102672. }
  102673. }
  102674. declare module BABYLON {
  102675. interface ThinEngine {
  102676. /**
  102677. * Unbind a list of render target textures from the webGL context
  102678. * This is used only when drawBuffer extension or webGL2 are active
  102679. * @param textures defines the render target textures to unbind
  102680. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  102681. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  102682. */
  102683. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  102684. /**
  102685. * Create a multi render target texture
  102686. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  102687. * @param size defines the size of the texture
  102688. * @param options defines the creation options
  102689. * @returns the cube texture as an InternalTexture
  102690. */
  102691. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  102692. /**
  102693. * Update the sample count for a given multiple render target texture
  102694. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  102695. * @param textures defines the textures to update
  102696. * @param samples defines the sample count to set
  102697. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  102698. */
  102699. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  102700. /**
  102701. * Select a subsets of attachments to draw to.
  102702. * @param attachments gl attachments
  102703. */
  102704. bindAttachments(attachments: number[]): void;
  102705. /**
  102706. * Creates a layout object to draw/clear on specific textures in a MRT
  102707. * @param textureStatus textureStatus[i] indicates if the i-th is active
  102708. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  102709. */
  102710. buildTextureLayout(textureStatus: boolean[]): number[];
  102711. /**
  102712. * Restores the webgl state to only draw on the main color attachment
  102713. */
  102714. restoreSingleAttachment(): void;
  102715. /**
  102716. * Clears a list of attachments
  102717. * @param attachments list of the attachments
  102718. * @param colorMain clear color for the main attachment (the first one)
  102719. * @param colorOthers clear color for the other attachments
  102720. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  102721. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  102722. */
  102723. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  102724. }
  102725. }
  102726. declare module BABYLON {
  102727. /**
  102728. * Creation options of the multi render target texture.
  102729. */
  102730. export interface IMultiRenderTargetOptions {
  102731. /**
  102732. * Define if the texture needs to create mip maps after render.
  102733. */
  102734. generateMipMaps?: boolean;
  102735. /**
  102736. * Define the types of all the draw buffers we want to create
  102737. */
  102738. types?: number[];
  102739. /**
  102740. * Define the sampling modes of all the draw buffers we want to create
  102741. */
  102742. samplingModes?: number[];
  102743. /**
  102744. * Define if a depth buffer is required
  102745. */
  102746. generateDepthBuffer?: boolean;
  102747. /**
  102748. * Define if a stencil buffer is required
  102749. */
  102750. generateStencilBuffer?: boolean;
  102751. /**
  102752. * Define if a depth texture is required instead of a depth buffer
  102753. */
  102754. generateDepthTexture?: boolean;
  102755. /**
  102756. * Define the number of desired draw buffers
  102757. */
  102758. textureCount?: number;
  102759. /**
  102760. * Define if aspect ratio should be adapted to the texture or stay the scene one
  102761. */
  102762. doNotChangeAspectRatio?: boolean;
  102763. /**
  102764. * Define the default type of the buffers we are creating
  102765. */
  102766. defaultType?: number;
  102767. }
  102768. /**
  102769. * A multi render target, like a render target provides the ability to render to a texture.
  102770. * Unlike the render target, it can render to several draw buffers in one draw.
  102771. * This is specially interesting in deferred rendering or for any effects requiring more than
  102772. * just one color from a single pass.
  102773. */
  102774. export class MultiRenderTarget extends RenderTargetTexture {
  102775. private _internalTextures;
  102776. private _textures;
  102777. private _multiRenderTargetOptions;
  102778. private _count;
  102779. /**
  102780. * Get if draw buffers are currently supported by the used hardware and browser.
  102781. */
  102782. get isSupported(): boolean;
  102783. /**
  102784. * Get the list of textures generated by the multi render target.
  102785. */
  102786. get textures(): Texture[];
  102787. /**
  102788. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  102789. */
  102790. get count(): number;
  102791. /**
  102792. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  102793. */
  102794. get depthTexture(): Texture;
  102795. /**
  102796. * Set the wrapping mode on U of all the textures we are rendering to.
  102797. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  102798. */
  102799. set wrapU(wrap: number);
  102800. /**
  102801. * Set the wrapping mode on V of all the textures we are rendering to.
  102802. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  102803. */
  102804. set wrapV(wrap: number);
  102805. /**
  102806. * Instantiate a new multi render target texture.
  102807. * A multi render target, like a render target provides the ability to render to a texture.
  102808. * Unlike the render target, it can render to several draw buffers in one draw.
  102809. * This is specially interesting in deferred rendering or for any effects requiring more than
  102810. * just one color from a single pass.
  102811. * @param name Define the name of the texture
  102812. * @param size Define the size of the buffers to render to
  102813. * @param count Define the number of target we are rendering into
  102814. * @param scene Define the scene the texture belongs to
  102815. * @param options Define the options used to create the multi render target
  102816. */
  102817. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  102818. private _initTypes;
  102819. /** @hidden */
  102820. _rebuild(forceFullRebuild?: boolean): void;
  102821. private _createInternalTextures;
  102822. private _createTextures;
  102823. /**
  102824. * Replaces a texture within the MRT.
  102825. * @param texture The new texture to insert in the MRT
  102826. * @param index The index of the texture to replace
  102827. */
  102828. replaceTexture(texture: Texture, index: number): void;
  102829. /**
  102830. * Define the number of samples used if MSAA is enabled.
  102831. */
  102832. get samples(): number;
  102833. set samples(value: number);
  102834. /**
  102835. * Resize all the textures in the multi render target.
  102836. * Be careful as it will recreate all the data in the new texture.
  102837. * @param size Define the new size
  102838. */
  102839. resize(size: any): void;
  102840. /**
  102841. * Changes the number of render targets in this MRT
  102842. * Be careful as it will recreate all the data in the new texture.
  102843. * @param count new texture count
  102844. * @param options Specifies texture types and sampling modes for new textures
  102845. */
  102846. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  102847. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  102848. /**
  102849. * Dispose the render targets and their associated resources
  102850. */
  102851. dispose(): void;
  102852. /**
  102853. * Release all the underlying texture used as draw buffers.
  102854. */
  102855. releaseInternalTextures(): void;
  102856. }
  102857. }
  102858. declare module BABYLON {
  102859. /** @hidden */
  102860. export var imageProcessingPixelShader: {
  102861. name: string;
  102862. shader: string;
  102863. };
  102864. }
  102865. declare module BABYLON {
  102866. /**
  102867. * ImageProcessingPostProcess
  102868. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  102869. */
  102870. export class ImageProcessingPostProcess extends PostProcess {
  102871. /**
  102872. * Default configuration related to image processing available in the PBR Material.
  102873. */
  102874. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102875. /**
  102876. * Gets the image processing configuration used either in this material.
  102877. */
  102878. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  102879. /**
  102880. * Sets the Default image processing configuration used either in the this material.
  102881. *
  102882. * If sets to null, the scene one is in use.
  102883. */
  102884. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  102885. /**
  102886. * Keep track of the image processing observer to allow dispose and replace.
  102887. */
  102888. private _imageProcessingObserver;
  102889. /**
  102890. * Attaches a new image processing configuration to the PBR Material.
  102891. * @param configuration
  102892. */
  102893. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  102894. /**
  102895. * If the post process is supported.
  102896. */
  102897. get isSupported(): boolean;
  102898. /**
  102899. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102900. */
  102901. get colorCurves(): Nullable<ColorCurves>;
  102902. /**
  102903. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102904. */
  102905. set colorCurves(value: Nullable<ColorCurves>);
  102906. /**
  102907. * Gets wether the color curves effect is enabled.
  102908. */
  102909. get colorCurvesEnabled(): boolean;
  102910. /**
  102911. * Sets wether the color curves effect is enabled.
  102912. */
  102913. set colorCurvesEnabled(value: boolean);
  102914. /**
  102915. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102916. */
  102917. get colorGradingTexture(): Nullable<BaseTexture>;
  102918. /**
  102919. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102920. */
  102921. set colorGradingTexture(value: Nullable<BaseTexture>);
  102922. /**
  102923. * Gets wether the color grading effect is enabled.
  102924. */
  102925. get colorGradingEnabled(): boolean;
  102926. /**
  102927. * Gets wether the color grading effect is enabled.
  102928. */
  102929. set colorGradingEnabled(value: boolean);
  102930. /**
  102931. * Gets exposure used in the effect.
  102932. */
  102933. get exposure(): number;
  102934. /**
  102935. * Sets exposure used in the effect.
  102936. */
  102937. set exposure(value: number);
  102938. /**
  102939. * Gets wether tonemapping is enabled or not.
  102940. */
  102941. get toneMappingEnabled(): boolean;
  102942. /**
  102943. * Sets wether tonemapping is enabled or not
  102944. */
  102945. set toneMappingEnabled(value: boolean);
  102946. /**
  102947. * Gets the type of tone mapping effect.
  102948. */
  102949. get toneMappingType(): number;
  102950. /**
  102951. * Sets the type of tone mapping effect.
  102952. */
  102953. set toneMappingType(value: number);
  102954. /**
  102955. * Gets contrast used in the effect.
  102956. */
  102957. get contrast(): number;
  102958. /**
  102959. * Sets contrast used in the effect.
  102960. */
  102961. set contrast(value: number);
  102962. /**
  102963. * Gets Vignette stretch size.
  102964. */
  102965. get vignetteStretch(): number;
  102966. /**
  102967. * Sets Vignette stretch size.
  102968. */
  102969. set vignetteStretch(value: number);
  102970. /**
  102971. * Gets Vignette centre X Offset.
  102972. */
  102973. get vignetteCentreX(): number;
  102974. /**
  102975. * Sets Vignette centre X Offset.
  102976. */
  102977. set vignetteCentreX(value: number);
  102978. /**
  102979. * Gets Vignette centre Y Offset.
  102980. */
  102981. get vignetteCentreY(): number;
  102982. /**
  102983. * Sets Vignette centre Y Offset.
  102984. */
  102985. set vignetteCentreY(value: number);
  102986. /**
  102987. * Gets Vignette weight or intensity of the vignette effect.
  102988. */
  102989. get vignetteWeight(): number;
  102990. /**
  102991. * Sets Vignette weight or intensity of the vignette effect.
  102992. */
  102993. set vignetteWeight(value: number);
  102994. /**
  102995. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102996. * if vignetteEnabled is set to true.
  102997. */
  102998. get vignetteColor(): Color4;
  102999. /**
  103000. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103001. * if vignetteEnabled is set to true.
  103002. */
  103003. set vignetteColor(value: Color4);
  103004. /**
  103005. * Gets Camera field of view used by the Vignette effect.
  103006. */
  103007. get vignetteCameraFov(): number;
  103008. /**
  103009. * Sets Camera field of view used by the Vignette effect.
  103010. */
  103011. set vignetteCameraFov(value: number);
  103012. /**
  103013. * Gets the vignette blend mode allowing different kind of effect.
  103014. */
  103015. get vignetteBlendMode(): number;
  103016. /**
  103017. * Sets the vignette blend mode allowing different kind of effect.
  103018. */
  103019. set vignetteBlendMode(value: number);
  103020. /**
  103021. * Gets wether the vignette effect is enabled.
  103022. */
  103023. get vignetteEnabled(): boolean;
  103024. /**
  103025. * Sets wether the vignette effect is enabled.
  103026. */
  103027. set vignetteEnabled(value: boolean);
  103028. private _fromLinearSpace;
  103029. /**
  103030. * Gets wether the input of the processing is in Gamma or Linear Space.
  103031. */
  103032. get fromLinearSpace(): boolean;
  103033. /**
  103034. * Sets wether the input of the processing is in Gamma or Linear Space.
  103035. */
  103036. set fromLinearSpace(value: boolean);
  103037. /**
  103038. * Defines cache preventing GC.
  103039. */
  103040. private _defines;
  103041. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  103042. /**
  103043. * "ImageProcessingPostProcess"
  103044. * @returns "ImageProcessingPostProcess"
  103045. */
  103046. getClassName(): string;
  103047. /**
  103048. * @hidden
  103049. */
  103050. _updateParameters(): void;
  103051. dispose(camera?: Camera): void;
  103052. }
  103053. }
  103054. declare module BABYLON {
  103055. /**
  103056. * Interface for defining prepass effects in the prepass post-process pipeline
  103057. */
  103058. export interface PrePassEffectConfiguration {
  103059. /**
  103060. * Name of the effect
  103061. */
  103062. name: string;
  103063. /**
  103064. * Post process to attach for this effect
  103065. */
  103066. postProcess?: PostProcess;
  103067. /**
  103068. * Textures required in the MRT
  103069. */
  103070. texturesRequired: number[];
  103071. /**
  103072. * Is the effect enabled
  103073. */
  103074. enabled: boolean;
  103075. /**
  103076. * Disposes the effect configuration
  103077. */
  103078. dispose?: () => void;
  103079. /**
  103080. * Creates the associated post process
  103081. */
  103082. createPostProcess?: () => PostProcess;
  103083. }
  103084. }
  103085. declare module BABYLON {
  103086. /**
  103087. * Options to be used when creating a FresnelParameters.
  103088. */
  103089. export type IFresnelParametersCreationOptions = {
  103090. /**
  103091. * Define the color used on edges (grazing angle)
  103092. */
  103093. leftColor?: Color3;
  103094. /**
  103095. * Define the color used on center
  103096. */
  103097. rightColor?: Color3;
  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. * Serialized format for FresnelParameters.
  103113. */
  103114. export type IFresnelParametersSerialized = {
  103115. /**
  103116. * Define the color used on edges (grazing angle) [as an array]
  103117. */
  103118. leftColor: number[];
  103119. /**
  103120. * Define the color used on center [as an array]
  103121. */
  103122. rightColor: number[];
  103123. /**
  103124. * Define bias applied to computed fresnel term
  103125. */
  103126. bias: number;
  103127. /**
  103128. * Defined the power exponent applied to fresnel term
  103129. */
  103130. power?: number;
  103131. /**
  103132. * Define if the fresnel effect is enable or not.
  103133. */
  103134. isEnabled: boolean;
  103135. };
  103136. /**
  103137. * This represents all the required information to add a fresnel effect on a material:
  103138. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103139. */
  103140. export class FresnelParameters {
  103141. private _isEnabled;
  103142. /**
  103143. * Define if the fresnel effect is enable or not.
  103144. */
  103145. get isEnabled(): boolean;
  103146. set isEnabled(value: boolean);
  103147. /**
  103148. * Define the color used on edges (grazing angle)
  103149. */
  103150. leftColor: Color3;
  103151. /**
  103152. * Define the color used on center
  103153. */
  103154. rightColor: Color3;
  103155. /**
  103156. * Define bias applied to computed fresnel term
  103157. */
  103158. bias: number;
  103159. /**
  103160. * Defined the power exponent applied to fresnel term
  103161. */
  103162. power: number;
  103163. /**
  103164. * Creates a new FresnelParameters object.
  103165. *
  103166. * @param options provide your own settings to optionally to override defaults
  103167. */
  103168. constructor(options?: IFresnelParametersCreationOptions);
  103169. /**
  103170. * Clones the current fresnel and its valuues
  103171. * @returns a clone fresnel configuration
  103172. */
  103173. clone(): FresnelParameters;
  103174. /**
  103175. * Determines equality between FresnelParameters objects
  103176. * @param otherFresnelParameters defines the second operand
  103177. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  103178. */
  103179. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  103180. /**
  103181. * Serializes the current fresnel parameters to a JSON representation.
  103182. * @return the JSON serialization
  103183. */
  103184. serialize(): IFresnelParametersSerialized;
  103185. /**
  103186. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  103187. * @param parsedFresnelParameters Define the JSON representation
  103188. * @returns the parsed parameters
  103189. */
  103190. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  103191. }
  103192. }
  103193. declare module BABYLON {
  103194. /**
  103195. * This groups all the flags used to control the materials channel.
  103196. */
  103197. export class MaterialFlags {
  103198. private static _DiffuseTextureEnabled;
  103199. /**
  103200. * Are diffuse textures enabled in the application.
  103201. */
  103202. static get DiffuseTextureEnabled(): boolean;
  103203. static set DiffuseTextureEnabled(value: boolean);
  103204. private static _DetailTextureEnabled;
  103205. /**
  103206. * Are detail textures enabled in the application.
  103207. */
  103208. static get DetailTextureEnabled(): boolean;
  103209. static set DetailTextureEnabled(value: boolean);
  103210. private static _AmbientTextureEnabled;
  103211. /**
  103212. * Are ambient textures enabled in the application.
  103213. */
  103214. static get AmbientTextureEnabled(): boolean;
  103215. static set AmbientTextureEnabled(value: boolean);
  103216. private static _OpacityTextureEnabled;
  103217. /**
  103218. * Are opacity textures enabled in the application.
  103219. */
  103220. static get OpacityTextureEnabled(): boolean;
  103221. static set OpacityTextureEnabled(value: boolean);
  103222. private static _ReflectionTextureEnabled;
  103223. /**
  103224. * Are reflection textures enabled in the application.
  103225. */
  103226. static get ReflectionTextureEnabled(): boolean;
  103227. static set ReflectionTextureEnabled(value: boolean);
  103228. private static _EmissiveTextureEnabled;
  103229. /**
  103230. * Are emissive textures enabled in the application.
  103231. */
  103232. static get EmissiveTextureEnabled(): boolean;
  103233. static set EmissiveTextureEnabled(value: boolean);
  103234. private static _SpecularTextureEnabled;
  103235. /**
  103236. * Are specular textures enabled in the application.
  103237. */
  103238. static get SpecularTextureEnabled(): boolean;
  103239. static set SpecularTextureEnabled(value: boolean);
  103240. private static _BumpTextureEnabled;
  103241. /**
  103242. * Are bump textures enabled in the application.
  103243. */
  103244. static get BumpTextureEnabled(): boolean;
  103245. static set BumpTextureEnabled(value: boolean);
  103246. private static _LightmapTextureEnabled;
  103247. /**
  103248. * Are lightmap textures enabled in the application.
  103249. */
  103250. static get LightmapTextureEnabled(): boolean;
  103251. static set LightmapTextureEnabled(value: boolean);
  103252. private static _RefractionTextureEnabled;
  103253. /**
  103254. * Are refraction textures enabled in the application.
  103255. */
  103256. static get RefractionTextureEnabled(): boolean;
  103257. static set RefractionTextureEnabled(value: boolean);
  103258. private static _ColorGradingTextureEnabled;
  103259. /**
  103260. * Are color grading textures enabled in the application.
  103261. */
  103262. static get ColorGradingTextureEnabled(): boolean;
  103263. static set ColorGradingTextureEnabled(value: boolean);
  103264. private static _FresnelEnabled;
  103265. /**
  103266. * Are fresnels enabled in the application.
  103267. */
  103268. static get FresnelEnabled(): boolean;
  103269. static set FresnelEnabled(value: boolean);
  103270. private static _ClearCoatTextureEnabled;
  103271. /**
  103272. * Are clear coat textures enabled in the application.
  103273. */
  103274. static get ClearCoatTextureEnabled(): boolean;
  103275. static set ClearCoatTextureEnabled(value: boolean);
  103276. private static _ClearCoatBumpTextureEnabled;
  103277. /**
  103278. * Are clear coat bump textures enabled in the application.
  103279. */
  103280. static get ClearCoatBumpTextureEnabled(): boolean;
  103281. static set ClearCoatBumpTextureEnabled(value: boolean);
  103282. private static _ClearCoatTintTextureEnabled;
  103283. /**
  103284. * Are clear coat tint textures enabled in the application.
  103285. */
  103286. static get ClearCoatTintTextureEnabled(): boolean;
  103287. static set ClearCoatTintTextureEnabled(value: boolean);
  103288. private static _SheenTextureEnabled;
  103289. /**
  103290. * Are sheen textures enabled in the application.
  103291. */
  103292. static get SheenTextureEnabled(): boolean;
  103293. static set SheenTextureEnabled(value: boolean);
  103294. private static _AnisotropicTextureEnabled;
  103295. /**
  103296. * Are anisotropic textures enabled in the application.
  103297. */
  103298. static get AnisotropicTextureEnabled(): boolean;
  103299. static set AnisotropicTextureEnabled(value: boolean);
  103300. private static _ThicknessTextureEnabled;
  103301. /**
  103302. * Are thickness textures enabled in the application.
  103303. */
  103304. static get ThicknessTextureEnabled(): boolean;
  103305. static set ThicknessTextureEnabled(value: boolean);
  103306. }
  103307. }
  103308. declare module BABYLON {
  103309. /** @hidden */
  103310. export var defaultFragmentDeclaration: {
  103311. name: string;
  103312. shader: string;
  103313. };
  103314. }
  103315. declare module BABYLON {
  103316. /** @hidden */
  103317. export var sceneUboDeclaration: {
  103318. name: string;
  103319. shader: string;
  103320. };
  103321. }
  103322. declare module BABYLON {
  103323. /** @hidden */
  103324. export var meshUboDeclaration: {
  103325. name: string;
  103326. shader: string;
  103327. };
  103328. }
  103329. declare module BABYLON {
  103330. /** @hidden */
  103331. export var defaultUboDeclaration: {
  103332. name: string;
  103333. shader: string;
  103334. };
  103335. }
  103336. declare module BABYLON {
  103337. /** @hidden */
  103338. export var prePassDeclaration: {
  103339. name: string;
  103340. shader: string;
  103341. };
  103342. }
  103343. declare module BABYLON {
  103344. /** @hidden */
  103345. export var lightFragmentDeclaration: {
  103346. name: string;
  103347. shader: string;
  103348. };
  103349. }
  103350. declare module BABYLON {
  103351. /** @hidden */
  103352. export var lightUboDeclaration: {
  103353. name: string;
  103354. shader: string;
  103355. };
  103356. }
  103357. declare module BABYLON {
  103358. /** @hidden */
  103359. export var lightsFragmentFunctions: {
  103360. name: string;
  103361. shader: string;
  103362. };
  103363. }
  103364. declare module BABYLON {
  103365. /** @hidden */
  103366. export var shadowsFragmentFunctions: {
  103367. name: string;
  103368. shader: string;
  103369. };
  103370. }
  103371. declare module BABYLON {
  103372. /** @hidden */
  103373. export var fresnelFunction: {
  103374. name: string;
  103375. shader: string;
  103376. };
  103377. }
  103378. declare module BABYLON {
  103379. /** @hidden */
  103380. export var bumpFragmentMainFunctions: {
  103381. name: string;
  103382. shader: string;
  103383. };
  103384. }
  103385. declare module BABYLON {
  103386. /** @hidden */
  103387. export var bumpFragmentFunctions: {
  103388. name: string;
  103389. shader: string;
  103390. };
  103391. }
  103392. declare module BABYLON {
  103393. /** @hidden */
  103394. export var logDepthDeclaration: {
  103395. name: string;
  103396. shader: string;
  103397. };
  103398. }
  103399. declare module BABYLON {
  103400. /** @hidden */
  103401. export var fogFragmentDeclaration: {
  103402. name: string;
  103403. shader: string;
  103404. };
  103405. }
  103406. declare module BABYLON {
  103407. /** @hidden */
  103408. export var bumpFragment: {
  103409. name: string;
  103410. shader: string;
  103411. };
  103412. }
  103413. declare module BABYLON {
  103414. /** @hidden */
  103415. export var depthPrePass: {
  103416. name: string;
  103417. shader: string;
  103418. };
  103419. }
  103420. declare module BABYLON {
  103421. /** @hidden */
  103422. export var lightFragment: {
  103423. name: string;
  103424. shader: string;
  103425. };
  103426. }
  103427. declare module BABYLON {
  103428. /** @hidden */
  103429. export var logDepthFragment: {
  103430. name: string;
  103431. shader: string;
  103432. };
  103433. }
  103434. declare module BABYLON {
  103435. /** @hidden */
  103436. export var fogFragment: {
  103437. name: string;
  103438. shader: string;
  103439. };
  103440. }
  103441. declare module BABYLON {
  103442. /** @hidden */
  103443. export var defaultPixelShader: {
  103444. name: string;
  103445. shader: string;
  103446. };
  103447. }
  103448. declare module BABYLON {
  103449. /** @hidden */
  103450. export var defaultVertexDeclaration: {
  103451. name: string;
  103452. shader: string;
  103453. };
  103454. }
  103455. declare module BABYLON {
  103456. /** @hidden */
  103457. export var bonesDeclaration: {
  103458. name: string;
  103459. shader: string;
  103460. };
  103461. }
  103462. declare module BABYLON {
  103463. /** @hidden */
  103464. export var prePassVertexDeclaration: {
  103465. name: string;
  103466. shader: string;
  103467. };
  103468. }
  103469. declare module BABYLON {
  103470. /** @hidden */
  103471. export var bumpVertexDeclaration: {
  103472. name: string;
  103473. shader: string;
  103474. };
  103475. }
  103476. declare module BABYLON {
  103477. /** @hidden */
  103478. export var fogVertexDeclaration: {
  103479. name: string;
  103480. shader: string;
  103481. };
  103482. }
  103483. declare module BABYLON {
  103484. /** @hidden */
  103485. export var lightVxFragmentDeclaration: {
  103486. name: string;
  103487. shader: string;
  103488. };
  103489. }
  103490. declare module BABYLON {
  103491. /** @hidden */
  103492. export var lightVxUboDeclaration: {
  103493. name: string;
  103494. shader: string;
  103495. };
  103496. }
  103497. declare module BABYLON {
  103498. /** @hidden */
  103499. export var morphTargetsVertexGlobalDeclaration: {
  103500. name: string;
  103501. shader: string;
  103502. };
  103503. }
  103504. declare module BABYLON {
  103505. /** @hidden */
  103506. export var morphTargetsVertexDeclaration: {
  103507. name: string;
  103508. shader: string;
  103509. };
  103510. }
  103511. declare module BABYLON {
  103512. /** @hidden */
  103513. export var morphTargetsVertex: {
  103514. name: string;
  103515. shader: string;
  103516. };
  103517. }
  103518. declare module BABYLON {
  103519. /** @hidden */
  103520. export var instancesVertex: {
  103521. name: string;
  103522. shader: string;
  103523. };
  103524. }
  103525. declare module BABYLON {
  103526. /** @hidden */
  103527. export var bonesVertex: {
  103528. name: string;
  103529. shader: string;
  103530. };
  103531. }
  103532. declare module BABYLON {
  103533. /** @hidden */
  103534. export var prePassVertex: {
  103535. name: string;
  103536. shader: string;
  103537. };
  103538. }
  103539. declare module BABYLON {
  103540. /** @hidden */
  103541. export var bumpVertex: {
  103542. name: string;
  103543. shader: string;
  103544. };
  103545. }
  103546. declare module BABYLON {
  103547. /** @hidden */
  103548. export var fogVertex: {
  103549. name: string;
  103550. shader: string;
  103551. };
  103552. }
  103553. declare module BABYLON {
  103554. /** @hidden */
  103555. export var shadowsVertex: {
  103556. name: string;
  103557. shader: string;
  103558. };
  103559. }
  103560. declare module BABYLON {
  103561. /** @hidden */
  103562. export var pointCloudVertex: {
  103563. name: string;
  103564. shader: string;
  103565. };
  103566. }
  103567. declare module BABYLON {
  103568. /** @hidden */
  103569. export var logDepthVertex: {
  103570. name: string;
  103571. shader: string;
  103572. };
  103573. }
  103574. declare module BABYLON {
  103575. /** @hidden */
  103576. export var defaultVertexShader: {
  103577. name: string;
  103578. shader: string;
  103579. };
  103580. }
  103581. declare module BABYLON {
  103582. /**
  103583. * @hidden
  103584. */
  103585. export interface IMaterialDetailMapDefines {
  103586. DETAIL: boolean;
  103587. DETAILDIRECTUV: number;
  103588. DETAIL_NORMALBLENDMETHOD: number;
  103589. /** @hidden */
  103590. _areTexturesDirty: boolean;
  103591. }
  103592. /**
  103593. * Define the code related to the detail map parameters of a material
  103594. *
  103595. * Inspired from:
  103596. * 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
  103597. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  103598. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  103599. */
  103600. export class DetailMapConfiguration {
  103601. private _texture;
  103602. /**
  103603. * The detail texture of the material.
  103604. */
  103605. texture: Nullable<BaseTexture>;
  103606. /**
  103607. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  103608. * Bigger values mean stronger blending
  103609. */
  103610. diffuseBlendLevel: number;
  103611. /**
  103612. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  103613. * Bigger values mean stronger blending. Only used with PBR materials
  103614. */
  103615. roughnessBlendLevel: number;
  103616. /**
  103617. * Defines how strong the bump effect from the detail map is
  103618. * Bigger values mean stronger effect
  103619. */
  103620. bumpLevel: number;
  103621. private _normalBlendMethod;
  103622. /**
  103623. * The method used to blend the bump and detail normals together
  103624. */
  103625. normalBlendMethod: number;
  103626. private _isEnabled;
  103627. /**
  103628. * Enable or disable the detail map on this material
  103629. */
  103630. isEnabled: boolean;
  103631. /** @hidden */
  103632. private _internalMarkAllSubMeshesAsTexturesDirty;
  103633. /** @hidden */
  103634. _markAllSubMeshesAsTexturesDirty(): void;
  103635. /**
  103636. * Instantiate a new detail map
  103637. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103638. */
  103639. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103640. /**
  103641. * Gets whether the submesh is ready to be used or not.
  103642. * @param defines the list of "defines" to update.
  103643. * @param scene defines the scene the material belongs to.
  103644. * @returns - boolean indicating that the submesh is ready or not.
  103645. */
  103646. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  103647. /**
  103648. * Update the defines for detail map usage
  103649. * @param defines the list of "defines" to update.
  103650. * @param scene defines the scene the material belongs to.
  103651. */
  103652. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  103653. /**
  103654. * Binds the material data.
  103655. * @param uniformBuffer defines the Uniform buffer to fill in.
  103656. * @param scene defines the scene the material belongs to.
  103657. * @param isFrozen defines whether the material is frozen or not.
  103658. */
  103659. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  103660. /**
  103661. * Checks to see if a texture is used in the material.
  103662. * @param texture - Base texture to use.
  103663. * @returns - Boolean specifying if a texture is used in the material.
  103664. */
  103665. hasTexture(texture: BaseTexture): boolean;
  103666. /**
  103667. * Returns an array of the actively used textures.
  103668. * @param activeTextures Array of BaseTextures
  103669. */
  103670. getActiveTextures(activeTextures: BaseTexture[]): void;
  103671. /**
  103672. * Returns the animatable textures.
  103673. * @param animatables Array of animatable textures.
  103674. */
  103675. getAnimatables(animatables: IAnimatable[]): void;
  103676. /**
  103677. * Disposes the resources of the material.
  103678. * @param forceDisposeTextures - Forces the disposal of all textures.
  103679. */
  103680. dispose(forceDisposeTextures?: boolean): void;
  103681. /**
  103682. * Get the current class name useful for serialization or dynamic coding.
  103683. * @returns "DetailMap"
  103684. */
  103685. getClassName(): string;
  103686. /**
  103687. * Add the required uniforms to the current list.
  103688. * @param uniforms defines the current uniform list.
  103689. */
  103690. static AddUniforms(uniforms: string[]): void;
  103691. /**
  103692. * Add the required samplers to the current list.
  103693. * @param samplers defines the current sampler list.
  103694. */
  103695. static AddSamplers(samplers: string[]): void;
  103696. /**
  103697. * Add the required uniforms to the current buffer.
  103698. * @param uniformBuffer defines the current uniform buffer.
  103699. */
  103700. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  103701. /**
  103702. * Makes a duplicate of the current instance into another one.
  103703. * @param detailMap define the instance where to copy the info
  103704. */
  103705. copyTo(detailMap: DetailMapConfiguration): void;
  103706. /**
  103707. * Serializes this detail map instance
  103708. * @returns - An object with the serialized instance.
  103709. */
  103710. serialize(): any;
  103711. /**
  103712. * Parses a detail map setting from a serialized object.
  103713. * @param source - Serialized object.
  103714. * @param scene Defines the scene we are parsing for
  103715. * @param rootUrl Defines the rootUrl to load from
  103716. */
  103717. parse(source: any, scene: Scene, rootUrl: string): void;
  103718. }
  103719. }
  103720. declare module BABYLON {
  103721. /** @hidden */
  103722. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  103723. MAINUV1: boolean;
  103724. MAINUV2: boolean;
  103725. DIFFUSE: boolean;
  103726. DIFFUSEDIRECTUV: number;
  103727. DETAIL: boolean;
  103728. DETAILDIRECTUV: number;
  103729. DETAIL_NORMALBLENDMETHOD: number;
  103730. AMBIENT: boolean;
  103731. AMBIENTDIRECTUV: number;
  103732. OPACITY: boolean;
  103733. OPACITYDIRECTUV: number;
  103734. OPACITYRGB: boolean;
  103735. REFLECTION: boolean;
  103736. EMISSIVE: boolean;
  103737. EMISSIVEDIRECTUV: number;
  103738. SPECULAR: boolean;
  103739. SPECULARDIRECTUV: number;
  103740. BUMP: boolean;
  103741. BUMPDIRECTUV: number;
  103742. PARALLAX: boolean;
  103743. PARALLAXOCCLUSION: boolean;
  103744. SPECULAROVERALPHA: boolean;
  103745. CLIPPLANE: boolean;
  103746. CLIPPLANE2: boolean;
  103747. CLIPPLANE3: boolean;
  103748. CLIPPLANE4: boolean;
  103749. CLIPPLANE5: boolean;
  103750. CLIPPLANE6: boolean;
  103751. ALPHATEST: boolean;
  103752. DEPTHPREPASS: boolean;
  103753. ALPHAFROMDIFFUSE: boolean;
  103754. POINTSIZE: boolean;
  103755. FOG: boolean;
  103756. SPECULARTERM: boolean;
  103757. DIFFUSEFRESNEL: boolean;
  103758. OPACITYFRESNEL: boolean;
  103759. REFLECTIONFRESNEL: boolean;
  103760. REFRACTIONFRESNEL: boolean;
  103761. EMISSIVEFRESNEL: boolean;
  103762. FRESNEL: boolean;
  103763. NORMAL: boolean;
  103764. UV1: boolean;
  103765. UV2: boolean;
  103766. VERTEXCOLOR: boolean;
  103767. VERTEXALPHA: boolean;
  103768. NUM_BONE_INFLUENCERS: number;
  103769. BonesPerMesh: number;
  103770. BONETEXTURE: boolean;
  103771. BONES_VELOCITY_ENABLED: boolean;
  103772. INSTANCES: boolean;
  103773. THIN_INSTANCES: boolean;
  103774. GLOSSINESS: boolean;
  103775. ROUGHNESS: boolean;
  103776. EMISSIVEASILLUMINATION: boolean;
  103777. LINKEMISSIVEWITHDIFFUSE: boolean;
  103778. REFLECTIONFRESNELFROMSPECULAR: boolean;
  103779. LIGHTMAP: boolean;
  103780. LIGHTMAPDIRECTUV: number;
  103781. OBJECTSPACE_NORMALMAP: boolean;
  103782. USELIGHTMAPASSHADOWMAP: boolean;
  103783. REFLECTIONMAP_3D: boolean;
  103784. REFLECTIONMAP_SPHERICAL: boolean;
  103785. REFLECTIONMAP_PLANAR: boolean;
  103786. REFLECTIONMAP_CUBIC: boolean;
  103787. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  103788. REFLECTIONMAP_PROJECTION: boolean;
  103789. REFLECTIONMAP_SKYBOX: boolean;
  103790. REFLECTIONMAP_EXPLICIT: boolean;
  103791. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  103792. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  103793. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  103794. INVERTCUBICMAP: boolean;
  103795. LOGARITHMICDEPTH: boolean;
  103796. REFRACTION: boolean;
  103797. REFRACTIONMAP_3D: boolean;
  103798. REFLECTIONOVERALPHA: boolean;
  103799. TWOSIDEDLIGHTING: boolean;
  103800. SHADOWFLOAT: boolean;
  103801. MORPHTARGETS: boolean;
  103802. MORPHTARGETS_NORMAL: boolean;
  103803. MORPHTARGETS_TANGENT: boolean;
  103804. MORPHTARGETS_UV: boolean;
  103805. NUM_MORPH_INFLUENCERS: number;
  103806. NONUNIFORMSCALING: boolean;
  103807. PREMULTIPLYALPHA: boolean;
  103808. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  103809. ALPHABLEND: boolean;
  103810. PREPASS: boolean;
  103811. PREPASS_IRRADIANCE: boolean;
  103812. PREPASS_IRRADIANCE_INDEX: number;
  103813. PREPASS_ALBEDO: boolean;
  103814. PREPASS_ALBEDO_INDEX: number;
  103815. PREPASS_DEPTHNORMAL: boolean;
  103816. PREPASS_DEPTHNORMAL_INDEX: number;
  103817. PREPASS_POSITION: boolean;
  103818. PREPASS_POSITION_INDEX: number;
  103819. PREPASS_VELOCITY: boolean;
  103820. PREPASS_VELOCITY_INDEX: number;
  103821. PREPASS_REFLECTIVITY: boolean;
  103822. PREPASS_REFLECTIVITY_INDEX: number;
  103823. SCENE_MRT_COUNT: number;
  103824. RGBDLIGHTMAP: boolean;
  103825. RGBDREFLECTION: boolean;
  103826. RGBDREFRACTION: boolean;
  103827. IMAGEPROCESSING: boolean;
  103828. VIGNETTE: boolean;
  103829. VIGNETTEBLENDMODEMULTIPLY: boolean;
  103830. VIGNETTEBLENDMODEOPAQUE: boolean;
  103831. TONEMAPPING: boolean;
  103832. TONEMAPPING_ACES: boolean;
  103833. CONTRAST: boolean;
  103834. COLORCURVES: boolean;
  103835. COLORGRADING: boolean;
  103836. COLORGRADING3D: boolean;
  103837. SAMPLER3DGREENDEPTH: boolean;
  103838. SAMPLER3DBGRMAP: boolean;
  103839. IMAGEPROCESSINGPOSTPROCESS: boolean;
  103840. MULTIVIEW: boolean;
  103841. /**
  103842. * If the reflection texture on this material is in linear color space
  103843. * @hidden
  103844. */
  103845. IS_REFLECTION_LINEAR: boolean;
  103846. /**
  103847. * If the refraction texture on this material is in linear color space
  103848. * @hidden
  103849. */
  103850. IS_REFRACTION_LINEAR: boolean;
  103851. EXPOSURE: boolean;
  103852. constructor();
  103853. setReflectionMode(modeToEnable: string): void;
  103854. }
  103855. /**
  103856. * This is the default material used in Babylon. It is the best trade off between quality
  103857. * and performances.
  103858. * @see https://doc.babylonjs.com/babylon101/materials
  103859. */
  103860. export class StandardMaterial extends PushMaterial {
  103861. private _diffuseTexture;
  103862. /**
  103863. * The basic texture of the material as viewed under a light.
  103864. */
  103865. diffuseTexture: Nullable<BaseTexture>;
  103866. private _ambientTexture;
  103867. /**
  103868. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  103869. */
  103870. ambientTexture: Nullable<BaseTexture>;
  103871. private _opacityTexture;
  103872. /**
  103873. * Define the transparency of the material from a texture.
  103874. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  103875. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  103876. */
  103877. opacityTexture: Nullable<BaseTexture>;
  103878. private _reflectionTexture;
  103879. /**
  103880. * Define the texture used to display the reflection.
  103881. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  103882. */
  103883. reflectionTexture: Nullable<BaseTexture>;
  103884. private _emissiveTexture;
  103885. /**
  103886. * Define texture of the material as if self lit.
  103887. * This will be mixed in the final result even in the absence of light.
  103888. */
  103889. emissiveTexture: Nullable<BaseTexture>;
  103890. private _specularTexture;
  103891. /**
  103892. * Define how the color and intensity of the highlight given by the light in the material.
  103893. */
  103894. specularTexture: Nullable<BaseTexture>;
  103895. private _bumpTexture;
  103896. /**
  103897. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  103898. * 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.
  103899. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  103900. */
  103901. bumpTexture: Nullable<BaseTexture>;
  103902. private _lightmapTexture;
  103903. /**
  103904. * Complex lighting can be computationally expensive to compute at runtime.
  103905. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  103906. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  103907. */
  103908. lightmapTexture: Nullable<BaseTexture>;
  103909. private _refractionTexture;
  103910. /**
  103911. * Define the texture used to display the refraction.
  103912. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  103913. */
  103914. refractionTexture: Nullable<BaseTexture>;
  103915. /**
  103916. * The color of the material lit by the environmental background lighting.
  103917. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  103918. */
  103919. ambientColor: Color3;
  103920. /**
  103921. * The basic color of the material as viewed under a light.
  103922. */
  103923. diffuseColor: Color3;
  103924. /**
  103925. * Define how the color and intensity of the highlight given by the light in the material.
  103926. */
  103927. specularColor: Color3;
  103928. /**
  103929. * Define the color of the material as if self lit.
  103930. * This will be mixed in the final result even in the absence of light.
  103931. */
  103932. emissiveColor: Color3;
  103933. /**
  103934. * Defines how sharp are the highlights in the material.
  103935. * The bigger the value the sharper giving a more glossy feeling to the result.
  103936. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  103937. */
  103938. specularPower: number;
  103939. private _useAlphaFromDiffuseTexture;
  103940. /**
  103941. * Does the transparency come from the diffuse texture alpha channel.
  103942. */
  103943. useAlphaFromDiffuseTexture: boolean;
  103944. private _useEmissiveAsIllumination;
  103945. /**
  103946. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  103947. */
  103948. useEmissiveAsIllumination: boolean;
  103949. private _linkEmissiveWithDiffuse;
  103950. /**
  103951. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  103952. * the emissive level when the final color is close to one.
  103953. */
  103954. linkEmissiveWithDiffuse: boolean;
  103955. private _useSpecularOverAlpha;
  103956. /**
  103957. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  103958. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  103959. */
  103960. useSpecularOverAlpha: boolean;
  103961. private _useReflectionOverAlpha;
  103962. /**
  103963. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  103964. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  103965. */
  103966. useReflectionOverAlpha: boolean;
  103967. private _disableLighting;
  103968. /**
  103969. * Does lights from the scene impacts this material.
  103970. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  103971. */
  103972. disableLighting: boolean;
  103973. private _useObjectSpaceNormalMap;
  103974. /**
  103975. * Allows using an object space normal map (instead of tangent space).
  103976. */
  103977. useObjectSpaceNormalMap: boolean;
  103978. private _useParallax;
  103979. /**
  103980. * Is parallax enabled or not.
  103981. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  103982. */
  103983. useParallax: boolean;
  103984. private _useParallaxOcclusion;
  103985. /**
  103986. * Is parallax occlusion enabled or not.
  103987. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  103988. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  103989. */
  103990. useParallaxOcclusion: boolean;
  103991. /**
  103992. * 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.
  103993. */
  103994. parallaxScaleBias: number;
  103995. private _roughness;
  103996. /**
  103997. * Helps to define how blurry the reflections should appears in the material.
  103998. */
  103999. roughness: number;
  104000. /**
  104001. * In case of refraction, define the value of the index of refraction.
  104002. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104003. */
  104004. indexOfRefraction: number;
  104005. /**
  104006. * Invert the refraction texture alongside the y axis.
  104007. * It can be useful with procedural textures or probe for instance.
  104008. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104009. */
  104010. invertRefractionY: boolean;
  104011. /**
  104012. * Defines the alpha limits in alpha test mode.
  104013. */
  104014. alphaCutOff: number;
  104015. private _useLightmapAsShadowmap;
  104016. /**
  104017. * In case of light mapping, define whether the map contains light or shadow informations.
  104018. */
  104019. useLightmapAsShadowmap: boolean;
  104020. private _diffuseFresnelParameters;
  104021. /**
  104022. * Define the diffuse fresnel parameters of the material.
  104023. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104024. */
  104025. diffuseFresnelParameters: FresnelParameters;
  104026. private _opacityFresnelParameters;
  104027. /**
  104028. * Define the opacity fresnel parameters of the material.
  104029. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104030. */
  104031. opacityFresnelParameters: FresnelParameters;
  104032. private _reflectionFresnelParameters;
  104033. /**
  104034. * Define the reflection fresnel parameters of the material.
  104035. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104036. */
  104037. reflectionFresnelParameters: FresnelParameters;
  104038. private _refractionFresnelParameters;
  104039. /**
  104040. * Define the refraction fresnel parameters of the material.
  104041. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104042. */
  104043. refractionFresnelParameters: FresnelParameters;
  104044. private _emissiveFresnelParameters;
  104045. /**
  104046. * Define the emissive fresnel parameters of the material.
  104047. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104048. */
  104049. emissiveFresnelParameters: FresnelParameters;
  104050. private _useReflectionFresnelFromSpecular;
  104051. /**
  104052. * If true automatically deducts the fresnels values from the material specularity.
  104053. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104054. */
  104055. useReflectionFresnelFromSpecular: boolean;
  104056. private _useGlossinessFromSpecularMapAlpha;
  104057. /**
  104058. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  104059. */
  104060. useGlossinessFromSpecularMapAlpha: boolean;
  104061. private _maxSimultaneousLights;
  104062. /**
  104063. * Defines the maximum number of lights that can be used in the material
  104064. */
  104065. maxSimultaneousLights: number;
  104066. private _invertNormalMapX;
  104067. /**
  104068. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  104069. */
  104070. invertNormalMapX: boolean;
  104071. private _invertNormalMapY;
  104072. /**
  104073. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  104074. */
  104075. invertNormalMapY: boolean;
  104076. private _twoSidedLighting;
  104077. /**
  104078. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104079. */
  104080. twoSidedLighting: boolean;
  104081. /**
  104082. * Default configuration related to image processing available in the standard Material.
  104083. */
  104084. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104085. /**
  104086. * Gets the image processing configuration used either in this material.
  104087. */
  104088. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  104089. /**
  104090. * Sets the Default image processing configuration used either in the this material.
  104091. *
  104092. * If sets to null, the scene one is in use.
  104093. */
  104094. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  104095. /**
  104096. * Keep track of the image processing observer to allow dispose and replace.
  104097. */
  104098. private _imageProcessingObserver;
  104099. /**
  104100. * Attaches a new image processing configuration to the Standard Material.
  104101. * @param configuration
  104102. */
  104103. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  104104. /**
  104105. * Defines additionnal PrePass parameters for the material.
  104106. */
  104107. readonly prePassConfiguration: PrePassConfiguration;
  104108. /**
  104109. * Gets wether the color curves effect is enabled.
  104110. */
  104111. get cameraColorCurvesEnabled(): boolean;
  104112. /**
  104113. * Sets wether the color curves effect is enabled.
  104114. */
  104115. set cameraColorCurvesEnabled(value: boolean);
  104116. /**
  104117. * Gets wether the color grading effect is enabled.
  104118. */
  104119. get cameraColorGradingEnabled(): boolean;
  104120. /**
  104121. * Gets wether the color grading effect is enabled.
  104122. */
  104123. set cameraColorGradingEnabled(value: boolean);
  104124. /**
  104125. * Gets wether tonemapping is enabled or not.
  104126. */
  104127. get cameraToneMappingEnabled(): boolean;
  104128. /**
  104129. * Sets wether tonemapping is enabled or not
  104130. */
  104131. set cameraToneMappingEnabled(value: boolean);
  104132. /**
  104133. * The camera exposure used on this material.
  104134. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104135. * This corresponds to a photographic exposure.
  104136. */
  104137. get cameraExposure(): number;
  104138. /**
  104139. * The camera exposure used on this material.
  104140. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104141. * This corresponds to a photographic exposure.
  104142. */
  104143. set cameraExposure(value: number);
  104144. /**
  104145. * Gets The camera contrast used on this material.
  104146. */
  104147. get cameraContrast(): number;
  104148. /**
  104149. * Sets The camera contrast used on this material.
  104150. */
  104151. set cameraContrast(value: number);
  104152. /**
  104153. * Gets the Color Grading 2D Lookup Texture.
  104154. */
  104155. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  104156. /**
  104157. * Sets the Color Grading 2D Lookup Texture.
  104158. */
  104159. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  104160. /**
  104161. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104162. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104163. * 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;
  104164. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104165. */
  104166. get cameraColorCurves(): Nullable<ColorCurves>;
  104167. /**
  104168. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104169. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104170. * 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;
  104171. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104172. */
  104173. set cameraColorCurves(value: Nullable<ColorCurves>);
  104174. /**
  104175. * Can this material render to several textures at once
  104176. */
  104177. get canRenderToMRT(): boolean;
  104178. /**
  104179. * Defines the detail map parameters for the material.
  104180. */
  104181. readonly detailMap: DetailMapConfiguration;
  104182. protected _renderTargets: SmartArray<RenderTargetTexture>;
  104183. protected _worldViewProjectionMatrix: Matrix;
  104184. protected _globalAmbientColor: Color3;
  104185. protected _useLogarithmicDepth: boolean;
  104186. protected _rebuildInParallel: boolean;
  104187. /**
  104188. * Instantiates a new standard material.
  104189. * This is the default material used in Babylon. It is the best trade off between quality
  104190. * and performances.
  104191. * @see https://doc.babylonjs.com/babylon101/materials
  104192. * @param name Define the name of the material in the scene
  104193. * @param scene Define the scene the material belong to
  104194. */
  104195. constructor(name: string, scene: Scene);
  104196. /**
  104197. * Gets a boolean indicating that current material needs to register RTT
  104198. */
  104199. get hasRenderTargetTextures(): boolean;
  104200. /**
  104201. * Gets the current class name of the material e.g. "StandardMaterial"
  104202. * Mainly use in serialization.
  104203. * @returns the class name
  104204. */
  104205. getClassName(): string;
  104206. /**
  104207. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  104208. * You can try switching to logarithmic depth.
  104209. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  104210. */
  104211. get useLogarithmicDepth(): boolean;
  104212. set useLogarithmicDepth(value: boolean);
  104213. /**
  104214. * Specifies if the material will require alpha blending
  104215. * @returns a boolean specifying if alpha blending is needed
  104216. */
  104217. needAlphaBlending(): boolean;
  104218. /**
  104219. * Specifies if this material should be rendered in alpha test mode
  104220. * @returns a boolean specifying if an alpha test is needed.
  104221. */
  104222. needAlphaTesting(): boolean;
  104223. /**
  104224. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  104225. */
  104226. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  104227. /**
  104228. * Specifies whether or not there is a usable alpha channel for transparency.
  104229. */
  104230. protected _hasAlphaChannel(): boolean;
  104231. /**
  104232. * Get the texture used for alpha test purpose.
  104233. * @returns the diffuse texture in case of the standard material.
  104234. */
  104235. getAlphaTestTexture(): Nullable<BaseTexture>;
  104236. /**
  104237. * Get if the submesh is ready to be used and all its information available.
  104238. * Child classes can use it to update shaders
  104239. * @param mesh defines the mesh to check
  104240. * @param subMesh defines which submesh to check
  104241. * @param useInstances specifies that instances should be used
  104242. * @returns a boolean indicating that the submesh is ready or not
  104243. */
  104244. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  104245. /**
  104246. * Builds the material UBO layouts.
  104247. * Used internally during the effect preparation.
  104248. */
  104249. buildUniformLayout(): void;
  104250. /**
  104251. * Unbinds the material from the mesh
  104252. */
  104253. unbind(): void;
  104254. /**
  104255. * Binds the submesh to this material by preparing the effect and shader to draw
  104256. * @param world defines the world transformation matrix
  104257. * @param mesh defines the mesh containing the submesh
  104258. * @param subMesh defines the submesh to bind the material to
  104259. */
  104260. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  104261. /**
  104262. * Get the list of animatables in the material.
  104263. * @returns the list of animatables object used in the material
  104264. */
  104265. getAnimatables(): IAnimatable[];
  104266. /**
  104267. * Gets the active textures from the material
  104268. * @returns an array of textures
  104269. */
  104270. getActiveTextures(): BaseTexture[];
  104271. /**
  104272. * Specifies if the material uses a texture
  104273. * @param texture defines the texture to check against the material
  104274. * @returns a boolean specifying if the material uses the texture
  104275. */
  104276. hasTexture(texture: BaseTexture): boolean;
  104277. /**
  104278. * Disposes the material
  104279. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  104280. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  104281. */
  104282. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  104283. /**
  104284. * Makes a duplicate of the material, and gives it a new name
  104285. * @param name defines the new name for the duplicated material
  104286. * @returns the cloned material
  104287. */
  104288. clone(name: string): StandardMaterial;
  104289. /**
  104290. * Serializes this material in a JSON representation
  104291. * @returns the serialized material object
  104292. */
  104293. serialize(): any;
  104294. /**
  104295. * Creates a standard material from parsed material data
  104296. * @param source defines the JSON representation of the material
  104297. * @param scene defines the hosting scene
  104298. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  104299. * @returns a new standard material
  104300. */
  104301. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  104302. /**
  104303. * Are diffuse textures enabled in the application.
  104304. */
  104305. static get DiffuseTextureEnabled(): boolean;
  104306. static set DiffuseTextureEnabled(value: boolean);
  104307. /**
  104308. * Are detail textures enabled in the application.
  104309. */
  104310. static get DetailTextureEnabled(): boolean;
  104311. static set DetailTextureEnabled(value: boolean);
  104312. /**
  104313. * Are ambient textures enabled in the application.
  104314. */
  104315. static get AmbientTextureEnabled(): boolean;
  104316. static set AmbientTextureEnabled(value: boolean);
  104317. /**
  104318. * Are opacity textures enabled in the application.
  104319. */
  104320. static get OpacityTextureEnabled(): boolean;
  104321. static set OpacityTextureEnabled(value: boolean);
  104322. /**
  104323. * Are reflection textures enabled in the application.
  104324. */
  104325. static get ReflectionTextureEnabled(): boolean;
  104326. static set ReflectionTextureEnabled(value: boolean);
  104327. /**
  104328. * Are emissive textures enabled in the application.
  104329. */
  104330. static get EmissiveTextureEnabled(): boolean;
  104331. static set EmissiveTextureEnabled(value: boolean);
  104332. /**
  104333. * Are specular textures enabled in the application.
  104334. */
  104335. static get SpecularTextureEnabled(): boolean;
  104336. static set SpecularTextureEnabled(value: boolean);
  104337. /**
  104338. * Are bump textures enabled in the application.
  104339. */
  104340. static get BumpTextureEnabled(): boolean;
  104341. static set BumpTextureEnabled(value: boolean);
  104342. /**
  104343. * Are lightmap textures enabled in the application.
  104344. */
  104345. static get LightmapTextureEnabled(): boolean;
  104346. static set LightmapTextureEnabled(value: boolean);
  104347. /**
  104348. * Are refraction textures enabled in the application.
  104349. */
  104350. static get RefractionTextureEnabled(): boolean;
  104351. static set RefractionTextureEnabled(value: boolean);
  104352. /**
  104353. * Are color grading textures enabled in the application.
  104354. */
  104355. static get ColorGradingTextureEnabled(): boolean;
  104356. static set ColorGradingTextureEnabled(value: boolean);
  104357. /**
  104358. * Are fresnels enabled in the application.
  104359. */
  104360. static get FresnelEnabled(): boolean;
  104361. static set FresnelEnabled(value: boolean);
  104362. }
  104363. }
  104364. declare module BABYLON {
  104365. /** @hidden */
  104366. export var rgbdDecodePixelShader: {
  104367. name: string;
  104368. shader: string;
  104369. };
  104370. }
  104371. declare module BABYLON {
  104372. /** @hidden */
  104373. export var passPixelShader: {
  104374. name: string;
  104375. shader: string;
  104376. };
  104377. }
  104378. declare module BABYLON {
  104379. /** @hidden */
  104380. export var passCubePixelShader: {
  104381. name: string;
  104382. shader: string;
  104383. };
  104384. }
  104385. declare module BABYLON {
  104386. /**
  104387. * PassPostProcess which produces an output the same as it's input
  104388. */
  104389. export class PassPostProcess extends PostProcess {
  104390. /**
  104391. * Gets a string identifying the name of the class
  104392. * @returns "PassPostProcess" string
  104393. */
  104394. getClassName(): string;
  104395. /**
  104396. * Creates the PassPostProcess
  104397. * @param name The name of the effect.
  104398. * @param options The required width/height ratio to downsize to before computing the render pass.
  104399. * @param camera The camera to apply the render pass to.
  104400. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104401. * @param engine The engine which the post process will be applied. (default: current engine)
  104402. * @param reusable If the post process can be reused on the same frame. (default: false)
  104403. * @param textureType The type of texture to be used when performing the post processing.
  104404. * @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)
  104405. */
  104406. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  104407. /** @hidden */
  104408. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  104409. }
  104410. /**
  104411. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  104412. */
  104413. export class PassCubePostProcess extends PostProcess {
  104414. private _face;
  104415. /**
  104416. * Gets or sets the cube face to display.
  104417. * * 0 is +X
  104418. * * 1 is -X
  104419. * * 2 is +Y
  104420. * * 3 is -Y
  104421. * * 4 is +Z
  104422. * * 5 is -Z
  104423. */
  104424. get face(): number;
  104425. set face(value: number);
  104426. /**
  104427. * Gets a string identifying the name of the class
  104428. * @returns "PassCubePostProcess" string
  104429. */
  104430. getClassName(): string;
  104431. /**
  104432. * Creates the PassCubePostProcess
  104433. * @param name The name of the effect.
  104434. * @param options The required width/height ratio to downsize to before computing the render pass.
  104435. * @param camera The camera to apply the render pass to.
  104436. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104437. * @param engine The engine which the post process will be applied. (default: current engine)
  104438. * @param reusable If the post process can be reused on the same frame. (default: false)
  104439. * @param textureType The type of texture to be used when performing the post processing.
  104440. * @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)
  104441. */
  104442. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  104443. /** @hidden */
  104444. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  104445. }
  104446. }
  104447. declare module BABYLON {
  104448. /**
  104449. * Class used to host texture specific utilities
  104450. */
  104451. export class TextureTools {
  104452. /**
  104453. * Uses the GPU to create a copy texture rescaled at a given size
  104454. * @param texture Texture to copy from
  104455. * @param width defines the desired width
  104456. * @param height defines the desired height
  104457. * @param useBilinearMode defines if bilinear mode has to be used
  104458. * @return the generated texture
  104459. */
  104460. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  104461. /**
  104462. * Apply a post process to a texture
  104463. * @param postProcessName name of the fragment post process
  104464. * @param internalTexture the texture to encode
  104465. * @param scene the scene hosting the texture
  104466. * @param type type of the output texture. If not provided, use the one from internalTexture
  104467. * @param samplingMode sampling moode to use to sample the source texture. If not provided, use the one from internalTexture
  104468. * @param format format of the output texture. If not provided, use the one from internalTexture
  104469. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  104470. */
  104471. static ApplyPostProcess(postProcessName: string, internalTexture: InternalTexture, scene: Scene, type?: number, samplingMode?: number, format?: number): Promise<InternalTexture>;
  104472. }
  104473. }
  104474. declare module BABYLON {
  104475. /**
  104476. * Class used to host RGBD texture specific utilities
  104477. */
  104478. export class RGBDTextureTools {
  104479. /**
  104480. * Expand the RGBD Texture from RGBD to Half Float if possible.
  104481. * @param texture the texture to expand.
  104482. */
  104483. static ExpandRGBDTexture(texture: Texture): void;
  104484. /**
  104485. * Encode the texture to RGBD if possible.
  104486. * @param internalTexture the texture to encode
  104487. * @param scene the scene hosting the texture
  104488. * @param outputTextureType type of the texture in which the encoding is performed
  104489. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  104490. */
  104491. static EncodeTextureToRGBD(internalTexture: InternalTexture, scene: Scene, outputTextureType?: number): Promise<InternalTexture>;
  104492. }
  104493. }
  104494. declare module BABYLON {
  104495. /**
  104496. * Class used to host texture specific utilities
  104497. */
  104498. export class BRDFTextureTools {
  104499. /**
  104500. * Prevents texture cache collision
  104501. */
  104502. private static _instanceNumber;
  104503. /**
  104504. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  104505. * @param scene defines the hosting scene
  104506. * @returns the environment BRDF texture
  104507. */
  104508. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  104509. private static _environmentBRDFBase64Texture;
  104510. }
  104511. }
  104512. declare module BABYLON {
  104513. /**
  104514. * @hidden
  104515. */
  104516. export interface IMaterialClearCoatDefines {
  104517. CLEARCOAT: boolean;
  104518. CLEARCOAT_DEFAULTIOR: boolean;
  104519. CLEARCOAT_TEXTURE: boolean;
  104520. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  104521. CLEARCOAT_TEXTUREDIRECTUV: number;
  104522. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  104523. CLEARCOAT_BUMP: boolean;
  104524. CLEARCOAT_BUMPDIRECTUV: number;
  104525. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  104526. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  104527. CLEARCOAT_REMAP_F0: boolean;
  104528. CLEARCOAT_TINT: boolean;
  104529. CLEARCOAT_TINT_TEXTURE: boolean;
  104530. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  104531. /** @hidden */
  104532. _areTexturesDirty: boolean;
  104533. }
  104534. /**
  104535. * Define the code related to the clear coat parameters of the pbr material.
  104536. */
  104537. export class PBRClearCoatConfiguration {
  104538. /**
  104539. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  104540. * The default fits with a polyurethane material.
  104541. * @hidden
  104542. */
  104543. static readonly _DefaultIndexOfRefraction: number;
  104544. private _isEnabled;
  104545. /**
  104546. * Defines if the clear coat is enabled in the material.
  104547. */
  104548. isEnabled: boolean;
  104549. /**
  104550. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  104551. */
  104552. intensity: number;
  104553. /**
  104554. * Defines the clear coat layer roughness.
  104555. */
  104556. roughness: number;
  104557. private _indexOfRefraction;
  104558. /**
  104559. * Defines the index of refraction of the clear coat.
  104560. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  104561. * The default fits with a polyurethane material.
  104562. * Changing the default value is more performance intensive.
  104563. */
  104564. indexOfRefraction: number;
  104565. private _texture;
  104566. /**
  104567. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  104568. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  104569. * if textureRoughness is not empty, else no texture roughness is used
  104570. */
  104571. texture: Nullable<BaseTexture>;
  104572. private _useRoughnessFromMainTexture;
  104573. /**
  104574. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  104575. * If false, the green channel from textureRoughness is used for roughness
  104576. */
  104577. useRoughnessFromMainTexture: boolean;
  104578. private _textureRoughness;
  104579. /**
  104580. * Stores the clear coat roughness in a texture (green channel)
  104581. * Not used if useRoughnessFromMainTexture is true
  104582. */
  104583. textureRoughness: Nullable<BaseTexture>;
  104584. private _remapF0OnInterfaceChange;
  104585. /**
  104586. * Defines if the F0 value should be remapped to account for the interface change in the material.
  104587. */
  104588. remapF0OnInterfaceChange: boolean;
  104589. private _bumpTexture;
  104590. /**
  104591. * Define the clear coat specific bump texture.
  104592. */
  104593. bumpTexture: Nullable<BaseTexture>;
  104594. private _isTintEnabled;
  104595. /**
  104596. * Defines if the clear coat tint is enabled in the material.
  104597. */
  104598. isTintEnabled: boolean;
  104599. /**
  104600. * Defines the clear coat tint of the material.
  104601. * This is only use if tint is enabled
  104602. */
  104603. tintColor: Color3;
  104604. /**
  104605. * Defines the distance at which the tint color should be found in the
  104606. * clear coat media.
  104607. * This is only use if tint is enabled
  104608. */
  104609. tintColorAtDistance: number;
  104610. /**
  104611. * Defines the clear coat layer thickness.
  104612. * This is only use if tint is enabled
  104613. */
  104614. tintThickness: number;
  104615. private _tintTexture;
  104616. /**
  104617. * Stores the clear tint values in a texture.
  104618. * rgb is tint
  104619. * a is a thickness factor
  104620. */
  104621. tintTexture: Nullable<BaseTexture>;
  104622. /** @hidden */
  104623. private _internalMarkAllSubMeshesAsTexturesDirty;
  104624. /** @hidden */
  104625. _markAllSubMeshesAsTexturesDirty(): void;
  104626. /**
  104627. * Instantiate a new istance of clear coat configuration.
  104628. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104629. */
  104630. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104631. /**
  104632. * Gets wehter the submesh is ready to be used or not.
  104633. * @param defines the list of "defines" to update.
  104634. * @param scene defines the scene the material belongs to.
  104635. * @param engine defines the engine the material belongs to.
  104636. * @param disableBumpMap defines wether the material disables bump or not.
  104637. * @returns - boolean indicating that the submesh is ready or not.
  104638. */
  104639. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  104640. /**
  104641. * Checks to see if a texture is used in the material.
  104642. * @param defines the list of "defines" to update.
  104643. * @param scene defines the scene to the material belongs to.
  104644. */
  104645. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  104646. /**
  104647. * Binds the material data.
  104648. * @param uniformBuffer defines the Uniform buffer to fill in.
  104649. * @param scene defines the scene the material belongs to.
  104650. * @param engine defines the engine the material belongs to.
  104651. * @param disableBumpMap defines wether the material disables bump or not.
  104652. * @param isFrozen defines wether the material is frozen or not.
  104653. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  104654. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  104655. * @param subMesh the submesh to bind data for
  104656. */
  104657. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  104658. /**
  104659. * Checks to see if a texture is used in the material.
  104660. * @param texture - Base texture to use.
  104661. * @returns - Boolean specifying if a texture is used in the material.
  104662. */
  104663. hasTexture(texture: BaseTexture): boolean;
  104664. /**
  104665. * Returns an array of the actively used textures.
  104666. * @param activeTextures Array of BaseTextures
  104667. */
  104668. getActiveTextures(activeTextures: BaseTexture[]): void;
  104669. /**
  104670. * Returns the animatable textures.
  104671. * @param animatables Array of animatable textures.
  104672. */
  104673. getAnimatables(animatables: IAnimatable[]): void;
  104674. /**
  104675. * Disposes the resources of the material.
  104676. * @param forceDisposeTextures - Forces the disposal of all textures.
  104677. */
  104678. dispose(forceDisposeTextures?: boolean): void;
  104679. /**
  104680. * Get the current class name of the texture useful for serialization or dynamic coding.
  104681. * @returns "PBRClearCoatConfiguration"
  104682. */
  104683. getClassName(): string;
  104684. /**
  104685. * Add fallbacks to the effect fallbacks list.
  104686. * @param defines defines the Base texture to use.
  104687. * @param fallbacks defines the current fallback list.
  104688. * @param currentRank defines the current fallback rank.
  104689. * @returns the new fallback rank.
  104690. */
  104691. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104692. /**
  104693. * Add the required uniforms to the current list.
  104694. * @param uniforms defines the current uniform list.
  104695. */
  104696. static AddUniforms(uniforms: string[]): void;
  104697. /**
  104698. * Add the required samplers to the current list.
  104699. * @param samplers defines the current sampler list.
  104700. */
  104701. static AddSamplers(samplers: string[]): void;
  104702. /**
  104703. * Add the required uniforms to the current buffer.
  104704. * @param uniformBuffer defines the current uniform buffer.
  104705. */
  104706. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104707. /**
  104708. * Makes a duplicate of the current configuration into another one.
  104709. * @param clearCoatConfiguration define the config where to copy the info
  104710. */
  104711. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  104712. /**
  104713. * Serializes this clear coat configuration.
  104714. * @returns - An object with the serialized config.
  104715. */
  104716. serialize(): any;
  104717. /**
  104718. * Parses a anisotropy Configuration from a serialized object.
  104719. * @param source - Serialized object.
  104720. * @param scene Defines the scene we are parsing for
  104721. * @param rootUrl Defines the rootUrl to load from
  104722. */
  104723. parse(source: any, scene: Scene, rootUrl: string): void;
  104724. }
  104725. }
  104726. declare module BABYLON {
  104727. /**
  104728. * @hidden
  104729. */
  104730. export interface IMaterialAnisotropicDefines {
  104731. ANISOTROPIC: boolean;
  104732. ANISOTROPIC_TEXTURE: boolean;
  104733. ANISOTROPIC_TEXTUREDIRECTUV: number;
  104734. MAINUV1: boolean;
  104735. _areTexturesDirty: boolean;
  104736. _needUVs: boolean;
  104737. }
  104738. /**
  104739. * Define the code related to the anisotropic parameters of the pbr material.
  104740. */
  104741. export class PBRAnisotropicConfiguration {
  104742. private _isEnabled;
  104743. /**
  104744. * Defines if the anisotropy is enabled in the material.
  104745. */
  104746. isEnabled: boolean;
  104747. /**
  104748. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  104749. */
  104750. intensity: number;
  104751. /**
  104752. * Defines if the effect is along the tangents, bitangents or in between.
  104753. * By default, the effect is "strectching" the highlights along the tangents.
  104754. */
  104755. direction: Vector2;
  104756. private _texture;
  104757. /**
  104758. * Stores the anisotropy values in a texture.
  104759. * rg is direction (like normal from -1 to 1)
  104760. * b is a intensity
  104761. */
  104762. texture: Nullable<BaseTexture>;
  104763. /** @hidden */
  104764. private _internalMarkAllSubMeshesAsTexturesDirty;
  104765. /** @hidden */
  104766. _markAllSubMeshesAsTexturesDirty(): void;
  104767. /**
  104768. * Instantiate a new istance of anisotropy configuration.
  104769. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  104770. */
  104771. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  104772. /**
  104773. * Specifies that the submesh is ready to be used.
  104774. * @param defines the list of "defines" to update.
  104775. * @param scene defines the scene the material belongs to.
  104776. * @returns - boolean indicating that the submesh is ready or not.
  104777. */
  104778. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  104779. /**
  104780. * Checks to see if a texture is used in the material.
  104781. * @param defines the list of "defines" to update.
  104782. * @param mesh the mesh we are preparing the defines for.
  104783. * @param scene defines the scene the material belongs to.
  104784. */
  104785. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  104786. /**
  104787. * Binds the material data.
  104788. * @param uniformBuffer defines the Uniform buffer to fill in.
  104789. * @param scene defines the scene the material belongs to.
  104790. * @param isFrozen defines wether the material is frozen or not.
  104791. */
  104792. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  104793. /**
  104794. * Checks to see if a texture is used in the material.
  104795. * @param texture - Base texture to use.
  104796. * @returns - Boolean specifying if a texture is used in the material.
  104797. */
  104798. hasTexture(texture: BaseTexture): boolean;
  104799. /**
  104800. * Returns an array of the actively used textures.
  104801. * @param activeTextures Array of BaseTextures
  104802. */
  104803. getActiveTextures(activeTextures: BaseTexture[]): void;
  104804. /**
  104805. * Returns the animatable textures.
  104806. * @param animatables Array of animatable textures.
  104807. */
  104808. getAnimatables(animatables: IAnimatable[]): void;
  104809. /**
  104810. * Disposes the resources of the material.
  104811. * @param forceDisposeTextures - Forces the disposal of all textures.
  104812. */
  104813. dispose(forceDisposeTextures?: boolean): void;
  104814. /**
  104815. * Get the current class name of the texture useful for serialization or dynamic coding.
  104816. * @returns "PBRAnisotropicConfiguration"
  104817. */
  104818. getClassName(): string;
  104819. /**
  104820. * Add fallbacks to the effect fallbacks list.
  104821. * @param defines defines the Base texture to use.
  104822. * @param fallbacks defines the current fallback list.
  104823. * @param currentRank defines the current fallback rank.
  104824. * @returns the new fallback rank.
  104825. */
  104826. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104827. /**
  104828. * Add the required uniforms to the current list.
  104829. * @param uniforms defines the current uniform list.
  104830. */
  104831. static AddUniforms(uniforms: string[]): void;
  104832. /**
  104833. * Add the required uniforms to the current buffer.
  104834. * @param uniformBuffer defines the current uniform buffer.
  104835. */
  104836. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104837. /**
  104838. * Add the required samplers to the current list.
  104839. * @param samplers defines the current sampler list.
  104840. */
  104841. static AddSamplers(samplers: string[]): void;
  104842. /**
  104843. * Makes a duplicate of the current configuration into another one.
  104844. * @param anisotropicConfiguration define the config where to copy the info
  104845. */
  104846. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  104847. /**
  104848. * Serializes this anisotropy configuration.
  104849. * @returns - An object with the serialized config.
  104850. */
  104851. serialize(): any;
  104852. /**
  104853. * Parses a anisotropy Configuration from a serialized object.
  104854. * @param source - Serialized object.
  104855. * @param scene Defines the scene we are parsing for
  104856. * @param rootUrl Defines the rootUrl to load from
  104857. */
  104858. parse(source: any, scene: Scene, rootUrl: string): void;
  104859. }
  104860. }
  104861. declare module BABYLON {
  104862. /**
  104863. * @hidden
  104864. */
  104865. export interface IMaterialBRDFDefines {
  104866. BRDF_V_HEIGHT_CORRELATED: boolean;
  104867. MS_BRDF_ENERGY_CONSERVATION: boolean;
  104868. SPHERICAL_HARMONICS: boolean;
  104869. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  104870. /** @hidden */
  104871. _areMiscDirty: boolean;
  104872. }
  104873. /**
  104874. * Define the code related to the BRDF parameters of the pbr material.
  104875. */
  104876. export class PBRBRDFConfiguration {
  104877. /**
  104878. * Default value used for the energy conservation.
  104879. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  104880. */
  104881. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  104882. /**
  104883. * Default value used for the Smith Visibility Height Correlated mode.
  104884. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  104885. */
  104886. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  104887. /**
  104888. * Default value used for the IBL diffuse part.
  104889. * This can help switching back to the polynomials mode globally which is a tiny bit
  104890. * less GPU intensive at the drawback of a lower quality.
  104891. */
  104892. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  104893. /**
  104894. * Default value used for activating energy conservation for the specular workflow.
  104895. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  104896. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  104897. */
  104898. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  104899. private _useEnergyConservation;
  104900. /**
  104901. * Defines if the material uses energy conservation.
  104902. */
  104903. useEnergyConservation: boolean;
  104904. private _useSmithVisibilityHeightCorrelated;
  104905. /**
  104906. * LEGACY Mode set to false
  104907. * Defines if the material uses height smith correlated visibility term.
  104908. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  104909. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  104910. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  104911. * Not relying on height correlated will also disable energy conservation.
  104912. */
  104913. useSmithVisibilityHeightCorrelated: boolean;
  104914. private _useSphericalHarmonics;
  104915. /**
  104916. * LEGACY Mode set to false
  104917. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  104918. * diffuse part of the IBL.
  104919. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  104920. * to the ground truth.
  104921. */
  104922. useSphericalHarmonics: boolean;
  104923. private _useSpecularGlossinessInputEnergyConservation;
  104924. /**
  104925. * Defines if the material uses energy conservation, when the specular workflow is active.
  104926. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  104927. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  104928. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  104929. */
  104930. useSpecularGlossinessInputEnergyConservation: boolean;
  104931. /** @hidden */
  104932. private _internalMarkAllSubMeshesAsMiscDirty;
  104933. /** @hidden */
  104934. _markAllSubMeshesAsMiscDirty(): void;
  104935. /**
  104936. * Instantiate a new istance of clear coat configuration.
  104937. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  104938. */
  104939. constructor(markAllSubMeshesAsMiscDirty: () => void);
  104940. /**
  104941. * Checks to see if a texture is used in the material.
  104942. * @param defines the list of "defines" to update.
  104943. */
  104944. prepareDefines(defines: IMaterialBRDFDefines): void;
  104945. /**
  104946. * Get the current class name of the texture useful for serialization or dynamic coding.
  104947. * @returns "PBRClearCoatConfiguration"
  104948. */
  104949. getClassName(): string;
  104950. /**
  104951. * Makes a duplicate of the current configuration into another one.
  104952. * @param brdfConfiguration define the config where to copy the info
  104953. */
  104954. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  104955. /**
  104956. * Serializes this BRDF configuration.
  104957. * @returns - An object with the serialized config.
  104958. */
  104959. serialize(): any;
  104960. /**
  104961. * Parses a anisotropy Configuration from a serialized object.
  104962. * @param source - Serialized object.
  104963. * @param scene Defines the scene we are parsing for
  104964. * @param rootUrl Defines the rootUrl to load from
  104965. */
  104966. parse(source: any, scene: Scene, rootUrl: string): void;
  104967. }
  104968. }
  104969. declare module BABYLON {
  104970. /**
  104971. * @hidden
  104972. */
  104973. export interface IMaterialSheenDefines {
  104974. SHEEN: boolean;
  104975. SHEEN_TEXTURE: boolean;
  104976. SHEEN_TEXTURE_ROUGHNESS: boolean;
  104977. SHEEN_TEXTUREDIRECTUV: number;
  104978. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  104979. SHEEN_LINKWITHALBEDO: boolean;
  104980. SHEEN_ROUGHNESS: boolean;
  104981. SHEEN_ALBEDOSCALING: boolean;
  104982. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  104983. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  104984. /** @hidden */
  104985. _areTexturesDirty: boolean;
  104986. }
  104987. /**
  104988. * Define the code related to the Sheen parameters of the pbr material.
  104989. */
  104990. export class PBRSheenConfiguration {
  104991. private _isEnabled;
  104992. /**
  104993. * Defines if the material uses sheen.
  104994. */
  104995. isEnabled: boolean;
  104996. private _linkSheenWithAlbedo;
  104997. /**
  104998. * Defines if the sheen is linked to the sheen color.
  104999. */
  105000. linkSheenWithAlbedo: boolean;
  105001. /**
  105002. * Defines the sheen intensity.
  105003. */
  105004. intensity: number;
  105005. /**
  105006. * Defines the sheen color.
  105007. */
  105008. color: Color3;
  105009. private _texture;
  105010. /**
  105011. * Stores the sheen tint values in a texture.
  105012. * rgb is tint
  105013. * 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)
  105014. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  105015. */
  105016. texture: Nullable<BaseTexture>;
  105017. private _useRoughnessFromMainTexture;
  105018. /**
  105019. * Indicates that the alpha channel of the texture property will be used for roughness.
  105020. * Has no effect if the roughness (and texture!) property is not defined
  105021. */
  105022. useRoughnessFromMainTexture: boolean;
  105023. private _roughness;
  105024. /**
  105025. * Defines the sheen roughness.
  105026. * It is not taken into account if linkSheenWithAlbedo is true.
  105027. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  105028. */
  105029. roughness: Nullable<number>;
  105030. private _textureRoughness;
  105031. /**
  105032. * Stores the sheen roughness in a texture.
  105033. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  105034. */
  105035. textureRoughness: Nullable<BaseTexture>;
  105036. private _albedoScaling;
  105037. /**
  105038. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  105039. * It allows the strength of the sheen effect to not depend on the base color of the material,
  105040. * making it easier to setup and tweak the effect
  105041. */
  105042. albedoScaling: boolean;
  105043. /** @hidden */
  105044. private _internalMarkAllSubMeshesAsTexturesDirty;
  105045. /** @hidden */
  105046. _markAllSubMeshesAsTexturesDirty(): void;
  105047. /**
  105048. * Instantiate a new istance of clear coat configuration.
  105049. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105050. */
  105051. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  105052. /**
  105053. * Specifies that the submesh is ready to be used.
  105054. * @param defines the list of "defines" to update.
  105055. * @param scene defines the scene the material belongs to.
  105056. * @returns - boolean indicating that the submesh is ready or not.
  105057. */
  105058. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  105059. /**
  105060. * Checks to see if a texture is used in the material.
  105061. * @param defines the list of "defines" to update.
  105062. * @param scene defines the scene the material belongs to.
  105063. */
  105064. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  105065. /**
  105066. * Binds the material data.
  105067. * @param uniformBuffer defines the Uniform buffer to fill in.
  105068. * @param scene defines the scene the material belongs to.
  105069. * @param isFrozen defines wether the material is frozen or not.
  105070. * @param subMesh the submesh to bind data for
  105071. */
  105072. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  105073. /**
  105074. * Checks to see if a texture is used in the material.
  105075. * @param texture - Base texture to use.
  105076. * @returns - Boolean specifying if a texture is used in the material.
  105077. */
  105078. hasTexture(texture: BaseTexture): boolean;
  105079. /**
  105080. * Returns an array of the actively used textures.
  105081. * @param activeTextures Array of BaseTextures
  105082. */
  105083. getActiveTextures(activeTextures: BaseTexture[]): void;
  105084. /**
  105085. * Returns the animatable textures.
  105086. * @param animatables Array of animatable textures.
  105087. */
  105088. getAnimatables(animatables: IAnimatable[]): void;
  105089. /**
  105090. * Disposes the resources of the material.
  105091. * @param forceDisposeTextures - Forces the disposal of all textures.
  105092. */
  105093. dispose(forceDisposeTextures?: boolean): void;
  105094. /**
  105095. * Get the current class name of the texture useful for serialization or dynamic coding.
  105096. * @returns "PBRSheenConfiguration"
  105097. */
  105098. getClassName(): string;
  105099. /**
  105100. * Add fallbacks to the effect fallbacks list.
  105101. * @param defines defines the Base texture to use.
  105102. * @param fallbacks defines the current fallback list.
  105103. * @param currentRank defines the current fallback rank.
  105104. * @returns the new fallback rank.
  105105. */
  105106. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105107. /**
  105108. * Add the required uniforms to the current list.
  105109. * @param uniforms defines the current uniform list.
  105110. */
  105111. static AddUniforms(uniforms: string[]): void;
  105112. /**
  105113. * Add the required uniforms to the current buffer.
  105114. * @param uniformBuffer defines the current uniform buffer.
  105115. */
  105116. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105117. /**
  105118. * Add the required samplers to the current list.
  105119. * @param samplers defines the current sampler list.
  105120. */
  105121. static AddSamplers(samplers: string[]): void;
  105122. /**
  105123. * Makes a duplicate of the current configuration into another one.
  105124. * @param sheenConfiguration define the config where to copy the info
  105125. */
  105126. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  105127. /**
  105128. * Serializes this BRDF configuration.
  105129. * @returns - An object with the serialized config.
  105130. */
  105131. serialize(): any;
  105132. /**
  105133. * Parses a anisotropy Configuration from a serialized object.
  105134. * @param source - Serialized object.
  105135. * @param scene Defines the scene we are parsing for
  105136. * @param rootUrl Defines the rootUrl to load from
  105137. */
  105138. parse(source: any, scene: Scene, rootUrl: string): void;
  105139. }
  105140. }
  105141. declare module BABYLON {
  105142. /**
  105143. * @hidden
  105144. */
  105145. export interface IMaterialSubSurfaceDefines {
  105146. SUBSURFACE: boolean;
  105147. SS_REFRACTION: boolean;
  105148. SS_TRANSLUCENCY: boolean;
  105149. SS_SCATTERING: boolean;
  105150. SS_THICKNESSANDMASK_TEXTURE: boolean;
  105151. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  105152. SS_REFRACTIONMAP_3D: boolean;
  105153. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  105154. SS_LODINREFRACTIONALPHA: boolean;
  105155. SS_GAMMAREFRACTION: boolean;
  105156. SS_RGBDREFRACTION: boolean;
  105157. SS_LINEARSPECULARREFRACTION: boolean;
  105158. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  105159. SS_ALBEDOFORREFRACTIONTINT: boolean;
  105160. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  105161. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  105162. /** @hidden */
  105163. _areTexturesDirty: boolean;
  105164. }
  105165. /**
  105166. * Define the code related to the sub surface parameters of the pbr material.
  105167. */
  105168. export class PBRSubSurfaceConfiguration {
  105169. private _isRefractionEnabled;
  105170. /**
  105171. * Defines if the refraction is enabled in the material.
  105172. */
  105173. isRefractionEnabled: boolean;
  105174. private _isTranslucencyEnabled;
  105175. /**
  105176. * Defines if the translucency is enabled in the material.
  105177. */
  105178. isTranslucencyEnabled: boolean;
  105179. private _isScatteringEnabled;
  105180. /**
  105181. * Defines if the sub surface scattering is enabled in the material.
  105182. */
  105183. isScatteringEnabled: boolean;
  105184. private _scatteringDiffusionProfileIndex;
  105185. /**
  105186. * Diffusion profile for subsurface scattering.
  105187. * Useful for better scattering in the skins or foliages.
  105188. */
  105189. get scatteringDiffusionProfile(): Nullable<Color3>;
  105190. set scatteringDiffusionProfile(c: Nullable<Color3>);
  105191. /**
  105192. * Defines the refraction intensity of the material.
  105193. * The refraction when enabled replaces the Diffuse part of the material.
  105194. * The intensity helps transitionning between diffuse and refraction.
  105195. */
  105196. refractionIntensity: number;
  105197. /**
  105198. * Defines the translucency intensity of the material.
  105199. * When translucency has been enabled, this defines how much of the "translucency"
  105200. * is addded to the diffuse part of the material.
  105201. */
  105202. translucencyIntensity: number;
  105203. /**
  105204. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  105205. */
  105206. useAlbedoToTintRefraction: boolean;
  105207. private _thicknessTexture;
  105208. /**
  105209. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  105210. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  105211. * 0 would mean minimumThickness
  105212. * 1 would mean maximumThickness
  105213. * The other channels might be use as a mask to vary the different effects intensity.
  105214. */
  105215. thicknessTexture: Nullable<BaseTexture>;
  105216. private _refractionTexture;
  105217. /**
  105218. * Defines the texture to use for refraction.
  105219. */
  105220. refractionTexture: Nullable<BaseTexture>;
  105221. private _indexOfRefraction;
  105222. /**
  105223. * Index of refraction of the material base layer.
  105224. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  105225. *
  105226. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  105227. *
  105228. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  105229. */
  105230. indexOfRefraction: number;
  105231. private _volumeIndexOfRefraction;
  105232. /**
  105233. * Index of refraction of the material's volume.
  105234. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  105235. *
  105236. * This ONLY impacts refraction. If not provided or given a non-valid value,
  105237. * the volume will use the same IOR as the surface.
  105238. */
  105239. get volumeIndexOfRefraction(): number;
  105240. set volumeIndexOfRefraction(value: number);
  105241. private _invertRefractionY;
  105242. /**
  105243. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  105244. */
  105245. invertRefractionY: boolean;
  105246. private _linkRefractionWithTransparency;
  105247. /**
  105248. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  105249. * Materials half opaque for instance using refraction could benefit from this control.
  105250. */
  105251. linkRefractionWithTransparency: boolean;
  105252. /**
  105253. * Defines the minimum thickness stored in the thickness map.
  105254. * If no thickness map is defined, this value will be used to simulate thickness.
  105255. */
  105256. minimumThickness: number;
  105257. /**
  105258. * Defines the maximum thickness stored in the thickness map.
  105259. */
  105260. maximumThickness: number;
  105261. /**
  105262. * Defines the volume tint of the material.
  105263. * This is used for both translucency and scattering.
  105264. */
  105265. tintColor: Color3;
  105266. /**
  105267. * Defines the distance at which the tint color should be found in the media.
  105268. * This is used for refraction only.
  105269. */
  105270. tintColorAtDistance: number;
  105271. /**
  105272. * Defines how far each channel transmit through the media.
  105273. * It is defined as a color to simplify it selection.
  105274. */
  105275. diffusionDistance: Color3;
  105276. private _useMaskFromThicknessTexture;
  105277. /**
  105278. * Stores the intensity of the different subsurface effects in the thickness texture.
  105279. * * the green channel is the translucency intensity.
  105280. * * the blue channel is the scattering intensity.
  105281. * * the alpha channel is the refraction intensity.
  105282. */
  105283. useMaskFromThicknessTexture: boolean;
  105284. private _scene;
  105285. private _useMaskFromThicknessTextureGltf;
  105286. /**
  105287. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  105288. * matches the channel-packing that is used by glTF.
  105289. * * the red channel is the transmission/translucency intensity.
  105290. * * the green channel is the thickness.
  105291. */
  105292. useMaskFromThicknessTextureGltf: boolean;
  105293. /** @hidden */
  105294. private _internalMarkAllSubMeshesAsTexturesDirty;
  105295. private _internalMarkScenePrePassDirty;
  105296. /** @hidden */
  105297. _markAllSubMeshesAsTexturesDirty(): void;
  105298. /** @hidden */
  105299. _markScenePrePassDirty(): void;
  105300. /**
  105301. * Instantiate a new istance of sub surface configuration.
  105302. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105303. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  105304. * @param scene The scene
  105305. */
  105306. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  105307. /**
  105308. * Gets wehter the submesh is ready to be used or not.
  105309. * @param defines the list of "defines" to update.
  105310. * @param scene defines the scene the material belongs to.
  105311. * @returns - boolean indicating that the submesh is ready or not.
  105312. */
  105313. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  105314. /**
  105315. * Checks to see if a texture is used in the material.
  105316. * @param defines the list of "defines" to update.
  105317. * @param scene defines the scene to the material belongs to.
  105318. */
  105319. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  105320. /**
  105321. * Binds the material data.
  105322. * @param uniformBuffer defines the Uniform buffer to fill in.
  105323. * @param scene defines the scene the material belongs to.
  105324. * @param engine defines the engine the material belongs to.
  105325. * @param isFrozen defines whether the material is frozen or not.
  105326. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  105327. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  105328. */
  105329. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  105330. /**
  105331. * Unbinds the material from the mesh.
  105332. * @param activeEffect defines the effect that should be unbound from.
  105333. * @returns true if unbound, otherwise false
  105334. */
  105335. unbind(activeEffect: Effect): boolean;
  105336. /**
  105337. * Returns the texture used for refraction or null if none is used.
  105338. * @param scene defines the scene the material belongs to.
  105339. * @returns - Refraction texture if present. If no refraction texture and refraction
  105340. * is linked with transparency, returns environment texture. Otherwise, returns null.
  105341. */
  105342. private _getRefractionTexture;
  105343. /**
  105344. * Returns true if alpha blending should be disabled.
  105345. */
  105346. get disableAlphaBlending(): boolean;
  105347. /**
  105348. * Fills the list of render target textures.
  105349. * @param renderTargets the list of render targets to update
  105350. */
  105351. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  105352. /**
  105353. * Checks to see if a texture is used in the material.
  105354. * @param texture - Base texture to use.
  105355. * @returns - Boolean specifying if a texture is used in the material.
  105356. */
  105357. hasTexture(texture: BaseTexture): boolean;
  105358. /**
  105359. * Gets a boolean indicating that current material needs to register RTT
  105360. * @returns true if this uses a render target otherwise false.
  105361. */
  105362. hasRenderTargetTextures(): boolean;
  105363. /**
  105364. * Returns an array of the actively used textures.
  105365. * @param activeTextures Array of BaseTextures
  105366. */
  105367. getActiveTextures(activeTextures: BaseTexture[]): void;
  105368. /**
  105369. * Returns the animatable textures.
  105370. * @param animatables Array of animatable textures.
  105371. */
  105372. getAnimatables(animatables: IAnimatable[]): void;
  105373. /**
  105374. * Disposes the resources of the material.
  105375. * @param forceDisposeTextures - Forces the disposal of all textures.
  105376. */
  105377. dispose(forceDisposeTextures?: boolean): void;
  105378. /**
  105379. * Get the current class name of the texture useful for serialization or dynamic coding.
  105380. * @returns "PBRSubSurfaceConfiguration"
  105381. */
  105382. getClassName(): string;
  105383. /**
  105384. * Add fallbacks to the effect fallbacks list.
  105385. * @param defines defines the Base texture to use.
  105386. * @param fallbacks defines the current fallback list.
  105387. * @param currentRank defines the current fallback rank.
  105388. * @returns the new fallback rank.
  105389. */
  105390. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  105391. /**
  105392. * Add the required uniforms to the current list.
  105393. * @param uniforms defines the current uniform list.
  105394. */
  105395. static AddUniforms(uniforms: string[]): void;
  105396. /**
  105397. * Add the required samplers to the current list.
  105398. * @param samplers defines the current sampler list.
  105399. */
  105400. static AddSamplers(samplers: string[]): void;
  105401. /**
  105402. * Add the required uniforms to the current buffer.
  105403. * @param uniformBuffer defines the current uniform buffer.
  105404. */
  105405. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105406. /**
  105407. * Makes a duplicate of the current configuration into another one.
  105408. * @param configuration define the config where to copy the info
  105409. */
  105410. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  105411. /**
  105412. * Serializes this Sub Surface configuration.
  105413. * @returns - An object with the serialized config.
  105414. */
  105415. serialize(): any;
  105416. /**
  105417. * Parses a anisotropy Configuration from a serialized object.
  105418. * @param source - Serialized object.
  105419. * @param scene Defines the scene we are parsing for
  105420. * @param rootUrl Defines the rootUrl to load from
  105421. */
  105422. parse(source: any, scene: Scene, rootUrl: string): void;
  105423. }
  105424. }
  105425. declare module BABYLON {
  105426. /**
  105427. * Class representing spherical harmonics coefficients to the 3rd degree
  105428. */
  105429. export class SphericalHarmonics {
  105430. /**
  105431. * Defines whether or not the harmonics have been prescaled for rendering.
  105432. */
  105433. preScaled: boolean;
  105434. /**
  105435. * The l0,0 coefficients of the spherical harmonics
  105436. */
  105437. l00: Vector3;
  105438. /**
  105439. * The l1,-1 coefficients of the spherical harmonics
  105440. */
  105441. l1_1: Vector3;
  105442. /**
  105443. * The l1,0 coefficients of the spherical harmonics
  105444. */
  105445. l10: Vector3;
  105446. /**
  105447. * The l1,1 coefficients of the spherical harmonics
  105448. */
  105449. l11: Vector3;
  105450. /**
  105451. * The l2,-2 coefficients of the spherical harmonics
  105452. */
  105453. l2_2: Vector3;
  105454. /**
  105455. * The l2,-1 coefficients of the spherical harmonics
  105456. */
  105457. l2_1: Vector3;
  105458. /**
  105459. * The l2,0 coefficients of the spherical harmonics
  105460. */
  105461. l20: Vector3;
  105462. /**
  105463. * The l2,1 coefficients of the spherical harmonics
  105464. */
  105465. l21: Vector3;
  105466. /**
  105467. * The l2,2 coefficients of the spherical harmonics
  105468. */
  105469. l22: Vector3;
  105470. /**
  105471. * Adds a light to the spherical harmonics
  105472. * @param direction the direction of the light
  105473. * @param color the color of the light
  105474. * @param deltaSolidAngle the delta solid angle of the light
  105475. */
  105476. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  105477. /**
  105478. * Scales the spherical harmonics by the given amount
  105479. * @param scale the amount to scale
  105480. */
  105481. scaleInPlace(scale: number): void;
  105482. /**
  105483. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  105484. *
  105485. * ```
  105486. * E_lm = A_l * L_lm
  105487. * ```
  105488. *
  105489. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  105490. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  105491. * the scaling factors are given in equation 9.
  105492. */
  105493. convertIncidentRadianceToIrradiance(): void;
  105494. /**
  105495. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  105496. *
  105497. * ```
  105498. * L = (1/pi) * E * rho
  105499. * ```
  105500. *
  105501. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  105502. */
  105503. convertIrradianceToLambertianRadiance(): void;
  105504. /**
  105505. * Integrates the reconstruction coefficients directly in to the SH preventing further
  105506. * required operations at run time.
  105507. *
  105508. * This is simply done by scaling back the SH with Ylm constants parameter.
  105509. * The trigonometric part being applied by the shader at run time.
  105510. */
  105511. preScaleForRendering(): void;
  105512. /**
  105513. * Constructs a spherical harmonics from an array.
  105514. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  105515. * @returns the spherical harmonics
  105516. */
  105517. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  105518. /**
  105519. * Gets the spherical harmonics from polynomial
  105520. * @param polynomial the spherical polynomial
  105521. * @returns the spherical harmonics
  105522. */
  105523. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  105524. }
  105525. /**
  105526. * Class representing spherical polynomial coefficients to the 3rd degree
  105527. */
  105528. export class SphericalPolynomial {
  105529. private _harmonics;
  105530. /**
  105531. * The spherical harmonics used to create the polynomials.
  105532. */
  105533. get preScaledHarmonics(): SphericalHarmonics;
  105534. /**
  105535. * The x coefficients of the spherical polynomial
  105536. */
  105537. x: Vector3;
  105538. /**
  105539. * The y coefficients of the spherical polynomial
  105540. */
  105541. y: Vector3;
  105542. /**
  105543. * The z coefficients of the spherical polynomial
  105544. */
  105545. z: Vector3;
  105546. /**
  105547. * The xx coefficients of the spherical polynomial
  105548. */
  105549. xx: Vector3;
  105550. /**
  105551. * The yy coefficients of the spherical polynomial
  105552. */
  105553. yy: Vector3;
  105554. /**
  105555. * The zz coefficients of the spherical polynomial
  105556. */
  105557. zz: Vector3;
  105558. /**
  105559. * The xy coefficients of the spherical polynomial
  105560. */
  105561. xy: Vector3;
  105562. /**
  105563. * The yz coefficients of the spherical polynomial
  105564. */
  105565. yz: Vector3;
  105566. /**
  105567. * The zx coefficients of the spherical polynomial
  105568. */
  105569. zx: Vector3;
  105570. /**
  105571. * Adds an ambient color to the spherical polynomial
  105572. * @param color the color to add
  105573. */
  105574. addAmbient(color: Color3): void;
  105575. /**
  105576. * Scales the spherical polynomial by the given amount
  105577. * @param scale the amount to scale
  105578. */
  105579. scaleInPlace(scale: number): void;
  105580. /**
  105581. * Gets the spherical polynomial from harmonics
  105582. * @param harmonics the spherical harmonics
  105583. * @returns the spherical polynomial
  105584. */
  105585. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  105586. /**
  105587. * Constructs a spherical polynomial from an array.
  105588. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  105589. * @returns the spherical polynomial
  105590. */
  105591. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  105592. }
  105593. }
  105594. declare module BABYLON {
  105595. /**
  105596. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  105597. */
  105598. export interface CubeMapInfo {
  105599. /**
  105600. * The pixel array for the front face.
  105601. * This is stored in format, left to right, up to down format.
  105602. */
  105603. front: Nullable<ArrayBufferView>;
  105604. /**
  105605. * The pixel array for the back face.
  105606. * This is stored in format, left to right, up to down format.
  105607. */
  105608. back: Nullable<ArrayBufferView>;
  105609. /**
  105610. * The pixel array for the left face.
  105611. * This is stored in format, left to right, up to down format.
  105612. */
  105613. left: Nullable<ArrayBufferView>;
  105614. /**
  105615. * The pixel array for the right face.
  105616. * This is stored in format, left to right, up to down format.
  105617. */
  105618. right: Nullable<ArrayBufferView>;
  105619. /**
  105620. * The pixel array for the up face.
  105621. * This is stored in format, left to right, up to down format.
  105622. */
  105623. up: Nullable<ArrayBufferView>;
  105624. /**
  105625. * The pixel array for the down face.
  105626. * This is stored in format, left to right, up to down format.
  105627. */
  105628. down: Nullable<ArrayBufferView>;
  105629. /**
  105630. * The size of the cubemap stored.
  105631. *
  105632. * Each faces will be size * size pixels.
  105633. */
  105634. size: number;
  105635. /**
  105636. * The format of the texture.
  105637. *
  105638. * RGBA, RGB.
  105639. */
  105640. format: number;
  105641. /**
  105642. * The type of the texture data.
  105643. *
  105644. * UNSIGNED_INT, FLOAT.
  105645. */
  105646. type: number;
  105647. /**
  105648. * Specifies whether the texture is in gamma space.
  105649. */
  105650. gammaSpace: boolean;
  105651. }
  105652. /**
  105653. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  105654. */
  105655. export class PanoramaToCubeMapTools {
  105656. private static FACE_LEFT;
  105657. private static FACE_RIGHT;
  105658. private static FACE_FRONT;
  105659. private static FACE_BACK;
  105660. private static FACE_DOWN;
  105661. private static FACE_UP;
  105662. /**
  105663. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  105664. *
  105665. * @param float32Array The source data.
  105666. * @param inputWidth The width of the input panorama.
  105667. * @param inputHeight The height of the input panorama.
  105668. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  105669. * @return The cubemap data
  105670. */
  105671. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  105672. private static CreateCubemapTexture;
  105673. private static CalcProjectionSpherical;
  105674. }
  105675. }
  105676. declare module BABYLON {
  105677. /**
  105678. * Helper class dealing with the extraction of spherical polynomial dataArray
  105679. * from a cube map.
  105680. */
  105681. export class CubeMapToSphericalPolynomialTools {
  105682. private static FileFaces;
  105683. /**
  105684. * Converts a texture to the according Spherical Polynomial data.
  105685. * This extracts the first 3 orders only as they are the only one used in the lighting.
  105686. *
  105687. * @param texture The texture to extract the information from.
  105688. * @return The Spherical Polynomial data.
  105689. */
  105690. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<Promise<SphericalPolynomial>>;
  105691. /**
  105692. * Converts a cubemap to the according Spherical Polynomial data.
  105693. * This extracts the first 3 orders only as they are the only one used in the lighting.
  105694. *
  105695. * @param cubeInfo The Cube map to extract the information from.
  105696. * @return The Spherical Polynomial data.
  105697. */
  105698. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  105699. }
  105700. }
  105701. declare module BABYLON {
  105702. interface BaseTexture {
  105703. /**
  105704. * Get the polynomial representation of the texture data.
  105705. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  105706. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  105707. */
  105708. sphericalPolynomial: Nullable<SphericalPolynomial>;
  105709. }
  105710. }
  105711. declare module BABYLON {
  105712. /** @hidden */
  105713. export var pbrFragmentDeclaration: {
  105714. name: string;
  105715. shader: string;
  105716. };
  105717. }
  105718. declare module BABYLON {
  105719. /** @hidden */
  105720. export var pbrUboDeclaration: {
  105721. name: string;
  105722. shader: string;
  105723. };
  105724. }
  105725. declare module BABYLON {
  105726. /** @hidden */
  105727. export var pbrFragmentExtraDeclaration: {
  105728. name: string;
  105729. shader: string;
  105730. };
  105731. }
  105732. declare module BABYLON {
  105733. /** @hidden */
  105734. export var pbrFragmentSamplersDeclaration: {
  105735. name: string;
  105736. shader: string;
  105737. };
  105738. }
  105739. declare module BABYLON {
  105740. /** @hidden */
  105741. export var subSurfaceScatteringFunctions: {
  105742. name: string;
  105743. shader: string;
  105744. };
  105745. }
  105746. declare module BABYLON {
  105747. /** @hidden */
  105748. export var importanceSampling: {
  105749. name: string;
  105750. shader: string;
  105751. };
  105752. }
  105753. declare module BABYLON {
  105754. /** @hidden */
  105755. export var pbrHelperFunctions: {
  105756. name: string;
  105757. shader: string;
  105758. };
  105759. }
  105760. declare module BABYLON {
  105761. /** @hidden */
  105762. export var harmonicsFunctions: {
  105763. name: string;
  105764. shader: string;
  105765. };
  105766. }
  105767. declare module BABYLON {
  105768. /** @hidden */
  105769. export var pbrDirectLightingSetupFunctions: {
  105770. name: string;
  105771. shader: string;
  105772. };
  105773. }
  105774. declare module BABYLON {
  105775. /** @hidden */
  105776. export var pbrDirectLightingFalloffFunctions: {
  105777. name: string;
  105778. shader: string;
  105779. };
  105780. }
  105781. declare module BABYLON {
  105782. /** @hidden */
  105783. export var pbrBRDFFunctions: {
  105784. name: string;
  105785. shader: string;
  105786. };
  105787. }
  105788. declare module BABYLON {
  105789. /** @hidden */
  105790. export var hdrFilteringFunctions: {
  105791. name: string;
  105792. shader: string;
  105793. };
  105794. }
  105795. declare module BABYLON {
  105796. /** @hidden */
  105797. export var pbrDirectLightingFunctions: {
  105798. name: string;
  105799. shader: string;
  105800. };
  105801. }
  105802. declare module BABYLON {
  105803. /** @hidden */
  105804. export var pbrIBLFunctions: {
  105805. name: string;
  105806. shader: string;
  105807. };
  105808. }
  105809. declare module BABYLON {
  105810. /** @hidden */
  105811. export var pbrBlockAlbedoOpacity: {
  105812. name: string;
  105813. shader: string;
  105814. };
  105815. }
  105816. declare module BABYLON {
  105817. /** @hidden */
  105818. export var pbrBlockReflectivity: {
  105819. name: string;
  105820. shader: string;
  105821. };
  105822. }
  105823. declare module BABYLON {
  105824. /** @hidden */
  105825. export var pbrBlockAmbientOcclusion: {
  105826. name: string;
  105827. shader: string;
  105828. };
  105829. }
  105830. declare module BABYLON {
  105831. /** @hidden */
  105832. export var pbrBlockAlphaFresnel: {
  105833. name: string;
  105834. shader: string;
  105835. };
  105836. }
  105837. declare module BABYLON {
  105838. /** @hidden */
  105839. export var pbrBlockAnisotropic: {
  105840. name: string;
  105841. shader: string;
  105842. };
  105843. }
  105844. declare module BABYLON {
  105845. /** @hidden */
  105846. export var pbrBlockReflection: {
  105847. name: string;
  105848. shader: string;
  105849. };
  105850. }
  105851. declare module BABYLON {
  105852. /** @hidden */
  105853. export var pbrBlockSheen: {
  105854. name: string;
  105855. shader: string;
  105856. };
  105857. }
  105858. declare module BABYLON {
  105859. /** @hidden */
  105860. export var pbrBlockClearcoat: {
  105861. name: string;
  105862. shader: string;
  105863. };
  105864. }
  105865. declare module BABYLON {
  105866. /** @hidden */
  105867. export var pbrBlockSubSurface: {
  105868. name: string;
  105869. shader: string;
  105870. };
  105871. }
  105872. declare module BABYLON {
  105873. /** @hidden */
  105874. export var pbrBlockNormalGeometric: {
  105875. name: string;
  105876. shader: string;
  105877. };
  105878. }
  105879. declare module BABYLON {
  105880. /** @hidden */
  105881. export var pbrBlockNormalFinal: {
  105882. name: string;
  105883. shader: string;
  105884. };
  105885. }
  105886. declare module BABYLON {
  105887. /** @hidden */
  105888. export var pbrBlockLightmapInit: {
  105889. name: string;
  105890. shader: string;
  105891. };
  105892. }
  105893. declare module BABYLON {
  105894. /** @hidden */
  105895. export var pbrBlockGeometryInfo: {
  105896. name: string;
  105897. shader: string;
  105898. };
  105899. }
  105900. declare module BABYLON {
  105901. /** @hidden */
  105902. export var pbrBlockReflectance0: {
  105903. name: string;
  105904. shader: string;
  105905. };
  105906. }
  105907. declare module BABYLON {
  105908. /** @hidden */
  105909. export var pbrBlockReflectance: {
  105910. name: string;
  105911. shader: string;
  105912. };
  105913. }
  105914. declare module BABYLON {
  105915. /** @hidden */
  105916. export var pbrBlockDirectLighting: {
  105917. name: string;
  105918. shader: string;
  105919. };
  105920. }
  105921. declare module BABYLON {
  105922. /** @hidden */
  105923. export var pbrBlockFinalLitComponents: {
  105924. name: string;
  105925. shader: string;
  105926. };
  105927. }
  105928. declare module BABYLON {
  105929. /** @hidden */
  105930. export var pbrBlockFinalUnlitComponents: {
  105931. name: string;
  105932. shader: string;
  105933. };
  105934. }
  105935. declare module BABYLON {
  105936. /** @hidden */
  105937. export var pbrBlockFinalColorComposition: {
  105938. name: string;
  105939. shader: string;
  105940. };
  105941. }
  105942. declare module BABYLON {
  105943. /** @hidden */
  105944. export var pbrBlockImageProcessing: {
  105945. name: string;
  105946. shader: string;
  105947. };
  105948. }
  105949. declare module BABYLON {
  105950. /** @hidden */
  105951. export var pbrDebug: {
  105952. name: string;
  105953. shader: string;
  105954. };
  105955. }
  105956. declare module BABYLON {
  105957. /** @hidden */
  105958. export var pbrPixelShader: {
  105959. name: string;
  105960. shader: string;
  105961. };
  105962. }
  105963. declare module BABYLON {
  105964. /** @hidden */
  105965. export var pbrVertexDeclaration: {
  105966. name: string;
  105967. shader: string;
  105968. };
  105969. }
  105970. declare module BABYLON {
  105971. /** @hidden */
  105972. export var pbrVertexShader: {
  105973. name: string;
  105974. shader: string;
  105975. };
  105976. }
  105977. declare module BABYLON {
  105978. /**
  105979. * Manages the defines for the PBR Material.
  105980. * @hidden
  105981. */
  105982. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  105983. PBR: boolean;
  105984. NUM_SAMPLES: string;
  105985. REALTIME_FILTERING: boolean;
  105986. MAINUV1: boolean;
  105987. MAINUV2: boolean;
  105988. UV1: boolean;
  105989. UV2: boolean;
  105990. ALBEDO: boolean;
  105991. GAMMAALBEDO: boolean;
  105992. ALBEDODIRECTUV: number;
  105993. VERTEXCOLOR: boolean;
  105994. DETAIL: boolean;
  105995. DETAILDIRECTUV: number;
  105996. DETAIL_NORMALBLENDMETHOD: number;
  105997. AMBIENT: boolean;
  105998. AMBIENTDIRECTUV: number;
  105999. AMBIENTINGRAYSCALE: boolean;
  106000. OPACITY: boolean;
  106001. VERTEXALPHA: boolean;
  106002. OPACITYDIRECTUV: number;
  106003. OPACITYRGB: boolean;
  106004. ALPHATEST: boolean;
  106005. DEPTHPREPASS: boolean;
  106006. ALPHABLEND: boolean;
  106007. ALPHAFROMALBEDO: boolean;
  106008. ALPHATESTVALUE: string;
  106009. SPECULAROVERALPHA: boolean;
  106010. RADIANCEOVERALPHA: boolean;
  106011. ALPHAFRESNEL: boolean;
  106012. LINEARALPHAFRESNEL: boolean;
  106013. PREMULTIPLYALPHA: boolean;
  106014. EMISSIVE: boolean;
  106015. EMISSIVEDIRECTUV: number;
  106016. REFLECTIVITY: boolean;
  106017. REFLECTIVITYDIRECTUV: number;
  106018. SPECULARTERM: boolean;
  106019. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  106020. MICROSURFACEAUTOMATIC: boolean;
  106021. LODBASEDMICROSFURACE: boolean;
  106022. MICROSURFACEMAP: boolean;
  106023. MICROSURFACEMAPDIRECTUV: number;
  106024. METALLICWORKFLOW: boolean;
  106025. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  106026. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  106027. METALLNESSSTOREINMETALMAPBLUE: boolean;
  106028. AOSTOREINMETALMAPRED: boolean;
  106029. METALLIC_REFLECTANCE: boolean;
  106030. METALLIC_REFLECTANCEDIRECTUV: number;
  106031. ENVIRONMENTBRDF: boolean;
  106032. ENVIRONMENTBRDF_RGBD: boolean;
  106033. NORMAL: boolean;
  106034. TANGENT: boolean;
  106035. BUMP: boolean;
  106036. BUMPDIRECTUV: number;
  106037. OBJECTSPACE_NORMALMAP: boolean;
  106038. PARALLAX: boolean;
  106039. PARALLAXOCCLUSION: boolean;
  106040. NORMALXYSCALE: boolean;
  106041. LIGHTMAP: boolean;
  106042. LIGHTMAPDIRECTUV: number;
  106043. USELIGHTMAPASSHADOWMAP: boolean;
  106044. GAMMALIGHTMAP: boolean;
  106045. RGBDLIGHTMAP: boolean;
  106046. REFLECTION: boolean;
  106047. REFLECTIONMAP_3D: boolean;
  106048. REFLECTIONMAP_SPHERICAL: boolean;
  106049. REFLECTIONMAP_PLANAR: boolean;
  106050. REFLECTIONMAP_CUBIC: boolean;
  106051. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  106052. REFLECTIONMAP_PROJECTION: boolean;
  106053. REFLECTIONMAP_SKYBOX: boolean;
  106054. REFLECTIONMAP_EXPLICIT: boolean;
  106055. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  106056. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  106057. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  106058. INVERTCUBICMAP: boolean;
  106059. USESPHERICALFROMREFLECTIONMAP: boolean;
  106060. USEIRRADIANCEMAP: boolean;
  106061. SPHERICAL_HARMONICS: boolean;
  106062. USESPHERICALINVERTEX: boolean;
  106063. REFLECTIONMAP_OPPOSITEZ: boolean;
  106064. LODINREFLECTIONALPHA: boolean;
  106065. GAMMAREFLECTION: boolean;
  106066. RGBDREFLECTION: boolean;
  106067. LINEARSPECULARREFLECTION: boolean;
  106068. RADIANCEOCCLUSION: boolean;
  106069. HORIZONOCCLUSION: boolean;
  106070. INSTANCES: boolean;
  106071. THIN_INSTANCES: boolean;
  106072. PREPASS: boolean;
  106073. PREPASS_IRRADIANCE: boolean;
  106074. PREPASS_IRRADIANCE_INDEX: number;
  106075. PREPASS_ALBEDO: boolean;
  106076. PREPASS_ALBEDO_INDEX: number;
  106077. PREPASS_DEPTHNORMAL: boolean;
  106078. PREPASS_DEPTHNORMAL_INDEX: number;
  106079. PREPASS_POSITION: boolean;
  106080. PREPASS_POSITION_INDEX: number;
  106081. PREPASS_VELOCITY: boolean;
  106082. PREPASS_VELOCITY_INDEX: number;
  106083. PREPASS_REFLECTIVITY: boolean;
  106084. PREPASS_REFLECTIVITY_INDEX: number;
  106085. SCENE_MRT_COUNT: number;
  106086. NUM_BONE_INFLUENCERS: number;
  106087. BonesPerMesh: number;
  106088. BONETEXTURE: boolean;
  106089. BONES_VELOCITY_ENABLED: boolean;
  106090. NONUNIFORMSCALING: boolean;
  106091. MORPHTARGETS: boolean;
  106092. MORPHTARGETS_NORMAL: boolean;
  106093. MORPHTARGETS_TANGENT: boolean;
  106094. MORPHTARGETS_UV: boolean;
  106095. NUM_MORPH_INFLUENCERS: number;
  106096. IMAGEPROCESSING: boolean;
  106097. VIGNETTE: boolean;
  106098. VIGNETTEBLENDMODEMULTIPLY: boolean;
  106099. VIGNETTEBLENDMODEOPAQUE: boolean;
  106100. TONEMAPPING: boolean;
  106101. TONEMAPPING_ACES: boolean;
  106102. CONTRAST: boolean;
  106103. COLORCURVES: boolean;
  106104. COLORGRADING: boolean;
  106105. COLORGRADING3D: boolean;
  106106. SAMPLER3DGREENDEPTH: boolean;
  106107. SAMPLER3DBGRMAP: boolean;
  106108. IMAGEPROCESSINGPOSTPROCESS: boolean;
  106109. EXPOSURE: boolean;
  106110. MULTIVIEW: boolean;
  106111. USEPHYSICALLIGHTFALLOFF: boolean;
  106112. USEGLTFLIGHTFALLOFF: boolean;
  106113. TWOSIDEDLIGHTING: boolean;
  106114. SHADOWFLOAT: boolean;
  106115. CLIPPLANE: boolean;
  106116. CLIPPLANE2: boolean;
  106117. CLIPPLANE3: boolean;
  106118. CLIPPLANE4: boolean;
  106119. CLIPPLANE5: boolean;
  106120. CLIPPLANE6: boolean;
  106121. POINTSIZE: boolean;
  106122. FOG: boolean;
  106123. LOGARITHMICDEPTH: boolean;
  106124. FORCENORMALFORWARD: boolean;
  106125. SPECULARAA: boolean;
  106126. CLEARCOAT: boolean;
  106127. CLEARCOAT_DEFAULTIOR: boolean;
  106128. CLEARCOAT_TEXTURE: boolean;
  106129. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  106130. CLEARCOAT_TEXTUREDIRECTUV: number;
  106131. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  106132. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  106133. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  106134. CLEARCOAT_BUMP: boolean;
  106135. CLEARCOAT_BUMPDIRECTUV: number;
  106136. CLEARCOAT_REMAP_F0: boolean;
  106137. CLEARCOAT_TINT: boolean;
  106138. CLEARCOAT_TINT_TEXTURE: boolean;
  106139. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  106140. ANISOTROPIC: boolean;
  106141. ANISOTROPIC_TEXTURE: boolean;
  106142. ANISOTROPIC_TEXTUREDIRECTUV: number;
  106143. BRDF_V_HEIGHT_CORRELATED: boolean;
  106144. MS_BRDF_ENERGY_CONSERVATION: boolean;
  106145. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  106146. SHEEN: boolean;
  106147. SHEEN_TEXTURE: boolean;
  106148. SHEEN_TEXTURE_ROUGHNESS: boolean;
  106149. SHEEN_TEXTUREDIRECTUV: number;
  106150. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  106151. SHEEN_LINKWITHALBEDO: boolean;
  106152. SHEEN_ROUGHNESS: boolean;
  106153. SHEEN_ALBEDOSCALING: boolean;
  106154. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  106155. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  106156. SUBSURFACE: boolean;
  106157. SS_REFRACTION: boolean;
  106158. SS_TRANSLUCENCY: boolean;
  106159. SS_SCATTERING: boolean;
  106160. SS_THICKNESSANDMASK_TEXTURE: boolean;
  106161. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  106162. SS_REFRACTIONMAP_3D: boolean;
  106163. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  106164. SS_LODINREFRACTIONALPHA: boolean;
  106165. SS_GAMMAREFRACTION: boolean;
  106166. SS_RGBDREFRACTION: boolean;
  106167. SS_LINEARSPECULARREFRACTION: boolean;
  106168. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  106169. SS_ALBEDOFORREFRACTIONTINT: boolean;
  106170. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  106171. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  106172. UNLIT: boolean;
  106173. DEBUGMODE: number;
  106174. /**
  106175. * Initializes the PBR Material defines.
  106176. */
  106177. constructor();
  106178. /**
  106179. * Resets the PBR Material defines.
  106180. */
  106181. reset(): void;
  106182. }
  106183. /**
  106184. * The Physically based material base class of BJS.
  106185. *
  106186. * This offers the main features of a standard PBR material.
  106187. * For more information, please refer to the documentation :
  106188. * https://doc.babylonjs.com/how_to/physically_based_rendering
  106189. */
  106190. export abstract class PBRBaseMaterial extends PushMaterial {
  106191. /**
  106192. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  106193. */
  106194. static readonly PBRMATERIAL_OPAQUE: number;
  106195. /**
  106196. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  106197. */
  106198. static readonly PBRMATERIAL_ALPHATEST: number;
  106199. /**
  106200. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  106201. */
  106202. static readonly PBRMATERIAL_ALPHABLEND: number;
  106203. /**
  106204. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  106205. * They are also discarded below the alpha cutoff threshold to improve performances.
  106206. */
  106207. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  106208. /**
  106209. * Defines the default value of how much AO map is occluding the analytical lights
  106210. * (point spot...).
  106211. */
  106212. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  106213. /**
  106214. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  106215. */
  106216. static readonly LIGHTFALLOFF_PHYSICAL: number;
  106217. /**
  106218. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  106219. * to enhance interoperability with other engines.
  106220. */
  106221. static readonly LIGHTFALLOFF_GLTF: number;
  106222. /**
  106223. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  106224. * to enhance interoperability with other materials.
  106225. */
  106226. static readonly LIGHTFALLOFF_STANDARD: number;
  106227. /**
  106228. * Intensity of the direct lights e.g. the four lights available in your scene.
  106229. * This impacts both the direct diffuse and specular highlights.
  106230. */
  106231. protected _directIntensity: number;
  106232. /**
  106233. * Intensity of the emissive part of the material.
  106234. * This helps controlling the emissive effect without modifying the emissive color.
  106235. */
  106236. protected _emissiveIntensity: number;
  106237. /**
  106238. * Intensity of the environment e.g. how much the environment will light the object
  106239. * either through harmonics for rough material or through the refelction for shiny ones.
  106240. */
  106241. protected _environmentIntensity: number;
  106242. /**
  106243. * This is a special control allowing the reduction of the specular highlights coming from the
  106244. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  106245. */
  106246. protected _specularIntensity: number;
  106247. /**
  106248. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  106249. */
  106250. private _lightingInfos;
  106251. /**
  106252. * Debug Control allowing disabling the bump map on this material.
  106253. */
  106254. protected _disableBumpMap: boolean;
  106255. /**
  106256. * AKA Diffuse Texture in standard nomenclature.
  106257. */
  106258. protected _albedoTexture: Nullable<BaseTexture>;
  106259. /**
  106260. * AKA Occlusion Texture in other nomenclature.
  106261. */
  106262. protected _ambientTexture: Nullable<BaseTexture>;
  106263. /**
  106264. * AKA Occlusion Texture Intensity in other nomenclature.
  106265. */
  106266. protected _ambientTextureStrength: number;
  106267. /**
  106268. * Defines how much the AO map is occluding the analytical lights (point spot...).
  106269. * 1 means it completely occludes it
  106270. * 0 mean it has no impact
  106271. */
  106272. protected _ambientTextureImpactOnAnalyticalLights: number;
  106273. /**
  106274. * Stores the alpha values in a texture.
  106275. */
  106276. protected _opacityTexture: Nullable<BaseTexture>;
  106277. /**
  106278. * Stores the reflection values in a texture.
  106279. */
  106280. protected _reflectionTexture: Nullable<BaseTexture>;
  106281. /**
  106282. * Stores the emissive values in a texture.
  106283. */
  106284. protected _emissiveTexture: Nullable<BaseTexture>;
  106285. /**
  106286. * AKA Specular texture in other nomenclature.
  106287. */
  106288. protected _reflectivityTexture: Nullable<BaseTexture>;
  106289. /**
  106290. * Used to switch from specular/glossiness to metallic/roughness workflow.
  106291. */
  106292. protected _metallicTexture: Nullable<BaseTexture>;
  106293. /**
  106294. * Specifies the metallic scalar of the metallic/roughness workflow.
  106295. * Can also be used to scale the metalness values of the metallic texture.
  106296. */
  106297. protected _metallic: Nullable<number>;
  106298. /**
  106299. * Specifies the roughness scalar of the metallic/roughness workflow.
  106300. * Can also be used to scale the roughness values of the metallic texture.
  106301. */
  106302. protected _roughness: Nullable<number>;
  106303. /**
  106304. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  106305. * By default the indexOfrefraction is used to compute F0;
  106306. *
  106307. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  106308. *
  106309. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  106310. * F90 = metallicReflectanceColor;
  106311. */
  106312. protected _metallicF0Factor: number;
  106313. /**
  106314. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  106315. * By default the F90 is always 1;
  106316. *
  106317. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  106318. *
  106319. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  106320. * F90 = metallicReflectanceColor;
  106321. */
  106322. protected _metallicReflectanceColor: Color3;
  106323. /**
  106324. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  106325. * This is multiply against the scalar values defined in the material.
  106326. */
  106327. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  106328. /**
  106329. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  106330. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  106331. */
  106332. protected _microSurfaceTexture: Nullable<BaseTexture>;
  106333. /**
  106334. * Stores surface normal data used to displace a mesh in a texture.
  106335. */
  106336. protected _bumpTexture: Nullable<BaseTexture>;
  106337. /**
  106338. * Stores the pre-calculated light information of a mesh in a texture.
  106339. */
  106340. protected _lightmapTexture: Nullable<BaseTexture>;
  106341. /**
  106342. * The color of a material in ambient lighting.
  106343. */
  106344. protected _ambientColor: Color3;
  106345. /**
  106346. * AKA Diffuse Color in other nomenclature.
  106347. */
  106348. protected _albedoColor: Color3;
  106349. /**
  106350. * AKA Specular Color in other nomenclature.
  106351. */
  106352. protected _reflectivityColor: Color3;
  106353. /**
  106354. * The color applied when light is reflected from a material.
  106355. */
  106356. protected _reflectionColor: Color3;
  106357. /**
  106358. * The color applied when light is emitted from a material.
  106359. */
  106360. protected _emissiveColor: Color3;
  106361. /**
  106362. * AKA Glossiness in other nomenclature.
  106363. */
  106364. protected _microSurface: number;
  106365. /**
  106366. * Specifies that the material will use the light map as a show map.
  106367. */
  106368. protected _useLightmapAsShadowmap: boolean;
  106369. /**
  106370. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  106371. * makes the reflect vector face the model (under horizon).
  106372. */
  106373. protected _useHorizonOcclusion: boolean;
  106374. /**
  106375. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  106376. * too much the area relying on ambient texture to define their ambient occlusion.
  106377. */
  106378. protected _useRadianceOcclusion: boolean;
  106379. /**
  106380. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  106381. */
  106382. protected _useAlphaFromAlbedoTexture: boolean;
  106383. /**
  106384. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  106385. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  106386. */
  106387. protected _useSpecularOverAlpha: boolean;
  106388. /**
  106389. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  106390. */
  106391. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  106392. /**
  106393. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  106394. */
  106395. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  106396. /**
  106397. * Specifies if the metallic texture contains the roughness information in its green channel.
  106398. */
  106399. protected _useRoughnessFromMetallicTextureGreen: boolean;
  106400. /**
  106401. * Specifies if the metallic texture contains the metallness information in its blue channel.
  106402. */
  106403. protected _useMetallnessFromMetallicTextureBlue: boolean;
  106404. /**
  106405. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  106406. */
  106407. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  106408. /**
  106409. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  106410. */
  106411. protected _useAmbientInGrayScale: boolean;
  106412. /**
  106413. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  106414. * The material will try to infer what glossiness each pixel should be.
  106415. */
  106416. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  106417. /**
  106418. * Defines the falloff type used in this material.
  106419. * It by default is Physical.
  106420. */
  106421. protected _lightFalloff: number;
  106422. /**
  106423. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  106424. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  106425. */
  106426. protected _useRadianceOverAlpha: boolean;
  106427. /**
  106428. * Allows using an object space normal map (instead of tangent space).
  106429. */
  106430. protected _useObjectSpaceNormalMap: boolean;
  106431. /**
  106432. * Allows using the bump map in parallax mode.
  106433. */
  106434. protected _useParallax: boolean;
  106435. /**
  106436. * Allows using the bump map in parallax occlusion mode.
  106437. */
  106438. protected _useParallaxOcclusion: boolean;
  106439. /**
  106440. * Controls the scale bias of the parallax mode.
  106441. */
  106442. protected _parallaxScaleBias: number;
  106443. /**
  106444. * If sets to true, disables all the lights affecting the material.
  106445. */
  106446. protected _disableLighting: boolean;
  106447. /**
  106448. * Number of Simultaneous lights allowed on the material.
  106449. */
  106450. protected _maxSimultaneousLights: number;
  106451. /**
  106452. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  106453. */
  106454. protected _invertNormalMapX: boolean;
  106455. /**
  106456. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  106457. */
  106458. protected _invertNormalMapY: boolean;
  106459. /**
  106460. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  106461. */
  106462. protected _twoSidedLighting: boolean;
  106463. /**
  106464. * Defines the alpha limits in alpha test mode.
  106465. */
  106466. protected _alphaCutOff: number;
  106467. /**
  106468. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  106469. */
  106470. protected _forceAlphaTest: boolean;
  106471. /**
  106472. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  106473. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  106474. */
  106475. protected _useAlphaFresnel: boolean;
  106476. /**
  106477. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  106478. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  106479. */
  106480. protected _useLinearAlphaFresnel: boolean;
  106481. /**
  106482. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  106483. * from cos thetav and roughness:
  106484. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  106485. */
  106486. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  106487. /**
  106488. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  106489. */
  106490. protected _forceIrradianceInFragment: boolean;
  106491. private _realTimeFiltering;
  106492. /**
  106493. * Enables realtime filtering on the texture.
  106494. */
  106495. get realTimeFiltering(): boolean;
  106496. set realTimeFiltering(b: boolean);
  106497. private _realTimeFilteringQuality;
  106498. /**
  106499. * Quality switch for realtime filtering
  106500. */
  106501. get realTimeFilteringQuality(): number;
  106502. set realTimeFilteringQuality(n: number);
  106503. /**
  106504. * Can this material render to several textures at once
  106505. */
  106506. get canRenderToMRT(): boolean;
  106507. /**
  106508. * Force normal to face away from face.
  106509. */
  106510. protected _forceNormalForward: boolean;
  106511. /**
  106512. * Enables specular anti aliasing in the PBR shader.
  106513. * It will both interacts on the Geometry for analytical and IBL lighting.
  106514. * It also prefilter the roughness map based on the bump values.
  106515. */
  106516. protected _enableSpecularAntiAliasing: boolean;
  106517. /**
  106518. * Default configuration related to image processing available in the PBR Material.
  106519. */
  106520. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106521. /**
  106522. * Keep track of the image processing observer to allow dispose and replace.
  106523. */
  106524. private _imageProcessingObserver;
  106525. /**
  106526. * Attaches a new image processing configuration to the PBR Material.
  106527. * @param configuration
  106528. */
  106529. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  106530. /**
  106531. * Stores the available render targets.
  106532. */
  106533. private _renderTargets;
  106534. /**
  106535. * Sets the global ambient color for the material used in lighting calculations.
  106536. */
  106537. private _globalAmbientColor;
  106538. /**
  106539. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  106540. */
  106541. private _useLogarithmicDepth;
  106542. /**
  106543. * If set to true, no lighting calculations will be applied.
  106544. */
  106545. private _unlit;
  106546. private _debugMode;
  106547. /**
  106548. * @hidden
  106549. * This is reserved for the inspector.
  106550. * Defines the material debug mode.
  106551. * It helps seeing only some components of the material while troubleshooting.
  106552. */
  106553. debugMode: number;
  106554. /**
  106555. * @hidden
  106556. * This is reserved for the inspector.
  106557. * Specify from where on screen the debug mode should start.
  106558. * The value goes from -1 (full screen) to 1 (not visible)
  106559. * It helps with side by side comparison against the final render
  106560. * This defaults to -1
  106561. */
  106562. private debugLimit;
  106563. /**
  106564. * @hidden
  106565. * This is reserved for the inspector.
  106566. * As the default viewing range might not be enough (if the ambient is really small for instance)
  106567. * You can use the factor to better multiply the final value.
  106568. */
  106569. private debugFactor;
  106570. /**
  106571. * Defines the clear coat layer parameters for the material.
  106572. */
  106573. readonly clearCoat: PBRClearCoatConfiguration;
  106574. /**
  106575. * Defines the anisotropic parameters for the material.
  106576. */
  106577. readonly anisotropy: PBRAnisotropicConfiguration;
  106578. /**
  106579. * Defines the BRDF parameters for the material.
  106580. */
  106581. readonly brdf: PBRBRDFConfiguration;
  106582. /**
  106583. * Defines the Sheen parameters for the material.
  106584. */
  106585. readonly sheen: PBRSheenConfiguration;
  106586. /**
  106587. * Defines the SubSurface parameters for the material.
  106588. */
  106589. readonly subSurface: PBRSubSurfaceConfiguration;
  106590. /**
  106591. * Defines additionnal PrePass parameters for the material.
  106592. */
  106593. readonly prePassConfiguration: PrePassConfiguration;
  106594. /**
  106595. * Defines the detail map parameters for the material.
  106596. */
  106597. readonly detailMap: DetailMapConfiguration;
  106598. protected _rebuildInParallel: boolean;
  106599. /**
  106600. * Instantiates a new PBRMaterial instance.
  106601. *
  106602. * @param name The material name
  106603. * @param scene The scene the material will be use in.
  106604. */
  106605. constructor(name: string, scene: Scene);
  106606. /**
  106607. * Gets a boolean indicating that current material needs to register RTT
  106608. */
  106609. get hasRenderTargetTextures(): boolean;
  106610. /**
  106611. * Gets the name of the material class.
  106612. */
  106613. getClassName(): string;
  106614. /**
  106615. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  106616. */
  106617. get useLogarithmicDepth(): boolean;
  106618. /**
  106619. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  106620. */
  106621. set useLogarithmicDepth(value: boolean);
  106622. /**
  106623. * Returns true if alpha blending should be disabled.
  106624. */
  106625. protected get _disableAlphaBlending(): boolean;
  106626. /**
  106627. * Specifies whether or not this material should be rendered in alpha blend mode.
  106628. */
  106629. needAlphaBlending(): boolean;
  106630. /**
  106631. * Specifies whether or not this material should be rendered in alpha test mode.
  106632. */
  106633. needAlphaTesting(): boolean;
  106634. /**
  106635. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  106636. */
  106637. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  106638. /**
  106639. * Specifies whether or not there is a usable alpha channel for transparency.
  106640. */
  106641. protected _hasAlphaChannel(): boolean;
  106642. /**
  106643. * Gets the texture used for the alpha test.
  106644. */
  106645. getAlphaTestTexture(): Nullable<BaseTexture>;
  106646. /**
  106647. * Specifies that the submesh is ready to be used.
  106648. * @param mesh - BJS mesh.
  106649. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  106650. * @param useInstances - Specifies that instances should be used.
  106651. * @returns - boolean indicating that the submesh is ready or not.
  106652. */
  106653. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  106654. /**
  106655. * Specifies if the material uses metallic roughness workflow.
  106656. * @returns boolean specifiying if the material uses metallic roughness workflow.
  106657. */
  106658. isMetallicWorkflow(): boolean;
  106659. private _prepareEffect;
  106660. private _prepareDefines;
  106661. /**
  106662. * Force shader compilation
  106663. */
  106664. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  106665. /**
  106666. * Initializes the uniform buffer layout for the shader.
  106667. */
  106668. buildUniformLayout(): void;
  106669. /**
  106670. * Unbinds the material from the mesh
  106671. */
  106672. unbind(): void;
  106673. /**
  106674. * Binds the submesh data.
  106675. * @param world - The world matrix.
  106676. * @param mesh - The BJS mesh.
  106677. * @param subMesh - A submesh of the BJS mesh.
  106678. */
  106679. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  106680. /**
  106681. * Returns the animatable textures.
  106682. * @returns - Array of animatable textures.
  106683. */
  106684. getAnimatables(): IAnimatable[];
  106685. /**
  106686. * Returns the texture used for reflections.
  106687. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  106688. */
  106689. private _getReflectionTexture;
  106690. /**
  106691. * Returns an array of the actively used textures.
  106692. * @returns - Array of BaseTextures
  106693. */
  106694. getActiveTextures(): BaseTexture[];
  106695. /**
  106696. * Checks to see if a texture is used in the material.
  106697. * @param texture - Base texture to use.
  106698. * @returns - Boolean specifying if a texture is used in the material.
  106699. */
  106700. hasTexture(texture: BaseTexture): boolean;
  106701. /**
  106702. * Sets the required values to the prepass renderer.
  106703. * @param prePassRenderer defines the prepass renderer to setup
  106704. */
  106705. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  106706. /**
  106707. * Disposes the resources of the material.
  106708. * @param forceDisposeEffect - Forces the disposal of effects.
  106709. * @param forceDisposeTextures - Forces the disposal of all textures.
  106710. */
  106711. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  106712. }
  106713. }
  106714. declare module BABYLON {
  106715. /**
  106716. * The Physically based material of BJS.
  106717. *
  106718. * This offers the main features of a standard PBR material.
  106719. * For more information, please refer to the documentation :
  106720. * https://doc.babylonjs.com/how_to/physically_based_rendering
  106721. */
  106722. export class PBRMaterial extends PBRBaseMaterial {
  106723. /**
  106724. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  106725. */
  106726. static readonly PBRMATERIAL_OPAQUE: number;
  106727. /**
  106728. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  106729. */
  106730. static readonly PBRMATERIAL_ALPHATEST: number;
  106731. /**
  106732. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  106733. */
  106734. static readonly PBRMATERIAL_ALPHABLEND: number;
  106735. /**
  106736. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  106737. * They are also discarded below the alpha cutoff threshold to improve performances.
  106738. */
  106739. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  106740. /**
  106741. * Defines the default value of how much AO map is occluding the analytical lights
  106742. * (point spot...).
  106743. */
  106744. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  106745. /**
  106746. * Intensity of the direct lights e.g. the four lights available in your scene.
  106747. * This impacts both the direct diffuse and specular highlights.
  106748. */
  106749. directIntensity: number;
  106750. /**
  106751. * Intensity of the emissive part of the material.
  106752. * This helps controlling the emissive effect without modifying the emissive color.
  106753. */
  106754. emissiveIntensity: number;
  106755. /**
  106756. * Intensity of the environment e.g. how much the environment will light the object
  106757. * either through harmonics for rough material or through the refelction for shiny ones.
  106758. */
  106759. environmentIntensity: number;
  106760. /**
  106761. * This is a special control allowing the reduction of the specular highlights coming from the
  106762. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  106763. */
  106764. specularIntensity: number;
  106765. /**
  106766. * Debug Control allowing disabling the bump map on this material.
  106767. */
  106768. disableBumpMap: boolean;
  106769. /**
  106770. * AKA Diffuse Texture in standard nomenclature.
  106771. */
  106772. albedoTexture: BaseTexture;
  106773. /**
  106774. * AKA Occlusion Texture in other nomenclature.
  106775. */
  106776. ambientTexture: BaseTexture;
  106777. /**
  106778. * AKA Occlusion Texture Intensity in other nomenclature.
  106779. */
  106780. ambientTextureStrength: number;
  106781. /**
  106782. * Defines how much the AO map is occluding the analytical lights (point spot...).
  106783. * 1 means it completely occludes it
  106784. * 0 mean it has no impact
  106785. */
  106786. ambientTextureImpactOnAnalyticalLights: number;
  106787. /**
  106788. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  106789. */
  106790. opacityTexture: BaseTexture;
  106791. /**
  106792. * Stores the reflection values in a texture.
  106793. */
  106794. reflectionTexture: Nullable<BaseTexture>;
  106795. /**
  106796. * Stores the emissive values in a texture.
  106797. */
  106798. emissiveTexture: BaseTexture;
  106799. /**
  106800. * AKA Specular texture in other nomenclature.
  106801. */
  106802. reflectivityTexture: BaseTexture;
  106803. /**
  106804. * Used to switch from specular/glossiness to metallic/roughness workflow.
  106805. */
  106806. metallicTexture: BaseTexture;
  106807. /**
  106808. * Specifies the metallic scalar of the metallic/roughness workflow.
  106809. * Can also be used to scale the metalness values of the metallic texture.
  106810. */
  106811. metallic: Nullable<number>;
  106812. /**
  106813. * Specifies the roughness scalar of the metallic/roughness workflow.
  106814. * Can also be used to scale the roughness values of the metallic texture.
  106815. */
  106816. roughness: Nullable<number>;
  106817. /**
  106818. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  106819. * By default the indexOfrefraction is used to compute F0;
  106820. *
  106821. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  106822. *
  106823. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  106824. * F90 = metallicReflectanceColor;
  106825. */
  106826. metallicF0Factor: number;
  106827. /**
  106828. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  106829. * By default the F90 is always 1;
  106830. *
  106831. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  106832. *
  106833. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  106834. * F90 = metallicReflectanceColor;
  106835. */
  106836. metallicReflectanceColor: Color3;
  106837. /**
  106838. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  106839. * This is multiply against the scalar values defined in the material.
  106840. */
  106841. metallicReflectanceTexture: Nullable<BaseTexture>;
  106842. /**
  106843. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  106844. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  106845. */
  106846. microSurfaceTexture: BaseTexture;
  106847. /**
  106848. * Stores surface normal data used to displace a mesh in a texture.
  106849. */
  106850. bumpTexture: BaseTexture;
  106851. /**
  106852. * Stores the pre-calculated light information of a mesh in a texture.
  106853. */
  106854. lightmapTexture: BaseTexture;
  106855. /**
  106856. * Stores the refracted light information in a texture.
  106857. */
  106858. get refractionTexture(): Nullable<BaseTexture>;
  106859. set refractionTexture(value: Nullable<BaseTexture>);
  106860. /**
  106861. * The color of a material in ambient lighting.
  106862. */
  106863. ambientColor: Color3;
  106864. /**
  106865. * AKA Diffuse Color in other nomenclature.
  106866. */
  106867. albedoColor: Color3;
  106868. /**
  106869. * AKA Specular Color in other nomenclature.
  106870. */
  106871. reflectivityColor: Color3;
  106872. /**
  106873. * The color reflected from the material.
  106874. */
  106875. reflectionColor: Color3;
  106876. /**
  106877. * The color emitted from the material.
  106878. */
  106879. emissiveColor: Color3;
  106880. /**
  106881. * AKA Glossiness in other nomenclature.
  106882. */
  106883. microSurface: number;
  106884. /**
  106885. * Index of refraction of the material base layer.
  106886. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  106887. *
  106888. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  106889. *
  106890. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  106891. */
  106892. get indexOfRefraction(): number;
  106893. set indexOfRefraction(value: number);
  106894. /**
  106895. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  106896. */
  106897. get invertRefractionY(): boolean;
  106898. set invertRefractionY(value: boolean);
  106899. /**
  106900. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  106901. * Materials half opaque for instance using refraction could benefit from this control.
  106902. */
  106903. get linkRefractionWithTransparency(): boolean;
  106904. set linkRefractionWithTransparency(value: boolean);
  106905. /**
  106906. * If true, the light map contains occlusion information instead of lighting info.
  106907. */
  106908. useLightmapAsShadowmap: boolean;
  106909. /**
  106910. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  106911. */
  106912. useAlphaFromAlbedoTexture: boolean;
  106913. /**
  106914. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  106915. */
  106916. forceAlphaTest: boolean;
  106917. /**
  106918. * Defines the alpha limits in alpha test mode.
  106919. */
  106920. alphaCutOff: number;
  106921. /**
  106922. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  106923. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  106924. */
  106925. useSpecularOverAlpha: boolean;
  106926. /**
  106927. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  106928. */
  106929. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  106930. /**
  106931. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  106932. */
  106933. useRoughnessFromMetallicTextureAlpha: boolean;
  106934. /**
  106935. * Specifies if the metallic texture contains the roughness information in its green channel.
  106936. */
  106937. useRoughnessFromMetallicTextureGreen: boolean;
  106938. /**
  106939. * Specifies if the metallic texture contains the metallness information in its blue channel.
  106940. */
  106941. useMetallnessFromMetallicTextureBlue: boolean;
  106942. /**
  106943. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  106944. */
  106945. useAmbientOcclusionFromMetallicTextureRed: boolean;
  106946. /**
  106947. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  106948. */
  106949. useAmbientInGrayScale: boolean;
  106950. /**
  106951. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  106952. * The material will try to infer what glossiness each pixel should be.
  106953. */
  106954. useAutoMicroSurfaceFromReflectivityMap: boolean;
  106955. /**
  106956. * BJS is using an harcoded light falloff based on a manually sets up range.
  106957. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  106958. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  106959. */
  106960. get usePhysicalLightFalloff(): boolean;
  106961. /**
  106962. * BJS is using an harcoded light falloff based on a manually sets up range.
  106963. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  106964. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  106965. */
  106966. set usePhysicalLightFalloff(value: boolean);
  106967. /**
  106968. * In order to support the falloff compatibility with gltf, a special mode has been added
  106969. * to reproduce the gltf light falloff.
  106970. */
  106971. get useGLTFLightFalloff(): boolean;
  106972. /**
  106973. * In order to support the falloff compatibility with gltf, a special mode has been added
  106974. * to reproduce the gltf light falloff.
  106975. */
  106976. set useGLTFLightFalloff(value: boolean);
  106977. /**
  106978. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  106979. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  106980. */
  106981. useRadianceOverAlpha: boolean;
  106982. /**
  106983. * Allows using an object space normal map (instead of tangent space).
  106984. */
  106985. useObjectSpaceNormalMap: boolean;
  106986. /**
  106987. * Allows using the bump map in parallax mode.
  106988. */
  106989. useParallax: boolean;
  106990. /**
  106991. * Allows using the bump map in parallax occlusion mode.
  106992. */
  106993. useParallaxOcclusion: boolean;
  106994. /**
  106995. * Controls the scale bias of the parallax mode.
  106996. */
  106997. parallaxScaleBias: number;
  106998. /**
  106999. * If sets to true, disables all the lights affecting the material.
  107000. */
  107001. disableLighting: boolean;
  107002. /**
  107003. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  107004. */
  107005. forceIrradianceInFragment: boolean;
  107006. /**
  107007. * Number of Simultaneous lights allowed on the material.
  107008. */
  107009. maxSimultaneousLights: number;
  107010. /**
  107011. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107012. */
  107013. invertNormalMapX: boolean;
  107014. /**
  107015. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107016. */
  107017. invertNormalMapY: boolean;
  107018. /**
  107019. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107020. */
  107021. twoSidedLighting: boolean;
  107022. /**
  107023. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107024. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  107025. */
  107026. useAlphaFresnel: boolean;
  107027. /**
  107028. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107029. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  107030. */
  107031. useLinearAlphaFresnel: boolean;
  107032. /**
  107033. * Let user defines the brdf lookup texture used for IBL.
  107034. * A default 8bit version is embedded but you could point at :
  107035. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  107036. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  107037. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  107038. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  107039. */
  107040. environmentBRDFTexture: Nullable<BaseTexture>;
  107041. /**
  107042. * Force normal to face away from face.
  107043. */
  107044. forceNormalForward: boolean;
  107045. /**
  107046. * Enables specular anti aliasing in the PBR shader.
  107047. * It will both interacts on the Geometry for analytical and IBL lighting.
  107048. * It also prefilter the roughness map based on the bump values.
  107049. */
  107050. enableSpecularAntiAliasing: boolean;
  107051. /**
  107052. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  107053. * makes the reflect vector face the model (under horizon).
  107054. */
  107055. useHorizonOcclusion: boolean;
  107056. /**
  107057. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  107058. * too much the area relying on ambient texture to define their ambient occlusion.
  107059. */
  107060. useRadianceOcclusion: boolean;
  107061. /**
  107062. * If set to true, no lighting calculations will be applied.
  107063. */
  107064. unlit: boolean;
  107065. /**
  107066. * Gets the image processing configuration used either in this material.
  107067. */
  107068. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  107069. /**
  107070. * Sets the Default image processing configuration used either in the this material.
  107071. *
  107072. * If sets to null, the scene one is in use.
  107073. */
  107074. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  107075. /**
  107076. * Gets wether the color curves effect is enabled.
  107077. */
  107078. get cameraColorCurvesEnabled(): boolean;
  107079. /**
  107080. * Sets wether the color curves effect is enabled.
  107081. */
  107082. set cameraColorCurvesEnabled(value: boolean);
  107083. /**
  107084. * Gets wether the color grading effect is enabled.
  107085. */
  107086. get cameraColorGradingEnabled(): boolean;
  107087. /**
  107088. * Gets wether the color grading effect is enabled.
  107089. */
  107090. set cameraColorGradingEnabled(value: boolean);
  107091. /**
  107092. * Gets wether tonemapping is enabled or not.
  107093. */
  107094. get cameraToneMappingEnabled(): boolean;
  107095. /**
  107096. * Sets wether tonemapping is enabled or not
  107097. */
  107098. set cameraToneMappingEnabled(value: boolean);
  107099. /**
  107100. * The camera exposure used on this material.
  107101. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107102. * This corresponds to a photographic exposure.
  107103. */
  107104. get cameraExposure(): number;
  107105. /**
  107106. * The camera exposure used on this material.
  107107. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107108. * This corresponds to a photographic exposure.
  107109. */
  107110. set cameraExposure(value: number);
  107111. /**
  107112. * Gets The camera contrast used on this material.
  107113. */
  107114. get cameraContrast(): number;
  107115. /**
  107116. * Sets The camera contrast used on this material.
  107117. */
  107118. set cameraContrast(value: number);
  107119. /**
  107120. * Gets the Color Grading 2D Lookup Texture.
  107121. */
  107122. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  107123. /**
  107124. * Sets the Color Grading 2D Lookup Texture.
  107125. */
  107126. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  107127. /**
  107128. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107129. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107130. * 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;
  107131. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107132. */
  107133. get cameraColorCurves(): Nullable<ColorCurves>;
  107134. /**
  107135. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107136. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107137. * 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;
  107138. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107139. */
  107140. set cameraColorCurves(value: Nullable<ColorCurves>);
  107141. /**
  107142. * Instantiates a new PBRMaterial instance.
  107143. *
  107144. * @param name The material name
  107145. * @param scene The scene the material will be use in.
  107146. */
  107147. constructor(name: string, scene: Scene);
  107148. /**
  107149. * Returns the name of this material class.
  107150. */
  107151. getClassName(): string;
  107152. /**
  107153. * Makes a duplicate of the current material.
  107154. * @param name - name to use for the new material.
  107155. */
  107156. clone(name: string): PBRMaterial;
  107157. /**
  107158. * Serializes this PBR Material.
  107159. * @returns - An object with the serialized material.
  107160. */
  107161. serialize(): any;
  107162. /**
  107163. * Parses a PBR Material from a serialized object.
  107164. * @param source - Serialized object.
  107165. * @param scene - BJS scene instance.
  107166. * @param rootUrl - url for the scene object
  107167. * @returns - PBRMaterial
  107168. */
  107169. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  107170. }
  107171. }
  107172. declare module BABYLON {
  107173. /** @hidden */
  107174. export var mrtFragmentDeclaration: {
  107175. name: string;
  107176. shader: string;
  107177. };
  107178. }
  107179. declare module BABYLON {
  107180. /** @hidden */
  107181. export var geometryPixelShader: {
  107182. name: string;
  107183. shader: string;
  107184. };
  107185. }
  107186. declare module BABYLON {
  107187. /** @hidden */
  107188. export var instancesDeclaration: {
  107189. name: string;
  107190. shader: string;
  107191. };
  107192. }
  107193. declare module BABYLON {
  107194. /** @hidden */
  107195. export var geometryVertexShader: {
  107196. name: string;
  107197. shader: string;
  107198. };
  107199. }
  107200. declare module BABYLON {
  107201. /** @hidden */
  107202. interface ISavedTransformationMatrix {
  107203. world: Matrix;
  107204. viewProjection: Matrix;
  107205. }
  107206. /**
  107207. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  107208. */
  107209. export class GeometryBufferRenderer {
  107210. /**
  107211. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  107212. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  107213. */
  107214. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  107215. /**
  107216. * Constant used to retrieve the position texture index in the G-Buffer textures array
  107217. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  107218. */
  107219. static readonly POSITION_TEXTURE_TYPE: number;
  107220. /**
  107221. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  107222. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  107223. */
  107224. static readonly VELOCITY_TEXTURE_TYPE: number;
  107225. /**
  107226. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  107227. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  107228. */
  107229. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  107230. /**
  107231. * Dictionary used to store the previous transformation matrices of each rendered mesh
  107232. * in order to compute objects velocities when enableVelocity is set to "true"
  107233. * @hidden
  107234. */
  107235. _previousTransformationMatrices: {
  107236. [index: number]: ISavedTransformationMatrix;
  107237. };
  107238. /**
  107239. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  107240. * in order to compute objects velocities when enableVelocity is set to "true"
  107241. * @hidden
  107242. */
  107243. _previousBonesTransformationMatrices: {
  107244. [index: number]: Float32Array;
  107245. };
  107246. /**
  107247. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  107248. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  107249. */
  107250. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  107251. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  107252. renderTransparentMeshes: boolean;
  107253. private _scene;
  107254. private _resizeObserver;
  107255. private _multiRenderTarget;
  107256. private _ratio;
  107257. private _enablePosition;
  107258. private _enableVelocity;
  107259. private _enableReflectivity;
  107260. private _positionIndex;
  107261. private _velocityIndex;
  107262. private _reflectivityIndex;
  107263. private _depthNormalIndex;
  107264. private _linkedWithPrePass;
  107265. private _prePassRenderer;
  107266. private _attachments;
  107267. protected _effect: Effect;
  107268. protected _cachedDefines: string;
  107269. /**
  107270. * @hidden
  107271. * Sets up internal structures to share outputs with PrePassRenderer
  107272. * This method should only be called by the PrePassRenderer itself
  107273. */
  107274. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  107275. /**
  107276. * @hidden
  107277. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  107278. * This method should only be called by the PrePassRenderer itself
  107279. */
  107280. _unlinkPrePassRenderer(): void;
  107281. /**
  107282. * @hidden
  107283. * Resets the geometry buffer layout
  107284. */
  107285. _resetLayout(): void;
  107286. /**
  107287. * @hidden
  107288. * Replaces a texture in the geometry buffer renderer
  107289. * Useful when linking textures of the prepass renderer
  107290. */
  107291. _forceTextureType(geometryBufferType: number, index: number): void;
  107292. /**
  107293. * @hidden
  107294. * Sets texture attachments
  107295. * Useful when linking textures of the prepass renderer
  107296. */
  107297. _setAttachments(attachments: number[]): void;
  107298. /**
  107299. * @hidden
  107300. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  107301. * Useful when linking textures of the prepass renderer
  107302. */
  107303. _linkInternalTexture(internalTexture: InternalTexture): void;
  107304. /**
  107305. * Gets the render list (meshes to be rendered) used in the G buffer.
  107306. */
  107307. get renderList(): Nullable<AbstractMesh[]>;
  107308. /**
  107309. * Set the render list (meshes to be rendered) used in the G buffer.
  107310. */
  107311. set renderList(meshes: Nullable<AbstractMesh[]>);
  107312. /**
  107313. * Gets wether or not G buffer are supported by the running hardware.
  107314. * This requires draw buffer supports
  107315. */
  107316. get isSupported(): boolean;
  107317. /**
  107318. * Returns the index of the given texture type in the G-Buffer textures array
  107319. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  107320. * @returns the index of the given texture type in the G-Buffer textures array
  107321. */
  107322. getTextureIndex(textureType: number): number;
  107323. /**
  107324. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  107325. */
  107326. get enablePosition(): boolean;
  107327. /**
  107328. * Sets whether or not objects positions are enabled for the G buffer.
  107329. */
  107330. set enablePosition(enable: boolean);
  107331. /**
  107332. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  107333. */
  107334. get enableVelocity(): boolean;
  107335. /**
  107336. * Sets wether or not objects velocities are enabled for the G buffer.
  107337. */
  107338. set enableVelocity(enable: boolean);
  107339. /**
  107340. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  107341. */
  107342. get enableReflectivity(): boolean;
  107343. /**
  107344. * Sets wether or not objects roughness are enabled for the G buffer.
  107345. */
  107346. set enableReflectivity(enable: boolean);
  107347. /**
  107348. * Gets the scene associated with the buffer.
  107349. */
  107350. get scene(): Scene;
  107351. /**
  107352. * Gets the ratio used by the buffer during its creation.
  107353. * How big is the buffer related to the main canvas.
  107354. */
  107355. get ratio(): number;
  107356. /** @hidden */
  107357. static _SceneComponentInitialization: (scene: Scene) => void;
  107358. /**
  107359. * Creates a new G Buffer for the scene
  107360. * @param scene The scene the buffer belongs to
  107361. * @param ratio How big is the buffer related to the main canvas.
  107362. */
  107363. constructor(scene: Scene, ratio?: number);
  107364. /**
  107365. * Checks wether everything is ready to render a submesh to the G buffer.
  107366. * @param subMesh the submesh to check readiness for
  107367. * @param useInstances is the mesh drawn using instance or not
  107368. * @returns true if ready otherwise false
  107369. */
  107370. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  107371. /**
  107372. * Gets the current underlying G Buffer.
  107373. * @returns the buffer
  107374. */
  107375. getGBuffer(): MultiRenderTarget;
  107376. /**
  107377. * Gets the number of samples used to render the buffer (anti aliasing).
  107378. */
  107379. get samples(): number;
  107380. /**
  107381. * Sets the number of samples used to render the buffer (anti aliasing).
  107382. */
  107383. set samples(value: number);
  107384. /**
  107385. * Disposes the renderer and frees up associated resources.
  107386. */
  107387. dispose(): void;
  107388. private _assignRenderTargetIndices;
  107389. protected _createRenderTargets(): void;
  107390. private _copyBonesTransformationMatrices;
  107391. }
  107392. }
  107393. declare module BABYLON {
  107394. /**
  107395. * Renders a pre pass of the scene
  107396. * This means every mesh in the scene will be rendered to a render target texture
  107397. * And then this texture will be composited to the rendering canvas with post processes
  107398. * It is necessary for effects like subsurface scattering or deferred shading
  107399. */
  107400. export class PrePassRenderer {
  107401. /** @hidden */
  107402. static _SceneComponentInitialization: (scene: Scene) => void;
  107403. private _textureFormats;
  107404. /**
  107405. * To save performance, we can excluded skinned meshes from the prepass
  107406. */
  107407. excludedSkinnedMesh: AbstractMesh[];
  107408. /**
  107409. * Force material to be excluded from the prepass
  107410. * Can be useful when `useGeometryBufferFallback` is set to `true`
  107411. * and you don't want a material to show in the effect.
  107412. */
  107413. excludedMaterials: Material[];
  107414. private _textureIndices;
  107415. private _scene;
  107416. private _engine;
  107417. private _isDirty;
  107418. /**
  107419. * Number of textures in the multi render target texture where the scene is directly rendered
  107420. */
  107421. mrtCount: number;
  107422. /**
  107423. * The render target where the scene is directly rendered
  107424. */
  107425. prePassRT: MultiRenderTarget;
  107426. private _multiRenderAttachments;
  107427. private _defaultAttachments;
  107428. private _postProcesses;
  107429. private readonly _clearColor;
  107430. /**
  107431. * Image processing post process for composition
  107432. */
  107433. imageProcessingPostProcess: ImageProcessingPostProcess;
  107434. /**
  107435. * Configuration for prepass effects
  107436. */
  107437. private _effectConfigurations;
  107438. private _mrtFormats;
  107439. private _mrtLayout;
  107440. private _enabled;
  107441. /**
  107442. * Indicates if the prepass is enabled
  107443. */
  107444. get enabled(): boolean;
  107445. /**
  107446. * How many samples are used for MSAA of the scene render target
  107447. */
  107448. get samples(): number;
  107449. set samples(n: number);
  107450. private _geometryBuffer;
  107451. private _useGeometryBufferFallback;
  107452. /**
  107453. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  107454. */
  107455. get useGeometryBufferFallback(): boolean;
  107456. set useGeometryBufferFallback(value: boolean);
  107457. /**
  107458. * Set to true to disable gamma transform in PrePass.
  107459. * Can be useful in case you already proceed to gamma transform on a material level
  107460. * and your post processes don't need to be in linear color space.
  107461. */
  107462. disableGammaTransform: boolean;
  107463. /**
  107464. * Instanciates a prepass renderer
  107465. * @param scene The scene
  107466. */
  107467. constructor(scene: Scene);
  107468. private _initializeAttachments;
  107469. private _createCompositionEffect;
  107470. /**
  107471. * Indicates if rendering a prepass is supported
  107472. */
  107473. get isSupported(): boolean;
  107474. /**
  107475. * Sets the proper output textures to draw in the engine.
  107476. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  107477. * @param subMesh Submesh on which the effect is applied
  107478. */
  107479. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  107480. /**
  107481. * Restores attachments for single texture draw.
  107482. */
  107483. restoreAttachments(): void;
  107484. /**
  107485. * @hidden
  107486. */
  107487. _beforeCameraDraw(): void;
  107488. /**
  107489. * @hidden
  107490. */
  107491. _afterCameraDraw(): void;
  107492. private _checkRTSize;
  107493. private _bindFrameBuffer;
  107494. /**
  107495. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  107496. */
  107497. clear(): void;
  107498. private _setState;
  107499. private _updateGeometryBufferLayout;
  107500. /**
  107501. * Adds an effect configuration to the prepass.
  107502. * If an effect has already been added, it won't add it twice and will return the configuration
  107503. * already present.
  107504. * @param cfg the effect configuration
  107505. * @return the effect configuration now used by the prepass
  107506. */
  107507. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  107508. /**
  107509. * Returns the index of a texture in the multi render target texture array.
  107510. * @param type Texture type
  107511. * @return The index
  107512. */
  107513. getIndex(type: number): number;
  107514. private _enable;
  107515. private _disable;
  107516. private _resetLayout;
  107517. private _resetPostProcessChain;
  107518. private _bindPostProcessChain;
  107519. /**
  107520. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  107521. */
  107522. markAsDirty(): void;
  107523. /**
  107524. * Enables a texture on the MultiRenderTarget for prepass
  107525. */
  107526. private _enableTextures;
  107527. private _update;
  107528. private _markAllMaterialsAsPrePassDirty;
  107529. /**
  107530. * Disposes the prepass renderer.
  107531. */
  107532. dispose(): void;
  107533. }
  107534. }
  107535. declare module BABYLON {
  107536. /**
  107537. * Size options for a post process
  107538. */
  107539. export type PostProcessOptions = {
  107540. width: number;
  107541. height: number;
  107542. };
  107543. /**
  107544. * PostProcess can be used to apply a shader to a texture after it has been rendered
  107545. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  107546. */
  107547. export class PostProcess {
  107548. /**
  107549. * Gets or sets the unique id of the post process
  107550. */
  107551. uniqueId: number;
  107552. /** Name of the PostProcess. */
  107553. name: string;
  107554. /**
  107555. * Width of the texture to apply the post process on
  107556. */
  107557. width: number;
  107558. /**
  107559. * Height of the texture to apply the post process on
  107560. */
  107561. height: number;
  107562. /**
  107563. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  107564. */
  107565. nodeMaterialSource: Nullable<NodeMaterial>;
  107566. /**
  107567. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  107568. * @hidden
  107569. */
  107570. _outputTexture: Nullable<InternalTexture>;
  107571. /**
  107572. * Sampling mode used by the shader
  107573. * See https://doc.babylonjs.com/classes/3.1/texture
  107574. */
  107575. renderTargetSamplingMode: number;
  107576. /**
  107577. * Clear color to use when screen clearing
  107578. */
  107579. clearColor: Color4;
  107580. /**
  107581. * If the buffer needs to be cleared before applying the post process. (default: true)
  107582. * Should be set to false if shader will overwrite all previous pixels.
  107583. */
  107584. autoClear: boolean;
  107585. /**
  107586. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  107587. */
  107588. alphaMode: number;
  107589. /**
  107590. * Sets the setAlphaBlendConstants of the babylon engine
  107591. */
  107592. alphaConstants: Color4;
  107593. /**
  107594. * Animations to be used for the post processing
  107595. */
  107596. animations: Animation[];
  107597. /**
  107598. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  107599. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  107600. */
  107601. enablePixelPerfectMode: boolean;
  107602. /**
  107603. * Force the postprocess to be applied without taking in account viewport
  107604. */
  107605. forceFullscreenViewport: boolean;
  107606. /**
  107607. * List of inspectable custom properties (used by the Inspector)
  107608. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  107609. */
  107610. inspectableCustomProperties: IInspectable[];
  107611. /**
  107612. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  107613. *
  107614. * | Value | Type | Description |
  107615. * | ----- | ----------------------------------- | ----------- |
  107616. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  107617. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  107618. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  107619. *
  107620. */
  107621. scaleMode: number;
  107622. /**
  107623. * Force textures to be a power of two (default: false)
  107624. */
  107625. alwaysForcePOT: boolean;
  107626. private _samples;
  107627. /**
  107628. * Number of sample textures (default: 1)
  107629. */
  107630. get samples(): number;
  107631. set samples(n: number);
  107632. /**
  107633. * Modify the scale of the post process to be the same as the viewport (default: false)
  107634. */
  107635. adaptScaleToCurrentViewport: boolean;
  107636. private _camera;
  107637. protected _scene: Scene;
  107638. private _engine;
  107639. private _options;
  107640. private _reusable;
  107641. private _textureType;
  107642. private _textureFormat;
  107643. /**
  107644. * Smart array of input and output textures for the post process.
  107645. * @hidden
  107646. */
  107647. _textures: SmartArray<InternalTexture>;
  107648. /**
  107649. * The index in _textures that corresponds to the output texture.
  107650. * @hidden
  107651. */
  107652. _currentRenderTextureInd: number;
  107653. private _effect;
  107654. private _samplers;
  107655. private _fragmentUrl;
  107656. private _vertexUrl;
  107657. private _parameters;
  107658. private _scaleRatio;
  107659. protected _indexParameters: any;
  107660. private _shareOutputWithPostProcess;
  107661. private _texelSize;
  107662. private _forcedOutputTexture;
  107663. /**
  107664. * Prepass configuration in case this post process needs a texture from prepass
  107665. * @hidden
  107666. */
  107667. _prePassEffectConfiguration: PrePassEffectConfiguration;
  107668. /**
  107669. * Returns the fragment url or shader name used in the post process.
  107670. * @returns the fragment url or name in the shader store.
  107671. */
  107672. getEffectName(): string;
  107673. /**
  107674. * An event triggered when the postprocess is activated.
  107675. */
  107676. onActivateObservable: Observable<Camera>;
  107677. private _onActivateObserver;
  107678. /**
  107679. * A function that is added to the onActivateObservable
  107680. */
  107681. set onActivate(callback: Nullable<(camera: Camera) => void>);
  107682. /**
  107683. * An event triggered when the postprocess changes its size.
  107684. */
  107685. onSizeChangedObservable: Observable<PostProcess>;
  107686. private _onSizeChangedObserver;
  107687. /**
  107688. * A function that is added to the onSizeChangedObservable
  107689. */
  107690. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  107691. /**
  107692. * An event triggered when the postprocess applies its effect.
  107693. */
  107694. onApplyObservable: Observable<Effect>;
  107695. private _onApplyObserver;
  107696. /**
  107697. * A function that is added to the onApplyObservable
  107698. */
  107699. set onApply(callback: (effect: Effect) => void);
  107700. /**
  107701. * An event triggered before rendering the postprocess
  107702. */
  107703. onBeforeRenderObservable: Observable<Effect>;
  107704. private _onBeforeRenderObserver;
  107705. /**
  107706. * A function that is added to the onBeforeRenderObservable
  107707. */
  107708. set onBeforeRender(callback: (effect: Effect) => void);
  107709. /**
  107710. * An event triggered after rendering the postprocess
  107711. */
  107712. onAfterRenderObservable: Observable<Effect>;
  107713. private _onAfterRenderObserver;
  107714. /**
  107715. * A function that is added to the onAfterRenderObservable
  107716. */
  107717. set onAfterRender(callback: (efect: Effect) => void);
  107718. /**
  107719. * 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
  107720. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  107721. */
  107722. get inputTexture(): InternalTexture;
  107723. set inputTexture(value: InternalTexture);
  107724. /**
  107725. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  107726. * the only way to unset it is to use this function to restore its internal state
  107727. */
  107728. restoreDefaultInputTexture(): void;
  107729. /**
  107730. * Gets the camera which post process is applied to.
  107731. * @returns The camera the post process is applied to.
  107732. */
  107733. getCamera(): Camera;
  107734. /**
  107735. * Gets the texel size of the postprocess.
  107736. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  107737. */
  107738. get texelSize(): Vector2;
  107739. /**
  107740. * Creates a new instance PostProcess
  107741. * @param name The name of the PostProcess.
  107742. * @param fragmentUrl The url of the fragment shader to be used.
  107743. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  107744. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  107745. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  107746. * @param camera The camera to apply the render pass to.
  107747. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107748. * @param engine The engine which the post process will be applied. (default: current engine)
  107749. * @param reusable If the post process can be reused on the same frame. (default: false)
  107750. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  107751. * @param textureType Type of textures used when performing the post process. (default: 0)
  107752. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  107753. * @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
  107754. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  107755. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  107756. */
  107757. 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);
  107758. /**
  107759. * Gets a string identifying the name of the class
  107760. * @returns "PostProcess" string
  107761. */
  107762. getClassName(): string;
  107763. /**
  107764. * Gets the engine which this post process belongs to.
  107765. * @returns The engine the post process was enabled with.
  107766. */
  107767. getEngine(): Engine;
  107768. /**
  107769. * The effect that is created when initializing the post process.
  107770. * @returns The created effect corresponding the the postprocess.
  107771. */
  107772. getEffect(): Effect;
  107773. /**
  107774. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  107775. * @param postProcess The post process to share the output with.
  107776. * @returns This post process.
  107777. */
  107778. shareOutputWith(postProcess: PostProcess): PostProcess;
  107779. /**
  107780. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  107781. * This should be called if the post process that shares output with this post process is disabled/disposed.
  107782. */
  107783. useOwnOutput(): void;
  107784. /**
  107785. * Updates the effect with the current post process compile time values and recompiles the shader.
  107786. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  107787. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  107788. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  107789. * @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
  107790. * @param onCompiled Called when the shader has been compiled.
  107791. * @param onError Called if there is an error when compiling a shader.
  107792. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  107793. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  107794. */
  107795. 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;
  107796. /**
  107797. * The post process is reusable if it can be used multiple times within one frame.
  107798. * @returns If the post process is reusable
  107799. */
  107800. isReusable(): boolean;
  107801. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  107802. markTextureDirty(): void;
  107803. /**
  107804. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  107805. * 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.
  107806. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  107807. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  107808. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  107809. * @returns The target texture that was bound to be written to.
  107810. */
  107811. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  107812. /**
  107813. * If the post process is supported.
  107814. */
  107815. get isSupported(): boolean;
  107816. /**
  107817. * The aspect ratio of the output texture.
  107818. */
  107819. get aspectRatio(): number;
  107820. /**
  107821. * Get a value indicating if the post-process is ready to be used
  107822. * @returns true if the post-process is ready (shader is compiled)
  107823. */
  107824. isReady(): boolean;
  107825. /**
  107826. * Binds all textures and uniforms to the shader, this will be run on every pass.
  107827. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  107828. */
  107829. apply(): Nullable<Effect>;
  107830. private _disposeTextures;
  107831. /**
  107832. * Sets the required values to the prepass renderer.
  107833. * @param prePassRenderer defines the prepass renderer to setup.
  107834. * @returns true if the pre pass is needed.
  107835. */
  107836. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  107837. /**
  107838. * Disposes the post process.
  107839. * @param camera The camera to dispose the post process on.
  107840. */
  107841. dispose(camera?: Camera): void;
  107842. /**
  107843. * Serializes the particle system to a JSON object
  107844. * @returns the JSON object
  107845. */
  107846. serialize(): any;
  107847. /**
  107848. * Creates a material from parsed material data
  107849. * @param parsedPostProcess defines parsed post process data
  107850. * @param scene defines the hosting scene
  107851. * @param rootUrl defines the root URL to use to load textures
  107852. * @returns a new post process
  107853. */
  107854. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  107855. }
  107856. }
  107857. declare module BABYLON {
  107858. /** @hidden */
  107859. export var kernelBlurVaryingDeclaration: {
  107860. name: string;
  107861. shader: string;
  107862. };
  107863. }
  107864. declare module BABYLON {
  107865. /** @hidden */
  107866. export var packingFunctions: {
  107867. name: string;
  107868. shader: string;
  107869. };
  107870. }
  107871. declare module BABYLON {
  107872. /** @hidden */
  107873. export var kernelBlurFragment: {
  107874. name: string;
  107875. shader: string;
  107876. };
  107877. }
  107878. declare module BABYLON {
  107879. /** @hidden */
  107880. export var kernelBlurFragment2: {
  107881. name: string;
  107882. shader: string;
  107883. };
  107884. }
  107885. declare module BABYLON {
  107886. /** @hidden */
  107887. export var kernelBlurPixelShader: {
  107888. name: string;
  107889. shader: string;
  107890. };
  107891. }
  107892. declare module BABYLON {
  107893. /** @hidden */
  107894. export var kernelBlurVertex: {
  107895. name: string;
  107896. shader: string;
  107897. };
  107898. }
  107899. declare module BABYLON {
  107900. /** @hidden */
  107901. export var kernelBlurVertexShader: {
  107902. name: string;
  107903. shader: string;
  107904. };
  107905. }
  107906. declare module BABYLON {
  107907. /**
  107908. * The Blur Post Process which blurs an image based on a kernel and direction.
  107909. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  107910. */
  107911. export class BlurPostProcess extends PostProcess {
  107912. private blockCompilation;
  107913. protected _kernel: number;
  107914. protected _idealKernel: number;
  107915. protected _packedFloat: boolean;
  107916. private _staticDefines;
  107917. /** The direction in which to blur the image. */
  107918. direction: Vector2;
  107919. /**
  107920. * Sets the length in pixels of the blur sample region
  107921. */
  107922. set kernel(v: number);
  107923. /**
  107924. * Gets the length in pixels of the blur sample region
  107925. */
  107926. get kernel(): number;
  107927. /**
  107928. * Sets wether or not the blur needs to unpack/repack floats
  107929. */
  107930. set packedFloat(v: boolean);
  107931. /**
  107932. * Gets wether or not the blur is unpacking/repacking floats
  107933. */
  107934. get packedFloat(): boolean;
  107935. /**
  107936. * Gets a string identifying the name of the class
  107937. * @returns "BlurPostProcess" string
  107938. */
  107939. getClassName(): string;
  107940. /**
  107941. * Creates a new instance BlurPostProcess
  107942. * @param name The name of the effect.
  107943. * @param direction The direction in which to blur the image.
  107944. * @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.
  107945. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  107946. * @param camera The camera to apply the render pass to.
  107947. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107948. * @param engine The engine which the post process will be applied. (default: current engine)
  107949. * @param reusable If the post process can be reused on the same frame. (default: false)
  107950. * @param textureType Type of textures used when performing the post process. (default: 0)
  107951. * @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)
  107952. */
  107953. 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);
  107954. /**
  107955. * Updates the effect with the current post process compile time values and recompiles the shader.
  107956. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  107957. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  107958. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  107959. * @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
  107960. * @param onCompiled Called when the shader has been compiled.
  107961. * @param onError Called if there is an error when compiling a shader.
  107962. */
  107963. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  107964. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  107965. /**
  107966. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  107967. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  107968. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  107969. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  107970. * The gaps between physical kernels are compensated for in the weighting of the samples
  107971. * @param idealKernel Ideal blur kernel.
  107972. * @return Nearest best kernel.
  107973. */
  107974. protected _nearestBestKernel(idealKernel: number): number;
  107975. /**
  107976. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  107977. * @param x The point on the Gaussian distribution to sample.
  107978. * @return the value of the Gaussian function at x.
  107979. */
  107980. protected _gaussianWeight(x: number): number;
  107981. /**
  107982. * Generates a string that can be used as a floating point number in GLSL.
  107983. * @param x Value to print.
  107984. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  107985. * @return GLSL float string.
  107986. */
  107987. protected _glslFloat(x: number, decimalFigures?: number): string;
  107988. /** @hidden */
  107989. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  107990. }
  107991. }
  107992. declare module BABYLON {
  107993. /**
  107994. * Mirror texture can be used to simulate the view from a mirror in a scene.
  107995. * It will dynamically be rendered every frame to adapt to the camera point of view.
  107996. * You can then easily use it as a reflectionTexture on a flat surface.
  107997. * In case the surface is not a plane, please consider relying on reflection probes.
  107998. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  107999. */
  108000. export class MirrorTexture extends RenderTargetTexture {
  108001. private scene;
  108002. /**
  108003. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  108004. * 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.
  108005. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  108006. */
  108007. mirrorPlane: Plane;
  108008. /**
  108009. * Define the blur ratio used to blur the reflection if needed.
  108010. */
  108011. set blurRatio(value: number);
  108012. get blurRatio(): number;
  108013. /**
  108014. * Define the adaptive blur kernel used to blur the reflection if needed.
  108015. * This will autocompute the closest best match for the `blurKernel`
  108016. */
  108017. set adaptiveBlurKernel(value: number);
  108018. /**
  108019. * Define the blur kernel used to blur the reflection if needed.
  108020. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  108021. */
  108022. set blurKernel(value: number);
  108023. /**
  108024. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  108025. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  108026. */
  108027. set blurKernelX(value: number);
  108028. get blurKernelX(): number;
  108029. /**
  108030. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  108031. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  108032. */
  108033. set blurKernelY(value: number);
  108034. get blurKernelY(): number;
  108035. private _autoComputeBlurKernel;
  108036. protected _onRatioRescale(): void;
  108037. private _updateGammaSpace;
  108038. private _imageProcessingConfigChangeObserver;
  108039. private _transformMatrix;
  108040. private _mirrorMatrix;
  108041. private _savedViewMatrix;
  108042. private _blurX;
  108043. private _blurY;
  108044. private _adaptiveBlurKernel;
  108045. private _blurKernelX;
  108046. private _blurKernelY;
  108047. private _blurRatio;
  108048. /**
  108049. * Instantiates a Mirror Texture.
  108050. * Mirror texture can be used to simulate the view from a mirror in a scene.
  108051. * It will dynamically be rendered every frame to adapt to the camera point of view.
  108052. * You can then easily use it as a reflectionTexture on a flat surface.
  108053. * In case the surface is not a plane, please consider relying on reflection probes.
  108054. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  108055. * @param name
  108056. * @param size
  108057. * @param scene
  108058. * @param generateMipMaps
  108059. * @param type
  108060. * @param samplingMode
  108061. * @param generateDepthBuffer
  108062. */
  108063. constructor(name: string, size: number | {
  108064. width: number;
  108065. height: number;
  108066. } | {
  108067. ratio: number;
  108068. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  108069. private _preparePostProcesses;
  108070. /**
  108071. * Clone the mirror texture.
  108072. * @returns the cloned texture
  108073. */
  108074. clone(): MirrorTexture;
  108075. /**
  108076. * Serialize the texture to a JSON representation you could use in Parse later on
  108077. * @returns the serialized JSON representation
  108078. */
  108079. serialize(): any;
  108080. /**
  108081. * Dispose the texture and release its associated resources.
  108082. */
  108083. dispose(): void;
  108084. }
  108085. }
  108086. declare module BABYLON {
  108087. /**
  108088. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  108089. * @see https://doc.babylonjs.com/babylon101/materials#texture
  108090. */
  108091. export class Texture extends BaseTexture {
  108092. /**
  108093. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  108094. */
  108095. static SerializeBuffers: boolean;
  108096. /**
  108097. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  108098. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  108099. */
  108100. static ForceSerializeBuffers: boolean;
  108101. /** @hidden */
  108102. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  108103. /** @hidden */
  108104. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  108105. /** @hidden */
  108106. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  108107. /** nearest is mag = nearest and min = nearest and mip = linear */
  108108. static readonly NEAREST_SAMPLINGMODE: number;
  108109. /** nearest is mag = nearest and min = nearest and mip = linear */
  108110. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  108111. /** Bilinear is mag = linear and min = linear and mip = nearest */
  108112. static readonly BILINEAR_SAMPLINGMODE: number;
  108113. /** Bilinear is mag = linear and min = linear and mip = nearest */
  108114. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  108115. /** Trilinear is mag = linear and min = linear and mip = linear */
  108116. static readonly TRILINEAR_SAMPLINGMODE: number;
  108117. /** Trilinear is mag = linear and min = linear and mip = linear */
  108118. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  108119. /** mag = nearest and min = nearest and mip = nearest */
  108120. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  108121. /** mag = nearest and min = linear and mip = nearest */
  108122. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  108123. /** mag = nearest and min = linear and mip = linear */
  108124. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  108125. /** mag = nearest and min = linear and mip = none */
  108126. static readonly NEAREST_LINEAR: number;
  108127. /** mag = nearest and min = nearest and mip = none */
  108128. static readonly NEAREST_NEAREST: number;
  108129. /** mag = linear and min = nearest and mip = nearest */
  108130. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  108131. /** mag = linear and min = nearest and mip = linear */
  108132. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  108133. /** mag = linear and min = linear and mip = none */
  108134. static readonly LINEAR_LINEAR: number;
  108135. /** mag = linear and min = nearest and mip = none */
  108136. static readonly LINEAR_NEAREST: number;
  108137. /** Explicit coordinates mode */
  108138. static readonly EXPLICIT_MODE: number;
  108139. /** Spherical coordinates mode */
  108140. static readonly SPHERICAL_MODE: number;
  108141. /** Planar coordinates mode */
  108142. static readonly PLANAR_MODE: number;
  108143. /** Cubic coordinates mode */
  108144. static readonly CUBIC_MODE: number;
  108145. /** Projection coordinates mode */
  108146. static readonly PROJECTION_MODE: number;
  108147. /** Inverse Cubic coordinates mode */
  108148. static readonly SKYBOX_MODE: number;
  108149. /** Inverse Cubic coordinates mode */
  108150. static readonly INVCUBIC_MODE: number;
  108151. /** Equirectangular coordinates mode */
  108152. static readonly EQUIRECTANGULAR_MODE: number;
  108153. /** Equirectangular Fixed coordinates mode */
  108154. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  108155. /** Equirectangular Fixed Mirrored coordinates mode */
  108156. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  108157. /** Texture is not repeating outside of 0..1 UVs */
  108158. static readonly CLAMP_ADDRESSMODE: number;
  108159. /** Texture is repeating outside of 0..1 UVs */
  108160. static readonly WRAP_ADDRESSMODE: number;
  108161. /** Texture is repeating and mirrored */
  108162. static readonly MIRROR_ADDRESSMODE: number;
  108163. /**
  108164. * 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
  108165. */
  108166. static UseSerializedUrlIfAny: boolean;
  108167. /**
  108168. * Define the url of the texture.
  108169. */
  108170. url: Nullable<string>;
  108171. /**
  108172. * Define an offset on the texture to offset the u coordinates of the UVs
  108173. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  108174. */
  108175. uOffset: number;
  108176. /**
  108177. * Define an offset on the texture to offset the v coordinates of the UVs
  108178. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  108179. */
  108180. vOffset: number;
  108181. /**
  108182. * Define an offset on the texture to scale the u coordinates of the UVs
  108183. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  108184. */
  108185. uScale: number;
  108186. /**
  108187. * Define an offset on the texture to scale the v coordinates of the UVs
  108188. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  108189. */
  108190. vScale: number;
  108191. /**
  108192. * Define an offset on the texture to rotate around the u coordinates of the UVs
  108193. * @see https://doc.babylonjs.com/how_to/more_materials
  108194. */
  108195. uAng: number;
  108196. /**
  108197. * Define an offset on the texture to rotate around the v coordinates of the UVs
  108198. * @see https://doc.babylonjs.com/how_to/more_materials
  108199. */
  108200. vAng: number;
  108201. /**
  108202. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  108203. * @see https://doc.babylonjs.com/how_to/more_materials
  108204. */
  108205. wAng: number;
  108206. /**
  108207. * Defines the center of rotation (U)
  108208. */
  108209. uRotationCenter: number;
  108210. /**
  108211. * Defines the center of rotation (V)
  108212. */
  108213. vRotationCenter: number;
  108214. /**
  108215. * Defines the center of rotation (W)
  108216. */
  108217. wRotationCenter: number;
  108218. /**
  108219. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  108220. */
  108221. homogeneousRotationInUVTransform: boolean;
  108222. /**
  108223. * Are mip maps generated for this texture or not.
  108224. */
  108225. get noMipmap(): boolean;
  108226. /**
  108227. * List of inspectable custom properties (used by the Inspector)
  108228. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  108229. */
  108230. inspectableCustomProperties: Nullable<IInspectable[]>;
  108231. private _noMipmap;
  108232. /** @hidden */
  108233. _invertY: boolean;
  108234. private _rowGenerationMatrix;
  108235. private _cachedTextureMatrix;
  108236. private _projectionModeMatrix;
  108237. private _t0;
  108238. private _t1;
  108239. private _t2;
  108240. private _cachedUOffset;
  108241. private _cachedVOffset;
  108242. private _cachedUScale;
  108243. private _cachedVScale;
  108244. private _cachedUAng;
  108245. private _cachedVAng;
  108246. private _cachedWAng;
  108247. private _cachedProjectionMatrixId;
  108248. private _cachedURotationCenter;
  108249. private _cachedVRotationCenter;
  108250. private _cachedWRotationCenter;
  108251. private _cachedHomogeneousRotationInUVTransform;
  108252. private _cachedCoordinatesMode;
  108253. /** @hidden */
  108254. protected _initialSamplingMode: number;
  108255. /** @hidden */
  108256. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  108257. private _deleteBuffer;
  108258. protected _format: Nullable<number>;
  108259. private _delayedOnLoad;
  108260. private _delayedOnError;
  108261. private _mimeType?;
  108262. private _loaderOptions?;
  108263. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  108264. get mimeType(): string | undefined;
  108265. /**
  108266. * Observable triggered once the texture has been loaded.
  108267. */
  108268. onLoadObservable: Observable<Texture>;
  108269. protected _isBlocking: boolean;
  108270. /**
  108271. * Is the texture preventing material to render while loading.
  108272. * If false, a default texture will be used instead of the loading one during the preparation step.
  108273. */
  108274. set isBlocking(value: boolean);
  108275. get isBlocking(): boolean;
  108276. /**
  108277. * Get the current sampling mode associated with the texture.
  108278. */
  108279. get samplingMode(): number;
  108280. /**
  108281. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  108282. */
  108283. get invertY(): boolean;
  108284. /**
  108285. * Instantiates a new texture.
  108286. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  108287. * @see https://doc.babylonjs.com/babylon101/materials#texture
  108288. * @param url defines the url of the picture to load as a texture
  108289. * @param sceneOrEngine defines the scene or engine the texture will belong to
  108290. * @param noMipmap defines if the texture will require mip maps or not
  108291. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  108292. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  108293. * @param onLoad defines a callback triggered when the texture has been loaded
  108294. * @param onError defines a callback triggered when an error occurred during the loading session
  108295. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  108296. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  108297. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  108298. * @param mimeType defines an optional mime type information
  108299. * @param loaderOptions options to be passed to the loader
  108300. */
  108301. 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);
  108302. /**
  108303. * Update the url (and optional buffer) of this texture if url was null during construction.
  108304. * @param url the url of the texture
  108305. * @param buffer the buffer of the texture (defaults to null)
  108306. * @param onLoad callback called when the texture is loaded (defaults to null)
  108307. */
  108308. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  108309. /**
  108310. * Finish the loading sequence of a texture flagged as delayed load.
  108311. * @hidden
  108312. */
  108313. delayLoad(): void;
  108314. private _prepareRowForTextureGeneration;
  108315. /**
  108316. * Checks if the texture has the same transform matrix than another texture
  108317. * @param texture texture to check against
  108318. * @returns true if the transforms are the same, else false
  108319. */
  108320. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  108321. /**
  108322. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  108323. * @returns the transform matrix of the texture.
  108324. */
  108325. getTextureMatrix(uBase?: number): Matrix;
  108326. /**
  108327. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  108328. * @returns The reflection texture transform
  108329. */
  108330. getReflectionTextureMatrix(): Matrix;
  108331. /**
  108332. * Clones the texture.
  108333. * @returns the cloned texture
  108334. */
  108335. clone(): Texture;
  108336. /**
  108337. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  108338. * @returns The JSON representation of the texture
  108339. */
  108340. serialize(): any;
  108341. /**
  108342. * Get the current class name of the texture useful for serialization or dynamic coding.
  108343. * @returns "Texture"
  108344. */
  108345. getClassName(): string;
  108346. /**
  108347. * Dispose the texture and release its associated resources.
  108348. */
  108349. dispose(): void;
  108350. /**
  108351. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  108352. * @param parsedTexture Define the JSON representation of the texture
  108353. * @param scene Define the scene the parsed texture should be instantiated in
  108354. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  108355. * @returns The parsed texture if successful
  108356. */
  108357. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  108358. /**
  108359. * Creates a texture from its base 64 representation.
  108360. * @param data Define the base64 payload without the data: prefix
  108361. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  108362. * @param scene Define the scene the texture should belong to
  108363. * @param noMipmap Forces the texture to not create mip map information if true
  108364. * @param invertY define if the texture needs to be inverted on the y axis during loading
  108365. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  108366. * @param onLoad define a callback triggered when the texture has been loaded
  108367. * @param onError define a callback triggered when an error occurred during the loading session
  108368. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  108369. * @returns the created texture
  108370. */
  108371. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  108372. /**
  108373. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  108374. * @param data Define the base64 payload without the data: prefix
  108375. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  108376. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  108377. * @param scene Define the scene the texture should belong to
  108378. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  108379. * @param noMipmap Forces the texture to not create mip map information if true
  108380. * @param invertY define if the texture needs to be inverted on the y axis during loading
  108381. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  108382. * @param onLoad define a callback triggered when the texture has been loaded
  108383. * @param onError define a callback triggered when an error occurred during the loading session
  108384. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  108385. * @returns the created texture
  108386. */
  108387. 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;
  108388. }
  108389. }
  108390. declare module BABYLON {
  108391. /**
  108392. * ThinSprite Class used to represent a thin sprite
  108393. * This is the base class for sprites but can also directly be used with ThinEngine
  108394. * @see https://doc.babylonjs.com/babylon101/sprites
  108395. */
  108396. export class ThinSprite {
  108397. /** Gets or sets the cell index in the sprite sheet */
  108398. cellIndex: number;
  108399. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  108400. cellRef: string;
  108401. /** Gets or sets the current world position */
  108402. position: IVector3Like;
  108403. /** Gets or sets the main color */
  108404. color: IColor4Like;
  108405. /** Gets or sets the width */
  108406. width: number;
  108407. /** Gets or sets the height */
  108408. height: number;
  108409. /** Gets or sets rotation angle */
  108410. angle: number;
  108411. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  108412. invertU: boolean;
  108413. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  108414. invertV: boolean;
  108415. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  108416. isVisible: boolean;
  108417. /**
  108418. * Returns a boolean indicating if the animation is started
  108419. */
  108420. get animationStarted(): boolean;
  108421. /** Gets the initial key for the animation (setting it will restart the animation) */
  108422. get fromIndex(): number;
  108423. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  108424. get toIndex(): number;
  108425. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  108426. get loopAnimation(): boolean;
  108427. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  108428. get delay(): number;
  108429. /** @hidden */
  108430. _xOffset: number;
  108431. /** @hidden */
  108432. _yOffset: number;
  108433. /** @hidden */
  108434. _xSize: number;
  108435. /** @hidden */
  108436. _ySize: number;
  108437. private _animationStarted;
  108438. protected _loopAnimation: boolean;
  108439. protected _fromIndex: number;
  108440. protected _toIndex: number;
  108441. protected _delay: number;
  108442. private _direction;
  108443. private _time;
  108444. private _onBaseAnimationEnd;
  108445. /**
  108446. * Creates a new Thin Sprite
  108447. */
  108448. constructor();
  108449. /**
  108450. * Starts an animation
  108451. * @param from defines the initial key
  108452. * @param to defines the end key
  108453. * @param loop defines if the animation must loop
  108454. * @param delay defines the start delay (in ms)
  108455. * @param onAnimationEnd defines a callback for when the animation ends
  108456. */
  108457. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  108458. /** Stops current animation (if any) */
  108459. stopAnimation(): void;
  108460. /** @hidden */
  108461. _animate(deltaTime: number): void;
  108462. }
  108463. }
  108464. declare module BABYLON {
  108465. /** @hidden */
  108466. export var imageProcessingCompatibility: {
  108467. name: string;
  108468. shader: string;
  108469. };
  108470. }
  108471. declare module BABYLON {
  108472. /** @hidden */
  108473. export var spritesPixelShader: {
  108474. name: string;
  108475. shader: string;
  108476. };
  108477. }
  108478. declare module BABYLON {
  108479. /** @hidden */
  108480. export var spritesVertexShader: {
  108481. name: string;
  108482. shader: string;
  108483. };
  108484. }
  108485. declare module BABYLON {
  108486. /**
  108487. * Class used to render sprites.
  108488. *
  108489. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  108490. */
  108491. export class SpriteRenderer {
  108492. /**
  108493. * Defines the texture of the spritesheet
  108494. */
  108495. texture: Nullable<ThinTexture>;
  108496. /**
  108497. * Defines the default width of a cell in the spritesheet
  108498. */
  108499. cellWidth: number;
  108500. /**
  108501. * Defines the default height of a cell in the spritesheet
  108502. */
  108503. cellHeight: number;
  108504. /**
  108505. * Blend mode use to render the particle, it can be any of
  108506. * the static Constants.ALPHA_x properties provided in this class.
  108507. * Default value is Constants.ALPHA_COMBINE
  108508. */
  108509. blendMode: number;
  108510. /**
  108511. * Gets or sets a boolean indicating if alpha mode is automatically
  108512. * reset.
  108513. */
  108514. autoResetAlpha: boolean;
  108515. /**
  108516. * Disables writing to the depth buffer when rendering the sprites.
  108517. * It can be handy to disable depth writing when using textures without alpha channel
  108518. * and setting some specific blend modes.
  108519. */
  108520. disableDepthWrite: boolean;
  108521. /**
  108522. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  108523. */
  108524. fogEnabled: boolean;
  108525. /**
  108526. * Gets the capacity of the manager
  108527. */
  108528. get capacity(): number;
  108529. private readonly _engine;
  108530. private readonly _useVAO;
  108531. private readonly _useInstancing;
  108532. private readonly _scene;
  108533. private readonly _capacity;
  108534. private readonly _epsilon;
  108535. private _vertexBufferSize;
  108536. private _vertexData;
  108537. private _buffer;
  108538. private _vertexBuffers;
  108539. private _spriteBuffer;
  108540. private _indexBuffer;
  108541. private _effectBase;
  108542. private _effectFog;
  108543. private _vertexArrayObject;
  108544. /**
  108545. * Creates a new sprite Renderer
  108546. * @param engine defines the engine the renderer works with
  108547. * @param capacity defines the maximum allowed number of sprites
  108548. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  108549. * @param scene defines the hosting scene
  108550. */
  108551. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  108552. /**
  108553. * Render all child sprites
  108554. * @param sprites defines the list of sprites to render
  108555. * @param deltaTime defines the time since last frame
  108556. * @param viewMatrix defines the viewMatrix to use to render the sprites
  108557. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  108558. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  108559. */
  108560. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  108561. private _appendSpriteVertex;
  108562. /**
  108563. * Release associated resources
  108564. */
  108565. dispose(): void;
  108566. }
  108567. }
  108568. declare module BABYLON {
  108569. /**
  108570. * Defines the minimum interface to fullfil in order to be a sprite manager.
  108571. */
  108572. export interface ISpriteManager extends IDisposable {
  108573. /**
  108574. * Gets manager's name
  108575. */
  108576. name: string;
  108577. /**
  108578. * Restricts the camera to viewing objects with the same layerMask.
  108579. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  108580. */
  108581. layerMask: number;
  108582. /**
  108583. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  108584. */
  108585. isPickable: boolean;
  108586. /**
  108587. * Gets the hosting scene
  108588. */
  108589. scene: Scene;
  108590. /**
  108591. * Specifies the rendering group id for this mesh (0 by default)
  108592. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  108593. */
  108594. renderingGroupId: number;
  108595. /**
  108596. * Defines the list of sprites managed by the manager.
  108597. */
  108598. sprites: Array<Sprite>;
  108599. /**
  108600. * Gets or sets the spritesheet texture
  108601. */
  108602. texture: Texture;
  108603. /** Defines the default width of a cell in the spritesheet */
  108604. cellWidth: number;
  108605. /** Defines the default height of a cell in the spritesheet */
  108606. cellHeight: number;
  108607. /**
  108608. * Tests the intersection of a sprite with a specific ray.
  108609. * @param ray The ray we are sending to test the collision
  108610. * @param camera The camera space we are sending rays in
  108611. * @param predicate A predicate allowing excluding sprites from the list of object to test
  108612. * @param fastCheck defines if the first intersection will be used (and not the closest)
  108613. * @returns picking info or null.
  108614. */
  108615. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  108616. /**
  108617. * Intersects the sprites with a ray
  108618. * @param ray defines the ray to intersect with
  108619. * @param camera defines the current active camera
  108620. * @param predicate defines a predicate used to select candidate sprites
  108621. * @returns null if no hit or a PickingInfo array
  108622. */
  108623. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  108624. /**
  108625. * Renders the list of sprites on screen.
  108626. */
  108627. render(): void;
  108628. }
  108629. /**
  108630. * Class used to manage multiple sprites on the same spritesheet
  108631. * @see https://doc.babylonjs.com/babylon101/sprites
  108632. */
  108633. export class SpriteManager implements ISpriteManager {
  108634. /** defines the manager's name */
  108635. name: string;
  108636. /** Define the Url to load snippets */
  108637. static SnippetUrl: string;
  108638. /** Snippet ID if the manager was created from the snippet server */
  108639. snippetId: string;
  108640. /** Gets the list of sprites */
  108641. sprites: Sprite[];
  108642. /** Gets or sets the rendering group id (0 by default) */
  108643. renderingGroupId: number;
  108644. /** Gets or sets camera layer mask */
  108645. layerMask: number;
  108646. /** Gets or sets a boolean indicating if the sprites are pickable */
  108647. isPickable: boolean;
  108648. /**
  108649. * An event triggered when the manager is disposed.
  108650. */
  108651. onDisposeObservable: Observable<SpriteManager>;
  108652. /**
  108653. * Callback called when the manager is disposed
  108654. */
  108655. set onDispose(callback: () => void);
  108656. /**
  108657. * Gets or sets the unique id of the sprite
  108658. */
  108659. uniqueId: number;
  108660. /**
  108661. * Gets the array of sprites
  108662. */
  108663. get children(): Sprite[];
  108664. /**
  108665. * Gets the hosting scene
  108666. */
  108667. get scene(): Scene;
  108668. /**
  108669. * Gets the capacity of the manager
  108670. */
  108671. get capacity(): number;
  108672. /**
  108673. * Gets or sets the spritesheet texture
  108674. */
  108675. get texture(): Texture;
  108676. set texture(value: Texture);
  108677. /** Defines the default width of a cell in the spritesheet */
  108678. get cellWidth(): number;
  108679. set cellWidth(value: number);
  108680. /** Defines the default height of a cell in the spritesheet */
  108681. get cellHeight(): number;
  108682. set cellHeight(value: number);
  108683. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  108684. get fogEnabled(): boolean;
  108685. set fogEnabled(value: boolean);
  108686. /**
  108687. * Blend mode use to render the particle, it can be any of
  108688. * the static Constants.ALPHA_x properties provided in this class.
  108689. * Default value is Constants.ALPHA_COMBINE
  108690. */
  108691. get blendMode(): number;
  108692. set blendMode(blendMode: number);
  108693. /** Disables writing to the depth buffer when rendering the sprites.
  108694. * It can be handy to disable depth writing when using textures without alpha channel
  108695. * and setting some specific blend modes.
  108696. */
  108697. disableDepthWrite: boolean;
  108698. private _spriteRenderer;
  108699. /** Associative array from JSON sprite data file */
  108700. private _cellData;
  108701. /** Array of sprite names from JSON sprite data file */
  108702. private _spriteMap;
  108703. /** True when packed cell data from JSON file is ready*/
  108704. private _packedAndReady;
  108705. private _textureContent;
  108706. private _onDisposeObserver;
  108707. private _fromPacked;
  108708. private _scene;
  108709. /**
  108710. * Creates a new sprite manager
  108711. * @param name defines the manager's name
  108712. * @param imgUrl defines the sprite sheet url
  108713. * @param capacity defines the maximum allowed number of sprites
  108714. * @param cellSize defines the size of a sprite cell
  108715. * @param scene defines the hosting scene
  108716. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  108717. * @param samplingMode defines the smapling mode to use with spritesheet
  108718. * @param fromPacked set to false; do not alter
  108719. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  108720. */
  108721. constructor(
  108722. /** defines the manager's name */
  108723. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  108724. /**
  108725. * Returns the string "SpriteManager"
  108726. * @returns "SpriteManager"
  108727. */
  108728. getClassName(): string;
  108729. private _makePacked;
  108730. private _checkTextureAlpha;
  108731. /**
  108732. * Intersects the sprites with a ray
  108733. * @param ray defines the ray to intersect with
  108734. * @param camera defines the current active camera
  108735. * @param predicate defines a predicate used to select candidate sprites
  108736. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  108737. * @returns null if no hit or a PickingInfo
  108738. */
  108739. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  108740. /**
  108741. * Intersects the sprites with a ray
  108742. * @param ray defines the ray to intersect with
  108743. * @param camera defines the current active camera
  108744. * @param predicate defines a predicate used to select candidate sprites
  108745. * @returns null if no hit or a PickingInfo array
  108746. */
  108747. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  108748. /**
  108749. * Render all child sprites
  108750. */
  108751. render(): void;
  108752. private _customUpdate;
  108753. /**
  108754. * Release associated resources
  108755. */
  108756. dispose(): void;
  108757. /**
  108758. * Serializes the sprite manager to a JSON object
  108759. * @param serializeTexture defines if the texture must be serialized as well
  108760. * @returns the JSON object
  108761. */
  108762. serialize(serializeTexture?: boolean): any;
  108763. /**
  108764. * Parses a JSON object to create a new sprite manager.
  108765. * @param parsedManager The JSON object to parse
  108766. * @param scene The scene to create the sprite managerin
  108767. * @param rootUrl The root url to use to load external dependencies like texture
  108768. * @returns the new sprite manager
  108769. */
  108770. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  108771. /**
  108772. * Creates a sprite manager from a snippet saved in a remote file
  108773. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  108774. * @param url defines the url to load from
  108775. * @param scene defines the hosting scene
  108776. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  108777. * @returns a promise that will resolve to the new sprite manager
  108778. */
  108779. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  108780. /**
  108781. * Creates a sprite manager from a snippet saved by the sprite editor
  108782. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  108783. * @param scene defines the hosting scene
  108784. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  108785. * @returns a promise that will resolve to the new sprite manager
  108786. */
  108787. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  108788. }
  108789. }
  108790. declare module BABYLON {
  108791. /**
  108792. * Class used to represent a sprite
  108793. * @see https://doc.babylonjs.com/babylon101/sprites
  108794. */
  108795. export class Sprite extends ThinSprite implements IAnimatable {
  108796. /** defines the name */
  108797. name: string;
  108798. /** Gets or sets the current world position */
  108799. position: Vector3;
  108800. /** Gets or sets the main color */
  108801. color: Color4;
  108802. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  108803. disposeWhenFinishedAnimating: boolean;
  108804. /** Gets the list of attached animations */
  108805. animations: Nullable<Array<Animation>>;
  108806. /** Gets or sets a boolean indicating if the sprite can be picked */
  108807. isPickable: boolean;
  108808. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  108809. useAlphaForPicking: boolean;
  108810. /**
  108811. * Gets or sets the associated action manager
  108812. */
  108813. actionManager: Nullable<ActionManager>;
  108814. /**
  108815. * An event triggered when the control has been disposed
  108816. */
  108817. onDisposeObservable: Observable<Sprite>;
  108818. private _manager;
  108819. private _onAnimationEnd;
  108820. /**
  108821. * Gets or sets the sprite size
  108822. */
  108823. get size(): number;
  108824. set size(value: number);
  108825. /**
  108826. * Gets or sets the unique id of the sprite
  108827. */
  108828. uniqueId: number;
  108829. /**
  108830. * Gets the manager of this sprite
  108831. */
  108832. get manager(): ISpriteManager;
  108833. /**
  108834. * Creates a new Sprite
  108835. * @param name defines the name
  108836. * @param manager defines the manager
  108837. */
  108838. constructor(
  108839. /** defines the name */
  108840. name: string, manager: ISpriteManager);
  108841. /**
  108842. * Returns the string "Sprite"
  108843. * @returns "Sprite"
  108844. */
  108845. getClassName(): string;
  108846. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  108847. get fromIndex(): number;
  108848. set fromIndex(value: number);
  108849. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  108850. get toIndex(): number;
  108851. set toIndex(value: number);
  108852. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  108853. get loopAnimation(): boolean;
  108854. set loopAnimation(value: boolean);
  108855. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  108856. get delay(): number;
  108857. set delay(value: number);
  108858. /**
  108859. * Starts an animation
  108860. * @param from defines the initial key
  108861. * @param to defines the end key
  108862. * @param loop defines if the animation must loop
  108863. * @param delay defines the start delay (in ms)
  108864. * @param onAnimationEnd defines a callback to call when animation ends
  108865. */
  108866. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  108867. private _endAnimation;
  108868. /** Release associated resources */
  108869. dispose(): void;
  108870. /**
  108871. * Serializes the sprite to a JSON object
  108872. * @returns the JSON object
  108873. */
  108874. serialize(): any;
  108875. /**
  108876. * Parses a JSON object to create a new sprite
  108877. * @param parsedSprite The JSON object to parse
  108878. * @param manager defines the hosting manager
  108879. * @returns the new sprite
  108880. */
  108881. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  108882. }
  108883. }
  108884. declare module BABYLON {
  108885. /**
  108886. * Information about the result of picking within a scene
  108887. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  108888. */
  108889. export class PickingInfo {
  108890. /** @hidden */
  108891. _pickingUnavailable: boolean;
  108892. /**
  108893. * If the pick collided with an object
  108894. */
  108895. hit: boolean;
  108896. /**
  108897. * Distance away where the pick collided
  108898. */
  108899. distance: number;
  108900. /**
  108901. * The location of pick collision
  108902. */
  108903. pickedPoint: Nullable<Vector3>;
  108904. /**
  108905. * The mesh corresponding the the pick collision
  108906. */
  108907. pickedMesh: Nullable<AbstractMesh>;
  108908. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  108909. bu: number;
  108910. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  108911. bv: number;
  108912. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  108913. faceId: number;
  108914. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  108915. subMeshFaceId: number;
  108916. /** Id of the the submesh that was picked */
  108917. subMeshId: number;
  108918. /** If a sprite was picked, this will be the sprite the pick collided with */
  108919. pickedSprite: Nullable<Sprite>;
  108920. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  108921. thinInstanceIndex: number;
  108922. /**
  108923. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  108924. */
  108925. originMesh: Nullable<AbstractMesh>;
  108926. /**
  108927. * The ray that was used to perform the picking.
  108928. */
  108929. ray: Nullable<Ray>;
  108930. /**
  108931. * Gets the normal correspodning to the face the pick collided with
  108932. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  108933. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  108934. * @returns The normal correspodning to the face the pick collided with
  108935. */
  108936. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  108937. /**
  108938. * Gets the texture coordinates of where the pick occured
  108939. * @returns the vector containing the coordnates of the texture
  108940. */
  108941. getTextureCoordinates(): Nullable<Vector2>;
  108942. }
  108943. }
  108944. declare module BABYLON {
  108945. /**
  108946. * Gather the list of pointer event types as constants.
  108947. */
  108948. export class PointerEventTypes {
  108949. /**
  108950. * 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.
  108951. */
  108952. static readonly POINTERDOWN: number;
  108953. /**
  108954. * The pointerup event is fired when a pointer is no longer active.
  108955. */
  108956. static readonly POINTERUP: number;
  108957. /**
  108958. * The pointermove event is fired when a pointer changes coordinates.
  108959. */
  108960. static readonly POINTERMOVE: number;
  108961. /**
  108962. * The pointerwheel event is fired when a mouse wheel has been rotated.
  108963. */
  108964. static readonly POINTERWHEEL: number;
  108965. /**
  108966. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  108967. */
  108968. static readonly POINTERPICK: number;
  108969. /**
  108970. * The pointertap event is fired when a the object has been touched and released without drag.
  108971. */
  108972. static readonly POINTERTAP: number;
  108973. /**
  108974. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  108975. */
  108976. static readonly POINTERDOUBLETAP: number;
  108977. }
  108978. /**
  108979. * Base class of pointer info types.
  108980. */
  108981. export class PointerInfoBase {
  108982. /**
  108983. * Defines the type of event (PointerEventTypes)
  108984. */
  108985. type: number;
  108986. /**
  108987. * Defines the related dom event
  108988. */
  108989. event: PointerEvent | MouseWheelEvent;
  108990. /**
  108991. * Instantiates the base class of pointers info.
  108992. * @param type Defines the type of event (PointerEventTypes)
  108993. * @param event Defines the related dom event
  108994. */
  108995. constructor(
  108996. /**
  108997. * Defines the type of event (PointerEventTypes)
  108998. */
  108999. type: number,
  109000. /**
  109001. * Defines the related dom event
  109002. */
  109003. event: PointerEvent | MouseWheelEvent);
  109004. }
  109005. /**
  109006. * This class is used to store pointer related info for the onPrePointerObservable event.
  109007. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  109008. */
  109009. export class PointerInfoPre extends PointerInfoBase {
  109010. /**
  109011. * Ray from a pointer if availible (eg. 6dof controller)
  109012. */
  109013. ray: Nullable<Ray>;
  109014. /**
  109015. * Defines the local position of the pointer on the canvas.
  109016. */
  109017. localPosition: Vector2;
  109018. /**
  109019. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  109020. */
  109021. skipOnPointerObservable: boolean;
  109022. /**
  109023. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  109024. * @param type Defines the type of event (PointerEventTypes)
  109025. * @param event Defines the related dom event
  109026. * @param localX Defines the local x coordinates of the pointer when the event occured
  109027. * @param localY Defines the local y coordinates of the pointer when the event occured
  109028. */
  109029. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  109030. }
  109031. /**
  109032. * This type contains all the data related to a pointer event in Babylon.js.
  109033. * 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.
  109034. */
  109035. export class PointerInfo extends PointerInfoBase {
  109036. /**
  109037. * Defines the picking info associated to the info (if any)\
  109038. */
  109039. pickInfo: Nullable<PickingInfo>;
  109040. /**
  109041. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  109042. * @param type Defines the type of event (PointerEventTypes)
  109043. * @param event Defines the related dom event
  109044. * @param pickInfo Defines the picking info associated to the info (if any)\
  109045. */
  109046. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  109047. /**
  109048. * Defines the picking info associated to the info (if any)\
  109049. */
  109050. pickInfo: Nullable<PickingInfo>);
  109051. }
  109052. /**
  109053. * Data relating to a touch event on the screen.
  109054. */
  109055. export interface PointerTouch {
  109056. /**
  109057. * X coordinate of touch.
  109058. */
  109059. x: number;
  109060. /**
  109061. * Y coordinate of touch.
  109062. */
  109063. y: number;
  109064. /**
  109065. * Id of touch. Unique for each finger.
  109066. */
  109067. pointerId: number;
  109068. /**
  109069. * Event type passed from DOM.
  109070. */
  109071. type: any;
  109072. }
  109073. }
  109074. declare module BABYLON {
  109075. /**
  109076. * Manage the mouse inputs to control the movement of a free camera.
  109077. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  109078. */
  109079. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  109080. /**
  109081. * Define if touch is enabled in the mouse input
  109082. */
  109083. touchEnabled: boolean;
  109084. /**
  109085. * Defines the camera the input is attached to.
  109086. */
  109087. camera: FreeCamera;
  109088. /**
  109089. * Defines the buttons associated with the input to handle camera move.
  109090. */
  109091. buttons: number[];
  109092. /**
  109093. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  109094. */
  109095. angularSensibility: number;
  109096. private _pointerInput;
  109097. private _onMouseMove;
  109098. private _observer;
  109099. private previousPosition;
  109100. /**
  109101. * Observable for when a pointer move event occurs containing the move offset
  109102. */
  109103. onPointerMovedObservable: Observable<{
  109104. offsetX: number;
  109105. offsetY: number;
  109106. }>;
  109107. /**
  109108. * @hidden
  109109. * If the camera should be rotated automatically based on pointer movement
  109110. */
  109111. _allowCameraRotation: boolean;
  109112. /**
  109113. * Manage the mouse inputs to control the movement of a free camera.
  109114. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  109115. * @param touchEnabled Defines if touch is enabled or not
  109116. */
  109117. constructor(
  109118. /**
  109119. * Define if touch is enabled in the mouse input
  109120. */
  109121. touchEnabled?: boolean);
  109122. /**
  109123. * Attach the input controls to a specific dom element to get the input from.
  109124. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109125. */
  109126. attachControl(noPreventDefault?: boolean): void;
  109127. /**
  109128. * Called on JS contextmenu event.
  109129. * Override this method to provide functionality.
  109130. */
  109131. protected onContextMenu(evt: PointerEvent): void;
  109132. /**
  109133. * Detach the current controls from the specified dom element.
  109134. */
  109135. detachControl(): void;
  109136. /**
  109137. * Gets the class name of the current intput.
  109138. * @returns the class name
  109139. */
  109140. getClassName(): string;
  109141. /**
  109142. * Get the friendly name associated with the input class.
  109143. * @returns the input friendly name
  109144. */
  109145. getSimpleName(): string;
  109146. }
  109147. }
  109148. declare module BABYLON {
  109149. /**
  109150. * Base class for mouse wheel input..
  109151. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  109152. * for example usage.
  109153. */
  109154. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  109155. /**
  109156. * Defines the camera the input is attached to.
  109157. */
  109158. abstract camera: Camera;
  109159. /**
  109160. * How fast is the camera moves in relation to X axis mouseWheel events.
  109161. * Use negative value to reverse direction.
  109162. */
  109163. wheelPrecisionX: number;
  109164. /**
  109165. * How fast is the camera moves in relation to Y axis mouseWheel events.
  109166. * Use negative value to reverse direction.
  109167. */
  109168. wheelPrecisionY: number;
  109169. /**
  109170. * How fast is the camera moves in relation to Z axis mouseWheel events.
  109171. * Use negative value to reverse direction.
  109172. */
  109173. wheelPrecisionZ: number;
  109174. /**
  109175. * Observable for when a mouse wheel move event occurs.
  109176. */
  109177. onChangedObservable: Observable<{
  109178. wheelDeltaX: number;
  109179. wheelDeltaY: number;
  109180. wheelDeltaZ: number;
  109181. }>;
  109182. private _wheel;
  109183. private _observer;
  109184. /**
  109185. * Attach the input controls to a specific dom element to get the input from.
  109186. * @param noPreventDefault Defines whether event caught by the controls
  109187. * should call preventdefault().
  109188. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109189. */
  109190. attachControl(noPreventDefault?: boolean): void;
  109191. /**
  109192. * Detach the current controls from the specified dom element.
  109193. */
  109194. detachControl(): void;
  109195. /**
  109196. * Called for each rendered frame.
  109197. */
  109198. checkInputs(): void;
  109199. /**
  109200. * Gets the class name of the current intput.
  109201. * @returns the class name
  109202. */
  109203. getClassName(): string;
  109204. /**
  109205. * Get the friendly name associated with the input class.
  109206. * @returns the input friendly name
  109207. */
  109208. getSimpleName(): string;
  109209. /**
  109210. * Incremental value of multiple mouse wheel movements of the X axis.
  109211. * Should be zero-ed when read.
  109212. */
  109213. protected _wheelDeltaX: number;
  109214. /**
  109215. * Incremental value of multiple mouse wheel movements of the Y axis.
  109216. * Should be zero-ed when read.
  109217. */
  109218. protected _wheelDeltaY: number;
  109219. /**
  109220. * Incremental value of multiple mouse wheel movements of the Z axis.
  109221. * Should be zero-ed when read.
  109222. */
  109223. protected _wheelDeltaZ: number;
  109224. /**
  109225. * Firefox uses a different scheme to report scroll distances to other
  109226. * browsers. Rather than use complicated methods to calculate the exact
  109227. * multiple we need to apply, let's just cheat and use a constant.
  109228. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  109229. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  109230. */
  109231. private readonly _ffMultiplier;
  109232. /**
  109233. * Different event attributes for wheel data fall into a few set ranges.
  109234. * Some relevant but dated date here:
  109235. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  109236. */
  109237. private readonly _normalize;
  109238. }
  109239. }
  109240. declare module BABYLON {
  109241. /**
  109242. * Manage the mouse wheel inputs to control a free camera.
  109243. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  109244. */
  109245. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  109246. /**
  109247. * Defines the camera the input is attached to.
  109248. */
  109249. camera: FreeCamera;
  109250. /**
  109251. * Gets the class name of the current input.
  109252. * @returns the class name
  109253. */
  109254. getClassName(): string;
  109255. /**
  109256. * Set which movement axis (relative to camera's orientation) the mouse
  109257. * wheel's X axis controls.
  109258. * @param axis The axis to be moved. Set null to clear.
  109259. */
  109260. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  109261. /**
  109262. * Get the configured movement axis (relative to camera's orientation) the
  109263. * mouse wheel's X axis controls.
  109264. * @returns The configured axis or null if none.
  109265. */
  109266. get wheelXMoveRelative(): Nullable<Coordinate>;
  109267. /**
  109268. * Set which movement axis (relative to camera's orientation) the mouse
  109269. * wheel's Y axis controls.
  109270. * @param axis The axis to be moved. Set null to clear.
  109271. */
  109272. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  109273. /**
  109274. * Get the configured movement axis (relative to camera's orientation) the
  109275. * mouse wheel's Y axis controls.
  109276. * @returns The configured axis or null if none.
  109277. */
  109278. get wheelYMoveRelative(): Nullable<Coordinate>;
  109279. /**
  109280. * Set which movement axis (relative to camera's orientation) the mouse
  109281. * wheel's Z axis controls.
  109282. * @param axis The axis to be moved. Set null to clear.
  109283. */
  109284. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  109285. /**
  109286. * Get the configured movement axis (relative to camera's orientation) the
  109287. * mouse wheel's Z axis controls.
  109288. * @returns The configured axis or null if none.
  109289. */
  109290. get wheelZMoveRelative(): Nullable<Coordinate>;
  109291. /**
  109292. * Set which rotation axis (relative to camera's orientation) the mouse
  109293. * wheel's X axis controls.
  109294. * @param axis The axis to be moved. Set null to clear.
  109295. */
  109296. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  109297. /**
  109298. * Get the configured rotation axis (relative to camera's orientation) the
  109299. * mouse wheel's X axis controls.
  109300. * @returns The configured axis or null if none.
  109301. */
  109302. get wheelXRotateRelative(): Nullable<Coordinate>;
  109303. /**
  109304. * Set which rotation axis (relative to camera's orientation) the mouse
  109305. * wheel's Y axis controls.
  109306. * @param axis The axis to be moved. Set null to clear.
  109307. */
  109308. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  109309. /**
  109310. * Get the configured rotation axis (relative to camera's orientation) the
  109311. * mouse wheel's Y axis controls.
  109312. * @returns The configured axis or null if none.
  109313. */
  109314. get wheelYRotateRelative(): Nullable<Coordinate>;
  109315. /**
  109316. * Set which rotation axis (relative to camera's orientation) the mouse
  109317. * wheel's Z axis controls.
  109318. * @param axis The axis to be moved. Set null to clear.
  109319. */
  109320. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  109321. /**
  109322. * Get the configured rotation axis (relative to camera's orientation) the
  109323. * mouse wheel's Z axis controls.
  109324. * @returns The configured axis or null if none.
  109325. */
  109326. get wheelZRotateRelative(): Nullable<Coordinate>;
  109327. /**
  109328. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  109329. * controls.
  109330. * @param axis The axis to be moved. Set null to clear.
  109331. */
  109332. set wheelXMoveScene(axis: Nullable<Coordinate>);
  109333. /**
  109334. * Get the configured movement axis (relative to the scene) the mouse wheel's
  109335. * X axis controls.
  109336. * @returns The configured axis or null if none.
  109337. */
  109338. get wheelXMoveScene(): Nullable<Coordinate>;
  109339. /**
  109340. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  109341. * controls.
  109342. * @param axis The axis to be moved. Set null to clear.
  109343. */
  109344. set wheelYMoveScene(axis: Nullable<Coordinate>);
  109345. /**
  109346. * Get the configured movement axis (relative to the scene) the mouse wheel's
  109347. * Y axis controls.
  109348. * @returns The configured axis or null if none.
  109349. */
  109350. get wheelYMoveScene(): Nullable<Coordinate>;
  109351. /**
  109352. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  109353. * controls.
  109354. * @param axis The axis to be moved. Set null to clear.
  109355. */
  109356. set wheelZMoveScene(axis: Nullable<Coordinate>);
  109357. /**
  109358. * Get the configured movement axis (relative to the scene) the mouse wheel's
  109359. * Z axis controls.
  109360. * @returns The configured axis or null if none.
  109361. */
  109362. get wheelZMoveScene(): Nullable<Coordinate>;
  109363. /**
  109364. * Called for each rendered frame.
  109365. */
  109366. checkInputs(): void;
  109367. private _moveRelative;
  109368. private _rotateRelative;
  109369. private _moveScene;
  109370. /**
  109371. * These are set to the desired default behaviour.
  109372. */
  109373. private _wheelXAction;
  109374. private _wheelXActionCoordinate;
  109375. private _wheelYAction;
  109376. private _wheelYActionCoordinate;
  109377. private _wheelZAction;
  109378. private _wheelZActionCoordinate;
  109379. /**
  109380. * Update the camera according to any configured properties for the 3
  109381. * mouse-wheel axis.
  109382. */
  109383. private _updateCamera;
  109384. }
  109385. }
  109386. declare module BABYLON {
  109387. /**
  109388. * Manage the touch inputs to control the movement of a free camera.
  109389. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  109390. */
  109391. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  109392. /**
  109393. * Define if mouse events can be treated as touch events
  109394. */
  109395. allowMouse: boolean;
  109396. /**
  109397. * Defines the camera the input is attached to.
  109398. */
  109399. camera: FreeCamera;
  109400. /**
  109401. * Defines the touch sensibility for rotation.
  109402. * The higher the faster.
  109403. */
  109404. touchAngularSensibility: number;
  109405. /**
  109406. * Defines the touch sensibility for move.
  109407. * The higher the faster.
  109408. */
  109409. touchMoveSensibility: number;
  109410. private _offsetX;
  109411. private _offsetY;
  109412. private _pointerPressed;
  109413. private _pointerInput?;
  109414. private _observer;
  109415. private _onLostFocus;
  109416. /**
  109417. * Manage the touch inputs to control the movement of a free camera.
  109418. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  109419. * @param allowMouse Defines if mouse events can be treated as touch events
  109420. */
  109421. constructor(
  109422. /**
  109423. * Define if mouse events can be treated as touch events
  109424. */
  109425. allowMouse?: boolean);
  109426. /**
  109427. * Attach the input controls to a specific dom element to get the input from.
  109428. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109429. */
  109430. attachControl(noPreventDefault?: boolean): void;
  109431. /**
  109432. * Detach the current controls from the specified dom element.
  109433. */
  109434. detachControl(): void;
  109435. /**
  109436. * Update the current camera state depending on the inputs that have been used this frame.
  109437. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  109438. */
  109439. checkInputs(): void;
  109440. /**
  109441. * Gets the class name of the current intput.
  109442. * @returns the class name
  109443. */
  109444. getClassName(): string;
  109445. /**
  109446. * Get the friendly name associated with the input class.
  109447. * @returns the input friendly name
  109448. */
  109449. getSimpleName(): string;
  109450. }
  109451. }
  109452. declare module BABYLON {
  109453. /**
  109454. * Default Inputs manager for the FreeCamera.
  109455. * It groups all the default supported inputs for ease of use.
  109456. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  109457. */
  109458. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  109459. /**
  109460. * @hidden
  109461. */
  109462. _mouseInput: Nullable<FreeCameraMouseInput>;
  109463. /**
  109464. * @hidden
  109465. */
  109466. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  109467. /**
  109468. * Instantiates a new FreeCameraInputsManager.
  109469. * @param camera Defines the camera the inputs belong to
  109470. */
  109471. constructor(camera: FreeCamera);
  109472. /**
  109473. * Add keyboard input support to the input manager.
  109474. * @returns the current input manager
  109475. */
  109476. addKeyboard(): FreeCameraInputsManager;
  109477. /**
  109478. * Add mouse input support to the input manager.
  109479. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  109480. * @returns the current input manager
  109481. */
  109482. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  109483. /**
  109484. * Removes the mouse input support from the manager
  109485. * @returns the current input manager
  109486. */
  109487. removeMouse(): FreeCameraInputsManager;
  109488. /**
  109489. * Add mouse wheel input support to the input manager.
  109490. * @returns the current input manager
  109491. */
  109492. addMouseWheel(): FreeCameraInputsManager;
  109493. /**
  109494. * Removes the mouse wheel input support from the manager
  109495. * @returns the current input manager
  109496. */
  109497. removeMouseWheel(): FreeCameraInputsManager;
  109498. /**
  109499. * Add touch input support to the input manager.
  109500. * @returns the current input manager
  109501. */
  109502. addTouch(): FreeCameraInputsManager;
  109503. /**
  109504. * Remove all attached input methods from a camera
  109505. */
  109506. clear(): void;
  109507. }
  109508. }
  109509. declare module BABYLON {
  109510. /**
  109511. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  109512. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  109513. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  109514. */
  109515. export class FreeCamera extends TargetCamera {
  109516. /**
  109517. * Define the collision ellipsoid of the camera.
  109518. * This is helpful to simulate a camera body like the player body around the camera
  109519. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  109520. */
  109521. ellipsoid: Vector3;
  109522. /**
  109523. * Define an offset for the position of the ellipsoid around the camera.
  109524. * This can be helpful to determine the center of the body near the gravity center of the body
  109525. * instead of its head.
  109526. */
  109527. ellipsoidOffset: Vector3;
  109528. /**
  109529. * Enable or disable collisions of the camera with the rest of the scene objects.
  109530. */
  109531. checkCollisions: boolean;
  109532. /**
  109533. * Enable or disable gravity on the camera.
  109534. */
  109535. applyGravity: boolean;
  109536. /**
  109537. * Define the input manager associated to the camera.
  109538. */
  109539. inputs: FreeCameraInputsManager;
  109540. /**
  109541. * Gets the input sensibility for a mouse input. (default is 2000.0)
  109542. * Higher values reduce sensitivity.
  109543. */
  109544. get angularSensibility(): number;
  109545. /**
  109546. * Sets the input sensibility for a mouse input. (default is 2000.0)
  109547. * Higher values reduce sensitivity.
  109548. */
  109549. set angularSensibility(value: number);
  109550. /**
  109551. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  109552. */
  109553. get keysUp(): number[];
  109554. set keysUp(value: number[]);
  109555. /**
  109556. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  109557. */
  109558. get keysUpward(): number[];
  109559. set keysUpward(value: number[]);
  109560. /**
  109561. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  109562. */
  109563. get keysDown(): number[];
  109564. set keysDown(value: number[]);
  109565. /**
  109566. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  109567. */
  109568. get keysDownward(): number[];
  109569. set keysDownward(value: number[]);
  109570. /**
  109571. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  109572. */
  109573. get keysLeft(): number[];
  109574. set keysLeft(value: number[]);
  109575. /**
  109576. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  109577. */
  109578. get keysRight(): number[];
  109579. set keysRight(value: number[]);
  109580. /**
  109581. * Event raised when the camera collide with a mesh in the scene.
  109582. */
  109583. onCollide: (collidedMesh: AbstractMesh) => void;
  109584. private _collider;
  109585. private _needMoveForGravity;
  109586. private _oldPosition;
  109587. private _diffPosition;
  109588. private _newPosition;
  109589. /** @hidden */
  109590. _localDirection: Vector3;
  109591. /** @hidden */
  109592. _transformedDirection: Vector3;
  109593. /**
  109594. * Instantiates a Free Camera.
  109595. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  109596. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  109597. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  109598. * @param name Define the name of the camera in the scene
  109599. * @param position Define the start position of the camera in the scene
  109600. * @param scene Define the scene the camera belongs to
  109601. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  109602. */
  109603. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  109604. /**
  109605. * Attach the input controls to a specific dom element to get the input from.
  109606. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109607. */
  109608. attachControl(noPreventDefault?: boolean): void;
  109609. /**
  109610. * Attach the input controls to a specific dom element to get the input from.
  109611. * @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
  109612. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109613. * BACK COMPAT SIGNATURE ONLY.
  109614. */
  109615. attachControl(ignored: any, noPreventDefault?: boolean): void;
  109616. /**
  109617. * Detach the current controls from the specified dom element.
  109618. */
  109619. detachControl(): void;
  109620. /**
  109621. * Detach the current controls from the specified dom element.
  109622. * @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
  109623. */
  109624. detachControl(ignored: any): void;
  109625. private _collisionMask;
  109626. /**
  109627. * Define a collision mask to limit the list of object the camera can collide with
  109628. */
  109629. get collisionMask(): number;
  109630. set collisionMask(mask: number);
  109631. /** @hidden */
  109632. _collideWithWorld(displacement: Vector3): void;
  109633. private _onCollisionPositionChange;
  109634. /** @hidden */
  109635. _checkInputs(): void;
  109636. /** @hidden */
  109637. _decideIfNeedsToMove(): boolean;
  109638. /** @hidden */
  109639. _updatePosition(): void;
  109640. /**
  109641. * Destroy the camera and release the current resources hold by it.
  109642. */
  109643. dispose(): void;
  109644. /**
  109645. * Gets the current object class name.
  109646. * @return the class name
  109647. */
  109648. getClassName(): string;
  109649. }
  109650. }
  109651. declare module BABYLON {
  109652. /**
  109653. * Represents a gamepad control stick position
  109654. */
  109655. export class StickValues {
  109656. /**
  109657. * The x component of the control stick
  109658. */
  109659. x: number;
  109660. /**
  109661. * The y component of the control stick
  109662. */
  109663. y: number;
  109664. /**
  109665. * Initializes the gamepad x and y control stick values
  109666. * @param x The x component of the gamepad control stick value
  109667. * @param y The y component of the gamepad control stick value
  109668. */
  109669. constructor(
  109670. /**
  109671. * The x component of the control stick
  109672. */
  109673. x: number,
  109674. /**
  109675. * The y component of the control stick
  109676. */
  109677. y: number);
  109678. }
  109679. /**
  109680. * An interface which manages callbacks for gamepad button changes
  109681. */
  109682. export interface GamepadButtonChanges {
  109683. /**
  109684. * Called when a gamepad has been changed
  109685. */
  109686. changed: boolean;
  109687. /**
  109688. * Called when a gamepad press event has been triggered
  109689. */
  109690. pressChanged: boolean;
  109691. /**
  109692. * Called when a touch event has been triggered
  109693. */
  109694. touchChanged: boolean;
  109695. /**
  109696. * Called when a value has changed
  109697. */
  109698. valueChanged: boolean;
  109699. }
  109700. /**
  109701. * Represents a gamepad
  109702. */
  109703. export class Gamepad {
  109704. /**
  109705. * The id of the gamepad
  109706. */
  109707. id: string;
  109708. /**
  109709. * The index of the gamepad
  109710. */
  109711. index: number;
  109712. /**
  109713. * The browser gamepad
  109714. */
  109715. browserGamepad: any;
  109716. /**
  109717. * Specifies what type of gamepad this represents
  109718. */
  109719. type: number;
  109720. private _leftStick;
  109721. private _rightStick;
  109722. /** @hidden */
  109723. _isConnected: boolean;
  109724. private _leftStickAxisX;
  109725. private _leftStickAxisY;
  109726. private _rightStickAxisX;
  109727. private _rightStickAxisY;
  109728. /**
  109729. * Triggered when the left control stick has been changed
  109730. */
  109731. private _onleftstickchanged;
  109732. /**
  109733. * Triggered when the right control stick has been changed
  109734. */
  109735. private _onrightstickchanged;
  109736. /**
  109737. * Represents a gamepad controller
  109738. */
  109739. static GAMEPAD: number;
  109740. /**
  109741. * Represents a generic controller
  109742. */
  109743. static GENERIC: number;
  109744. /**
  109745. * Represents an XBox controller
  109746. */
  109747. static XBOX: number;
  109748. /**
  109749. * Represents a pose-enabled controller
  109750. */
  109751. static POSE_ENABLED: number;
  109752. /**
  109753. * Represents an Dual Shock controller
  109754. */
  109755. static DUALSHOCK: number;
  109756. /**
  109757. * Specifies whether the left control stick should be Y-inverted
  109758. */
  109759. protected _invertLeftStickY: boolean;
  109760. /**
  109761. * Specifies if the gamepad has been connected
  109762. */
  109763. get isConnected(): boolean;
  109764. /**
  109765. * Initializes the gamepad
  109766. * @param id The id of the gamepad
  109767. * @param index The index of the gamepad
  109768. * @param browserGamepad The browser gamepad
  109769. * @param leftStickX The x component of the left joystick
  109770. * @param leftStickY The y component of the left joystick
  109771. * @param rightStickX The x component of the right joystick
  109772. * @param rightStickY The y component of the right joystick
  109773. */
  109774. constructor(
  109775. /**
  109776. * The id of the gamepad
  109777. */
  109778. id: string,
  109779. /**
  109780. * The index of the gamepad
  109781. */
  109782. index: number,
  109783. /**
  109784. * The browser gamepad
  109785. */
  109786. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  109787. /**
  109788. * Callback triggered when the left joystick has changed
  109789. * @param callback
  109790. */
  109791. onleftstickchanged(callback: (values: StickValues) => void): void;
  109792. /**
  109793. * Callback triggered when the right joystick has changed
  109794. * @param callback
  109795. */
  109796. onrightstickchanged(callback: (values: StickValues) => void): void;
  109797. /**
  109798. * Gets the left joystick
  109799. */
  109800. get leftStick(): StickValues;
  109801. /**
  109802. * Sets the left joystick values
  109803. */
  109804. set leftStick(newValues: StickValues);
  109805. /**
  109806. * Gets the right joystick
  109807. */
  109808. get rightStick(): StickValues;
  109809. /**
  109810. * Sets the right joystick value
  109811. */
  109812. set rightStick(newValues: StickValues);
  109813. /**
  109814. * Updates the gamepad joystick positions
  109815. */
  109816. update(): void;
  109817. /**
  109818. * Disposes the gamepad
  109819. */
  109820. dispose(): void;
  109821. }
  109822. /**
  109823. * Represents a generic gamepad
  109824. */
  109825. export class GenericPad extends Gamepad {
  109826. private _buttons;
  109827. private _onbuttondown;
  109828. private _onbuttonup;
  109829. /**
  109830. * Observable triggered when a button has been pressed
  109831. */
  109832. onButtonDownObservable: Observable<number>;
  109833. /**
  109834. * Observable triggered when a button has been released
  109835. */
  109836. onButtonUpObservable: Observable<number>;
  109837. /**
  109838. * Callback triggered when a button has been pressed
  109839. * @param callback Called when a button has been pressed
  109840. */
  109841. onbuttondown(callback: (buttonPressed: number) => void): void;
  109842. /**
  109843. * Callback triggered when a button has been released
  109844. * @param callback Called when a button has been released
  109845. */
  109846. onbuttonup(callback: (buttonReleased: number) => void): void;
  109847. /**
  109848. * Initializes the generic gamepad
  109849. * @param id The id of the generic gamepad
  109850. * @param index The index of the generic gamepad
  109851. * @param browserGamepad The browser gamepad
  109852. */
  109853. constructor(id: string, index: number, browserGamepad: any);
  109854. private _setButtonValue;
  109855. /**
  109856. * Updates the generic gamepad
  109857. */
  109858. update(): void;
  109859. /**
  109860. * Disposes the generic gamepad
  109861. */
  109862. dispose(): void;
  109863. }
  109864. }
  109865. declare module BABYLON {
  109866. /**
  109867. * Defines a runtime animation
  109868. */
  109869. export class RuntimeAnimation {
  109870. private _events;
  109871. /**
  109872. * The current frame of the runtime animation
  109873. */
  109874. private _currentFrame;
  109875. /**
  109876. * The animation used by the runtime animation
  109877. */
  109878. private _animation;
  109879. /**
  109880. * The target of the runtime animation
  109881. */
  109882. private _target;
  109883. /**
  109884. * The initiating animatable
  109885. */
  109886. private _host;
  109887. /**
  109888. * The original value of the runtime animation
  109889. */
  109890. private _originalValue;
  109891. /**
  109892. * The original blend value of the runtime animation
  109893. */
  109894. private _originalBlendValue;
  109895. /**
  109896. * The offsets cache of the runtime animation
  109897. */
  109898. private _offsetsCache;
  109899. /**
  109900. * The high limits cache of the runtime animation
  109901. */
  109902. private _highLimitsCache;
  109903. /**
  109904. * Specifies if the runtime animation has been stopped
  109905. */
  109906. private _stopped;
  109907. /**
  109908. * The blending factor of the runtime animation
  109909. */
  109910. private _blendingFactor;
  109911. /**
  109912. * The BabylonJS scene
  109913. */
  109914. private _scene;
  109915. /**
  109916. * The current value of the runtime animation
  109917. */
  109918. private _currentValue;
  109919. /** @hidden */
  109920. _animationState: _IAnimationState;
  109921. /**
  109922. * The active target of the runtime animation
  109923. */
  109924. private _activeTargets;
  109925. private _currentActiveTarget;
  109926. private _directTarget;
  109927. /**
  109928. * The target path of the runtime animation
  109929. */
  109930. private _targetPath;
  109931. /**
  109932. * The weight of the runtime animation
  109933. */
  109934. private _weight;
  109935. /**
  109936. * The ratio offset of the runtime animation
  109937. */
  109938. private _ratioOffset;
  109939. /**
  109940. * The previous delay of the runtime animation
  109941. */
  109942. private _previousDelay;
  109943. /**
  109944. * The previous ratio of the runtime animation
  109945. */
  109946. private _previousRatio;
  109947. private _enableBlending;
  109948. private _keys;
  109949. private _minFrame;
  109950. private _maxFrame;
  109951. private _minValue;
  109952. private _maxValue;
  109953. private _targetIsArray;
  109954. /**
  109955. * Gets the current frame of the runtime animation
  109956. */
  109957. get currentFrame(): number;
  109958. /**
  109959. * Gets the weight of the runtime animation
  109960. */
  109961. get weight(): number;
  109962. /**
  109963. * Gets the current value of the runtime animation
  109964. */
  109965. get currentValue(): any;
  109966. /**
  109967. * Gets the target path of the runtime animation
  109968. */
  109969. get targetPath(): string;
  109970. /**
  109971. * Gets the actual target of the runtime animation
  109972. */
  109973. get target(): any;
  109974. /**
  109975. * Gets the additive state of the runtime animation
  109976. */
  109977. get isAdditive(): boolean;
  109978. /** @hidden */
  109979. _onLoop: () => void;
  109980. /**
  109981. * Create a new RuntimeAnimation object
  109982. * @param target defines the target of the animation
  109983. * @param animation defines the source animation object
  109984. * @param scene defines the hosting scene
  109985. * @param host defines the initiating Animatable
  109986. */
  109987. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  109988. private _preparePath;
  109989. /**
  109990. * Gets the animation from the runtime animation
  109991. */
  109992. get animation(): Animation;
  109993. /**
  109994. * Resets the runtime animation to the beginning
  109995. * @param restoreOriginal defines whether to restore the target property to the original value
  109996. */
  109997. reset(restoreOriginal?: boolean): void;
  109998. /**
  109999. * Specifies if the runtime animation is stopped
  110000. * @returns Boolean specifying if the runtime animation is stopped
  110001. */
  110002. isStopped(): boolean;
  110003. /**
  110004. * Disposes of the runtime animation
  110005. */
  110006. dispose(): void;
  110007. /**
  110008. * Apply the interpolated value to the target
  110009. * @param currentValue defines the value computed by the animation
  110010. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  110011. */
  110012. setValue(currentValue: any, weight: number): void;
  110013. private _getOriginalValues;
  110014. private _setValue;
  110015. /**
  110016. * Gets the loop pmode of the runtime animation
  110017. * @returns Loop Mode
  110018. */
  110019. private _getCorrectLoopMode;
  110020. /**
  110021. * Move the current animation to a given frame
  110022. * @param frame defines the frame to move to
  110023. */
  110024. goToFrame(frame: number): void;
  110025. /**
  110026. * @hidden Internal use only
  110027. */
  110028. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  110029. /**
  110030. * Execute the current animation
  110031. * @param delay defines the delay to add to the current frame
  110032. * @param from defines the lower bound of the animation range
  110033. * @param to defines the upper bound of the animation range
  110034. * @param loop defines if the current animation must loop
  110035. * @param speedRatio defines the current speed ratio
  110036. * @param weight defines the weight of the animation (default is -1 so no weight)
  110037. * @param onLoop optional callback called when animation loops
  110038. * @returns a boolean indicating if the animation is running
  110039. */
  110040. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  110041. }
  110042. }
  110043. declare module BABYLON {
  110044. /**
  110045. * Class used to store an actual running animation
  110046. */
  110047. export class Animatable {
  110048. /** defines the target object */
  110049. target: any;
  110050. /** defines the starting frame number (default is 0) */
  110051. fromFrame: number;
  110052. /** defines the ending frame number (default is 100) */
  110053. toFrame: number;
  110054. /** defines if the animation must loop (default is false) */
  110055. loopAnimation: boolean;
  110056. /** defines a callback to call when animation ends if it is not looping */
  110057. onAnimationEnd?: (() => void) | null | undefined;
  110058. /** defines a callback to call when animation loops */
  110059. onAnimationLoop?: (() => void) | null | undefined;
  110060. /** defines whether the animation should be evaluated additively */
  110061. isAdditive: boolean;
  110062. private _localDelayOffset;
  110063. private _pausedDelay;
  110064. private _runtimeAnimations;
  110065. private _paused;
  110066. private _scene;
  110067. private _speedRatio;
  110068. private _weight;
  110069. private _syncRoot;
  110070. /**
  110071. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  110072. * This will only apply for non looping animation (default is true)
  110073. */
  110074. disposeOnEnd: boolean;
  110075. /**
  110076. * Gets a boolean indicating if the animation has started
  110077. */
  110078. animationStarted: boolean;
  110079. /**
  110080. * Observer raised when the animation ends
  110081. */
  110082. onAnimationEndObservable: Observable<Animatable>;
  110083. /**
  110084. * Observer raised when the animation loops
  110085. */
  110086. onAnimationLoopObservable: Observable<Animatable>;
  110087. /**
  110088. * Gets the root Animatable used to synchronize and normalize animations
  110089. */
  110090. get syncRoot(): Nullable<Animatable>;
  110091. /**
  110092. * Gets the current frame of the first RuntimeAnimation
  110093. * Used to synchronize Animatables
  110094. */
  110095. get masterFrame(): number;
  110096. /**
  110097. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  110098. */
  110099. get weight(): number;
  110100. set weight(value: number);
  110101. /**
  110102. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  110103. */
  110104. get speedRatio(): number;
  110105. set speedRatio(value: number);
  110106. /**
  110107. * Creates a new Animatable
  110108. * @param scene defines the hosting scene
  110109. * @param target defines the target object
  110110. * @param fromFrame defines the starting frame number (default is 0)
  110111. * @param toFrame defines the ending frame number (default is 100)
  110112. * @param loopAnimation defines if the animation must loop (default is false)
  110113. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  110114. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  110115. * @param animations defines a group of animation to add to the new Animatable
  110116. * @param onAnimationLoop defines a callback to call when animation loops
  110117. * @param isAdditive defines whether the animation should be evaluated additively
  110118. */
  110119. constructor(scene: Scene,
  110120. /** defines the target object */
  110121. target: any,
  110122. /** defines the starting frame number (default is 0) */
  110123. fromFrame?: number,
  110124. /** defines the ending frame number (default is 100) */
  110125. toFrame?: number,
  110126. /** defines if the animation must loop (default is false) */
  110127. loopAnimation?: boolean, speedRatio?: number,
  110128. /** defines a callback to call when animation ends if it is not looping */
  110129. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  110130. /** defines a callback to call when animation loops */
  110131. onAnimationLoop?: (() => void) | null | undefined,
  110132. /** defines whether the animation should be evaluated additively */
  110133. isAdditive?: boolean);
  110134. /**
  110135. * Synchronize and normalize current Animatable with a source Animatable
  110136. * This is useful when using animation weights and when animations are not of the same length
  110137. * @param root defines the root Animatable to synchronize with
  110138. * @returns the current Animatable
  110139. */
  110140. syncWith(root: Animatable): Animatable;
  110141. /**
  110142. * Gets the list of runtime animations
  110143. * @returns an array of RuntimeAnimation
  110144. */
  110145. getAnimations(): RuntimeAnimation[];
  110146. /**
  110147. * Adds more animations to the current animatable
  110148. * @param target defines the target of the animations
  110149. * @param animations defines the new animations to add
  110150. */
  110151. appendAnimations(target: any, animations: Animation[]): void;
  110152. /**
  110153. * Gets the source animation for a specific property
  110154. * @param property defines the propertyu to look for
  110155. * @returns null or the source animation for the given property
  110156. */
  110157. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  110158. /**
  110159. * Gets the runtime animation for a specific property
  110160. * @param property defines the propertyu to look for
  110161. * @returns null or the runtime animation for the given property
  110162. */
  110163. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  110164. /**
  110165. * Resets the animatable to its original state
  110166. */
  110167. reset(): void;
  110168. /**
  110169. * Allows the animatable to blend with current running animations
  110170. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  110171. * @param blendingSpeed defines the blending speed to use
  110172. */
  110173. enableBlending(blendingSpeed: number): void;
  110174. /**
  110175. * Disable animation blending
  110176. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  110177. */
  110178. disableBlending(): void;
  110179. /**
  110180. * Jump directly to a given frame
  110181. * @param frame defines the frame to jump to
  110182. */
  110183. goToFrame(frame: number): void;
  110184. /**
  110185. * Pause the animation
  110186. */
  110187. pause(): void;
  110188. /**
  110189. * Restart the animation
  110190. */
  110191. restart(): void;
  110192. private _raiseOnAnimationEnd;
  110193. /**
  110194. * Stop and delete the current animation
  110195. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  110196. * @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)
  110197. */
  110198. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  110199. /**
  110200. * Wait asynchronously for the animation to end
  110201. * @returns a promise which will be fullfilled when the animation ends
  110202. */
  110203. waitAsync(): Promise<Animatable>;
  110204. /** @hidden */
  110205. _animate(delay: number): boolean;
  110206. }
  110207. interface Scene {
  110208. /** @hidden */
  110209. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  110210. /** @hidden */
  110211. _processLateAnimationBindingsForMatrices(holder: {
  110212. totalWeight: number;
  110213. totalAdditiveWeight: number;
  110214. animations: RuntimeAnimation[];
  110215. additiveAnimations: RuntimeAnimation[];
  110216. originalValue: Matrix;
  110217. }): any;
  110218. /** @hidden */
  110219. _processLateAnimationBindingsForQuaternions(holder: {
  110220. totalWeight: number;
  110221. totalAdditiveWeight: number;
  110222. animations: RuntimeAnimation[];
  110223. additiveAnimations: RuntimeAnimation[];
  110224. originalValue: Quaternion;
  110225. }, refQuaternion: Quaternion): Quaternion;
  110226. /** @hidden */
  110227. _processLateAnimationBindings(): void;
  110228. /**
  110229. * Will start the animation sequence of a given target
  110230. * @param target defines the target
  110231. * @param from defines from which frame should animation start
  110232. * @param to defines until which frame should animation run.
  110233. * @param weight defines the weight to apply to the animation (1.0 by default)
  110234. * @param loop defines if the animation loops
  110235. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  110236. * @param onAnimationEnd defines the function to be executed when the animation ends
  110237. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  110238. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  110239. * @param onAnimationLoop defines the callback to call when an animation loops
  110240. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  110241. * @returns the animatable object created for this animation
  110242. */
  110243. 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;
  110244. /**
  110245. * Will start the animation sequence of a given target
  110246. * @param target defines the target
  110247. * @param from defines from which frame should animation start
  110248. * @param to defines until which frame should animation run.
  110249. * @param loop defines if the animation loops
  110250. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  110251. * @param onAnimationEnd defines the function to be executed when the animation ends
  110252. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  110253. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  110254. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  110255. * @param onAnimationLoop defines the callback to call when an animation loops
  110256. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  110257. * @returns the animatable object created for this animation
  110258. */
  110259. 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;
  110260. /**
  110261. * Will start the animation sequence of a given target and its hierarchy
  110262. * @param target defines the target
  110263. * @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.
  110264. * @param from defines from which frame should animation start
  110265. * @param to defines until which frame should animation run.
  110266. * @param loop defines if the animation loops
  110267. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  110268. * @param onAnimationEnd defines the function to be executed when the animation ends
  110269. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  110270. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  110271. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  110272. * @param onAnimationLoop defines the callback to call when an animation loops
  110273. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  110274. * @returns the list of created animatables
  110275. */
  110276. 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[];
  110277. /**
  110278. * Begin a new animation on a given node
  110279. * @param target defines the target where the animation will take place
  110280. * @param animations defines the list of animations to start
  110281. * @param from defines the initial value
  110282. * @param to defines the final value
  110283. * @param loop defines if you want animation to loop (off by default)
  110284. * @param speedRatio defines the speed ratio to apply to all animations
  110285. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  110286. * @param onAnimationLoop defines the callback to call when an animation loops
  110287. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  110288. * @returns the list of created animatables
  110289. */
  110290. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  110291. /**
  110292. * Begin a new animation on a given node and its hierarchy
  110293. * @param target defines the root node where the animation will take place
  110294. * @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.
  110295. * @param animations defines the list of animations to start
  110296. * @param from defines the initial value
  110297. * @param to defines the final value
  110298. * @param loop defines if you want animation to loop (off by default)
  110299. * @param speedRatio defines the speed ratio to apply to all animations
  110300. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  110301. * @param onAnimationLoop defines the callback to call when an animation loops
  110302. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  110303. * @returns the list of animatables created for all nodes
  110304. */
  110305. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  110306. /**
  110307. * Gets the animatable associated with a specific target
  110308. * @param target defines the target of the animatable
  110309. * @returns the required animatable if found
  110310. */
  110311. getAnimatableByTarget(target: any): Nullable<Animatable>;
  110312. /**
  110313. * Gets all animatables associated with a given target
  110314. * @param target defines the target to look animatables for
  110315. * @returns an array of Animatables
  110316. */
  110317. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  110318. /**
  110319. * Stops and removes all animations that have been applied to the scene
  110320. */
  110321. stopAllAnimations(): void;
  110322. /**
  110323. * Gets the current delta time used by animation engine
  110324. */
  110325. deltaTime: number;
  110326. }
  110327. interface Bone {
  110328. /**
  110329. * Copy an animation range from another bone
  110330. * @param source defines the source bone
  110331. * @param rangeName defines the range name to copy
  110332. * @param frameOffset defines the frame offset
  110333. * @param rescaleAsRequired defines if rescaling must be applied if required
  110334. * @param skelDimensionsRatio defines the scaling ratio
  110335. * @returns true if operation was successful
  110336. */
  110337. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  110338. }
  110339. }
  110340. declare module BABYLON {
  110341. /**
  110342. * Class used to override all child animations of a given target
  110343. */
  110344. export class AnimationPropertiesOverride {
  110345. /**
  110346. * Gets or sets a value indicating if animation blending must be used
  110347. */
  110348. enableBlending: boolean;
  110349. /**
  110350. * Gets or sets the blending speed to use when enableBlending is true
  110351. */
  110352. blendingSpeed: number;
  110353. /**
  110354. * Gets or sets the default loop mode to use
  110355. */
  110356. loopMode: number;
  110357. }
  110358. }
  110359. declare module BABYLON {
  110360. /**
  110361. * Class used to handle skinning animations
  110362. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  110363. */
  110364. export class Skeleton implements IAnimatable {
  110365. /** defines the skeleton name */
  110366. name: string;
  110367. /** defines the skeleton Id */
  110368. id: string;
  110369. /**
  110370. * Defines the list of child bones
  110371. */
  110372. bones: Bone[];
  110373. /**
  110374. * Defines an estimate of the dimension of the skeleton at rest
  110375. */
  110376. dimensionsAtRest: Vector3;
  110377. /**
  110378. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  110379. */
  110380. needInitialSkinMatrix: boolean;
  110381. /**
  110382. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  110383. */
  110384. overrideMesh: Nullable<AbstractMesh>;
  110385. /**
  110386. * Gets the list of animations attached to this skeleton
  110387. */
  110388. animations: Array<Animation>;
  110389. private _scene;
  110390. private _isDirty;
  110391. private _transformMatrices;
  110392. private _transformMatrixTexture;
  110393. private _meshesWithPoseMatrix;
  110394. private _animatables;
  110395. private _identity;
  110396. private _synchronizedWithMesh;
  110397. private _ranges;
  110398. private _lastAbsoluteTransformsUpdateId;
  110399. private _canUseTextureForBones;
  110400. private _uniqueId;
  110401. /** @hidden */
  110402. _numBonesWithLinkedTransformNode: number;
  110403. /** @hidden */
  110404. _hasWaitingData: Nullable<boolean>;
  110405. /** @hidden */
  110406. _waitingOverrideMeshId: Nullable<string>;
  110407. /**
  110408. * Specifies if the skeleton should be serialized
  110409. */
  110410. doNotSerialize: boolean;
  110411. private _useTextureToStoreBoneMatrices;
  110412. /**
  110413. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  110414. * Please note that this option is not available if the hardware does not support it
  110415. */
  110416. get useTextureToStoreBoneMatrices(): boolean;
  110417. set useTextureToStoreBoneMatrices(value: boolean);
  110418. private _animationPropertiesOverride;
  110419. /**
  110420. * Gets or sets the animation properties override
  110421. */
  110422. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  110423. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  110424. /**
  110425. * List of inspectable custom properties (used by the Inspector)
  110426. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  110427. */
  110428. inspectableCustomProperties: IInspectable[];
  110429. /**
  110430. * An observable triggered before computing the skeleton's matrices
  110431. */
  110432. onBeforeComputeObservable: Observable<Skeleton>;
  110433. /**
  110434. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  110435. */
  110436. get isUsingTextureForMatrices(): boolean;
  110437. /**
  110438. * Gets the unique ID of this skeleton
  110439. */
  110440. get uniqueId(): number;
  110441. /**
  110442. * Creates a new skeleton
  110443. * @param name defines the skeleton name
  110444. * @param id defines the skeleton Id
  110445. * @param scene defines the hosting scene
  110446. */
  110447. constructor(
  110448. /** defines the skeleton name */
  110449. name: string,
  110450. /** defines the skeleton Id */
  110451. id: string, scene: Scene);
  110452. /**
  110453. * Gets the current object class name.
  110454. * @return the class name
  110455. */
  110456. getClassName(): string;
  110457. /**
  110458. * Returns an array containing the root bones
  110459. * @returns an array containing the root bones
  110460. */
  110461. getChildren(): Array<Bone>;
  110462. /**
  110463. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  110464. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  110465. * @returns a Float32Array containing matrices data
  110466. */
  110467. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  110468. /**
  110469. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  110470. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  110471. * @returns a raw texture containing the data
  110472. */
  110473. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  110474. /**
  110475. * Gets the current hosting scene
  110476. * @returns a scene object
  110477. */
  110478. getScene(): Scene;
  110479. /**
  110480. * Gets a string representing the current skeleton data
  110481. * @param fullDetails defines a boolean indicating if we want a verbose version
  110482. * @returns a string representing the current skeleton data
  110483. */
  110484. toString(fullDetails?: boolean): string;
  110485. /**
  110486. * Get bone's index searching by name
  110487. * @param name defines bone's name to search for
  110488. * @return the indice of the bone. Returns -1 if not found
  110489. */
  110490. getBoneIndexByName(name: string): number;
  110491. /**
  110492. * Creater a new animation range
  110493. * @param name defines the name of the range
  110494. * @param from defines the start key
  110495. * @param to defines the end key
  110496. */
  110497. createAnimationRange(name: string, from: number, to: number): void;
  110498. /**
  110499. * Delete a specific animation range
  110500. * @param name defines the name of the range
  110501. * @param deleteFrames defines if frames must be removed as well
  110502. */
  110503. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  110504. /**
  110505. * Gets a specific animation range
  110506. * @param name defines the name of the range to look for
  110507. * @returns the requested animation range or null if not found
  110508. */
  110509. getAnimationRange(name: string): Nullable<AnimationRange>;
  110510. /**
  110511. * Gets the list of all animation ranges defined on this skeleton
  110512. * @returns an array
  110513. */
  110514. getAnimationRanges(): Nullable<AnimationRange>[];
  110515. /**
  110516. * Copy animation range from a source skeleton.
  110517. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  110518. * @param source defines the source skeleton
  110519. * @param name defines the name of the range to copy
  110520. * @param rescaleAsRequired defines if rescaling must be applied if required
  110521. * @returns true if operation was successful
  110522. */
  110523. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  110524. /**
  110525. * Forces the skeleton to go to rest pose
  110526. */
  110527. returnToRest(): void;
  110528. private _getHighestAnimationFrame;
  110529. /**
  110530. * Begin a specific animation range
  110531. * @param name defines the name of the range to start
  110532. * @param loop defines if looping must be turned on (false by default)
  110533. * @param speedRatio defines the speed ratio to apply (1 by default)
  110534. * @param onAnimationEnd defines a callback which will be called when animation will end
  110535. * @returns a new animatable
  110536. */
  110537. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  110538. /**
  110539. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  110540. * @param skeleton defines the Skeleton containing the animation range to convert
  110541. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  110542. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  110543. * @returns the original skeleton
  110544. */
  110545. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  110546. /** @hidden */
  110547. _markAsDirty(): void;
  110548. /** @hidden */
  110549. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  110550. /** @hidden */
  110551. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  110552. private _computeTransformMatrices;
  110553. /**
  110554. * Build all resources required to render a skeleton
  110555. */
  110556. prepare(): void;
  110557. /**
  110558. * Gets the list of animatables currently running for this skeleton
  110559. * @returns an array of animatables
  110560. */
  110561. getAnimatables(): IAnimatable[];
  110562. /**
  110563. * Clone the current skeleton
  110564. * @param name defines the name of the new skeleton
  110565. * @param id defines the id of the new skeleton
  110566. * @returns the new skeleton
  110567. */
  110568. clone(name: string, id?: string): Skeleton;
  110569. /**
  110570. * Enable animation blending for this skeleton
  110571. * @param blendingSpeed defines the blending speed to apply
  110572. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  110573. */
  110574. enableBlending(blendingSpeed?: number): void;
  110575. /**
  110576. * Releases all resources associated with the current skeleton
  110577. */
  110578. dispose(): void;
  110579. /**
  110580. * Serialize the skeleton in a JSON object
  110581. * @returns a JSON object
  110582. */
  110583. serialize(): any;
  110584. /**
  110585. * Creates a new skeleton from serialized data
  110586. * @param parsedSkeleton defines the serialized data
  110587. * @param scene defines the hosting scene
  110588. * @returns a new skeleton
  110589. */
  110590. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  110591. /**
  110592. * Compute all node absolute transforms
  110593. * @param forceUpdate defines if computation must be done even if cache is up to date
  110594. */
  110595. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  110596. /**
  110597. * Gets the root pose matrix
  110598. * @returns a matrix
  110599. */
  110600. getPoseMatrix(): Nullable<Matrix>;
  110601. /**
  110602. * Sorts bones per internal index
  110603. */
  110604. sortBones(): void;
  110605. private _sortBones;
  110606. /**
  110607. * Set the current local matrix as the restPose for all bones in the skeleton.
  110608. */
  110609. setCurrentPoseAsRest(): void;
  110610. }
  110611. }
  110612. declare module BABYLON {
  110613. /**
  110614. * Class used to store bone information
  110615. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  110616. */
  110617. export class Bone extends Node {
  110618. /**
  110619. * defines the bone name
  110620. */
  110621. name: string;
  110622. private static _tmpVecs;
  110623. private static _tmpQuat;
  110624. private static _tmpMats;
  110625. /**
  110626. * Gets the list of child bones
  110627. */
  110628. children: Bone[];
  110629. /** Gets the animations associated with this bone */
  110630. animations: Animation[];
  110631. /**
  110632. * Gets or sets bone length
  110633. */
  110634. length: number;
  110635. /**
  110636. * @hidden Internal only
  110637. * Set this value to map this bone to a different index in the transform matrices
  110638. * Set this value to -1 to exclude the bone from the transform matrices
  110639. */
  110640. _index: Nullable<number>;
  110641. private _skeleton;
  110642. private _localMatrix;
  110643. private _restPose;
  110644. private _bindPose;
  110645. private _baseMatrix;
  110646. private _absoluteTransform;
  110647. private _invertedAbsoluteTransform;
  110648. private _parent;
  110649. private _scalingDeterminant;
  110650. private _worldTransform;
  110651. private _localScaling;
  110652. private _localRotation;
  110653. private _localPosition;
  110654. private _needToDecompose;
  110655. private _needToCompose;
  110656. /** @hidden */
  110657. _linkedTransformNode: Nullable<TransformNode>;
  110658. /** @hidden */
  110659. _waitingTransformNodeId: Nullable<string>;
  110660. /** @hidden */
  110661. get _matrix(): Matrix;
  110662. /** @hidden */
  110663. set _matrix(value: Matrix);
  110664. /**
  110665. * Create a new bone
  110666. * @param name defines the bone name
  110667. * @param skeleton defines the parent skeleton
  110668. * @param parentBone defines the parent (can be null if the bone is the root)
  110669. * @param localMatrix defines the local matrix
  110670. * @param restPose defines the rest pose matrix
  110671. * @param baseMatrix defines the base matrix
  110672. * @param index defines index of the bone in the hiearchy
  110673. */
  110674. constructor(
  110675. /**
  110676. * defines the bone name
  110677. */
  110678. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  110679. /**
  110680. * Gets the current object class name.
  110681. * @return the class name
  110682. */
  110683. getClassName(): string;
  110684. /**
  110685. * Gets the parent skeleton
  110686. * @returns a skeleton
  110687. */
  110688. getSkeleton(): Skeleton;
  110689. /**
  110690. * Gets parent bone
  110691. * @returns a bone or null if the bone is the root of the bone hierarchy
  110692. */
  110693. getParent(): Nullable<Bone>;
  110694. /**
  110695. * Returns an array containing the root bones
  110696. * @returns an array containing the root bones
  110697. */
  110698. getChildren(): Array<Bone>;
  110699. /**
  110700. * Gets the node index in matrix array generated for rendering
  110701. * @returns the node index
  110702. */
  110703. getIndex(): number;
  110704. /**
  110705. * Sets the parent bone
  110706. * @param parent defines the parent (can be null if the bone is the root)
  110707. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  110708. */
  110709. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  110710. /**
  110711. * Gets the local matrix
  110712. * @returns a matrix
  110713. */
  110714. getLocalMatrix(): Matrix;
  110715. /**
  110716. * Gets the base matrix (initial matrix which remains unchanged)
  110717. * @returns a matrix
  110718. */
  110719. getBaseMatrix(): Matrix;
  110720. /**
  110721. * Gets the rest pose matrix
  110722. * @returns a matrix
  110723. */
  110724. getRestPose(): Matrix;
  110725. /**
  110726. * Sets the rest pose matrix
  110727. * @param matrix the local-space rest pose to set for this bone
  110728. */
  110729. setRestPose(matrix: Matrix): void;
  110730. /**
  110731. * Gets the bind pose matrix
  110732. * @returns the bind pose matrix
  110733. */
  110734. getBindPose(): Matrix;
  110735. /**
  110736. * Sets the bind pose matrix
  110737. * @param matrix the local-space bind pose to set for this bone
  110738. */
  110739. setBindPose(matrix: Matrix): void;
  110740. /**
  110741. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  110742. */
  110743. getWorldMatrix(): Matrix;
  110744. /**
  110745. * Sets the local matrix to rest pose matrix
  110746. */
  110747. returnToRest(): void;
  110748. /**
  110749. * Gets the inverse of the absolute transform matrix.
  110750. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  110751. * @returns a matrix
  110752. */
  110753. getInvertedAbsoluteTransform(): Matrix;
  110754. /**
  110755. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  110756. * @returns a matrix
  110757. */
  110758. getAbsoluteTransform(): Matrix;
  110759. /**
  110760. * Links with the given transform node.
  110761. * The local matrix of this bone is copied from the transform node every frame.
  110762. * @param transformNode defines the transform node to link to
  110763. */
  110764. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  110765. /**
  110766. * Gets the node used to drive the bone's transformation
  110767. * @returns a transform node or null
  110768. */
  110769. getTransformNode(): Nullable<TransformNode>;
  110770. /** Gets or sets current position (in local space) */
  110771. get position(): Vector3;
  110772. set position(newPosition: Vector3);
  110773. /** Gets or sets current rotation (in local space) */
  110774. get rotation(): Vector3;
  110775. set rotation(newRotation: Vector3);
  110776. /** Gets or sets current rotation quaternion (in local space) */
  110777. get rotationQuaternion(): Quaternion;
  110778. set rotationQuaternion(newRotation: Quaternion);
  110779. /** Gets or sets current scaling (in local space) */
  110780. get scaling(): Vector3;
  110781. set scaling(newScaling: Vector3);
  110782. /**
  110783. * Gets the animation properties override
  110784. */
  110785. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  110786. private _decompose;
  110787. private _compose;
  110788. /**
  110789. * Update the base and local matrices
  110790. * @param matrix defines the new base or local matrix
  110791. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  110792. * @param updateLocalMatrix defines if the local matrix should be updated
  110793. */
  110794. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  110795. /** @hidden */
  110796. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  110797. /**
  110798. * Flag the bone as dirty (Forcing it to update everything)
  110799. */
  110800. markAsDirty(): void;
  110801. /** @hidden */
  110802. _markAsDirtyAndCompose(): void;
  110803. private _markAsDirtyAndDecompose;
  110804. /**
  110805. * Translate the bone in local or world space
  110806. * @param vec The amount to translate the bone
  110807. * @param space The space that the translation is in
  110808. * @param mesh The mesh that this bone is attached to. This is only used in world space
  110809. */
  110810. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  110811. /**
  110812. * Set the postion of the bone in local or world space
  110813. * @param position The position to set the bone
  110814. * @param space The space that the position is in
  110815. * @param mesh The mesh that this bone is attached to. This is only used in world space
  110816. */
  110817. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  110818. /**
  110819. * Set the absolute position of the bone (world space)
  110820. * @param position The position to set the bone
  110821. * @param mesh The mesh that this bone is attached to
  110822. */
  110823. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  110824. /**
  110825. * Scale the bone on the x, y and z axes (in local space)
  110826. * @param x The amount to scale the bone on the x axis
  110827. * @param y The amount to scale the bone on the y axis
  110828. * @param z The amount to scale the bone on the z axis
  110829. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  110830. */
  110831. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  110832. /**
  110833. * Set the bone scaling in local space
  110834. * @param scale defines the scaling vector
  110835. */
  110836. setScale(scale: Vector3): void;
  110837. /**
  110838. * Gets the current scaling in local space
  110839. * @returns the current scaling vector
  110840. */
  110841. getScale(): Vector3;
  110842. /**
  110843. * Gets the current scaling in local space and stores it in a target vector
  110844. * @param result defines the target vector
  110845. */
  110846. getScaleToRef(result: Vector3): void;
  110847. /**
  110848. * Set the yaw, pitch, and roll of the bone in local or world space
  110849. * @param yaw The rotation of the bone on the y axis
  110850. * @param pitch The rotation of the bone on the x axis
  110851. * @param roll The rotation of the bone on the z axis
  110852. * @param space The space that the axes of rotation are in
  110853. * @param mesh The mesh that this bone is attached to. This is only used in world space
  110854. */
  110855. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  110856. /**
  110857. * Add a rotation to the bone on an axis in local or world space
  110858. * @param axis The axis to rotate the bone on
  110859. * @param amount The amount to rotate the bone
  110860. * @param space The space that the axis is in
  110861. * @param mesh The mesh that this bone is attached to. This is only used in world space
  110862. */
  110863. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  110864. /**
  110865. * Set the rotation of the bone to a particular axis angle in local or world space
  110866. * @param axis The axis to rotate the bone on
  110867. * @param angle The angle that the bone should be rotated to
  110868. * @param space The space that the axis is in
  110869. * @param mesh The mesh that this bone is attached to. This is only used in world space
  110870. */
  110871. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  110872. /**
  110873. * Set the euler rotation of the bone in local or world space
  110874. * @param rotation The euler rotation that the bone should be set to
  110875. * @param space The space that the rotation is in
  110876. * @param mesh The mesh that this bone is attached to. This is only used in world space
  110877. */
  110878. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  110879. /**
  110880. * Set the quaternion rotation of the bone in local or world space
  110881. * @param quat The quaternion rotation that the bone should be set to
  110882. * @param space The space that the rotation is in
  110883. * @param mesh The mesh that this bone is attached to. This is only used in world space
  110884. */
  110885. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  110886. /**
  110887. * Set the rotation matrix of the bone in local or world space
  110888. * @param rotMat The rotation matrix that the bone should be set to
  110889. * @param space The space that the rotation is in
  110890. * @param mesh The mesh that this bone is attached to. This is only used in world space
  110891. */
  110892. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  110893. private _rotateWithMatrix;
  110894. private _getNegativeRotationToRef;
  110895. /**
  110896. * Get the position of the bone in local or world space
  110897. * @param space The space that the returned position is in
  110898. * @param mesh The mesh that this bone is attached to. This is only used in world space
  110899. * @returns The position of the bone
  110900. */
  110901. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  110902. /**
  110903. * Copy the position of the bone to a vector3 in local or world space
  110904. * @param space The space that the returned position is in
  110905. * @param mesh The mesh that this bone is attached to. This is only used in world space
  110906. * @param result The vector3 to copy the position to
  110907. */
  110908. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  110909. /**
  110910. * Get the absolute position of the bone (world space)
  110911. * @param mesh The mesh that this bone is attached to
  110912. * @returns The absolute position of the bone
  110913. */
  110914. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  110915. /**
  110916. * Copy the absolute position of the bone (world space) to the result param
  110917. * @param mesh The mesh that this bone is attached to
  110918. * @param result The vector3 to copy the absolute position to
  110919. */
  110920. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  110921. /**
  110922. * Compute the absolute transforms of this bone and its children
  110923. */
  110924. computeAbsoluteTransforms(): void;
  110925. /**
  110926. * Get the world direction from an axis that is in the local space of the bone
  110927. * @param localAxis The local direction that is used to compute the world direction
  110928. * @param mesh The mesh that this bone is attached to
  110929. * @returns The world direction
  110930. */
  110931. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  110932. /**
  110933. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  110934. * @param localAxis The local direction that is used to compute the world direction
  110935. * @param mesh The mesh that this bone is attached to
  110936. * @param result The vector3 that the world direction will be copied to
  110937. */
  110938. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  110939. /**
  110940. * Get the euler rotation of the bone in local or world space
  110941. * @param space The space that the rotation should be in
  110942. * @param mesh The mesh that this bone is attached to. This is only used in world space
  110943. * @returns The euler rotation
  110944. */
  110945. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  110946. /**
  110947. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  110948. * @param space The space that the rotation should be in
  110949. * @param mesh The mesh that this bone is attached to. This is only used in world space
  110950. * @param result The vector3 that the rotation should be copied to
  110951. */
  110952. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  110953. /**
  110954. * Get the quaternion rotation of the bone in either local or world space
  110955. * @param space The space that the rotation should be in
  110956. * @param mesh The mesh that this bone is attached to. This is only used in world space
  110957. * @returns The quaternion rotation
  110958. */
  110959. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  110960. /**
  110961. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  110962. * @param space The space that the rotation should be in
  110963. * @param mesh The mesh that this bone is attached to. This is only used in world space
  110964. * @param result The quaternion that the rotation should be copied to
  110965. */
  110966. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  110967. /**
  110968. * Get the rotation matrix of the bone in local or world space
  110969. * @param space The space that the rotation should be in
  110970. * @param mesh The mesh that this bone is attached to. This is only used in world space
  110971. * @returns The rotation matrix
  110972. */
  110973. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  110974. /**
  110975. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  110976. * @param space The space that the rotation should be in
  110977. * @param mesh The mesh that this bone is attached to. This is only used in world space
  110978. * @param result The quaternion that the rotation should be copied to
  110979. */
  110980. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  110981. /**
  110982. * Get the world position of a point that is in the local space of the bone
  110983. * @param position The local position
  110984. * @param mesh The mesh that this bone is attached to
  110985. * @returns The world position
  110986. */
  110987. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  110988. /**
  110989. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  110990. * @param position The local position
  110991. * @param mesh The mesh that this bone is attached to
  110992. * @param result The vector3 that the world position should be copied to
  110993. */
  110994. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  110995. /**
  110996. * Get the local position of a point that is in world space
  110997. * @param position The world position
  110998. * @param mesh The mesh that this bone is attached to
  110999. * @returns The local position
  111000. */
  111001. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  111002. /**
  111003. * Get the local position of a point that is in world space and copy it to the result param
  111004. * @param position The world position
  111005. * @param mesh The mesh that this bone is attached to
  111006. * @param result The vector3 that the local position should be copied to
  111007. */
  111008. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  111009. /**
  111010. * Set the current local matrix as the restPose for this bone.
  111011. */
  111012. setCurrentPoseAsRest(): void;
  111013. }
  111014. }
  111015. declare module BABYLON {
  111016. /**
  111017. * 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.
  111018. * @see https://doc.babylonjs.com/how_to/transformnode
  111019. */
  111020. export class TransformNode extends Node {
  111021. /**
  111022. * Object will not rotate to face the camera
  111023. */
  111024. static BILLBOARDMODE_NONE: number;
  111025. /**
  111026. * Object will rotate to face the camera but only on the x axis
  111027. */
  111028. static BILLBOARDMODE_X: number;
  111029. /**
  111030. * Object will rotate to face the camera but only on the y axis
  111031. */
  111032. static BILLBOARDMODE_Y: number;
  111033. /**
  111034. * Object will rotate to face the camera but only on the z axis
  111035. */
  111036. static BILLBOARDMODE_Z: number;
  111037. /**
  111038. * Object will rotate to face the camera
  111039. */
  111040. static BILLBOARDMODE_ALL: number;
  111041. /**
  111042. * Object will rotate to face the camera's position instead of orientation
  111043. */
  111044. static BILLBOARDMODE_USE_POSITION: number;
  111045. private static _TmpRotation;
  111046. private static _TmpScaling;
  111047. private static _TmpTranslation;
  111048. private _forward;
  111049. private _forwardInverted;
  111050. private _up;
  111051. private _right;
  111052. private _rightInverted;
  111053. private _position;
  111054. private _rotation;
  111055. private _rotationQuaternion;
  111056. protected _scaling: Vector3;
  111057. protected _isDirty: boolean;
  111058. private _transformToBoneReferal;
  111059. private _isAbsoluteSynced;
  111060. private _billboardMode;
  111061. /**
  111062. * Gets or sets the billboard mode. Default is 0.
  111063. *
  111064. * | Value | Type | Description |
  111065. * | --- | --- | --- |
  111066. * | 0 | BILLBOARDMODE_NONE | |
  111067. * | 1 | BILLBOARDMODE_X | |
  111068. * | 2 | BILLBOARDMODE_Y | |
  111069. * | 4 | BILLBOARDMODE_Z | |
  111070. * | 7 | BILLBOARDMODE_ALL | |
  111071. *
  111072. */
  111073. get billboardMode(): number;
  111074. set billboardMode(value: number);
  111075. private _preserveParentRotationForBillboard;
  111076. /**
  111077. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  111078. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  111079. */
  111080. get preserveParentRotationForBillboard(): boolean;
  111081. set preserveParentRotationForBillboard(value: boolean);
  111082. /**
  111083. * 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
  111084. */
  111085. scalingDeterminant: number;
  111086. private _infiniteDistance;
  111087. /**
  111088. * Gets or sets the distance of the object to max, often used by skybox
  111089. */
  111090. get infiniteDistance(): boolean;
  111091. set infiniteDistance(value: boolean);
  111092. /**
  111093. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  111094. * By default the system will update normals to compensate
  111095. */
  111096. ignoreNonUniformScaling: boolean;
  111097. /**
  111098. * 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
  111099. */
  111100. reIntegrateRotationIntoRotationQuaternion: boolean;
  111101. /** @hidden */
  111102. _poseMatrix: Nullable<Matrix>;
  111103. /** @hidden */
  111104. _localMatrix: Matrix;
  111105. private _usePivotMatrix;
  111106. private _absolutePosition;
  111107. private _absoluteScaling;
  111108. private _absoluteRotationQuaternion;
  111109. private _pivotMatrix;
  111110. private _pivotMatrixInverse;
  111111. /** @hidden */
  111112. _postMultiplyPivotMatrix: boolean;
  111113. protected _isWorldMatrixFrozen: boolean;
  111114. /** @hidden */
  111115. _indexInSceneTransformNodesArray: number;
  111116. /**
  111117. * An event triggered after the world matrix is updated
  111118. */
  111119. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  111120. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  111121. /**
  111122. * Gets a string identifying the name of the class
  111123. * @returns "TransformNode" string
  111124. */
  111125. getClassName(): string;
  111126. /**
  111127. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  111128. */
  111129. get position(): Vector3;
  111130. set position(newPosition: Vector3);
  111131. /**
  111132. * 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)).
  111133. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  111134. */
  111135. get rotation(): Vector3;
  111136. set rotation(newRotation: Vector3);
  111137. /**
  111138. * 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)).
  111139. */
  111140. get scaling(): Vector3;
  111141. set scaling(newScaling: Vector3);
  111142. /**
  111143. * 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).
  111144. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  111145. */
  111146. get rotationQuaternion(): Nullable<Quaternion>;
  111147. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  111148. /**
  111149. * The forward direction of that transform in world space.
  111150. */
  111151. get forward(): Vector3;
  111152. /**
  111153. * The up direction of that transform in world space.
  111154. */
  111155. get up(): Vector3;
  111156. /**
  111157. * The right direction of that transform in world space.
  111158. */
  111159. get right(): Vector3;
  111160. /**
  111161. * Copies the parameter passed Matrix into the mesh Pose matrix.
  111162. * @param matrix the matrix to copy the pose from
  111163. * @returns this TransformNode.
  111164. */
  111165. updatePoseMatrix(matrix: Matrix): TransformNode;
  111166. /**
  111167. * Returns the mesh Pose matrix.
  111168. * @returns the pose matrix
  111169. */
  111170. getPoseMatrix(): Matrix;
  111171. /** @hidden */
  111172. _isSynchronized(): boolean;
  111173. /** @hidden */
  111174. _initCache(): void;
  111175. /**
  111176. * Flag the transform node as dirty (Forcing it to update everything)
  111177. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  111178. * @returns this transform node
  111179. */
  111180. markAsDirty(property: string): TransformNode;
  111181. /**
  111182. * Returns the current mesh absolute position.
  111183. * Returns a Vector3.
  111184. */
  111185. get absolutePosition(): Vector3;
  111186. /**
  111187. * Returns the current mesh absolute scaling.
  111188. * Returns a Vector3.
  111189. */
  111190. get absoluteScaling(): Vector3;
  111191. /**
  111192. * Returns the current mesh absolute rotation.
  111193. * Returns a Quaternion.
  111194. */
  111195. get absoluteRotationQuaternion(): Quaternion;
  111196. /**
  111197. * Sets a new matrix to apply before all other transformation
  111198. * @param matrix defines the transform matrix
  111199. * @returns the current TransformNode
  111200. */
  111201. setPreTransformMatrix(matrix: Matrix): TransformNode;
  111202. /**
  111203. * Sets a new pivot matrix to the current node
  111204. * @param matrix defines the new pivot matrix to use
  111205. * @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
  111206. * @returns the current TransformNode
  111207. */
  111208. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  111209. /**
  111210. * Returns the mesh pivot matrix.
  111211. * Default : Identity.
  111212. * @returns the matrix
  111213. */
  111214. getPivotMatrix(): Matrix;
  111215. /**
  111216. * Instantiate (when possible) or clone that node with its hierarchy
  111217. * @param newParent defines the new parent to use for the instance (or clone)
  111218. * @param options defines options to configure how copy is done
  111219. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  111220. * @returns an instance (or a clone) of the current node with its hiearchy
  111221. */
  111222. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  111223. doNotInstantiate: boolean;
  111224. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  111225. /**
  111226. * Prevents the World matrix to be computed any longer
  111227. * @param newWorldMatrix defines an optional matrix to use as world matrix
  111228. * @returns the TransformNode.
  111229. */
  111230. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  111231. /**
  111232. * Allows back the World matrix computation.
  111233. * @returns the TransformNode.
  111234. */
  111235. unfreezeWorldMatrix(): this;
  111236. /**
  111237. * True if the World matrix has been frozen.
  111238. */
  111239. get isWorldMatrixFrozen(): boolean;
  111240. /**
  111241. * Retuns the mesh absolute position in the World.
  111242. * @returns a Vector3.
  111243. */
  111244. getAbsolutePosition(): Vector3;
  111245. /**
  111246. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  111247. * @param absolutePosition the absolute position to set
  111248. * @returns the TransformNode.
  111249. */
  111250. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  111251. /**
  111252. * Sets the mesh position in its local space.
  111253. * @param vector3 the position to set in localspace
  111254. * @returns the TransformNode.
  111255. */
  111256. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  111257. /**
  111258. * Returns the mesh position in the local space from the current World matrix values.
  111259. * @returns a new Vector3.
  111260. */
  111261. getPositionExpressedInLocalSpace(): Vector3;
  111262. /**
  111263. * Translates the mesh along the passed Vector3 in its local space.
  111264. * @param vector3 the distance to translate in localspace
  111265. * @returns the TransformNode.
  111266. */
  111267. locallyTranslate(vector3: Vector3): TransformNode;
  111268. private static _lookAtVectorCache;
  111269. /**
  111270. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  111271. * @param targetPoint the position (must be in same space as current mesh) to look at
  111272. * @param yawCor optional yaw (y-axis) correction in radians
  111273. * @param pitchCor optional pitch (x-axis) correction in radians
  111274. * @param rollCor optional roll (z-axis) correction in radians
  111275. * @param space the choosen space of the target
  111276. * @returns the TransformNode.
  111277. */
  111278. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  111279. /**
  111280. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  111281. * This Vector3 is expressed in the World space.
  111282. * @param localAxis axis to rotate
  111283. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  111284. */
  111285. getDirection(localAxis: Vector3): Vector3;
  111286. /**
  111287. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  111288. * localAxis is expressed in the mesh local space.
  111289. * result is computed in the Wordl space from the mesh World matrix.
  111290. * @param localAxis axis to rotate
  111291. * @param result the resulting transformnode
  111292. * @returns this TransformNode.
  111293. */
  111294. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  111295. /**
  111296. * Sets this transform node rotation to the given local axis.
  111297. * @param localAxis the axis in local space
  111298. * @param yawCor optional yaw (y-axis) correction in radians
  111299. * @param pitchCor optional pitch (x-axis) correction in radians
  111300. * @param rollCor optional roll (z-axis) correction in radians
  111301. * @returns this TransformNode
  111302. */
  111303. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  111304. /**
  111305. * Sets a new pivot point to the current node
  111306. * @param point defines the new pivot point to use
  111307. * @param space defines if the point is in world or local space (local by default)
  111308. * @returns the current TransformNode
  111309. */
  111310. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  111311. /**
  111312. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  111313. * @returns the pivot point
  111314. */
  111315. getPivotPoint(): Vector3;
  111316. /**
  111317. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  111318. * @param result the vector3 to store the result
  111319. * @returns this TransformNode.
  111320. */
  111321. getPivotPointToRef(result: Vector3): TransformNode;
  111322. /**
  111323. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  111324. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  111325. */
  111326. getAbsolutePivotPoint(): Vector3;
  111327. /**
  111328. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  111329. * @param result vector3 to store the result
  111330. * @returns this TransformNode.
  111331. */
  111332. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  111333. /**
  111334. * Defines the passed node as the parent of the current node.
  111335. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  111336. * @see https://doc.babylonjs.com/how_to/parenting
  111337. * @param node the node ot set as the parent
  111338. * @returns this TransformNode.
  111339. */
  111340. setParent(node: Nullable<Node>): TransformNode;
  111341. private _nonUniformScaling;
  111342. /**
  111343. * True if the scaling property of this object is non uniform eg. (1,2,1)
  111344. */
  111345. get nonUniformScaling(): boolean;
  111346. /** @hidden */
  111347. _updateNonUniformScalingState(value: boolean): boolean;
  111348. /**
  111349. * Attach the current TransformNode to another TransformNode associated with a bone
  111350. * @param bone Bone affecting the TransformNode
  111351. * @param affectedTransformNode TransformNode associated with the bone
  111352. * @returns this object
  111353. */
  111354. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  111355. /**
  111356. * Detach the transform node if its associated with a bone
  111357. * @returns this object
  111358. */
  111359. detachFromBone(): TransformNode;
  111360. private static _rotationAxisCache;
  111361. /**
  111362. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  111363. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  111364. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  111365. * The passed axis is also normalized.
  111366. * @param axis the axis to rotate around
  111367. * @param amount the amount to rotate in radians
  111368. * @param space Space to rotate in (Default: local)
  111369. * @returns the TransformNode.
  111370. */
  111371. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  111372. /**
  111373. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  111374. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  111375. * The passed axis is also normalized. .
  111376. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  111377. * @param point the point to rotate around
  111378. * @param axis the axis to rotate around
  111379. * @param amount the amount to rotate in radians
  111380. * @returns the TransformNode
  111381. */
  111382. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  111383. /**
  111384. * Translates the mesh along the axis vector for the passed distance in the given space.
  111385. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  111386. * @param axis the axis to translate in
  111387. * @param distance the distance to translate
  111388. * @param space Space to rotate in (Default: local)
  111389. * @returns the TransformNode.
  111390. */
  111391. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  111392. /**
  111393. * Adds a rotation step to the mesh current rotation.
  111394. * x, y, z are Euler angles expressed in radians.
  111395. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  111396. * This means this rotation is made in the mesh local space only.
  111397. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  111398. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  111399. * ```javascript
  111400. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  111401. * ```
  111402. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  111403. * 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.
  111404. * @param x Rotation to add
  111405. * @param y Rotation to add
  111406. * @param z Rotation to add
  111407. * @returns the TransformNode.
  111408. */
  111409. addRotation(x: number, y: number, z: number): TransformNode;
  111410. /**
  111411. * @hidden
  111412. */
  111413. protected _getEffectiveParent(): Nullable<Node>;
  111414. /**
  111415. * Computes the world matrix of the node
  111416. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  111417. * @returns the world matrix
  111418. */
  111419. computeWorldMatrix(force?: boolean): Matrix;
  111420. /**
  111421. * Resets this nodeTransform's local matrix to Matrix.Identity().
  111422. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  111423. */
  111424. resetLocalMatrix(independentOfChildren?: boolean): void;
  111425. protected _afterComputeWorldMatrix(): void;
  111426. /**
  111427. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  111428. * @param func callback function to add
  111429. *
  111430. * @returns the TransformNode.
  111431. */
  111432. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  111433. /**
  111434. * Removes a registered callback function.
  111435. * @param func callback function to remove
  111436. * @returns the TransformNode.
  111437. */
  111438. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  111439. /**
  111440. * Gets the position of the current mesh in camera space
  111441. * @param camera defines the camera to use
  111442. * @returns a position
  111443. */
  111444. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  111445. /**
  111446. * Returns the distance from the mesh to the active camera
  111447. * @param camera defines the camera to use
  111448. * @returns the distance
  111449. */
  111450. getDistanceToCamera(camera?: Nullable<Camera>): number;
  111451. /**
  111452. * Clone the current transform node
  111453. * @param name Name of the new clone
  111454. * @param newParent New parent for the clone
  111455. * @param doNotCloneChildren Do not clone children hierarchy
  111456. * @returns the new transform node
  111457. */
  111458. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  111459. /**
  111460. * Serializes the objects information.
  111461. * @param currentSerializationObject defines the object to serialize in
  111462. * @returns the serialized object
  111463. */
  111464. serialize(currentSerializationObject?: any): any;
  111465. /**
  111466. * Returns a new TransformNode object parsed from the source provided.
  111467. * @param parsedTransformNode is the source.
  111468. * @param scene the scne the object belongs to
  111469. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  111470. * @returns a new TransformNode object parsed from the source provided.
  111471. */
  111472. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  111473. /**
  111474. * Get all child-transformNodes of this node
  111475. * @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
  111476. * @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
  111477. * @returns an array of TransformNode
  111478. */
  111479. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  111480. /**
  111481. * Releases resources associated with this transform node.
  111482. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  111483. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  111484. */
  111485. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  111486. /**
  111487. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  111488. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  111489. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  111490. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  111491. * @returns the current mesh
  111492. */
  111493. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  111494. private _syncAbsoluteScalingAndRotation;
  111495. }
  111496. }
  111497. declare module BABYLON {
  111498. /**
  111499. * Defines the types of pose enabled controllers that are supported
  111500. */
  111501. export enum PoseEnabledControllerType {
  111502. /**
  111503. * HTC Vive
  111504. */
  111505. VIVE = 0,
  111506. /**
  111507. * Oculus Rift
  111508. */
  111509. OCULUS = 1,
  111510. /**
  111511. * Windows mixed reality
  111512. */
  111513. WINDOWS = 2,
  111514. /**
  111515. * Samsung gear VR
  111516. */
  111517. GEAR_VR = 3,
  111518. /**
  111519. * Google Daydream
  111520. */
  111521. DAYDREAM = 4,
  111522. /**
  111523. * Generic
  111524. */
  111525. GENERIC = 5
  111526. }
  111527. /**
  111528. * Defines the MutableGamepadButton interface for the state of a gamepad button
  111529. */
  111530. export interface MutableGamepadButton {
  111531. /**
  111532. * Value of the button/trigger
  111533. */
  111534. value: number;
  111535. /**
  111536. * If the button/trigger is currently touched
  111537. */
  111538. touched: boolean;
  111539. /**
  111540. * If the button/trigger is currently pressed
  111541. */
  111542. pressed: boolean;
  111543. }
  111544. /**
  111545. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  111546. * @hidden
  111547. */
  111548. export interface ExtendedGamepadButton extends GamepadButton {
  111549. /**
  111550. * If the button/trigger is currently pressed
  111551. */
  111552. readonly pressed: boolean;
  111553. /**
  111554. * If the button/trigger is currently touched
  111555. */
  111556. readonly touched: boolean;
  111557. /**
  111558. * Value of the button/trigger
  111559. */
  111560. readonly value: number;
  111561. }
  111562. /** @hidden */
  111563. export interface _GamePadFactory {
  111564. /**
  111565. * Returns whether or not the current gamepad can be created for this type of controller.
  111566. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  111567. * @returns true if it can be created, otherwise false
  111568. */
  111569. canCreate(gamepadInfo: any): boolean;
  111570. /**
  111571. * Creates a new instance of the Gamepad.
  111572. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  111573. * @returns the new gamepad instance
  111574. */
  111575. create(gamepadInfo: any): Gamepad;
  111576. }
  111577. /**
  111578. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  111579. */
  111580. export class PoseEnabledControllerHelper {
  111581. /** @hidden */
  111582. static _ControllerFactories: _GamePadFactory[];
  111583. /** @hidden */
  111584. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  111585. /**
  111586. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  111587. * @param vrGamepad the gamepad to initialized
  111588. * @returns a vr controller of the type the gamepad identified as
  111589. */
  111590. static InitiateController(vrGamepad: any): Gamepad;
  111591. }
  111592. /**
  111593. * Defines the PoseEnabledController object that contains state of a vr capable controller
  111594. */
  111595. export class PoseEnabledController extends Gamepad implements PoseControlled {
  111596. /**
  111597. * If the controller is used in a webXR session
  111598. */
  111599. isXR: boolean;
  111600. private _deviceRoomPosition;
  111601. private _deviceRoomRotationQuaternion;
  111602. /**
  111603. * The device position in babylon space
  111604. */
  111605. devicePosition: Vector3;
  111606. /**
  111607. * The device rotation in babylon space
  111608. */
  111609. deviceRotationQuaternion: Quaternion;
  111610. /**
  111611. * The scale factor of the device in babylon space
  111612. */
  111613. deviceScaleFactor: number;
  111614. /**
  111615. * (Likely devicePosition should be used instead) The device position in its room space
  111616. */
  111617. position: Vector3;
  111618. /**
  111619. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  111620. */
  111621. rotationQuaternion: Quaternion;
  111622. /**
  111623. * The type of controller (Eg. Windows mixed reality)
  111624. */
  111625. controllerType: PoseEnabledControllerType;
  111626. protected _calculatedPosition: Vector3;
  111627. private _calculatedRotation;
  111628. /**
  111629. * The raw pose from the device
  111630. */
  111631. rawPose: DevicePose;
  111632. private _trackPosition;
  111633. private _maxRotationDistFromHeadset;
  111634. private _draggedRoomRotation;
  111635. /**
  111636. * @hidden
  111637. */
  111638. _disableTrackPosition(fixedPosition: Vector3): void;
  111639. /**
  111640. * Internal, the mesh attached to the controller
  111641. * @hidden
  111642. */
  111643. _mesh: Nullable<AbstractMesh>;
  111644. private _poseControlledCamera;
  111645. private _leftHandSystemQuaternion;
  111646. /**
  111647. * Internal, matrix used to convert room space to babylon space
  111648. * @hidden
  111649. */
  111650. _deviceToWorld: Matrix;
  111651. /**
  111652. * Node to be used when casting a ray from the controller
  111653. * @hidden
  111654. */
  111655. _pointingPoseNode: Nullable<TransformNode>;
  111656. /**
  111657. * Name of the child mesh that can be used to cast a ray from the controller
  111658. */
  111659. static readonly POINTING_POSE: string;
  111660. /**
  111661. * Creates a new PoseEnabledController from a gamepad
  111662. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  111663. */
  111664. constructor(browserGamepad: any);
  111665. private _workingMatrix;
  111666. /**
  111667. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  111668. */
  111669. update(): void;
  111670. /**
  111671. * Updates only the pose device and mesh without doing any button event checking
  111672. */
  111673. protected _updatePoseAndMesh(): void;
  111674. /**
  111675. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  111676. * @param poseData raw pose fromthe device
  111677. */
  111678. updateFromDevice(poseData: DevicePose): void;
  111679. /**
  111680. * @hidden
  111681. */
  111682. _meshAttachedObservable: Observable<AbstractMesh>;
  111683. /**
  111684. * Attaches a mesh to the controller
  111685. * @param mesh the mesh to be attached
  111686. */
  111687. attachToMesh(mesh: AbstractMesh): void;
  111688. /**
  111689. * Attaches the controllers mesh to a camera
  111690. * @param camera the camera the mesh should be attached to
  111691. */
  111692. attachToPoseControlledCamera(camera: TargetCamera): void;
  111693. /**
  111694. * Disposes of the controller
  111695. */
  111696. dispose(): void;
  111697. /**
  111698. * The mesh that is attached to the controller
  111699. */
  111700. get mesh(): Nullable<AbstractMesh>;
  111701. /**
  111702. * Gets the ray of the controller in the direction the controller is pointing
  111703. * @param length the length the resulting ray should be
  111704. * @returns a ray in the direction the controller is pointing
  111705. */
  111706. getForwardRay(length?: number): Ray;
  111707. }
  111708. }
  111709. declare module BABYLON {
  111710. /**
  111711. * Defines the WebVRController object that represents controllers tracked in 3D space
  111712. */
  111713. export abstract class WebVRController extends PoseEnabledController {
  111714. /**
  111715. * Internal, the default controller model for the controller
  111716. */
  111717. protected _defaultModel: Nullable<AbstractMesh>;
  111718. /**
  111719. * Fired when the trigger state has changed
  111720. */
  111721. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  111722. /**
  111723. * Fired when the main button state has changed
  111724. */
  111725. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111726. /**
  111727. * Fired when the secondary button state has changed
  111728. */
  111729. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111730. /**
  111731. * Fired when the pad state has changed
  111732. */
  111733. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  111734. /**
  111735. * Fired when controllers stick values have changed
  111736. */
  111737. onPadValuesChangedObservable: Observable<StickValues>;
  111738. /**
  111739. * Array of button availible on the controller
  111740. */
  111741. protected _buttons: Array<MutableGamepadButton>;
  111742. private _onButtonStateChange;
  111743. /**
  111744. * Fired when a controller button's state has changed
  111745. * @param callback the callback containing the button that was modified
  111746. */
  111747. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  111748. /**
  111749. * X and Y axis corresponding to the controllers joystick
  111750. */
  111751. pad: StickValues;
  111752. /**
  111753. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  111754. */
  111755. hand: string;
  111756. /**
  111757. * The default controller model for the controller
  111758. */
  111759. get defaultModel(): Nullable<AbstractMesh>;
  111760. /**
  111761. * Creates a new WebVRController from a gamepad
  111762. * @param vrGamepad the gamepad that the WebVRController should be created from
  111763. */
  111764. constructor(vrGamepad: any);
  111765. /**
  111766. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  111767. */
  111768. update(): void;
  111769. /**
  111770. * Function to be called when a button is modified
  111771. */
  111772. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111773. /**
  111774. * Loads a mesh and attaches it to the controller
  111775. * @param scene the scene the mesh should be added to
  111776. * @param meshLoaded callback for when the mesh has been loaded
  111777. */
  111778. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111779. private _setButtonValue;
  111780. private _changes;
  111781. private _checkChanges;
  111782. /**
  111783. * Disposes of th webVRCOntroller
  111784. */
  111785. dispose(): void;
  111786. }
  111787. }
  111788. declare module BABYLON {
  111789. /**
  111790. * The HemisphericLight simulates the ambient environment light,
  111791. * so the passed direction is the light reflection direction, not the incoming direction.
  111792. */
  111793. export class HemisphericLight extends Light {
  111794. /**
  111795. * The groundColor is the light in the opposite direction to the one specified during creation.
  111796. * 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.
  111797. */
  111798. groundColor: Color3;
  111799. /**
  111800. * The light reflection direction, not the incoming direction.
  111801. */
  111802. direction: Vector3;
  111803. /**
  111804. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  111805. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  111806. * The HemisphericLight can't cast shadows.
  111807. * Documentation : https://doc.babylonjs.com/babylon101/lights
  111808. * @param name The friendly name of the light
  111809. * @param direction The direction of the light reflection
  111810. * @param scene The scene the light belongs to
  111811. */
  111812. constructor(name: string, direction: Vector3, scene: Scene);
  111813. protected _buildUniformLayout(): void;
  111814. /**
  111815. * Returns the string "HemisphericLight".
  111816. * @return The class name
  111817. */
  111818. getClassName(): string;
  111819. /**
  111820. * Sets the HemisphericLight direction towards the passed target (Vector3).
  111821. * Returns the updated direction.
  111822. * @param target The target the direction should point to
  111823. * @return The computed direction
  111824. */
  111825. setDirectionToTarget(target: Vector3): Vector3;
  111826. /**
  111827. * Returns the shadow generator associated to the light.
  111828. * @returns Always null for hemispheric lights because it does not support shadows.
  111829. */
  111830. getShadowGenerator(): Nullable<IShadowGenerator>;
  111831. /**
  111832. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  111833. * @param effect The effect to update
  111834. * @param lightIndex The index of the light in the effect to update
  111835. * @returns The hemispheric light
  111836. */
  111837. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  111838. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  111839. /**
  111840. * Computes the world matrix of the node
  111841. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  111842. * @param useWasUpdatedFlag defines a reserved property
  111843. * @returns the world matrix
  111844. */
  111845. computeWorldMatrix(): Matrix;
  111846. /**
  111847. * Returns the integer 3.
  111848. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  111849. */
  111850. getTypeID(): number;
  111851. /**
  111852. * Prepares the list of defines specific to the light type.
  111853. * @param defines the list of defines
  111854. * @param lightIndex defines the index of the light for the effect
  111855. */
  111856. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  111857. }
  111858. }
  111859. declare module BABYLON {
  111860. /** @hidden */
  111861. export var vrMultiviewToSingleviewPixelShader: {
  111862. name: string;
  111863. shader: string;
  111864. };
  111865. }
  111866. declare module BABYLON {
  111867. /**
  111868. * Renders to multiple views with a single draw call
  111869. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  111870. */
  111871. export class MultiviewRenderTarget extends RenderTargetTexture {
  111872. /**
  111873. * Creates a multiview render target
  111874. * @param scene scene used with the render target
  111875. * @param size the size of the render target (used for each view)
  111876. */
  111877. constructor(scene: Scene, size?: number | {
  111878. width: number;
  111879. height: number;
  111880. } | {
  111881. ratio: number;
  111882. });
  111883. /**
  111884. * @hidden
  111885. * @param faceIndex the face index, if its a cube texture
  111886. */
  111887. _bindFrameBuffer(faceIndex?: number): void;
  111888. /**
  111889. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  111890. * @returns the view count
  111891. */
  111892. getViewCount(): number;
  111893. }
  111894. }
  111895. declare module BABYLON {
  111896. interface Engine {
  111897. /**
  111898. * Creates a new multiview render target
  111899. * @param width defines the width of the texture
  111900. * @param height defines the height of the texture
  111901. * @returns the created multiview texture
  111902. */
  111903. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  111904. /**
  111905. * Binds a multiview framebuffer to be drawn to
  111906. * @param multiviewTexture texture to bind
  111907. */
  111908. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  111909. }
  111910. interface Camera {
  111911. /**
  111912. * @hidden
  111913. * 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)
  111914. */
  111915. _useMultiviewToSingleView: boolean;
  111916. /**
  111917. * @hidden
  111918. * 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)
  111919. */
  111920. _multiviewTexture: Nullable<RenderTargetTexture>;
  111921. /**
  111922. * @hidden
  111923. * ensures the multiview texture of the camera exists and has the specified width/height
  111924. * @param width height to set on the multiview texture
  111925. * @param height width to set on the multiview texture
  111926. */
  111927. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  111928. }
  111929. interface Scene {
  111930. /** @hidden */
  111931. _transformMatrixR: Matrix;
  111932. /** @hidden */
  111933. _multiviewSceneUbo: Nullable<UniformBuffer>;
  111934. /** @hidden */
  111935. _createMultiviewUbo(): void;
  111936. /** @hidden */
  111937. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  111938. /** @hidden */
  111939. _renderMultiviewToSingleView(camera: Camera): void;
  111940. }
  111941. }
  111942. declare module BABYLON {
  111943. /**
  111944. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  111945. * This will not be used for webXR as it supports displaying texture arrays directly
  111946. */
  111947. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  111948. /**
  111949. * Gets a string identifying the name of the class
  111950. * @returns "VRMultiviewToSingleviewPostProcess" string
  111951. */
  111952. getClassName(): string;
  111953. /**
  111954. * Initializes a VRMultiviewToSingleview
  111955. * @param name name of the post process
  111956. * @param camera camera to be applied to
  111957. * @param scaleFactor scaling factor to the size of the output texture
  111958. */
  111959. constructor(name: string, camera: Camera, scaleFactor: number);
  111960. }
  111961. }
  111962. declare module BABYLON {
  111963. /**
  111964. * Interface used to define additional presentation attributes
  111965. */
  111966. export interface IVRPresentationAttributes {
  111967. /**
  111968. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  111969. */
  111970. highRefreshRate: boolean;
  111971. /**
  111972. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  111973. */
  111974. foveationLevel: number;
  111975. }
  111976. interface Engine {
  111977. /** @hidden */
  111978. _vrDisplay: any;
  111979. /** @hidden */
  111980. _vrSupported: boolean;
  111981. /** @hidden */
  111982. _oldSize: Size;
  111983. /** @hidden */
  111984. _oldHardwareScaleFactor: number;
  111985. /** @hidden */
  111986. _vrExclusivePointerMode: boolean;
  111987. /** @hidden */
  111988. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  111989. /** @hidden */
  111990. _onVRDisplayPointerRestricted: () => void;
  111991. /** @hidden */
  111992. _onVRDisplayPointerUnrestricted: () => void;
  111993. /** @hidden */
  111994. _onVrDisplayConnect: Nullable<(display: any) => void>;
  111995. /** @hidden */
  111996. _onVrDisplayDisconnect: Nullable<() => void>;
  111997. /** @hidden */
  111998. _onVrDisplayPresentChange: Nullable<() => void>;
  111999. /**
  112000. * Observable signaled when VR display mode changes
  112001. */
  112002. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  112003. /**
  112004. * Observable signaled when VR request present is complete
  112005. */
  112006. onVRRequestPresentComplete: Observable<boolean>;
  112007. /**
  112008. * Observable signaled when VR request present starts
  112009. */
  112010. onVRRequestPresentStart: Observable<Engine>;
  112011. /**
  112012. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  112013. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  112014. */
  112015. isInVRExclusivePointerMode: boolean;
  112016. /**
  112017. * Gets a boolean indicating if a webVR device was detected
  112018. * @returns true if a webVR device was detected
  112019. */
  112020. isVRDevicePresent(): boolean;
  112021. /**
  112022. * Gets the current webVR device
  112023. * @returns the current webVR device (or null)
  112024. */
  112025. getVRDevice(): any;
  112026. /**
  112027. * Initializes a webVR display and starts listening to display change events
  112028. * The onVRDisplayChangedObservable will be notified upon these changes
  112029. * @returns A promise containing a VRDisplay and if vr is supported
  112030. */
  112031. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  112032. /** @hidden */
  112033. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  112034. /**
  112035. * Gets or sets the presentation attributes used to configure VR rendering
  112036. */
  112037. vrPresentationAttributes?: IVRPresentationAttributes;
  112038. /**
  112039. * Call this function to switch to webVR mode
  112040. * Will do nothing if webVR is not supported or if there is no webVR device
  112041. * @param options the webvr options provided to the camera. mainly used for multiview
  112042. * @see https://doc.babylonjs.com/how_to/webvr_camera
  112043. */
  112044. enableVR(options: WebVROptions): void;
  112045. /** @hidden */
  112046. _onVRFullScreenTriggered(): void;
  112047. }
  112048. }
  112049. declare module BABYLON {
  112050. /**
  112051. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  112052. * IMPORTANT!! The data is right-hand data.
  112053. * @export
  112054. * @interface DevicePose
  112055. */
  112056. export interface DevicePose {
  112057. /**
  112058. * The position of the device, values in array are [x,y,z].
  112059. */
  112060. readonly position: Nullable<Float32Array>;
  112061. /**
  112062. * The linearVelocity of the device, values in array are [x,y,z].
  112063. */
  112064. readonly linearVelocity: Nullable<Float32Array>;
  112065. /**
  112066. * The linearAcceleration of the device, values in array are [x,y,z].
  112067. */
  112068. readonly linearAcceleration: Nullable<Float32Array>;
  112069. /**
  112070. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  112071. */
  112072. readonly orientation: Nullable<Float32Array>;
  112073. /**
  112074. * The angularVelocity of the device, values in array are [x,y,z].
  112075. */
  112076. readonly angularVelocity: Nullable<Float32Array>;
  112077. /**
  112078. * The angularAcceleration of the device, values in array are [x,y,z].
  112079. */
  112080. readonly angularAcceleration: Nullable<Float32Array>;
  112081. }
  112082. /**
  112083. * Interface representing a pose controlled object in Babylon.
  112084. * A pose controlled object has both regular pose values as well as pose values
  112085. * from an external device such as a VR head mounted display
  112086. */
  112087. export interface PoseControlled {
  112088. /**
  112089. * The position of the object in babylon space.
  112090. */
  112091. position: Vector3;
  112092. /**
  112093. * The rotation quaternion of the object in babylon space.
  112094. */
  112095. rotationQuaternion: Quaternion;
  112096. /**
  112097. * The position of the device in babylon space.
  112098. */
  112099. devicePosition?: Vector3;
  112100. /**
  112101. * The rotation quaternion of the device in babylon space.
  112102. */
  112103. deviceRotationQuaternion: Quaternion;
  112104. /**
  112105. * The raw pose coming from the device.
  112106. */
  112107. rawPose: Nullable<DevicePose>;
  112108. /**
  112109. * The scale of the device to be used when translating from device space to babylon space.
  112110. */
  112111. deviceScaleFactor: number;
  112112. /**
  112113. * Updates the poseControlled values based on the input device pose.
  112114. * @param poseData the pose data to update the object with
  112115. */
  112116. updateFromDevice(poseData: DevicePose): void;
  112117. }
  112118. /**
  112119. * Set of options to customize the webVRCamera
  112120. */
  112121. export interface WebVROptions {
  112122. /**
  112123. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  112124. */
  112125. trackPosition?: boolean;
  112126. /**
  112127. * Sets the scale of the vrDevice in babylon space. (default: 1)
  112128. */
  112129. positionScale?: number;
  112130. /**
  112131. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  112132. */
  112133. displayName?: string;
  112134. /**
  112135. * Should the native controller meshes be initialized. (default: true)
  112136. */
  112137. controllerMeshes?: boolean;
  112138. /**
  112139. * Creating a default HemiLight only on controllers. (default: true)
  112140. */
  112141. defaultLightingOnControllers?: boolean;
  112142. /**
  112143. * If you don't want to use the default VR button of the helper. (default: false)
  112144. */
  112145. useCustomVRButton?: boolean;
  112146. /**
  112147. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  112148. */
  112149. customVRButton?: HTMLButtonElement;
  112150. /**
  112151. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  112152. */
  112153. rayLength?: number;
  112154. /**
  112155. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  112156. */
  112157. defaultHeight?: number;
  112158. /**
  112159. * If multiview should be used if availible (default: false)
  112160. */
  112161. useMultiview?: boolean;
  112162. }
  112163. /**
  112164. * This represents a WebVR camera.
  112165. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  112166. * @example https://doc.babylonjs.com/how_to/webvr_camera
  112167. */
  112168. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  112169. private webVROptions;
  112170. /**
  112171. * @hidden
  112172. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  112173. */
  112174. _vrDevice: any;
  112175. /**
  112176. * The rawPose of the vrDevice.
  112177. */
  112178. rawPose: Nullable<DevicePose>;
  112179. private _onVREnabled;
  112180. private _specsVersion;
  112181. private _attached;
  112182. private _frameData;
  112183. protected _descendants: Array<Node>;
  112184. private _deviceRoomPosition;
  112185. /** @hidden */
  112186. _deviceRoomRotationQuaternion: Quaternion;
  112187. private _standingMatrix;
  112188. /**
  112189. * Represents device position in babylon space.
  112190. */
  112191. devicePosition: Vector3;
  112192. /**
  112193. * Represents device rotation in babylon space.
  112194. */
  112195. deviceRotationQuaternion: Quaternion;
  112196. /**
  112197. * The scale of the device to be used when translating from device space to babylon space.
  112198. */
  112199. deviceScaleFactor: number;
  112200. private _deviceToWorld;
  112201. private _worldToDevice;
  112202. /**
  112203. * References to the webVR controllers for the vrDevice.
  112204. */
  112205. controllers: Array<WebVRController>;
  112206. /**
  112207. * Emits an event when a controller is attached.
  112208. */
  112209. onControllersAttachedObservable: Observable<WebVRController[]>;
  112210. /**
  112211. * Emits an event when a controller's mesh has been loaded;
  112212. */
  112213. onControllerMeshLoadedObservable: Observable<WebVRController>;
  112214. /**
  112215. * Emits an event when the HMD's pose has been updated.
  112216. */
  112217. onPoseUpdatedFromDeviceObservable: Observable<any>;
  112218. private _poseSet;
  112219. /**
  112220. * If the rig cameras be used as parent instead of this camera.
  112221. */
  112222. rigParenting: boolean;
  112223. private _lightOnControllers;
  112224. private _defaultHeight?;
  112225. /**
  112226. * Instantiates a WebVRFreeCamera.
  112227. * @param name The name of the WebVRFreeCamera
  112228. * @param position The starting anchor position for the camera
  112229. * @param scene The scene the camera belongs to
  112230. * @param webVROptions a set of customizable options for the webVRCamera
  112231. */
  112232. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  112233. /**
  112234. * Gets the device distance from the ground in meters.
  112235. * @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.
  112236. */
  112237. deviceDistanceToRoomGround(): number;
  112238. /**
  112239. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  112240. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  112241. */
  112242. useStandingMatrix(callback?: (bool: boolean) => void): void;
  112243. /**
  112244. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  112245. * @returns A promise with a boolean set to if the standing matrix is supported.
  112246. */
  112247. useStandingMatrixAsync(): Promise<boolean>;
  112248. /**
  112249. * Disposes the camera
  112250. */
  112251. dispose(): void;
  112252. /**
  112253. * Gets a vrController by name.
  112254. * @param name The name of the controller to retreive
  112255. * @returns the controller matching the name specified or null if not found
  112256. */
  112257. getControllerByName(name: string): Nullable<WebVRController>;
  112258. private _leftController;
  112259. /**
  112260. * The controller corresponding to the users left hand.
  112261. */
  112262. get leftController(): Nullable<WebVRController>;
  112263. private _rightController;
  112264. /**
  112265. * The controller corresponding to the users right hand.
  112266. */
  112267. get rightController(): Nullable<WebVRController>;
  112268. /**
  112269. * Casts a ray forward from the vrCamera's gaze.
  112270. * @param length Length of the ray (default: 100)
  112271. * @returns the ray corresponding to the gaze
  112272. */
  112273. getForwardRay(length?: number): Ray;
  112274. /**
  112275. * @hidden
  112276. * Updates the camera based on device's frame data
  112277. */
  112278. _checkInputs(): void;
  112279. /**
  112280. * Updates the poseControlled values based on the input device pose.
  112281. * @param poseData Pose coming from the device
  112282. */
  112283. updateFromDevice(poseData: DevicePose): void;
  112284. private _detachIfAttached;
  112285. /**
  112286. * WebVR's attach control will start broadcasting frames to the device.
  112287. * Note that in certain browsers (chrome for example) this function must be called
  112288. * within a user-interaction callback. Example:
  112289. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  112290. *
  112291. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  112292. */
  112293. attachControl(noPreventDefault?: boolean): void;
  112294. /**
  112295. * Detach the current controls from the specified dom element.
  112296. */
  112297. detachControl(): void;
  112298. /**
  112299. * @returns the name of this class
  112300. */
  112301. getClassName(): string;
  112302. /**
  112303. * Calls resetPose on the vrDisplay
  112304. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  112305. */
  112306. resetToCurrentRotation(): void;
  112307. /**
  112308. * @hidden
  112309. * Updates the rig cameras (left and right eye)
  112310. */
  112311. _updateRigCameras(): void;
  112312. private _workingVector;
  112313. private _oneVector;
  112314. private _workingMatrix;
  112315. private updateCacheCalled;
  112316. private _correctPositionIfNotTrackPosition;
  112317. /**
  112318. * @hidden
  112319. * Updates the cached values of the camera
  112320. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  112321. */
  112322. _updateCache(ignoreParentClass?: boolean): void;
  112323. /**
  112324. * @hidden
  112325. * Get current device position in babylon world
  112326. */
  112327. _computeDevicePosition(): void;
  112328. /**
  112329. * Updates the current device position and rotation in the babylon world
  112330. */
  112331. update(): void;
  112332. /**
  112333. * @hidden
  112334. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  112335. * @returns an identity matrix
  112336. */
  112337. _getViewMatrix(): Matrix;
  112338. private _tmpMatrix;
  112339. /**
  112340. * This function is called by the two RIG cameras.
  112341. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  112342. * @hidden
  112343. */
  112344. _getWebVRViewMatrix(): Matrix;
  112345. /** @hidden */
  112346. _getWebVRProjectionMatrix(): Matrix;
  112347. private _onGamepadConnectedObserver;
  112348. private _onGamepadDisconnectedObserver;
  112349. private _updateCacheWhenTrackingDisabledObserver;
  112350. /**
  112351. * Initializes the controllers and their meshes
  112352. */
  112353. initControllers(): void;
  112354. }
  112355. }
  112356. declare module BABYLON {
  112357. /**
  112358. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  112359. *
  112360. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  112361. *
  112362. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  112363. */
  112364. export class MaterialHelper {
  112365. /**
  112366. * Bind the current view position to an effect.
  112367. * @param effect The effect to be bound
  112368. * @param scene The scene the eyes position is used from
  112369. * @param variableName name of the shader variable that will hold the eye position
  112370. * @param isVector3 true to indicates that variableName is a Vector3 and not a Vector4
  112371. * @return the computed eye position
  112372. */
  112373. static BindEyePosition(effect: Nullable<Effect>, scene: Scene, variableName?: string, isVector3?: boolean): Vector4;
  112374. /**
  112375. * Helps preparing the defines values about the UVs in used in the effect.
  112376. * UVs are shared as much as we can accross channels in the shaders.
  112377. * @param texture The texture we are preparing the UVs for
  112378. * @param defines The defines to update
  112379. * @param key The channel key "diffuse", "specular"... used in the shader
  112380. */
  112381. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  112382. /**
  112383. * Binds a texture matrix value to its corrsponding uniform
  112384. * @param texture The texture to bind the matrix for
  112385. * @param uniformBuffer The uniform buffer receivin the data
  112386. * @param key The channel key "diffuse", "specular"... used in the shader
  112387. */
  112388. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  112389. /**
  112390. * Gets the current status of the fog (should it be enabled?)
  112391. * @param mesh defines the mesh to evaluate for fog support
  112392. * @param scene defines the hosting scene
  112393. * @returns true if fog must be enabled
  112394. */
  112395. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  112396. /**
  112397. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  112398. * @param mesh defines the current mesh
  112399. * @param scene defines the current scene
  112400. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  112401. * @param pointsCloud defines if point cloud rendering has to be turned on
  112402. * @param fogEnabled defines if fog has to be turned on
  112403. * @param alphaTest defines if alpha testing has to be turned on
  112404. * @param defines defines the current list of defines
  112405. */
  112406. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  112407. /**
  112408. * Helper used to prepare the list of defines associated with frame values for shader compilation
  112409. * @param scene defines the current scene
  112410. * @param engine defines the current engine
  112411. * @param defines specifies the list of active defines
  112412. * @param useInstances defines if instances have to be turned on
  112413. * @param useClipPlane defines if clip plane have to be turned on
  112414. * @param useInstances defines if instances have to be turned on
  112415. * @param useThinInstances defines if thin instances have to be turned on
  112416. */
  112417. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  112418. /**
  112419. * Prepares the defines for bones
  112420. * @param mesh The mesh containing the geometry data we will draw
  112421. * @param defines The defines to update
  112422. */
  112423. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  112424. /**
  112425. * Prepares the defines for morph targets
  112426. * @param mesh The mesh containing the geometry data we will draw
  112427. * @param defines The defines to update
  112428. */
  112429. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  112430. /**
  112431. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  112432. * @param mesh The mesh containing the geometry data we will draw
  112433. * @param defines The defines to update
  112434. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  112435. * @param useBones Precise whether bones should be used or not (override mesh info)
  112436. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  112437. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  112438. * @returns false if defines are considered not dirty and have not been checked
  112439. */
  112440. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  112441. /**
  112442. * Prepares the defines related to multiview
  112443. * @param scene The scene we are intending to draw
  112444. * @param defines The defines to update
  112445. */
  112446. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  112447. /**
  112448. * Prepares the defines related to the prepass
  112449. * @param scene The scene we are intending to draw
  112450. * @param defines The defines to update
  112451. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  112452. */
  112453. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  112454. /**
  112455. * Prepares the defines related to the light information passed in parameter
  112456. * @param scene The scene we are intending to draw
  112457. * @param mesh The mesh the effect is compiling for
  112458. * @param light The light the effect is compiling for
  112459. * @param lightIndex The index of the light
  112460. * @param defines The defines to update
  112461. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  112462. * @param state Defines the current state regarding what is needed (normals, etc...)
  112463. */
  112464. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  112465. needNormals: boolean;
  112466. needRebuild: boolean;
  112467. shadowEnabled: boolean;
  112468. specularEnabled: boolean;
  112469. lightmapMode: boolean;
  112470. }): void;
  112471. /**
  112472. * Prepares the defines related to the light information passed in parameter
  112473. * @param scene The scene we are intending to draw
  112474. * @param mesh The mesh the effect is compiling for
  112475. * @param defines The defines to update
  112476. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  112477. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  112478. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  112479. * @returns true if normals will be required for the rest of the effect
  112480. */
  112481. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  112482. /**
  112483. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  112484. * @param lightIndex defines the light index
  112485. * @param uniformsList The uniform list
  112486. * @param samplersList The sampler list
  112487. * @param projectedLightTexture defines if projected texture must be used
  112488. * @param uniformBuffersList defines an optional list of uniform buffers
  112489. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  112490. */
  112491. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  112492. /**
  112493. * Prepares the uniforms and samplers list to be used in the effect
  112494. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  112495. * @param samplersList The sampler list
  112496. * @param defines The defines helping in the list generation
  112497. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  112498. */
  112499. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  112500. /**
  112501. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  112502. * @param defines The defines to update while falling back
  112503. * @param fallbacks The authorized effect fallbacks
  112504. * @param maxSimultaneousLights The maximum number of lights allowed
  112505. * @param rank the current rank of the Effect
  112506. * @returns The newly affected rank
  112507. */
  112508. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  112509. private static _TmpMorphInfluencers;
  112510. /**
  112511. * Prepares the list of attributes required for morph targets according to the effect defines.
  112512. * @param attribs The current list of supported attribs
  112513. * @param mesh The mesh to prepare the morph targets attributes for
  112514. * @param influencers The number of influencers
  112515. */
  112516. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  112517. /**
  112518. * Prepares the list of attributes required for morph targets according to the effect defines.
  112519. * @param attribs The current list of supported attribs
  112520. * @param mesh The mesh to prepare the morph targets attributes for
  112521. * @param defines The current Defines of the effect
  112522. */
  112523. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  112524. /**
  112525. * Prepares the list of attributes required for bones according to the effect defines.
  112526. * @param attribs The current list of supported attribs
  112527. * @param mesh The mesh to prepare the bones attributes for
  112528. * @param defines The current Defines of the effect
  112529. * @param fallbacks The current efffect fallback strategy
  112530. */
  112531. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  112532. /**
  112533. * Check and prepare the list of attributes required for instances according to the effect defines.
  112534. * @param attribs The current list of supported attribs
  112535. * @param defines The current MaterialDefines of the effect
  112536. */
  112537. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  112538. /**
  112539. * Add the list of attributes required for instances to the attribs array.
  112540. * @param attribs The current list of supported attribs
  112541. */
  112542. static PushAttributesForInstances(attribs: string[]): void;
  112543. /**
  112544. * Binds the light information to the effect.
  112545. * @param light The light containing the generator
  112546. * @param effect The effect we are binding the data to
  112547. * @param lightIndex The light index in the effect used to render
  112548. */
  112549. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  112550. /**
  112551. * Binds the lights information from the scene to the effect for the given mesh.
  112552. * @param light Light to bind
  112553. * @param lightIndex Light index
  112554. * @param scene The scene where the light belongs to
  112555. * @param effect The effect we are binding the data to
  112556. * @param useSpecular Defines if specular is supported
  112557. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  112558. */
  112559. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  112560. /**
  112561. * Binds the lights information from the scene to the effect for the given mesh.
  112562. * @param scene The scene the lights belongs to
  112563. * @param mesh The mesh we are binding the information to render
  112564. * @param effect The effect we are binding the data to
  112565. * @param defines The generated defines for the effect
  112566. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  112567. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  112568. */
  112569. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  112570. private static _tempFogColor;
  112571. /**
  112572. * Binds the fog information from the scene to the effect for the given mesh.
  112573. * @param scene The scene the lights belongs to
  112574. * @param mesh The mesh we are binding the information to render
  112575. * @param effect The effect we are binding the data to
  112576. * @param linearSpace Defines if the fog effect is applied in linear space
  112577. */
  112578. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  112579. /**
  112580. * Binds the bones information from the mesh to the effect.
  112581. * @param mesh The mesh we are binding the information to render
  112582. * @param effect The effect we are binding the data to
  112583. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  112584. */
  112585. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  112586. private static _CopyBonesTransformationMatrices;
  112587. /**
  112588. * Binds the morph targets information from the mesh to the effect.
  112589. * @param abstractMesh The mesh we are binding the information to render
  112590. * @param effect The effect we are binding the data to
  112591. */
  112592. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  112593. /**
  112594. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  112595. * @param defines The generated defines used in the effect
  112596. * @param effect The effect we are binding the data to
  112597. * @param scene The scene we are willing to render with logarithmic scale for
  112598. */
  112599. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  112600. /**
  112601. * Binds the clip plane information from the scene to the effect.
  112602. * @param scene The scene the clip plane information are extracted from
  112603. * @param effect The effect we are binding the data to
  112604. */
  112605. static BindClipPlane(effect: Effect, scene: Scene): void;
  112606. }
  112607. }
  112608. declare module BABYLON {
  112609. /** @hidden */
  112610. export var bayerDitherFunctions: {
  112611. name: string;
  112612. shader: string;
  112613. };
  112614. }
  112615. declare module BABYLON {
  112616. /** @hidden */
  112617. export var shadowMapFragmentDeclaration: {
  112618. name: string;
  112619. shader: string;
  112620. };
  112621. }
  112622. declare module BABYLON {
  112623. /** @hidden */
  112624. export var shadowMapFragment: {
  112625. name: string;
  112626. shader: string;
  112627. };
  112628. }
  112629. declare module BABYLON {
  112630. /** @hidden */
  112631. export var shadowMapPixelShader: {
  112632. name: string;
  112633. shader: string;
  112634. };
  112635. }
  112636. declare module BABYLON {
  112637. /** @hidden */
  112638. export var shadowMapVertexDeclaration: {
  112639. name: string;
  112640. shader: string;
  112641. };
  112642. }
  112643. declare module BABYLON {
  112644. /** @hidden */
  112645. export var shadowMapVertexNormalBias: {
  112646. name: string;
  112647. shader: string;
  112648. };
  112649. }
  112650. declare module BABYLON {
  112651. /** @hidden */
  112652. export var shadowMapVertexMetric: {
  112653. name: string;
  112654. shader: string;
  112655. };
  112656. }
  112657. declare module BABYLON {
  112658. /** @hidden */
  112659. export var shadowMapVertexShader: {
  112660. name: string;
  112661. shader: string;
  112662. };
  112663. }
  112664. declare module BABYLON {
  112665. /** @hidden */
  112666. export var depthBoxBlurPixelShader: {
  112667. name: string;
  112668. shader: string;
  112669. };
  112670. }
  112671. declare module BABYLON {
  112672. /** @hidden */
  112673. export var shadowMapFragmentSoftTransparentShadow: {
  112674. name: string;
  112675. shader: string;
  112676. };
  112677. }
  112678. declare module BABYLON {
  112679. /**
  112680. * Creates an instance based on a source mesh.
  112681. */
  112682. export class InstancedMesh extends AbstractMesh {
  112683. private _sourceMesh;
  112684. private _currentLOD;
  112685. /** @hidden */
  112686. _indexInSourceMeshInstanceArray: number;
  112687. constructor(name: string, source: Mesh);
  112688. /**
  112689. * Returns the string "InstancedMesh".
  112690. */
  112691. getClassName(): string;
  112692. /** Gets the list of lights affecting that mesh */
  112693. get lightSources(): Light[];
  112694. _resyncLightSources(): void;
  112695. _resyncLightSource(light: Light): void;
  112696. _removeLightSource(light: Light, dispose: boolean): void;
  112697. /**
  112698. * If the source mesh receives shadows
  112699. */
  112700. get receiveShadows(): boolean;
  112701. /**
  112702. * The material of the source mesh
  112703. */
  112704. get material(): Nullable<Material>;
  112705. /**
  112706. * Visibility of the source mesh
  112707. */
  112708. get visibility(): number;
  112709. /**
  112710. * Skeleton of the source mesh
  112711. */
  112712. get skeleton(): Nullable<Skeleton>;
  112713. /**
  112714. * Rendering ground id of the source mesh
  112715. */
  112716. get renderingGroupId(): number;
  112717. set renderingGroupId(value: number);
  112718. /**
  112719. * Returns the total number of vertices (integer).
  112720. */
  112721. getTotalVertices(): number;
  112722. /**
  112723. * Returns a positive integer : the total number of indices in this mesh geometry.
  112724. * @returns the numner of indices or zero if the mesh has no geometry.
  112725. */
  112726. getTotalIndices(): number;
  112727. /**
  112728. * The source mesh of the instance
  112729. */
  112730. get sourceMesh(): Mesh;
  112731. /**
  112732. * Creates a new InstancedMesh object from the mesh model.
  112733. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  112734. * @param name defines the name of the new instance
  112735. * @returns a new InstancedMesh
  112736. */
  112737. createInstance(name: string): InstancedMesh;
  112738. /**
  112739. * Is this node ready to be used/rendered
  112740. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  112741. * @return {boolean} is it ready
  112742. */
  112743. isReady(completeCheck?: boolean): boolean;
  112744. /**
  112745. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  112746. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  112747. * @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.
  112748. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  112749. */
  112750. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  112751. /**
  112752. * Sets the vertex data of the mesh geometry for the requested `kind`.
  112753. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  112754. * The `data` are either a numeric array either a Float32Array.
  112755. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  112756. * 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).
  112757. * Note that a new underlying VertexBuffer object is created each call.
  112758. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  112759. *
  112760. * Possible `kind` values :
  112761. * - VertexBuffer.PositionKind
  112762. * - VertexBuffer.UVKind
  112763. * - VertexBuffer.UV2Kind
  112764. * - VertexBuffer.UV3Kind
  112765. * - VertexBuffer.UV4Kind
  112766. * - VertexBuffer.UV5Kind
  112767. * - VertexBuffer.UV6Kind
  112768. * - VertexBuffer.ColorKind
  112769. * - VertexBuffer.MatricesIndicesKind
  112770. * - VertexBuffer.MatricesIndicesExtraKind
  112771. * - VertexBuffer.MatricesWeightsKind
  112772. * - VertexBuffer.MatricesWeightsExtraKind
  112773. *
  112774. * Returns the Mesh.
  112775. */
  112776. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  112777. /**
  112778. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  112779. * If the mesh has no geometry, it is simply returned as it is.
  112780. * The `data` are either a numeric array either a Float32Array.
  112781. * No new underlying VertexBuffer object is created.
  112782. * 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.
  112783. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  112784. *
  112785. * Possible `kind` values :
  112786. * - VertexBuffer.PositionKind
  112787. * - VertexBuffer.UVKind
  112788. * - VertexBuffer.UV2Kind
  112789. * - VertexBuffer.UV3Kind
  112790. * - VertexBuffer.UV4Kind
  112791. * - VertexBuffer.UV5Kind
  112792. * - VertexBuffer.UV6Kind
  112793. * - VertexBuffer.ColorKind
  112794. * - VertexBuffer.MatricesIndicesKind
  112795. * - VertexBuffer.MatricesIndicesExtraKind
  112796. * - VertexBuffer.MatricesWeightsKind
  112797. * - VertexBuffer.MatricesWeightsExtraKind
  112798. *
  112799. * Returns the Mesh.
  112800. */
  112801. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  112802. /**
  112803. * Sets the mesh indices.
  112804. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  112805. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  112806. * This method creates a new index buffer each call.
  112807. * Returns the Mesh.
  112808. */
  112809. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  112810. /**
  112811. * Boolean : True if the mesh owns the requested kind of data.
  112812. */
  112813. isVerticesDataPresent(kind: string): boolean;
  112814. /**
  112815. * Returns an array of indices (IndicesArray).
  112816. */
  112817. getIndices(): Nullable<IndicesArray>;
  112818. get _positions(): Nullable<Vector3[]>;
  112819. /**
  112820. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  112821. * This means the mesh underlying bounding box and sphere are recomputed.
  112822. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  112823. * @returns the current mesh
  112824. */
  112825. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  112826. /** @hidden */
  112827. _preActivate(): InstancedMesh;
  112828. /** @hidden */
  112829. _activate(renderId: number, intermediateRendering: boolean): boolean;
  112830. /** @hidden */
  112831. _postActivate(): void;
  112832. getWorldMatrix(): Matrix;
  112833. get isAnInstance(): boolean;
  112834. /**
  112835. * Returns the current associated LOD AbstractMesh.
  112836. */
  112837. getLOD(camera: Camera): AbstractMesh;
  112838. /** @hidden */
  112839. _preActivateForIntermediateRendering(renderId: number): Mesh;
  112840. /** @hidden */
  112841. _syncSubMeshes(): InstancedMesh;
  112842. /** @hidden */
  112843. _generatePointsArray(): boolean;
  112844. /** @hidden */
  112845. _updateBoundingInfo(): AbstractMesh;
  112846. /**
  112847. * Creates a new InstancedMesh from the current mesh.
  112848. * - name (string) : the cloned mesh name
  112849. * - newParent (optional Node) : the optional Node to parent the clone to.
  112850. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  112851. *
  112852. * Returns the clone.
  112853. */
  112854. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  112855. /**
  112856. * Disposes the InstancedMesh.
  112857. * Returns nothing.
  112858. */
  112859. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  112860. }
  112861. interface Mesh {
  112862. /**
  112863. * Register a custom buffer that will be instanced
  112864. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  112865. * @param kind defines the buffer kind
  112866. * @param stride defines the stride in floats
  112867. */
  112868. registerInstancedBuffer(kind: string, stride: number): void;
  112869. /**
  112870. * true to use the edge renderer for all instances of this mesh
  112871. */
  112872. edgesShareWithInstances: boolean;
  112873. /** @hidden */
  112874. _userInstancedBuffersStorage: {
  112875. data: {
  112876. [key: string]: Float32Array;
  112877. };
  112878. sizes: {
  112879. [key: string]: number;
  112880. };
  112881. vertexBuffers: {
  112882. [key: string]: Nullable<VertexBuffer>;
  112883. };
  112884. strides: {
  112885. [key: string]: number;
  112886. };
  112887. };
  112888. }
  112889. interface AbstractMesh {
  112890. /**
  112891. * Object used to store instanced buffers defined by user
  112892. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  112893. */
  112894. instancedBuffers: {
  112895. [key: string]: any;
  112896. };
  112897. }
  112898. }
  112899. declare module BABYLON {
  112900. /**
  112901. * Defines the options associated with the creation of a shader material.
  112902. */
  112903. export interface IShaderMaterialOptions {
  112904. /**
  112905. * Does the material work in alpha blend mode
  112906. */
  112907. needAlphaBlending: boolean;
  112908. /**
  112909. * Does the material work in alpha test mode
  112910. */
  112911. needAlphaTesting: boolean;
  112912. /**
  112913. * The list of attribute names used in the shader
  112914. */
  112915. attributes: string[];
  112916. /**
  112917. * The list of unifrom names used in the shader
  112918. */
  112919. uniforms: string[];
  112920. /**
  112921. * The list of UBO names used in the shader
  112922. */
  112923. uniformBuffers: string[];
  112924. /**
  112925. * The list of sampler names used in the shader
  112926. */
  112927. samplers: string[];
  112928. /**
  112929. * The list of defines used in the shader
  112930. */
  112931. defines: string[];
  112932. }
  112933. /**
  112934. * 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.
  112935. *
  112936. * This returned material effects how the mesh will look based on the code in the shaders.
  112937. *
  112938. * @see https://doc.babylonjs.com/how_to/shader_material
  112939. */
  112940. export class ShaderMaterial extends Material {
  112941. private _shaderPath;
  112942. private _options;
  112943. private _textures;
  112944. private _textureArrays;
  112945. private _floats;
  112946. private _ints;
  112947. private _floatsArrays;
  112948. private _colors3;
  112949. private _colors3Arrays;
  112950. private _colors4;
  112951. private _colors4Arrays;
  112952. private _vectors2;
  112953. private _vectors3;
  112954. private _vectors4;
  112955. private _matrices;
  112956. private _matrixArrays;
  112957. private _matrices3x3;
  112958. private _matrices2x2;
  112959. private _vectors2Arrays;
  112960. private _vectors3Arrays;
  112961. private _vectors4Arrays;
  112962. private _cachedWorldViewMatrix;
  112963. private _cachedWorldViewProjectionMatrix;
  112964. private _renderId;
  112965. private _multiview;
  112966. private _cachedDefines;
  112967. /** Define the Url to load snippets */
  112968. static SnippetUrl: string;
  112969. /** Snippet ID if the material was created from the snippet server */
  112970. snippetId: string;
  112971. /**
  112972. * Instantiate a new shader material.
  112973. * 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.
  112974. * This returned material effects how the mesh will look based on the code in the shaders.
  112975. * @see https://doc.babylonjs.com/how_to/shader_material
  112976. * @param name Define the name of the material in the scene
  112977. * @param scene Define the scene the material belongs to
  112978. * @param shaderPath Defines the route to the shader code in one of three ways:
  112979. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  112980. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  112981. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  112982. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  112983. * @param options Define the options used to create the shader
  112984. */
  112985. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  112986. /**
  112987. * Gets the shader path used to define the shader code
  112988. * It can be modified to trigger a new compilation
  112989. */
  112990. get shaderPath(): any;
  112991. /**
  112992. * Sets the shader path used to define the shader code
  112993. * It can be modified to trigger a new compilation
  112994. */
  112995. set shaderPath(shaderPath: any);
  112996. /**
  112997. * Gets the options used to compile the shader.
  112998. * They can be modified to trigger a new compilation
  112999. */
  113000. get options(): IShaderMaterialOptions;
  113001. /**
  113002. * Gets the current class name of the material e.g. "ShaderMaterial"
  113003. * Mainly use in serialization.
  113004. * @returns the class name
  113005. */
  113006. getClassName(): string;
  113007. /**
  113008. * Specifies if the material will require alpha blending
  113009. * @returns a boolean specifying if alpha blending is needed
  113010. */
  113011. needAlphaBlending(): boolean;
  113012. /**
  113013. * Specifies if this material should be rendered in alpha test mode
  113014. * @returns a boolean specifying if an alpha test is needed.
  113015. */
  113016. needAlphaTesting(): boolean;
  113017. private _checkUniform;
  113018. /**
  113019. * Set a texture in the shader.
  113020. * @param name Define the name of the uniform samplers as defined in the shader
  113021. * @param texture Define the texture to bind to this sampler
  113022. * @return the material itself allowing "fluent" like uniform updates
  113023. */
  113024. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  113025. /**
  113026. * Set a texture array in the shader.
  113027. * @param name Define the name of the uniform sampler array as defined in the shader
  113028. * @param textures Define the list of textures to bind to this sampler
  113029. * @return the material itself allowing "fluent" like uniform updates
  113030. */
  113031. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  113032. /**
  113033. * Set a float in the shader.
  113034. * @param name Define the name of the uniform as defined in the shader
  113035. * @param value Define the value to give to the uniform
  113036. * @return the material itself allowing "fluent" like uniform updates
  113037. */
  113038. setFloat(name: string, value: number): ShaderMaterial;
  113039. /**
  113040. * Set a int in the shader.
  113041. * @param name Define the name of the uniform as defined in the shader
  113042. * @param value Define the value to give to the uniform
  113043. * @return the material itself allowing "fluent" like uniform updates
  113044. */
  113045. setInt(name: string, value: number): ShaderMaterial;
  113046. /**
  113047. * Set an array of floats in the shader.
  113048. * @param name Define the name of the uniform as defined in the shader
  113049. * @param value Define the value to give to the uniform
  113050. * @return the material itself allowing "fluent" like uniform updates
  113051. */
  113052. setFloats(name: string, value: number[]): ShaderMaterial;
  113053. /**
  113054. * Set a vec3 in the shader from a Color3.
  113055. * @param name Define the name of the uniform as defined in the shader
  113056. * @param value Define the value to give to the uniform
  113057. * @return the material itself allowing "fluent" like uniform updates
  113058. */
  113059. setColor3(name: string, value: Color3): ShaderMaterial;
  113060. /**
  113061. * Set a vec3 array in the shader from a Color3 array.
  113062. * @param name Define the name of the uniform as defined in the shader
  113063. * @param value Define the value to give to the uniform
  113064. * @return the material itself allowing "fluent" like uniform updates
  113065. */
  113066. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  113067. /**
  113068. * Set a vec4 in the shader from a Color4.
  113069. * @param name Define the name of the uniform as defined in the shader
  113070. * @param value Define the value to give to the uniform
  113071. * @return the material itself allowing "fluent" like uniform updates
  113072. */
  113073. setColor4(name: string, value: Color4): ShaderMaterial;
  113074. /**
  113075. * Set a vec4 array in the shader from a Color4 array.
  113076. * @param name Define the name of the uniform as defined in the shader
  113077. * @param value Define the value to give to the uniform
  113078. * @return the material itself allowing "fluent" like uniform updates
  113079. */
  113080. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  113081. /**
  113082. * Set a vec2 in the shader from a Vector2.
  113083. * @param name Define the name of the uniform as defined in the shader
  113084. * @param value Define the value to give to the uniform
  113085. * @return the material itself allowing "fluent" like uniform updates
  113086. */
  113087. setVector2(name: string, value: Vector2): ShaderMaterial;
  113088. /**
  113089. * Set a vec3 in the shader from a Vector3.
  113090. * @param name Define the name of the uniform as defined in the shader
  113091. * @param value Define the value to give to the uniform
  113092. * @return the material itself allowing "fluent" like uniform updates
  113093. */
  113094. setVector3(name: string, value: Vector3): ShaderMaterial;
  113095. /**
  113096. * Set a vec4 in the shader from a Vector4.
  113097. * @param name Define the name of the uniform as defined in the shader
  113098. * @param value Define the value to give to the uniform
  113099. * @return the material itself allowing "fluent" like uniform updates
  113100. */
  113101. setVector4(name: string, value: Vector4): ShaderMaterial;
  113102. /**
  113103. * Set a mat4 in the shader from a Matrix.
  113104. * @param name Define the name of the uniform as defined in the shader
  113105. * @param value Define the value to give to the uniform
  113106. * @return the material itself allowing "fluent" like uniform updates
  113107. */
  113108. setMatrix(name: string, value: Matrix): ShaderMaterial;
  113109. /**
  113110. * Set a float32Array in the shader from a matrix array.
  113111. * @param name Define the name of the uniform as defined in the shader
  113112. * @param value Define the value to give to the uniform
  113113. * @return the material itself allowing "fluent" like uniform updates
  113114. */
  113115. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  113116. /**
  113117. * Set a mat3 in the shader from a Float32Array.
  113118. * @param name Define the name of the uniform as defined in the shader
  113119. * @param value Define the value to give to the uniform
  113120. * @return the material itself allowing "fluent" like uniform updates
  113121. */
  113122. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  113123. /**
  113124. * Set a mat2 in the shader from a Float32Array.
  113125. * @param name Define the name of the uniform as defined in the shader
  113126. * @param value Define the value to give to the uniform
  113127. * @return the material itself allowing "fluent" like uniform updates
  113128. */
  113129. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  113130. /**
  113131. * Set a vec2 array in the shader from a number array.
  113132. * @param name Define the name of the uniform as defined in the shader
  113133. * @param value Define the value to give to the uniform
  113134. * @return the material itself allowing "fluent" like uniform updates
  113135. */
  113136. setArray2(name: string, value: number[]): ShaderMaterial;
  113137. /**
  113138. * Set a vec3 array in the shader from a number array.
  113139. * @param name Define the name of the uniform as defined in the shader
  113140. * @param value Define the value to give to the uniform
  113141. * @return the material itself allowing "fluent" like uniform updates
  113142. */
  113143. setArray3(name: string, value: number[]): ShaderMaterial;
  113144. /**
  113145. * Set a vec4 array in the shader from a number array.
  113146. * @param name Define the name of the uniform as defined in the shader
  113147. * @param value Define the value to give to the uniform
  113148. * @return the material itself allowing "fluent" like uniform updates
  113149. */
  113150. setArray4(name: string, value: number[]): ShaderMaterial;
  113151. private _checkCache;
  113152. /**
  113153. * Specifies that the submesh is ready to be used
  113154. * @param mesh defines the mesh to check
  113155. * @param subMesh defines which submesh to check
  113156. * @param useInstances specifies that instances should be used
  113157. * @returns a boolean indicating that the submesh is ready or not
  113158. */
  113159. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  113160. /**
  113161. * Checks if the material is ready to render the requested mesh
  113162. * @param mesh Define the mesh to render
  113163. * @param useInstances Define whether or not the material is used with instances
  113164. * @returns true if ready, otherwise false
  113165. */
  113166. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  113167. /**
  113168. * Binds the world matrix to the material
  113169. * @param world defines the world transformation matrix
  113170. * @param effectOverride - If provided, use this effect instead of internal effect
  113171. */
  113172. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  113173. /**
  113174. * Binds the submesh to this material by preparing the effect and shader to draw
  113175. * @param world defines the world transformation matrix
  113176. * @param mesh defines the mesh containing the submesh
  113177. * @param subMesh defines the submesh to bind the material to
  113178. */
  113179. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  113180. /**
  113181. * Binds the material to the mesh
  113182. * @param world defines the world transformation matrix
  113183. * @param mesh defines the mesh to bind the material to
  113184. * @param effectOverride - If provided, use this effect instead of internal effect
  113185. */
  113186. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  113187. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  113188. /**
  113189. * Gets the active textures from the material
  113190. * @returns an array of textures
  113191. */
  113192. getActiveTextures(): BaseTexture[];
  113193. /**
  113194. * Specifies if the material uses a texture
  113195. * @param texture defines the texture to check against the material
  113196. * @returns a boolean specifying if the material uses the texture
  113197. */
  113198. hasTexture(texture: BaseTexture): boolean;
  113199. /**
  113200. * Makes a duplicate of the material, and gives it a new name
  113201. * @param name defines the new name for the duplicated material
  113202. * @returns the cloned material
  113203. */
  113204. clone(name: string): ShaderMaterial;
  113205. /**
  113206. * Disposes the material
  113207. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  113208. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  113209. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  113210. */
  113211. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  113212. /**
  113213. * Serializes this material in a JSON representation
  113214. * @returns the serialized material object
  113215. */
  113216. serialize(): any;
  113217. /**
  113218. * Creates a shader material from parsed shader material data
  113219. * @param source defines the JSON represnetation of the material
  113220. * @param scene defines the hosting scene
  113221. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  113222. * @returns a new material
  113223. */
  113224. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  113225. /**
  113226. * Creates a new ShaderMaterial from a snippet saved in a remote file
  113227. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  113228. * @param url defines the url to load from
  113229. * @param scene defines the hosting scene
  113230. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  113231. * @returns a promise that will resolve to the new ShaderMaterial
  113232. */
  113233. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  113234. /**
  113235. * Creates a ShaderMaterial from a snippet saved by the Inspector
  113236. * @param snippetId defines the snippet to load
  113237. * @param scene defines the hosting scene
  113238. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  113239. * @returns a promise that will resolve to the new ShaderMaterial
  113240. */
  113241. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  113242. }
  113243. }
  113244. declare module BABYLON {
  113245. /** @hidden */
  113246. export var colorPixelShader: {
  113247. name: string;
  113248. shader: string;
  113249. };
  113250. }
  113251. declare module BABYLON {
  113252. /** @hidden */
  113253. export var colorVertexShader: {
  113254. name: string;
  113255. shader: string;
  113256. };
  113257. }
  113258. declare module BABYLON {
  113259. /**
  113260. * Line mesh
  113261. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  113262. */
  113263. export class LinesMesh extends Mesh {
  113264. /**
  113265. * If vertex color should be applied to the mesh
  113266. */
  113267. readonly useVertexColor?: boolean | undefined;
  113268. /**
  113269. * If vertex alpha should be applied to the mesh
  113270. */
  113271. readonly useVertexAlpha?: boolean | undefined;
  113272. /**
  113273. * Color of the line (Default: White)
  113274. */
  113275. color: Color3;
  113276. /**
  113277. * Alpha of the line (Default: 1)
  113278. */
  113279. alpha: number;
  113280. /**
  113281. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  113282. * This margin is expressed in world space coordinates, so its value may vary.
  113283. * Default value is 0.1
  113284. */
  113285. intersectionThreshold: number;
  113286. private _colorShader;
  113287. private color4;
  113288. /**
  113289. * Creates a new LinesMesh
  113290. * @param name defines the name
  113291. * @param scene defines the hosting scene
  113292. * @param parent defines the parent mesh if any
  113293. * @param source defines the optional source LinesMesh used to clone data from
  113294. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  113295. * When false, achieved by calling a clone(), also passing False.
  113296. * This will make creation of children, recursive.
  113297. * @param useVertexColor defines if this LinesMesh supports vertex color
  113298. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  113299. */
  113300. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  113301. /**
  113302. * If vertex color should be applied to the mesh
  113303. */
  113304. useVertexColor?: boolean | undefined,
  113305. /**
  113306. * If vertex alpha should be applied to the mesh
  113307. */
  113308. useVertexAlpha?: boolean | undefined);
  113309. private _addClipPlaneDefine;
  113310. private _removeClipPlaneDefine;
  113311. isReady(): boolean;
  113312. /**
  113313. * Returns the string "LineMesh"
  113314. */
  113315. getClassName(): string;
  113316. /**
  113317. * @hidden
  113318. */
  113319. get material(): Material;
  113320. /**
  113321. * @hidden
  113322. */
  113323. set material(value: Material);
  113324. /**
  113325. * @hidden
  113326. */
  113327. get checkCollisions(): boolean;
  113328. set checkCollisions(value: boolean);
  113329. /** @hidden */
  113330. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  113331. /** @hidden */
  113332. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  113333. /**
  113334. * Disposes of the line mesh
  113335. * @param doNotRecurse If children should be disposed
  113336. */
  113337. dispose(doNotRecurse?: boolean): void;
  113338. /**
  113339. * Returns a new LineMesh object cloned from the current one.
  113340. */
  113341. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  113342. /**
  113343. * Creates a new InstancedLinesMesh object from the mesh model.
  113344. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  113345. * @param name defines the name of the new instance
  113346. * @returns a new InstancedLinesMesh
  113347. */
  113348. createInstance(name: string): InstancedLinesMesh;
  113349. }
  113350. /**
  113351. * Creates an instance based on a source LinesMesh
  113352. */
  113353. export class InstancedLinesMesh extends InstancedMesh {
  113354. /**
  113355. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  113356. * This margin is expressed in world space coordinates, so its value may vary.
  113357. * Initilized with the intersectionThreshold value of the source LinesMesh
  113358. */
  113359. intersectionThreshold: number;
  113360. constructor(name: string, source: LinesMesh);
  113361. /**
  113362. * Returns the string "InstancedLinesMesh".
  113363. */
  113364. getClassName(): string;
  113365. }
  113366. }
  113367. declare module BABYLON {
  113368. /** @hidden */
  113369. export var linePixelShader: {
  113370. name: string;
  113371. shader: string;
  113372. };
  113373. }
  113374. declare module BABYLON {
  113375. /** @hidden */
  113376. export var lineVertexShader: {
  113377. name: string;
  113378. shader: string;
  113379. };
  113380. }
  113381. declare module BABYLON {
  113382. interface Scene {
  113383. /** @hidden */
  113384. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  113385. }
  113386. interface AbstractMesh {
  113387. /**
  113388. * Gets the edgesRenderer associated with the mesh
  113389. */
  113390. edgesRenderer: Nullable<EdgesRenderer>;
  113391. }
  113392. interface LinesMesh {
  113393. /**
  113394. * Enables the edge rendering mode on the mesh.
  113395. * This mode makes the mesh edges visible
  113396. * @param epsilon defines the maximal distance between two angles to detect a face
  113397. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  113398. * @returns the currentAbstractMesh
  113399. * @see https://www.babylonjs-playground.com/#19O9TU#0
  113400. */
  113401. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  113402. }
  113403. interface InstancedLinesMesh {
  113404. /**
  113405. * Enables the edge rendering mode on the mesh.
  113406. * This mode makes the mesh edges visible
  113407. * @param epsilon defines the maximal distance between two angles to detect a face
  113408. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  113409. * @returns the current InstancedLinesMesh
  113410. * @see https://www.babylonjs-playground.com/#19O9TU#0
  113411. */
  113412. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  113413. }
  113414. /**
  113415. * Defines the minimum contract an Edges renderer should follow.
  113416. */
  113417. export interface IEdgesRenderer extends IDisposable {
  113418. /**
  113419. * Gets or sets a boolean indicating if the edgesRenderer is active
  113420. */
  113421. isEnabled: boolean;
  113422. /**
  113423. * Renders the edges of the attached mesh,
  113424. */
  113425. render(): void;
  113426. /**
  113427. * Checks wether or not the edges renderer is ready to render.
  113428. * @return true if ready, otherwise false.
  113429. */
  113430. isReady(): boolean;
  113431. /**
  113432. * List of instances to render in case the source mesh has instances
  113433. */
  113434. customInstances: SmartArray<Matrix>;
  113435. }
  113436. /**
  113437. * Defines the additional options of the edges renderer
  113438. */
  113439. export interface IEdgesRendererOptions {
  113440. /**
  113441. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  113442. * If not defined, the default value is true
  113443. */
  113444. useAlternateEdgeFinder?: boolean;
  113445. /**
  113446. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  113447. * If not defined, the default value is true.
  113448. * 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)
  113449. * This option is used only if useAlternateEdgeFinder = true
  113450. */
  113451. useFastVertexMerger?: boolean;
  113452. /**
  113453. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  113454. * The default value is 1e-6
  113455. * This option is used only if useAlternateEdgeFinder = true
  113456. */
  113457. epsilonVertexMerge?: number;
  113458. /**
  113459. * 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
  113460. * 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.
  113461. * This option is used only if useAlternateEdgeFinder = true
  113462. */
  113463. applyTessellation?: boolean;
  113464. /**
  113465. * 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
  113466. * The default value is 1e-6
  113467. * This option is used only if useAlternateEdgeFinder = true
  113468. */
  113469. epsilonVertexAligned?: number;
  113470. }
  113471. /**
  113472. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  113473. */
  113474. export class EdgesRenderer implements IEdgesRenderer {
  113475. /**
  113476. * Define the size of the edges with an orthographic camera
  113477. */
  113478. edgesWidthScalerForOrthographic: number;
  113479. /**
  113480. * Define the size of the edges with a perspective camera
  113481. */
  113482. edgesWidthScalerForPerspective: number;
  113483. protected _source: AbstractMesh;
  113484. protected _linesPositions: number[];
  113485. protected _linesNormals: number[];
  113486. protected _linesIndices: number[];
  113487. protected _epsilon: number;
  113488. protected _indicesCount: number;
  113489. protected _lineShader: ShaderMaterial;
  113490. protected _ib: DataBuffer;
  113491. protected _buffers: {
  113492. [key: string]: Nullable<VertexBuffer>;
  113493. };
  113494. protected _buffersForInstances: {
  113495. [key: string]: Nullable<VertexBuffer>;
  113496. };
  113497. protected _checkVerticesInsteadOfIndices: boolean;
  113498. protected _options: Nullable<IEdgesRendererOptions>;
  113499. private _meshRebuildObserver;
  113500. private _meshDisposeObserver;
  113501. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  113502. isEnabled: boolean;
  113503. /** Gets the vertices generated by the edge renderer */
  113504. get linesPositions(): Immutable<Array<number>>;
  113505. /** Gets the normals generated by the edge renderer */
  113506. get linesNormals(): Immutable<Array<number>>;
  113507. /** Gets the indices generated by the edge renderer */
  113508. get linesIndices(): Immutable<Array<number>>;
  113509. /**
  113510. * List of instances to render in case the source mesh has instances
  113511. */
  113512. customInstances: SmartArray<Matrix>;
  113513. private static GetShader;
  113514. /**
  113515. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  113516. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  113517. * @param source Mesh used to create edges
  113518. * @param epsilon sum of angles in adjacency to check for edge
  113519. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  113520. * @param generateEdgesLines - should generate Lines or only prepare resources.
  113521. * @param options The options to apply when generating the edges
  113522. */
  113523. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  113524. protected _prepareRessources(): void;
  113525. /** @hidden */
  113526. _rebuild(): void;
  113527. /**
  113528. * Releases the required resources for the edges renderer
  113529. */
  113530. dispose(): void;
  113531. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  113532. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  113533. /**
  113534. * Checks if the pair of p0 and p1 is en edge
  113535. * @param faceIndex
  113536. * @param edge
  113537. * @param faceNormals
  113538. * @param p0
  113539. * @param p1
  113540. * @private
  113541. */
  113542. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  113543. /**
  113544. * push line into the position, normal and index buffer
  113545. * @protected
  113546. */
  113547. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  113548. /**
  113549. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  113550. */
  113551. private _tessellateTriangle;
  113552. private _generateEdgesLinesAlternate;
  113553. /**
  113554. * Generates lines edges from adjacencjes
  113555. * @private
  113556. */
  113557. _generateEdgesLines(): void;
  113558. /**
  113559. * Checks wether or not the edges renderer is ready to render.
  113560. * @return true if ready, otherwise false.
  113561. */
  113562. isReady(): boolean;
  113563. /**
  113564. * Renders the edges of the attached mesh,
  113565. */
  113566. render(): void;
  113567. }
  113568. /**
  113569. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  113570. */
  113571. export class LineEdgesRenderer extends EdgesRenderer {
  113572. /**
  113573. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  113574. * @param source LineMesh used to generate edges
  113575. * @param epsilon not important (specified angle for edge detection)
  113576. * @param checkVerticesInsteadOfIndices not important for LineMesh
  113577. */
  113578. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  113579. /**
  113580. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  113581. */
  113582. _generateEdgesLines(): void;
  113583. }
  113584. }
  113585. declare module BABYLON {
  113586. /**
  113587. * This represents the object necessary to create a rendering group.
  113588. * This is exclusively used and created by the rendering manager.
  113589. * To modify the behavior, you use the available helpers in your scene or meshes.
  113590. * @hidden
  113591. */
  113592. export class RenderingGroup {
  113593. index: number;
  113594. private static _zeroVector;
  113595. private _scene;
  113596. private _opaqueSubMeshes;
  113597. private _transparentSubMeshes;
  113598. private _alphaTestSubMeshes;
  113599. private _depthOnlySubMeshes;
  113600. private _particleSystems;
  113601. private _spriteManagers;
  113602. private _opaqueSortCompareFn;
  113603. private _alphaTestSortCompareFn;
  113604. private _transparentSortCompareFn;
  113605. private _renderOpaque;
  113606. private _renderAlphaTest;
  113607. private _renderTransparent;
  113608. /** @hidden */
  113609. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  113610. onBeforeTransparentRendering: () => void;
  113611. /**
  113612. * Set the opaque sort comparison function.
  113613. * If null the sub meshes will be render in the order they were created
  113614. */
  113615. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  113616. /**
  113617. * Set the alpha test sort comparison function.
  113618. * If null the sub meshes will be render in the order they were created
  113619. */
  113620. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  113621. /**
  113622. * Set the transparent sort comparison function.
  113623. * If null the sub meshes will be render in the order they were created
  113624. */
  113625. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  113626. /**
  113627. * Creates a new rendering group.
  113628. * @param index The rendering group index
  113629. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  113630. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  113631. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  113632. */
  113633. 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>);
  113634. /**
  113635. * Render all the sub meshes contained in the group.
  113636. * @param customRenderFunction Used to override the default render behaviour of the group.
  113637. * @returns true if rendered some submeshes.
  113638. */
  113639. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  113640. /**
  113641. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  113642. * @param subMeshes The submeshes to render
  113643. */
  113644. private renderOpaqueSorted;
  113645. /**
  113646. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  113647. * @param subMeshes The submeshes to render
  113648. */
  113649. private renderAlphaTestSorted;
  113650. /**
  113651. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  113652. * @param subMeshes The submeshes to render
  113653. */
  113654. private renderTransparentSorted;
  113655. /**
  113656. * Renders the submeshes in a specified order.
  113657. * @param subMeshes The submeshes to sort before render
  113658. * @param sortCompareFn The comparison function use to sort
  113659. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  113660. * @param transparent Specifies to activate blending if true
  113661. */
  113662. private static renderSorted;
  113663. /**
  113664. * Renders the submeshes in the order they were dispatched (no sort applied).
  113665. * @param subMeshes The submeshes to render
  113666. */
  113667. private static renderUnsorted;
  113668. /**
  113669. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  113670. * are rendered back to front if in the same alpha index.
  113671. *
  113672. * @param a The first submesh
  113673. * @param b The second submesh
  113674. * @returns The result of the comparison
  113675. */
  113676. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  113677. /**
  113678. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  113679. * are rendered back to front.
  113680. *
  113681. * @param a The first submesh
  113682. * @param b The second submesh
  113683. * @returns The result of the comparison
  113684. */
  113685. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  113686. /**
  113687. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  113688. * are rendered front to back (prevent overdraw).
  113689. *
  113690. * @param a The first submesh
  113691. * @param b The second submesh
  113692. * @returns The result of the comparison
  113693. */
  113694. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  113695. /**
  113696. * Resets the different lists of submeshes to prepare a new frame.
  113697. */
  113698. prepare(): void;
  113699. dispose(): void;
  113700. /**
  113701. * Inserts the submesh in its correct queue depending on its material.
  113702. * @param subMesh The submesh to dispatch
  113703. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  113704. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  113705. */
  113706. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  113707. dispatchSprites(spriteManager: ISpriteManager): void;
  113708. dispatchParticles(particleSystem: IParticleSystem): void;
  113709. private _renderParticles;
  113710. private _renderSprites;
  113711. }
  113712. }
  113713. declare module BABYLON {
  113714. /**
  113715. * Interface describing the different options available in the rendering manager
  113716. * regarding Auto Clear between groups.
  113717. */
  113718. export interface IRenderingManagerAutoClearSetup {
  113719. /**
  113720. * Defines whether or not autoclear is enable.
  113721. */
  113722. autoClear: boolean;
  113723. /**
  113724. * Defines whether or not to autoclear the depth buffer.
  113725. */
  113726. depth: boolean;
  113727. /**
  113728. * Defines whether or not to autoclear the stencil buffer.
  113729. */
  113730. stencil: boolean;
  113731. }
  113732. /**
  113733. * This class is used by the onRenderingGroupObservable
  113734. */
  113735. export class RenderingGroupInfo {
  113736. /**
  113737. * The Scene that being rendered
  113738. */
  113739. scene: Scene;
  113740. /**
  113741. * The camera currently used for the rendering pass
  113742. */
  113743. camera: Nullable<Camera>;
  113744. /**
  113745. * The ID of the renderingGroup being processed
  113746. */
  113747. renderingGroupId: number;
  113748. }
  113749. /**
  113750. * This is the manager responsible of all the rendering for meshes sprites and particles.
  113751. * It is enable to manage the different groups as well as the different necessary sort functions.
  113752. * This should not be used directly aside of the few static configurations
  113753. */
  113754. export class RenderingManager {
  113755. /**
  113756. * The max id used for rendering groups (not included)
  113757. */
  113758. static MAX_RENDERINGGROUPS: number;
  113759. /**
  113760. * The min id used for rendering groups (included)
  113761. */
  113762. static MIN_RENDERINGGROUPS: number;
  113763. /**
  113764. * Used to globally prevent autoclearing scenes.
  113765. */
  113766. static AUTOCLEAR: boolean;
  113767. /**
  113768. * @hidden
  113769. */
  113770. _useSceneAutoClearSetup: boolean;
  113771. private _scene;
  113772. private _renderingGroups;
  113773. private _depthStencilBufferAlreadyCleaned;
  113774. private _autoClearDepthStencil;
  113775. private _customOpaqueSortCompareFn;
  113776. private _customAlphaTestSortCompareFn;
  113777. private _customTransparentSortCompareFn;
  113778. private _renderingGroupInfo;
  113779. /**
  113780. * Instantiates a new rendering group for a particular scene
  113781. * @param scene Defines the scene the groups belongs to
  113782. */
  113783. constructor(scene: Scene);
  113784. private _clearDepthStencilBuffer;
  113785. /**
  113786. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  113787. * @hidden
  113788. */
  113789. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  113790. /**
  113791. * Resets the different information of the group to prepare a new frame
  113792. * @hidden
  113793. */
  113794. reset(): void;
  113795. /**
  113796. * Dispose and release the group and its associated resources.
  113797. * @hidden
  113798. */
  113799. dispose(): void;
  113800. /**
  113801. * Clear the info related to rendering groups preventing retention points during dispose.
  113802. */
  113803. freeRenderingGroups(): void;
  113804. private _prepareRenderingGroup;
  113805. /**
  113806. * Add a sprite manager to the rendering manager in order to render it this frame.
  113807. * @param spriteManager Define the sprite manager to render
  113808. */
  113809. dispatchSprites(spriteManager: ISpriteManager): void;
  113810. /**
  113811. * Add a particle system to the rendering manager in order to render it this frame.
  113812. * @param particleSystem Define the particle system to render
  113813. */
  113814. dispatchParticles(particleSystem: IParticleSystem): void;
  113815. /**
  113816. * Add a submesh to the manager in order to render it this frame
  113817. * @param subMesh The submesh to dispatch
  113818. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  113819. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  113820. */
  113821. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  113822. /**
  113823. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  113824. * This allowed control for front to back rendering or reversly depending of the special needs.
  113825. *
  113826. * @param renderingGroupId The rendering group id corresponding to its index
  113827. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  113828. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  113829. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  113830. */
  113831. 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;
  113832. /**
  113833. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  113834. *
  113835. * @param renderingGroupId The rendering group id corresponding to its index
  113836. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  113837. * @param depth Automatically clears depth between groups if true and autoClear is true.
  113838. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  113839. */
  113840. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  113841. /**
  113842. * Gets the current auto clear configuration for one rendering group of the rendering
  113843. * manager.
  113844. * @param index the rendering group index to get the information for
  113845. * @returns The auto clear setup for the requested rendering group
  113846. */
  113847. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  113848. }
  113849. }
  113850. declare module BABYLON {
  113851. /**
  113852. * Defines the options associated with the creation of a custom shader for a shadow generator.
  113853. */
  113854. export interface ICustomShaderOptions {
  113855. /**
  113856. * Gets or sets the custom shader name to use
  113857. */
  113858. shaderName: string;
  113859. /**
  113860. * The list of attribute names used in the shader
  113861. */
  113862. attributes?: string[];
  113863. /**
  113864. * The list of unifrom names used in the shader
  113865. */
  113866. uniforms?: string[];
  113867. /**
  113868. * The list of sampler names used in the shader
  113869. */
  113870. samplers?: string[];
  113871. /**
  113872. * The list of defines used in the shader
  113873. */
  113874. defines?: string[];
  113875. }
  113876. /**
  113877. * Interface to implement to create a shadow generator compatible with BJS.
  113878. */
  113879. export interface IShadowGenerator {
  113880. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  113881. id: string;
  113882. /**
  113883. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  113884. * @returns The render target texture if present otherwise, null
  113885. */
  113886. getShadowMap(): Nullable<RenderTargetTexture>;
  113887. /**
  113888. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  113889. * @param subMesh The submesh we want to render in the shadow map
  113890. * @param useInstances Defines wether will draw in the map using instances
  113891. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  113892. * @returns true if ready otherwise, false
  113893. */
  113894. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  113895. /**
  113896. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  113897. * @param defines Defines of the material we want to update
  113898. * @param lightIndex Index of the light in the enabled light list of the material
  113899. */
  113900. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  113901. /**
  113902. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  113903. * defined in the generator but impacting the effect).
  113904. * It implies the unifroms available on the materials are the standard BJS ones.
  113905. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  113906. * @param effect The effect we are binfing the information for
  113907. */
  113908. bindShadowLight(lightIndex: string, effect: Effect): void;
  113909. /**
  113910. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  113911. * (eq to shadow prjection matrix * light transform matrix)
  113912. * @returns The transform matrix used to create the shadow map
  113913. */
  113914. getTransformMatrix(): Matrix;
  113915. /**
  113916. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  113917. * Cube and 2D textures for instance.
  113918. */
  113919. recreateShadowMap(): void;
  113920. /**
  113921. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  113922. * @param onCompiled Callback triggered at the and of the effects compilation
  113923. * @param options Sets of optional options forcing the compilation with different modes
  113924. */
  113925. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  113926. useInstances: boolean;
  113927. }>): void;
  113928. /**
  113929. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  113930. * @param options Sets of optional options forcing the compilation with different modes
  113931. * @returns A promise that resolves when the compilation completes
  113932. */
  113933. forceCompilationAsync(options?: Partial<{
  113934. useInstances: boolean;
  113935. }>): Promise<void>;
  113936. /**
  113937. * Serializes the shadow generator setup to a json object.
  113938. * @returns The serialized JSON object
  113939. */
  113940. serialize(): any;
  113941. /**
  113942. * Disposes the Shadow map and related Textures and effects.
  113943. */
  113944. dispose(): void;
  113945. }
  113946. /**
  113947. * Default implementation IShadowGenerator.
  113948. * This is the main object responsible of generating shadows in the framework.
  113949. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  113950. */
  113951. export class ShadowGenerator implements IShadowGenerator {
  113952. private static _Counter;
  113953. /**
  113954. * Name of the shadow generator class
  113955. */
  113956. static CLASSNAME: string;
  113957. /**
  113958. * Shadow generator mode None: no filtering applied.
  113959. */
  113960. static readonly FILTER_NONE: number;
  113961. /**
  113962. * Shadow generator mode ESM: Exponential Shadow Mapping.
  113963. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  113964. */
  113965. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  113966. /**
  113967. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  113968. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  113969. */
  113970. static readonly FILTER_POISSONSAMPLING: number;
  113971. /**
  113972. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  113973. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  113974. */
  113975. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  113976. /**
  113977. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  113978. * edge artifacts on steep falloff.
  113979. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  113980. */
  113981. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  113982. /**
  113983. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  113984. * edge artifacts on steep falloff.
  113985. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  113986. */
  113987. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  113988. /**
  113989. * Shadow generator mode PCF: Percentage Closer Filtering
  113990. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  113991. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  113992. */
  113993. static readonly FILTER_PCF: number;
  113994. /**
  113995. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  113996. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  113997. * Contact Hardening
  113998. */
  113999. static readonly FILTER_PCSS: number;
  114000. /**
  114001. * Reserved for PCF and PCSS
  114002. * Highest Quality.
  114003. *
  114004. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  114005. *
  114006. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  114007. */
  114008. static readonly QUALITY_HIGH: number;
  114009. /**
  114010. * Reserved for PCF and PCSS
  114011. * Good tradeoff for quality/perf cross devices
  114012. *
  114013. * Execute PCF on a 3*3 kernel.
  114014. *
  114015. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  114016. */
  114017. static readonly QUALITY_MEDIUM: number;
  114018. /**
  114019. * Reserved for PCF and PCSS
  114020. * The lowest quality but the fastest.
  114021. *
  114022. * Execute PCF on a 1*1 kernel.
  114023. *
  114024. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  114025. */
  114026. static readonly QUALITY_LOW: number;
  114027. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  114028. id: string;
  114029. /** Gets or sets the custom shader name to use */
  114030. customShaderOptions: ICustomShaderOptions;
  114031. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  114032. customAllowRendering: (subMesh: SubMesh) => boolean;
  114033. /**
  114034. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  114035. */
  114036. onBeforeShadowMapRenderObservable: Observable<Effect>;
  114037. /**
  114038. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  114039. */
  114040. onAfterShadowMapRenderObservable: Observable<Effect>;
  114041. /**
  114042. * Observable triggered before a mesh is rendered in the shadow map.
  114043. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  114044. */
  114045. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  114046. /**
  114047. * Observable triggered after a mesh is rendered in the shadow map.
  114048. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  114049. */
  114050. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  114051. protected _bias: number;
  114052. /**
  114053. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  114054. */
  114055. get bias(): number;
  114056. /**
  114057. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  114058. */
  114059. set bias(bias: number);
  114060. protected _normalBias: number;
  114061. /**
  114062. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  114063. */
  114064. get normalBias(): number;
  114065. /**
  114066. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  114067. */
  114068. set normalBias(normalBias: number);
  114069. protected _blurBoxOffset: number;
  114070. /**
  114071. * Gets the blur box offset: offset applied during the blur pass.
  114072. * Only useful if useKernelBlur = false
  114073. */
  114074. get blurBoxOffset(): number;
  114075. /**
  114076. * Sets the blur box offset: offset applied during the blur pass.
  114077. * Only useful if useKernelBlur = false
  114078. */
  114079. set blurBoxOffset(value: number);
  114080. protected _blurScale: number;
  114081. /**
  114082. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  114083. * 2 means half of the size.
  114084. */
  114085. get blurScale(): number;
  114086. /**
  114087. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  114088. * 2 means half of the size.
  114089. */
  114090. set blurScale(value: number);
  114091. protected _blurKernel: number;
  114092. /**
  114093. * Gets the blur kernel: kernel size of the blur pass.
  114094. * Only useful if useKernelBlur = true
  114095. */
  114096. get blurKernel(): number;
  114097. /**
  114098. * Sets the blur kernel: kernel size of the blur pass.
  114099. * Only useful if useKernelBlur = true
  114100. */
  114101. set blurKernel(value: number);
  114102. protected _useKernelBlur: boolean;
  114103. /**
  114104. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  114105. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  114106. */
  114107. get useKernelBlur(): boolean;
  114108. /**
  114109. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  114110. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  114111. */
  114112. set useKernelBlur(value: boolean);
  114113. protected _depthScale: number;
  114114. /**
  114115. * Gets the depth scale used in ESM mode.
  114116. */
  114117. get depthScale(): number;
  114118. /**
  114119. * Sets the depth scale used in ESM mode.
  114120. * This can override the scale stored on the light.
  114121. */
  114122. set depthScale(value: number);
  114123. protected _validateFilter(filter: number): number;
  114124. protected _filter: number;
  114125. /**
  114126. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  114127. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  114128. */
  114129. get filter(): number;
  114130. /**
  114131. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  114132. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  114133. */
  114134. set filter(value: number);
  114135. /**
  114136. * Gets if the current filter is set to Poisson Sampling.
  114137. */
  114138. get usePoissonSampling(): boolean;
  114139. /**
  114140. * Sets the current filter to Poisson Sampling.
  114141. */
  114142. set usePoissonSampling(value: boolean);
  114143. /**
  114144. * Gets if the current filter is set to ESM.
  114145. */
  114146. get useExponentialShadowMap(): boolean;
  114147. /**
  114148. * Sets the current filter is to ESM.
  114149. */
  114150. set useExponentialShadowMap(value: boolean);
  114151. /**
  114152. * Gets if the current filter is set to filtered ESM.
  114153. */
  114154. get useBlurExponentialShadowMap(): boolean;
  114155. /**
  114156. * Gets if the current filter is set to filtered ESM.
  114157. */
  114158. set useBlurExponentialShadowMap(value: boolean);
  114159. /**
  114160. * Gets if the current filter is set to "close ESM" (using the inverse of the
  114161. * exponential to prevent steep falloff artifacts).
  114162. */
  114163. get useCloseExponentialShadowMap(): boolean;
  114164. /**
  114165. * Sets the current filter to "close ESM" (using the inverse of the
  114166. * exponential to prevent steep falloff artifacts).
  114167. */
  114168. set useCloseExponentialShadowMap(value: boolean);
  114169. /**
  114170. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  114171. * exponential to prevent steep falloff artifacts).
  114172. */
  114173. get useBlurCloseExponentialShadowMap(): boolean;
  114174. /**
  114175. * Sets the current filter to filtered "close ESM" (using the inverse of the
  114176. * exponential to prevent steep falloff artifacts).
  114177. */
  114178. set useBlurCloseExponentialShadowMap(value: boolean);
  114179. /**
  114180. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  114181. */
  114182. get usePercentageCloserFiltering(): boolean;
  114183. /**
  114184. * Sets the current filter to "PCF" (percentage closer filtering).
  114185. */
  114186. set usePercentageCloserFiltering(value: boolean);
  114187. protected _filteringQuality: number;
  114188. /**
  114189. * Gets the PCF or PCSS Quality.
  114190. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  114191. */
  114192. get filteringQuality(): number;
  114193. /**
  114194. * Sets the PCF or PCSS Quality.
  114195. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  114196. */
  114197. set filteringQuality(filteringQuality: number);
  114198. /**
  114199. * Gets if the current filter is set to "PCSS" (contact hardening).
  114200. */
  114201. get useContactHardeningShadow(): boolean;
  114202. /**
  114203. * Sets the current filter to "PCSS" (contact hardening).
  114204. */
  114205. set useContactHardeningShadow(value: boolean);
  114206. protected _contactHardeningLightSizeUVRatio: number;
  114207. /**
  114208. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  114209. * Using a ratio helps keeping shape stability independently of the map size.
  114210. *
  114211. * It does not account for the light projection as it was having too much
  114212. * instability during the light setup or during light position changes.
  114213. *
  114214. * Only valid if useContactHardeningShadow is true.
  114215. */
  114216. get contactHardeningLightSizeUVRatio(): number;
  114217. /**
  114218. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  114219. * Using a ratio helps keeping shape stability independently of the map size.
  114220. *
  114221. * It does not account for the light projection as it was having too much
  114222. * instability during the light setup or during light position changes.
  114223. *
  114224. * Only valid if useContactHardeningShadow is true.
  114225. */
  114226. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  114227. protected _darkness: number;
  114228. /** Gets or sets the actual darkness of a shadow */
  114229. get darkness(): number;
  114230. set darkness(value: number);
  114231. /**
  114232. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  114233. * 0 means strongest and 1 would means no shadow.
  114234. * @returns the darkness.
  114235. */
  114236. getDarkness(): number;
  114237. /**
  114238. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  114239. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  114240. * @returns the shadow generator allowing fluent coding.
  114241. */
  114242. setDarkness(darkness: number): ShadowGenerator;
  114243. protected _transparencyShadow: boolean;
  114244. /** Gets or sets the ability to have transparent shadow */
  114245. get transparencyShadow(): boolean;
  114246. set transparencyShadow(value: boolean);
  114247. /**
  114248. * Sets the ability to have transparent shadow (boolean).
  114249. * @param transparent True if transparent else False
  114250. * @returns the shadow generator allowing fluent coding
  114251. */
  114252. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  114253. /**
  114254. * Enables or disables shadows with varying strength based on the transparency
  114255. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  114256. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  114257. * mesh.visibility * alphaTexture.a
  114258. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  114259. */
  114260. enableSoftTransparentShadow: boolean;
  114261. protected _shadowMap: Nullable<RenderTargetTexture>;
  114262. protected _shadowMap2: Nullable<RenderTargetTexture>;
  114263. /**
  114264. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  114265. * @returns The render target texture if present otherwise, null
  114266. */
  114267. getShadowMap(): Nullable<RenderTargetTexture>;
  114268. /**
  114269. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  114270. * @returns The render target texture if the shadow map is present otherwise, null
  114271. */
  114272. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  114273. /**
  114274. * Gets the class name of that object
  114275. * @returns "ShadowGenerator"
  114276. */
  114277. getClassName(): string;
  114278. /**
  114279. * Helper function to add a mesh and its descendants to the list of shadow casters.
  114280. * @param mesh Mesh to add
  114281. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  114282. * @returns the Shadow Generator itself
  114283. */
  114284. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  114285. /**
  114286. * Helper function to remove a mesh and its descendants from the list of shadow casters
  114287. * @param mesh Mesh to remove
  114288. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  114289. * @returns the Shadow Generator itself
  114290. */
  114291. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  114292. /**
  114293. * Controls the extent to which the shadows fade out at the edge of the frustum
  114294. */
  114295. frustumEdgeFalloff: number;
  114296. protected _light: IShadowLight;
  114297. /**
  114298. * Returns the associated light object.
  114299. * @returns the light generating the shadow
  114300. */
  114301. getLight(): IShadowLight;
  114302. /**
  114303. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  114304. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  114305. * It might on the other hand introduce peter panning.
  114306. */
  114307. forceBackFacesOnly: boolean;
  114308. protected _scene: Scene;
  114309. protected _lightDirection: Vector3;
  114310. protected _viewMatrix: Matrix;
  114311. protected _projectionMatrix: Matrix;
  114312. protected _transformMatrix: Matrix;
  114313. protected _cachedPosition: Vector3;
  114314. protected _cachedDirection: Vector3;
  114315. protected _cachedDefines: string;
  114316. protected _currentRenderID: number;
  114317. protected _boxBlurPostprocess: Nullable<PostProcess>;
  114318. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  114319. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  114320. protected _blurPostProcesses: PostProcess[];
  114321. protected _mapSize: number;
  114322. protected _currentFaceIndex: number;
  114323. protected _currentFaceIndexCache: number;
  114324. protected _textureType: number;
  114325. protected _defaultTextureMatrix: Matrix;
  114326. protected _storedUniqueId: Nullable<number>;
  114327. protected _nameForCustomEffect: string;
  114328. /** @hidden */
  114329. static _SceneComponentInitialization: (scene: Scene) => void;
  114330. /**
  114331. * Gets or sets the size of the texture what stores the shadows
  114332. */
  114333. get mapSize(): number;
  114334. set mapSize(size: number);
  114335. /**
  114336. * Creates a ShadowGenerator object.
  114337. * A ShadowGenerator is the required tool to use the shadows.
  114338. * Each light casting shadows needs to use its own ShadowGenerator.
  114339. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  114340. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  114341. * @param light The light object generating the shadows.
  114342. * @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.
  114343. */
  114344. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  114345. protected _initializeGenerator(): void;
  114346. protected _createTargetRenderTexture(): void;
  114347. protected _initializeShadowMap(): void;
  114348. protected _initializeBlurRTTAndPostProcesses(): void;
  114349. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  114350. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  114351. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  114352. protected _applyFilterValues(): void;
  114353. /**
  114354. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  114355. * @param onCompiled Callback triggered at the and of the effects compilation
  114356. * @param options Sets of optional options forcing the compilation with different modes
  114357. */
  114358. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  114359. useInstances: boolean;
  114360. }>): void;
  114361. /**
  114362. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  114363. * @param options Sets of optional options forcing the compilation with different modes
  114364. * @returns A promise that resolves when the compilation completes
  114365. */
  114366. forceCompilationAsync(options?: Partial<{
  114367. useInstances: boolean;
  114368. }>): Promise<void>;
  114369. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  114370. private _prepareShadowDefines;
  114371. /**
  114372. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  114373. * @param subMesh The submesh we want to render in the shadow map
  114374. * @param useInstances Defines wether will draw in the map using instances
  114375. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  114376. * @returns true if ready otherwise, false
  114377. */
  114378. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  114379. /**
  114380. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  114381. * @param defines Defines of the material we want to update
  114382. * @param lightIndex Index of the light in the enabled light list of the material
  114383. */
  114384. prepareDefines(defines: any, lightIndex: number): void;
  114385. /**
  114386. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  114387. * defined in the generator but impacting the effect).
  114388. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  114389. * @param effect The effect we are binfing the information for
  114390. */
  114391. bindShadowLight(lightIndex: string, effect: Effect): void;
  114392. /**
  114393. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  114394. * (eq to shadow prjection matrix * light transform matrix)
  114395. * @returns The transform matrix used to create the shadow map
  114396. */
  114397. getTransformMatrix(): Matrix;
  114398. /**
  114399. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  114400. * Cube and 2D textures for instance.
  114401. */
  114402. recreateShadowMap(): void;
  114403. protected _disposeBlurPostProcesses(): void;
  114404. protected _disposeRTTandPostProcesses(): void;
  114405. /**
  114406. * Disposes the ShadowGenerator.
  114407. * Returns nothing.
  114408. */
  114409. dispose(): void;
  114410. /**
  114411. * Serializes the shadow generator setup to a json object.
  114412. * @returns The serialized JSON object
  114413. */
  114414. serialize(): any;
  114415. /**
  114416. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  114417. * @param parsedShadowGenerator The JSON object to parse
  114418. * @param scene The scene to create the shadow map for
  114419. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  114420. * @returns The parsed shadow generator
  114421. */
  114422. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  114423. }
  114424. }
  114425. declare module BABYLON {
  114426. /**
  114427. * Options to be used when creating a shadow depth material
  114428. */
  114429. export interface IIOptionShadowDepthMaterial {
  114430. /** Variables in the vertex shader code that need to have their names remapped.
  114431. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  114432. * "var_name" should be either: worldPos or vNormalW
  114433. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  114434. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  114435. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  114436. */
  114437. remappedVariables?: string[];
  114438. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  114439. standalone?: boolean;
  114440. }
  114441. /**
  114442. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  114443. */
  114444. export class ShadowDepthWrapper {
  114445. private _scene;
  114446. private _options?;
  114447. private _baseMaterial;
  114448. private _onEffectCreatedObserver;
  114449. private _subMeshToEffect;
  114450. private _subMeshToDepthEffect;
  114451. private _meshes;
  114452. /** @hidden */
  114453. _matriceNames: any;
  114454. /** Gets the standalone status of the wrapper */
  114455. get standalone(): boolean;
  114456. /** Gets the base material the wrapper is built upon */
  114457. get baseMaterial(): Material;
  114458. /**
  114459. * Instantiate a new shadow depth wrapper.
  114460. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  114461. * generate the shadow depth map. For more information, please refer to the documentation:
  114462. * https://doc.babylonjs.com/babylon101/shadows
  114463. * @param baseMaterial Material to wrap
  114464. * @param scene Define the scene the material belongs to
  114465. * @param options Options used to create the wrapper
  114466. */
  114467. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  114468. /**
  114469. * Gets the effect to use to generate the depth map
  114470. * @param subMesh subMesh to get the effect for
  114471. * @param shadowGenerator shadow generator to get the effect for
  114472. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  114473. */
  114474. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  114475. /**
  114476. * Specifies that the submesh is ready to be used for depth rendering
  114477. * @param subMesh submesh to check
  114478. * @param defines the list of defines to take into account when checking the effect
  114479. * @param shadowGenerator combined with subMesh, it defines the effect to check
  114480. * @param useInstances specifies that instances should be used
  114481. * @returns a boolean indicating that the submesh is ready or not
  114482. */
  114483. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  114484. /**
  114485. * Disposes the resources
  114486. */
  114487. dispose(): void;
  114488. private _makeEffect;
  114489. }
  114490. }
  114491. declare module BABYLON {
  114492. /**
  114493. * Options for compiling materials.
  114494. */
  114495. export interface IMaterialCompilationOptions {
  114496. /**
  114497. * Defines whether clip planes are enabled.
  114498. */
  114499. clipPlane: boolean;
  114500. /**
  114501. * Defines whether instances are enabled.
  114502. */
  114503. useInstances: boolean;
  114504. }
  114505. /**
  114506. * Options passed when calling customShaderNameResolve
  114507. */
  114508. export interface ICustomShaderNameResolveOptions {
  114509. /**
  114510. * 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
  114511. */
  114512. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  114513. }
  114514. /**
  114515. * Base class for the main features of a material in Babylon.js
  114516. */
  114517. export class Material implements IAnimatable {
  114518. /**
  114519. * Returns the triangle fill mode
  114520. */
  114521. static readonly TriangleFillMode: number;
  114522. /**
  114523. * Returns the wireframe mode
  114524. */
  114525. static readonly WireFrameFillMode: number;
  114526. /**
  114527. * Returns the point fill mode
  114528. */
  114529. static readonly PointFillMode: number;
  114530. /**
  114531. * Returns the point list draw mode
  114532. */
  114533. static readonly PointListDrawMode: number;
  114534. /**
  114535. * Returns the line list draw mode
  114536. */
  114537. static readonly LineListDrawMode: number;
  114538. /**
  114539. * Returns the line loop draw mode
  114540. */
  114541. static readonly LineLoopDrawMode: number;
  114542. /**
  114543. * Returns the line strip draw mode
  114544. */
  114545. static readonly LineStripDrawMode: number;
  114546. /**
  114547. * Returns the triangle strip draw mode
  114548. */
  114549. static readonly TriangleStripDrawMode: number;
  114550. /**
  114551. * Returns the triangle fan draw mode
  114552. */
  114553. static readonly TriangleFanDrawMode: number;
  114554. /**
  114555. * Stores the clock-wise side orientation
  114556. */
  114557. static readonly ClockWiseSideOrientation: number;
  114558. /**
  114559. * Stores the counter clock-wise side orientation
  114560. */
  114561. static readonly CounterClockWiseSideOrientation: number;
  114562. /**
  114563. * The dirty texture flag value
  114564. */
  114565. static readonly TextureDirtyFlag: number;
  114566. /**
  114567. * The dirty light flag value
  114568. */
  114569. static readonly LightDirtyFlag: number;
  114570. /**
  114571. * The dirty fresnel flag value
  114572. */
  114573. static readonly FresnelDirtyFlag: number;
  114574. /**
  114575. * The dirty attribute flag value
  114576. */
  114577. static readonly AttributesDirtyFlag: number;
  114578. /**
  114579. * The dirty misc flag value
  114580. */
  114581. static readonly MiscDirtyFlag: number;
  114582. /**
  114583. * The dirty prepass flag value
  114584. */
  114585. static readonly PrePassDirtyFlag: number;
  114586. /**
  114587. * The all dirty flag value
  114588. */
  114589. static readonly AllDirtyFlag: number;
  114590. /**
  114591. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  114592. */
  114593. static readonly MATERIAL_OPAQUE: number;
  114594. /**
  114595. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  114596. */
  114597. static readonly MATERIAL_ALPHATEST: number;
  114598. /**
  114599. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114600. */
  114601. static readonly MATERIAL_ALPHABLEND: number;
  114602. /**
  114603. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114604. * They are also discarded below the alpha cutoff threshold to improve performances.
  114605. */
  114606. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  114607. /**
  114608. * The Whiteout method is used to blend normals.
  114609. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  114610. */
  114611. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  114612. /**
  114613. * The Reoriented Normal Mapping method is used to blend normals.
  114614. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  114615. */
  114616. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  114617. /**
  114618. * Custom callback helping to override the default shader used in the material.
  114619. */
  114620. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  114621. /**
  114622. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  114623. */
  114624. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  114625. /**
  114626. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  114627. * This means that the material can keep using a previous shader while a new one is being compiled.
  114628. * This is mostly used when shader parallel compilation is supported (true by default)
  114629. */
  114630. allowShaderHotSwapping: boolean;
  114631. /**
  114632. * The ID of the material
  114633. */
  114634. id: string;
  114635. /**
  114636. * Gets or sets the unique id of the material
  114637. */
  114638. uniqueId: number;
  114639. /**
  114640. * The name of the material
  114641. */
  114642. name: string;
  114643. /**
  114644. * Gets or sets user defined metadata
  114645. */
  114646. metadata: any;
  114647. /**
  114648. * For internal use only. Please do not use.
  114649. */
  114650. reservedDataStore: any;
  114651. /**
  114652. * Specifies if the ready state should be checked on each call
  114653. */
  114654. checkReadyOnEveryCall: boolean;
  114655. /**
  114656. * Specifies if the ready state should be checked once
  114657. */
  114658. checkReadyOnlyOnce: boolean;
  114659. /**
  114660. * The state of the material
  114661. */
  114662. state: string;
  114663. /**
  114664. * If the material can be rendered to several textures with MRT extension
  114665. */
  114666. get canRenderToMRT(): boolean;
  114667. /**
  114668. * The alpha value of the material
  114669. */
  114670. protected _alpha: number;
  114671. /**
  114672. * List of inspectable custom properties (used by the Inspector)
  114673. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  114674. */
  114675. inspectableCustomProperties: IInspectable[];
  114676. /**
  114677. * Sets the alpha value of the material
  114678. */
  114679. set alpha(value: number);
  114680. /**
  114681. * Gets the alpha value of the material
  114682. */
  114683. get alpha(): number;
  114684. /**
  114685. * Specifies if back face culling is enabled
  114686. */
  114687. protected _backFaceCulling: boolean;
  114688. /**
  114689. * Sets the back-face culling state
  114690. */
  114691. set backFaceCulling(value: boolean);
  114692. /**
  114693. * Gets the back-face culling state
  114694. */
  114695. get backFaceCulling(): boolean;
  114696. /**
  114697. * Stores the value for side orientation
  114698. */
  114699. sideOrientation: number;
  114700. /**
  114701. * Callback triggered when the material is compiled
  114702. */
  114703. onCompiled: Nullable<(effect: Effect) => void>;
  114704. /**
  114705. * Callback triggered when an error occurs
  114706. */
  114707. onError: Nullable<(effect: Effect, errors: string) => void>;
  114708. /**
  114709. * Callback triggered to get the render target textures
  114710. */
  114711. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  114712. /**
  114713. * Gets a boolean indicating that current material needs to register RTT
  114714. */
  114715. get hasRenderTargetTextures(): boolean;
  114716. /**
  114717. * Specifies if the material should be serialized
  114718. */
  114719. doNotSerialize: boolean;
  114720. /**
  114721. * @hidden
  114722. */
  114723. _storeEffectOnSubMeshes: boolean;
  114724. /**
  114725. * Stores the animations for the material
  114726. */
  114727. animations: Nullable<Array<Animation>>;
  114728. /**
  114729. * An event triggered when the material is disposed
  114730. */
  114731. onDisposeObservable: Observable<Material>;
  114732. /**
  114733. * An observer which watches for dispose events
  114734. */
  114735. private _onDisposeObserver;
  114736. private _onUnBindObservable;
  114737. /**
  114738. * Called during a dispose event
  114739. */
  114740. set onDispose(callback: () => void);
  114741. private _onBindObservable;
  114742. /**
  114743. * An event triggered when the material is bound
  114744. */
  114745. get onBindObservable(): Observable<AbstractMesh>;
  114746. /**
  114747. * An observer which watches for bind events
  114748. */
  114749. private _onBindObserver;
  114750. /**
  114751. * Called during a bind event
  114752. */
  114753. set onBind(callback: (Mesh: AbstractMesh) => void);
  114754. /**
  114755. * An event triggered when the material is unbound
  114756. */
  114757. get onUnBindObservable(): Observable<Material>;
  114758. protected _onEffectCreatedObservable: Nullable<Observable<{
  114759. effect: Effect;
  114760. subMesh: Nullable<SubMesh>;
  114761. }>>;
  114762. /**
  114763. * An event triggered when the effect is (re)created
  114764. */
  114765. get onEffectCreatedObservable(): Observable<{
  114766. effect: Effect;
  114767. subMesh: Nullable<SubMesh>;
  114768. }>;
  114769. /**
  114770. * Stores the value of the alpha mode
  114771. */
  114772. private _alphaMode;
  114773. /**
  114774. * Sets the value of the alpha mode.
  114775. *
  114776. * | Value | Type | Description |
  114777. * | --- | --- | --- |
  114778. * | 0 | ALPHA_DISABLE | |
  114779. * | 1 | ALPHA_ADD | |
  114780. * | 2 | ALPHA_COMBINE | |
  114781. * | 3 | ALPHA_SUBTRACT | |
  114782. * | 4 | ALPHA_MULTIPLY | |
  114783. * | 5 | ALPHA_MAXIMIZED | |
  114784. * | 6 | ALPHA_ONEONE | |
  114785. * | 7 | ALPHA_PREMULTIPLIED | |
  114786. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  114787. * | 9 | ALPHA_INTERPOLATE | |
  114788. * | 10 | ALPHA_SCREENMODE | |
  114789. *
  114790. */
  114791. set alphaMode(value: number);
  114792. /**
  114793. * Gets the value of the alpha mode
  114794. */
  114795. get alphaMode(): number;
  114796. /**
  114797. * Stores the state of the need depth pre-pass value
  114798. */
  114799. private _needDepthPrePass;
  114800. /**
  114801. * Sets the need depth pre-pass value
  114802. */
  114803. set needDepthPrePass(value: boolean);
  114804. /**
  114805. * Gets the depth pre-pass value
  114806. */
  114807. get needDepthPrePass(): boolean;
  114808. /**
  114809. * Specifies if depth writing should be disabled
  114810. */
  114811. disableDepthWrite: boolean;
  114812. /**
  114813. * Specifies if color writing should be disabled
  114814. */
  114815. disableColorWrite: boolean;
  114816. /**
  114817. * Specifies if depth writing should be forced
  114818. */
  114819. forceDepthWrite: boolean;
  114820. /**
  114821. * Specifies the depth function that should be used. 0 means the default engine function
  114822. */
  114823. depthFunction: number;
  114824. /**
  114825. * Specifies if there should be a separate pass for culling
  114826. */
  114827. separateCullingPass: boolean;
  114828. /**
  114829. * Stores the state specifing if fog should be enabled
  114830. */
  114831. private _fogEnabled;
  114832. /**
  114833. * Sets the state for enabling fog
  114834. */
  114835. set fogEnabled(value: boolean);
  114836. /**
  114837. * Gets the value of the fog enabled state
  114838. */
  114839. get fogEnabled(): boolean;
  114840. /**
  114841. * Stores the size of points
  114842. */
  114843. pointSize: number;
  114844. /**
  114845. * Stores the z offset value
  114846. */
  114847. zOffset: number;
  114848. get wireframe(): boolean;
  114849. /**
  114850. * Sets the state of wireframe mode
  114851. */
  114852. set wireframe(value: boolean);
  114853. /**
  114854. * Gets the value specifying if point clouds are enabled
  114855. */
  114856. get pointsCloud(): boolean;
  114857. /**
  114858. * Sets the state of point cloud mode
  114859. */
  114860. set pointsCloud(value: boolean);
  114861. /**
  114862. * Gets the material fill mode
  114863. */
  114864. get fillMode(): number;
  114865. /**
  114866. * Sets the material fill mode
  114867. */
  114868. set fillMode(value: number);
  114869. /**
  114870. * @hidden
  114871. * Stores the effects for the material
  114872. */
  114873. _effect: Nullable<Effect>;
  114874. /**
  114875. * Specifies if uniform buffers should be used
  114876. */
  114877. private _useUBO;
  114878. /**
  114879. * Stores a reference to the scene
  114880. */
  114881. private _scene;
  114882. private _needToBindSceneUbo;
  114883. /**
  114884. * Stores the fill mode state
  114885. */
  114886. private _fillMode;
  114887. /**
  114888. * Specifies if the depth write state should be cached
  114889. */
  114890. private _cachedDepthWriteState;
  114891. /**
  114892. * Specifies if the color write state should be cached
  114893. */
  114894. private _cachedColorWriteState;
  114895. /**
  114896. * Specifies if the depth function state should be cached
  114897. */
  114898. private _cachedDepthFunctionState;
  114899. /**
  114900. * Stores the uniform buffer
  114901. */
  114902. protected _uniformBuffer: UniformBuffer;
  114903. /** @hidden */
  114904. _indexInSceneMaterialArray: number;
  114905. /** @hidden */
  114906. meshMap: Nullable<{
  114907. [id: string]: AbstractMesh | undefined;
  114908. }>;
  114909. /**
  114910. * Creates a material instance
  114911. * @param name defines the name of the material
  114912. * @param scene defines the scene to reference
  114913. * @param doNotAdd specifies if the material should be added to the scene
  114914. */
  114915. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  114916. /**
  114917. * Returns a string representation of the current material
  114918. * @param fullDetails defines a boolean indicating which levels of logging is desired
  114919. * @returns a string with material information
  114920. */
  114921. toString(fullDetails?: boolean): string;
  114922. /**
  114923. * Gets the class name of the material
  114924. * @returns a string with the class name of the material
  114925. */
  114926. getClassName(): string;
  114927. /**
  114928. * Specifies if updates for the material been locked
  114929. */
  114930. get isFrozen(): boolean;
  114931. /**
  114932. * Locks updates for the material
  114933. */
  114934. freeze(): void;
  114935. /**
  114936. * Unlocks updates for the material
  114937. */
  114938. unfreeze(): void;
  114939. /**
  114940. * Specifies if the material is ready to be used
  114941. * @param mesh defines the mesh to check
  114942. * @param useInstances specifies if instances should be used
  114943. * @returns a boolean indicating if the material is ready to be used
  114944. */
  114945. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  114946. /**
  114947. * Specifies that the submesh is ready to be used
  114948. * @param mesh defines the mesh to check
  114949. * @param subMesh defines which submesh to check
  114950. * @param useInstances specifies that instances should be used
  114951. * @returns a boolean indicating that the submesh is ready or not
  114952. */
  114953. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  114954. /**
  114955. * Returns the material effect
  114956. * @returns the effect associated with the material
  114957. */
  114958. getEffect(): Nullable<Effect>;
  114959. /**
  114960. * Returns the current scene
  114961. * @returns a Scene
  114962. */
  114963. getScene(): Scene;
  114964. /**
  114965. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  114966. */
  114967. protected _forceAlphaTest: boolean;
  114968. /**
  114969. * The transparency mode of the material.
  114970. */
  114971. protected _transparencyMode: Nullable<number>;
  114972. /**
  114973. * Gets the current transparency mode.
  114974. */
  114975. get transparencyMode(): Nullable<number>;
  114976. /**
  114977. * Sets the transparency mode of the material.
  114978. *
  114979. * | Value | Type | Description |
  114980. * | ----- | ----------------------------------- | ----------- |
  114981. * | 0 | OPAQUE | |
  114982. * | 1 | ALPHATEST | |
  114983. * | 2 | ALPHABLEND | |
  114984. * | 3 | ALPHATESTANDBLEND | |
  114985. *
  114986. */
  114987. set transparencyMode(value: Nullable<number>);
  114988. /**
  114989. * Returns true if alpha blending should be disabled.
  114990. */
  114991. protected get _disableAlphaBlending(): boolean;
  114992. /**
  114993. * Specifies whether or not this material should be rendered in alpha blend mode.
  114994. * @returns a boolean specifying if alpha blending is needed
  114995. */
  114996. needAlphaBlending(): boolean;
  114997. /**
  114998. * Specifies if the mesh will require alpha blending
  114999. * @param mesh defines the mesh to check
  115000. * @returns a boolean specifying if alpha blending is needed for the mesh
  115001. */
  115002. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  115003. /**
  115004. * Specifies whether or not this material should be rendered in alpha test mode.
  115005. * @returns a boolean specifying if an alpha test is needed.
  115006. */
  115007. needAlphaTesting(): boolean;
  115008. /**
  115009. * Specifies if material alpha testing should be turned on for the mesh
  115010. * @param mesh defines the mesh to check
  115011. */
  115012. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  115013. /**
  115014. * Gets the texture used for the alpha test
  115015. * @returns the texture to use for alpha testing
  115016. */
  115017. getAlphaTestTexture(): Nullable<BaseTexture>;
  115018. /**
  115019. * Marks the material to indicate that it needs to be re-calculated
  115020. */
  115021. markDirty(): void;
  115022. /** @hidden */
  115023. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  115024. /**
  115025. * Binds the material to the mesh
  115026. * @param world defines the world transformation matrix
  115027. * @param mesh defines the mesh to bind the material to
  115028. */
  115029. bind(world: Matrix, mesh?: Mesh): void;
  115030. /**
  115031. * Binds the submesh to the material
  115032. * @param world defines the world transformation matrix
  115033. * @param mesh defines the mesh containing the submesh
  115034. * @param subMesh defines the submesh to bind the material to
  115035. */
  115036. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  115037. /**
  115038. * Binds the world matrix to the material
  115039. * @param world defines the world transformation matrix
  115040. */
  115041. bindOnlyWorldMatrix(world: Matrix): void;
  115042. /**
  115043. * Update the scene ubo before it can be used in rendering processing
  115044. * @param scene the scene to retrieve the ubo from
  115045. * @returns the scene UniformBuffer
  115046. */
  115047. finalizeSceneUbo(scene: Scene): UniformBuffer;
  115048. /**
  115049. * Binds the scene's uniform buffer to the effect.
  115050. * @param effect defines the effect to bind to the scene uniform buffer
  115051. * @param sceneUbo defines the uniform buffer storing scene data
  115052. */
  115053. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  115054. /**
  115055. * Binds the view matrix to the effect
  115056. * @param effect defines the effect to bind the view matrix to
  115057. */
  115058. bindView(effect: Effect): void;
  115059. /**
  115060. * Binds the view projection and projection matrices to the effect
  115061. * @param effect defines the effect to bind the view projection and projection matrices to
  115062. */
  115063. bindViewProjection(effect: Effect): void;
  115064. /**
  115065. * Binds the view matrix to the effect
  115066. * @param effect defines the effect to bind the view matrix to
  115067. * @param variableName name of the shader variable that will hold the eye position
  115068. */
  115069. bindEyePosition(effect: Effect, variableName?: string): void;
  115070. /**
  115071. * Processes to execute after binding the material to a mesh
  115072. * @param mesh defines the rendered mesh
  115073. */
  115074. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  115075. /**
  115076. * Unbinds the material from the mesh
  115077. */
  115078. unbind(): void;
  115079. /**
  115080. * Gets the active textures from the material
  115081. * @returns an array of textures
  115082. */
  115083. getActiveTextures(): BaseTexture[];
  115084. /**
  115085. * Specifies if the material uses a texture
  115086. * @param texture defines the texture to check against the material
  115087. * @returns a boolean specifying if the material uses the texture
  115088. */
  115089. hasTexture(texture: BaseTexture): boolean;
  115090. /**
  115091. * Makes a duplicate of the material, and gives it a new name
  115092. * @param name defines the new name for the duplicated material
  115093. * @returns the cloned material
  115094. */
  115095. clone(name: string): Nullable<Material>;
  115096. /**
  115097. * Gets the meshes bound to the material
  115098. * @returns an array of meshes bound to the material
  115099. */
  115100. getBindedMeshes(): AbstractMesh[];
  115101. /**
  115102. * Force shader compilation
  115103. * @param mesh defines the mesh associated with this material
  115104. * @param onCompiled defines a function to execute once the material is compiled
  115105. * @param options defines the options to configure the compilation
  115106. * @param onError defines a function to execute if the material fails compiling
  115107. */
  115108. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  115109. /**
  115110. * Force shader compilation
  115111. * @param mesh defines the mesh that will use this material
  115112. * @param options defines additional options for compiling the shaders
  115113. * @returns a promise that resolves when the compilation completes
  115114. */
  115115. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  115116. private static readonly _AllDirtyCallBack;
  115117. private static readonly _ImageProcessingDirtyCallBack;
  115118. private static readonly _TextureDirtyCallBack;
  115119. private static readonly _FresnelDirtyCallBack;
  115120. private static readonly _MiscDirtyCallBack;
  115121. private static readonly _PrePassDirtyCallBack;
  115122. private static readonly _LightsDirtyCallBack;
  115123. private static readonly _AttributeDirtyCallBack;
  115124. private static _FresnelAndMiscDirtyCallBack;
  115125. private static _TextureAndMiscDirtyCallBack;
  115126. private static readonly _DirtyCallbackArray;
  115127. private static readonly _RunDirtyCallBacks;
  115128. /**
  115129. * Marks a define in the material to indicate that it needs to be re-computed
  115130. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  115131. */
  115132. markAsDirty(flag: number): void;
  115133. /**
  115134. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  115135. * @param func defines a function which checks material defines against the submeshes
  115136. */
  115137. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  115138. /**
  115139. * Indicates that the scene should check if the rendering now needs a prepass
  115140. */
  115141. protected _markScenePrePassDirty(): void;
  115142. /**
  115143. * Indicates that we need to re-calculated for all submeshes
  115144. */
  115145. protected _markAllSubMeshesAsAllDirty(): void;
  115146. /**
  115147. * Indicates that image processing needs to be re-calculated for all submeshes
  115148. */
  115149. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  115150. /**
  115151. * Indicates that textures need to be re-calculated for all submeshes
  115152. */
  115153. protected _markAllSubMeshesAsTexturesDirty(): void;
  115154. /**
  115155. * Indicates that fresnel needs to be re-calculated for all submeshes
  115156. */
  115157. protected _markAllSubMeshesAsFresnelDirty(): void;
  115158. /**
  115159. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  115160. */
  115161. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  115162. /**
  115163. * Indicates that lights need to be re-calculated for all submeshes
  115164. */
  115165. protected _markAllSubMeshesAsLightsDirty(): void;
  115166. /**
  115167. * Indicates that attributes need to be re-calculated for all submeshes
  115168. */
  115169. protected _markAllSubMeshesAsAttributesDirty(): void;
  115170. /**
  115171. * Indicates that misc needs to be re-calculated for all submeshes
  115172. */
  115173. protected _markAllSubMeshesAsMiscDirty(): void;
  115174. /**
  115175. * Indicates that prepass needs to be re-calculated for all submeshes
  115176. */
  115177. protected _markAllSubMeshesAsPrePassDirty(): void;
  115178. /**
  115179. * Indicates that textures and misc need to be re-calculated for all submeshes
  115180. */
  115181. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  115182. /**
  115183. * Sets the required values to the prepass renderer.
  115184. * @param prePassRenderer defines the prepass renderer to setup.
  115185. * @returns true if the pre pass is needed.
  115186. */
  115187. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  115188. /**
  115189. * Disposes the material
  115190. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  115191. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  115192. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  115193. */
  115194. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  115195. /** @hidden */
  115196. private releaseVertexArrayObject;
  115197. /**
  115198. * Serializes this material
  115199. * @returns the serialized material object
  115200. */
  115201. serialize(): any;
  115202. /**
  115203. * Creates a material from parsed material data
  115204. * @param parsedMaterial defines parsed material data
  115205. * @param scene defines the hosting scene
  115206. * @param rootUrl defines the root URL to use to load textures
  115207. * @returns a new material
  115208. */
  115209. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  115210. }
  115211. }
  115212. declare module BABYLON {
  115213. /**
  115214. * A multi-material is used to apply different materials to different parts of the same object without the need of
  115215. * separate meshes. This can be use to improve performances.
  115216. * @see https://doc.babylonjs.com/how_to/multi_materials
  115217. */
  115218. export class MultiMaterial extends Material {
  115219. private _subMaterials;
  115220. /**
  115221. * Gets or Sets the list of Materials used within the multi material.
  115222. * They need to be ordered according to the submeshes order in the associated mesh
  115223. */
  115224. get subMaterials(): Nullable<Material>[];
  115225. set subMaterials(value: Nullable<Material>[]);
  115226. /**
  115227. * Function used to align with Node.getChildren()
  115228. * @returns the list of Materials used within the multi material
  115229. */
  115230. getChildren(): Nullable<Material>[];
  115231. /**
  115232. * Instantiates a new Multi Material
  115233. * A multi-material is used to apply different materials to different parts of the same object without the need of
  115234. * separate meshes. This can be use to improve performances.
  115235. * @see https://doc.babylonjs.com/how_to/multi_materials
  115236. * @param name Define the name in the scene
  115237. * @param scene Define the scene the material belongs to
  115238. */
  115239. constructor(name: string, scene: Scene);
  115240. private _hookArray;
  115241. /**
  115242. * Get one of the submaterial by its index in the submaterials array
  115243. * @param index The index to look the sub material at
  115244. * @returns The Material if the index has been defined
  115245. */
  115246. getSubMaterial(index: number): Nullable<Material>;
  115247. /**
  115248. * Get the list of active textures for the whole sub materials list.
  115249. * @returns All the textures that will be used during the rendering
  115250. */
  115251. getActiveTextures(): BaseTexture[];
  115252. /**
  115253. * Specifies if any sub-materials of this multi-material use a given texture.
  115254. * @param texture Defines the texture to check against this multi-material's sub-materials.
  115255. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  115256. */
  115257. hasTexture(texture: BaseTexture): boolean;
  115258. /**
  115259. * Gets the current class name of the material e.g. "MultiMaterial"
  115260. * Mainly use in serialization.
  115261. * @returns the class name
  115262. */
  115263. getClassName(): string;
  115264. /**
  115265. * Checks if the material is ready to render the requested sub mesh
  115266. * @param mesh Define the mesh the submesh belongs to
  115267. * @param subMesh Define the sub mesh to look readyness for
  115268. * @param useInstances Define whether or not the material is used with instances
  115269. * @returns true if ready, otherwise false
  115270. */
  115271. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  115272. /**
  115273. * Clones the current material and its related sub materials
  115274. * @param name Define the name of the newly cloned material
  115275. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  115276. * @returns the cloned material
  115277. */
  115278. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  115279. /**
  115280. * Serializes the materials into a JSON representation.
  115281. * @returns the JSON representation
  115282. */
  115283. serialize(): any;
  115284. /**
  115285. * Dispose the material and release its associated resources
  115286. * @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)
  115287. * @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)
  115288. * @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)
  115289. */
  115290. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  115291. /**
  115292. * Creates a MultiMaterial from parsed MultiMaterial data.
  115293. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  115294. * @param scene defines the hosting scene
  115295. * @returns a new MultiMaterial
  115296. */
  115297. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  115298. }
  115299. }
  115300. declare module BABYLON {
  115301. /** @hidden */
  115302. export interface ICustomEffect {
  115303. effect: Effect;
  115304. defines: string;
  115305. }
  115306. /**
  115307. * Defines a subdivision inside a mesh
  115308. */
  115309. export class SubMesh implements ICullable {
  115310. /** the material index to use */
  115311. materialIndex: number;
  115312. /** vertex index start */
  115313. verticesStart: number;
  115314. /** vertices count */
  115315. verticesCount: number;
  115316. /** index start */
  115317. indexStart: number;
  115318. /** indices count */
  115319. indexCount: number;
  115320. /** @hidden */
  115321. _materialDefines: Nullable<MaterialDefines>;
  115322. /** @hidden */
  115323. _materialEffect: Nullable<Effect>;
  115324. /** @hidden */
  115325. _effectOverride: Nullable<Effect>;
  115326. private _customEffects;
  115327. /**
  115328. * Gets material defines used by the effect associated to the sub mesh
  115329. */
  115330. get materialDefines(): Nullable<MaterialDefines>;
  115331. /**
  115332. * Sets material defines used by the effect associated to the sub mesh
  115333. */
  115334. set materialDefines(defines: Nullable<MaterialDefines>);
  115335. /** @hidden */
  115336. _getCustomEffect(name: string, createIfNotExisting?: boolean): Nullable<ICustomEffect>;
  115337. /** @hidden */
  115338. _removeCustomEffect(name: string): void;
  115339. /**
  115340. * Gets associated effect
  115341. */
  115342. get effect(): Nullable<Effect>;
  115343. /**
  115344. * Sets associated effect (effect used to render this submesh)
  115345. * @param effect defines the effect to associate with
  115346. * @param defines defines the set of defines used to compile this effect
  115347. */
  115348. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  115349. /** @hidden */
  115350. _linesIndexCount: number;
  115351. private _mesh;
  115352. private _renderingMesh;
  115353. private _boundingInfo;
  115354. private _linesIndexBuffer;
  115355. /** @hidden */
  115356. _lastColliderWorldVertices: Nullable<Vector3[]>;
  115357. /** @hidden */
  115358. _trianglePlanes: Plane[];
  115359. /** @hidden */
  115360. _lastColliderTransformMatrix: Nullable<Matrix>;
  115361. /** @hidden */
  115362. _renderId: number;
  115363. /** @hidden */
  115364. _alphaIndex: number;
  115365. /** @hidden */
  115366. _distanceToCamera: number;
  115367. /** @hidden */
  115368. _id: number;
  115369. private _currentMaterial;
  115370. /**
  115371. * Add a new submesh to a mesh
  115372. * @param materialIndex defines the material index to use
  115373. * @param verticesStart defines vertex index start
  115374. * @param verticesCount defines vertices count
  115375. * @param indexStart defines index start
  115376. * @param indexCount defines indices count
  115377. * @param mesh defines the parent mesh
  115378. * @param renderingMesh defines an optional rendering mesh
  115379. * @param createBoundingBox defines if bounding box should be created for this submesh
  115380. * @returns the new submesh
  115381. */
  115382. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  115383. /**
  115384. * Creates a new submesh
  115385. * @param materialIndex defines the material index to use
  115386. * @param verticesStart defines vertex index start
  115387. * @param verticesCount defines vertices count
  115388. * @param indexStart defines index start
  115389. * @param indexCount defines indices count
  115390. * @param mesh defines the parent mesh
  115391. * @param renderingMesh defines an optional rendering mesh
  115392. * @param createBoundingBox defines if bounding box should be created for this submesh
  115393. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  115394. */
  115395. constructor(
  115396. /** the material index to use */
  115397. materialIndex: number,
  115398. /** vertex index start */
  115399. verticesStart: number,
  115400. /** vertices count */
  115401. verticesCount: number,
  115402. /** index start */
  115403. indexStart: number,
  115404. /** indices count */
  115405. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  115406. /**
  115407. * Returns true if this submesh covers the entire parent mesh
  115408. * @ignorenaming
  115409. */
  115410. get IsGlobal(): boolean;
  115411. /**
  115412. * Returns the submesh BoudingInfo object
  115413. * @returns current bounding info (or mesh's one if the submesh is global)
  115414. */
  115415. getBoundingInfo(): BoundingInfo;
  115416. /**
  115417. * Sets the submesh BoundingInfo
  115418. * @param boundingInfo defines the new bounding info to use
  115419. * @returns the SubMesh
  115420. */
  115421. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  115422. /**
  115423. * Returns the mesh of the current submesh
  115424. * @return the parent mesh
  115425. */
  115426. getMesh(): AbstractMesh;
  115427. /**
  115428. * Returns the rendering mesh of the submesh
  115429. * @returns the rendering mesh (could be different from parent mesh)
  115430. */
  115431. getRenderingMesh(): Mesh;
  115432. /**
  115433. * Returns the replacement mesh of the submesh
  115434. * @returns the replacement mesh (could be different from parent mesh)
  115435. */
  115436. getReplacementMesh(): Nullable<AbstractMesh>;
  115437. /**
  115438. * Returns the effective mesh of the submesh
  115439. * @returns the effective mesh (could be different from parent mesh)
  115440. */
  115441. getEffectiveMesh(): AbstractMesh;
  115442. /**
  115443. * Returns the submesh material
  115444. * @returns null or the current material
  115445. */
  115446. getMaterial(): Nullable<Material>;
  115447. private _IsMultiMaterial;
  115448. /**
  115449. * Sets a new updated BoundingInfo object to the submesh
  115450. * @param data defines an optional position array to use to determine the bounding info
  115451. * @returns the SubMesh
  115452. */
  115453. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  115454. /** @hidden */
  115455. _checkCollision(collider: Collider): boolean;
  115456. /**
  115457. * Updates the submesh BoundingInfo
  115458. * @param world defines the world matrix to use to update the bounding info
  115459. * @returns the submesh
  115460. */
  115461. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  115462. /**
  115463. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  115464. * @param frustumPlanes defines the frustum planes
  115465. * @returns true if the submesh is intersecting with the frustum
  115466. */
  115467. isInFrustum(frustumPlanes: Plane[]): boolean;
  115468. /**
  115469. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  115470. * @param frustumPlanes defines the frustum planes
  115471. * @returns true if the submesh is inside the frustum
  115472. */
  115473. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  115474. /**
  115475. * Renders the submesh
  115476. * @param enableAlphaMode defines if alpha needs to be used
  115477. * @returns the submesh
  115478. */
  115479. render(enableAlphaMode: boolean): SubMesh;
  115480. /**
  115481. * @hidden
  115482. */
  115483. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  115484. /**
  115485. * Checks if the submesh intersects with a ray
  115486. * @param ray defines the ray to test
  115487. * @returns true is the passed ray intersects the submesh bounding box
  115488. */
  115489. canIntersects(ray: Ray): boolean;
  115490. /**
  115491. * Intersects current submesh with a ray
  115492. * @param ray defines the ray to test
  115493. * @param positions defines mesh's positions array
  115494. * @param indices defines mesh's indices array
  115495. * @param fastCheck defines if the first intersection will be used (and not the closest)
  115496. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  115497. * @returns intersection info or null if no intersection
  115498. */
  115499. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  115500. /** @hidden */
  115501. private _intersectLines;
  115502. /** @hidden */
  115503. private _intersectUnIndexedLines;
  115504. /** @hidden */
  115505. private _intersectTriangles;
  115506. /** @hidden */
  115507. private _intersectUnIndexedTriangles;
  115508. /** @hidden */
  115509. _rebuild(): void;
  115510. /**
  115511. * Creates a new submesh from the passed mesh
  115512. * @param newMesh defines the new hosting mesh
  115513. * @param newRenderingMesh defines an optional rendering mesh
  115514. * @returns the new submesh
  115515. */
  115516. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  115517. /**
  115518. * Release associated resources
  115519. */
  115520. dispose(): void;
  115521. /**
  115522. * Gets the class name
  115523. * @returns the string "SubMesh".
  115524. */
  115525. getClassName(): string;
  115526. /**
  115527. * Creates a new submesh from indices data
  115528. * @param materialIndex the index of the main mesh material
  115529. * @param startIndex the index where to start the copy in the mesh indices array
  115530. * @param indexCount the number of indices to copy then from the startIndex
  115531. * @param mesh the main mesh to create the submesh from
  115532. * @param renderingMesh the optional rendering mesh
  115533. * @returns a new submesh
  115534. */
  115535. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  115536. }
  115537. }
  115538. declare module BABYLON {
  115539. /**
  115540. * Class used to represent data loading progression
  115541. */
  115542. export class SceneLoaderFlags {
  115543. private static _ForceFullSceneLoadingForIncremental;
  115544. private static _ShowLoadingScreen;
  115545. private static _CleanBoneMatrixWeights;
  115546. private static _loggingLevel;
  115547. /**
  115548. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  115549. */
  115550. static get ForceFullSceneLoadingForIncremental(): boolean;
  115551. static set ForceFullSceneLoadingForIncremental(value: boolean);
  115552. /**
  115553. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  115554. */
  115555. static get ShowLoadingScreen(): boolean;
  115556. static set ShowLoadingScreen(value: boolean);
  115557. /**
  115558. * Defines the current logging level (while loading the scene)
  115559. * @ignorenaming
  115560. */
  115561. static get loggingLevel(): number;
  115562. static set loggingLevel(value: number);
  115563. /**
  115564. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  115565. */
  115566. static get CleanBoneMatrixWeights(): boolean;
  115567. static set CleanBoneMatrixWeights(value: boolean);
  115568. }
  115569. }
  115570. declare module BABYLON {
  115571. /**
  115572. * Class used to store geometry data (vertex buffers + index buffer)
  115573. */
  115574. export class Geometry implements IGetSetVerticesData {
  115575. /**
  115576. * Gets or sets the ID of the geometry
  115577. */
  115578. id: string;
  115579. /**
  115580. * Gets or sets the unique ID of the geometry
  115581. */
  115582. uniqueId: number;
  115583. /**
  115584. * Gets the delay loading state of the geometry (none by default which means not delayed)
  115585. */
  115586. delayLoadState: number;
  115587. /**
  115588. * Gets the file containing the data to load when running in delay load state
  115589. */
  115590. delayLoadingFile: Nullable<string>;
  115591. /**
  115592. * Callback called when the geometry is updated
  115593. */
  115594. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  115595. private _scene;
  115596. private _engine;
  115597. private _meshes;
  115598. private _totalVertices;
  115599. /** @hidden */
  115600. _indices: IndicesArray;
  115601. /** @hidden */
  115602. _vertexBuffers: {
  115603. [key: string]: VertexBuffer;
  115604. };
  115605. private _isDisposed;
  115606. private _extend;
  115607. private _boundingBias;
  115608. /** @hidden */
  115609. _delayInfo: Array<string>;
  115610. private _indexBuffer;
  115611. private _indexBufferIsUpdatable;
  115612. /** @hidden */
  115613. _boundingInfo: Nullable<BoundingInfo>;
  115614. /** @hidden */
  115615. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  115616. /** @hidden */
  115617. _softwareSkinningFrameId: number;
  115618. private _vertexArrayObjects;
  115619. private _updatable;
  115620. /** @hidden */
  115621. _positions: Nullable<Vector3[]>;
  115622. private _positionsCache;
  115623. /**
  115624. * 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
  115625. */
  115626. get boundingBias(): Vector2;
  115627. /**
  115628. * 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
  115629. */
  115630. set boundingBias(value: Vector2);
  115631. /**
  115632. * Static function used to attach a new empty geometry to a mesh
  115633. * @param mesh defines the mesh to attach the geometry to
  115634. * @returns the new Geometry
  115635. */
  115636. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  115637. /** Get the list of meshes using this geometry */
  115638. get meshes(): Mesh[];
  115639. /**
  115640. * 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
  115641. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  115642. */
  115643. useBoundingInfoFromGeometry: boolean;
  115644. /**
  115645. * Creates a new geometry
  115646. * @param id defines the unique ID
  115647. * @param scene defines the hosting scene
  115648. * @param vertexData defines the VertexData used to get geometry data
  115649. * @param updatable defines if geometry must be updatable (false by default)
  115650. * @param mesh defines the mesh that will be associated with the geometry
  115651. */
  115652. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  115653. /**
  115654. * Gets the current extend of the geometry
  115655. */
  115656. get extend(): {
  115657. minimum: Vector3;
  115658. maximum: Vector3;
  115659. };
  115660. /**
  115661. * Gets the hosting scene
  115662. * @returns the hosting Scene
  115663. */
  115664. getScene(): Scene;
  115665. /**
  115666. * Gets the hosting engine
  115667. * @returns the hosting Engine
  115668. */
  115669. getEngine(): Engine;
  115670. /**
  115671. * Defines if the geometry is ready to use
  115672. * @returns true if the geometry is ready to be used
  115673. */
  115674. isReady(): boolean;
  115675. /**
  115676. * Gets a value indicating that the geometry should not be serialized
  115677. */
  115678. get doNotSerialize(): boolean;
  115679. /** @hidden */
  115680. _rebuild(): void;
  115681. /**
  115682. * Affects all geometry data in one call
  115683. * @param vertexData defines the geometry data
  115684. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  115685. */
  115686. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  115687. /**
  115688. * Set specific vertex data
  115689. * @param kind defines the data kind (Position, normal, etc...)
  115690. * @param data defines the vertex data to use
  115691. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  115692. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  115693. */
  115694. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  115695. /**
  115696. * Removes a specific vertex data
  115697. * @param kind defines the data kind (Position, normal, etc...)
  115698. */
  115699. removeVerticesData(kind: string): void;
  115700. /**
  115701. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  115702. * @param buffer defines the vertex buffer to use
  115703. * @param totalVertices defines the total number of vertices for position kind (could be null)
  115704. */
  115705. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  115706. /**
  115707. * Update a specific vertex buffer
  115708. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  115709. * It will do nothing if the buffer is not updatable
  115710. * @param kind defines the data kind (Position, normal, etc...)
  115711. * @param data defines the data to use
  115712. * @param offset defines the offset in the target buffer where to store the data
  115713. * @param useBytes set to true if the offset is in bytes
  115714. */
  115715. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  115716. /**
  115717. * Update a specific vertex buffer
  115718. * This function will create a new buffer if the current one is not updatable
  115719. * @param kind defines the data kind (Position, normal, etc...)
  115720. * @param data defines the data to use
  115721. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  115722. */
  115723. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  115724. private _updateBoundingInfo;
  115725. /** @hidden */
  115726. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  115727. /**
  115728. * Gets total number of vertices
  115729. * @returns the total number of vertices
  115730. */
  115731. getTotalVertices(): number;
  115732. /**
  115733. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  115734. * @param kind defines the data kind (Position, normal, etc...)
  115735. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  115736. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  115737. * @returns a float array containing vertex data
  115738. */
  115739. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  115740. /**
  115741. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  115742. * @param kind defines the data kind (Position, normal, etc...)
  115743. * @returns true if the vertex buffer with the specified kind is updatable
  115744. */
  115745. isVertexBufferUpdatable(kind: string): boolean;
  115746. /**
  115747. * Gets a specific vertex buffer
  115748. * @param kind defines the data kind (Position, normal, etc...)
  115749. * @returns a VertexBuffer
  115750. */
  115751. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  115752. /**
  115753. * Returns all vertex buffers
  115754. * @return an object holding all vertex buffers indexed by kind
  115755. */
  115756. getVertexBuffers(): Nullable<{
  115757. [key: string]: VertexBuffer;
  115758. }>;
  115759. /**
  115760. * Gets a boolean indicating if specific vertex buffer is present
  115761. * @param kind defines the data kind (Position, normal, etc...)
  115762. * @returns true if data is present
  115763. */
  115764. isVerticesDataPresent(kind: string): boolean;
  115765. /**
  115766. * Gets a list of all attached data kinds (Position, normal, etc...)
  115767. * @returns a list of string containing all kinds
  115768. */
  115769. getVerticesDataKinds(): string[];
  115770. /**
  115771. * Update index buffer
  115772. * @param indices defines the indices to store in the index buffer
  115773. * @param offset defines the offset in the target buffer where to store the data
  115774. * @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)
  115775. */
  115776. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  115777. /**
  115778. * Creates a new index buffer
  115779. * @param indices defines the indices to store in the index buffer
  115780. * @param totalVertices defines the total number of vertices (could be null)
  115781. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  115782. */
  115783. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  115784. /**
  115785. * Return the total number of indices
  115786. * @returns the total number of indices
  115787. */
  115788. getTotalIndices(): number;
  115789. /**
  115790. * Gets the index buffer array
  115791. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  115792. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  115793. * @returns the index buffer array
  115794. */
  115795. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  115796. /**
  115797. * Gets the index buffer
  115798. * @return the index buffer
  115799. */
  115800. getIndexBuffer(): Nullable<DataBuffer>;
  115801. /** @hidden */
  115802. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  115803. /**
  115804. * Release the associated resources for a specific mesh
  115805. * @param mesh defines the source mesh
  115806. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  115807. */
  115808. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  115809. /**
  115810. * Apply current geometry to a given mesh
  115811. * @param mesh defines the mesh to apply geometry to
  115812. */
  115813. applyToMesh(mesh: Mesh): void;
  115814. private _updateExtend;
  115815. private _applyToMesh;
  115816. private notifyUpdate;
  115817. /**
  115818. * Load the geometry if it was flagged as delay loaded
  115819. * @param scene defines the hosting scene
  115820. * @param onLoaded defines a callback called when the geometry is loaded
  115821. */
  115822. load(scene: Scene, onLoaded?: () => void): void;
  115823. private _queueLoad;
  115824. /**
  115825. * Invert the geometry to move from a right handed system to a left handed one.
  115826. */
  115827. toLeftHanded(): void;
  115828. /** @hidden */
  115829. _resetPointsArrayCache(): void;
  115830. /** @hidden */
  115831. _generatePointsArray(): boolean;
  115832. /**
  115833. * Gets a value indicating if the geometry is disposed
  115834. * @returns true if the geometry was disposed
  115835. */
  115836. isDisposed(): boolean;
  115837. private _disposeVertexArrayObjects;
  115838. /**
  115839. * Free all associated resources
  115840. */
  115841. dispose(): void;
  115842. /**
  115843. * Clone the current geometry into a new geometry
  115844. * @param id defines the unique ID of the new geometry
  115845. * @returns a new geometry object
  115846. */
  115847. copy(id: string): Geometry;
  115848. /**
  115849. * Serialize the current geometry info (and not the vertices data) into a JSON object
  115850. * @return a JSON representation of the current geometry data (without the vertices data)
  115851. */
  115852. serialize(): any;
  115853. private toNumberArray;
  115854. /**
  115855. * Serialize all vertices data into a JSON oject
  115856. * @returns a JSON representation of the current geometry data
  115857. */
  115858. serializeVerticeData(): any;
  115859. /**
  115860. * Extracts a clone of a mesh geometry
  115861. * @param mesh defines the source mesh
  115862. * @param id defines the unique ID of the new geometry object
  115863. * @returns the new geometry object
  115864. */
  115865. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  115866. /**
  115867. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  115868. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  115869. * Be aware Math.random() could cause collisions, but:
  115870. * "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"
  115871. * @returns a string containing a new GUID
  115872. */
  115873. static RandomId(): string;
  115874. /** @hidden */
  115875. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  115876. private static _CleanMatricesWeights;
  115877. /**
  115878. * Create a new geometry from persisted data (Using .babylon file format)
  115879. * @param parsedVertexData defines the persisted data
  115880. * @param scene defines the hosting scene
  115881. * @param rootUrl defines the root url to use to load assets (like delayed data)
  115882. * @returns the new geometry object
  115883. */
  115884. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  115885. }
  115886. }
  115887. declare module BABYLON {
  115888. /**
  115889. * Defines a target to use with MorphTargetManager
  115890. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  115891. */
  115892. export class MorphTarget implements IAnimatable {
  115893. /** defines the name of the target */
  115894. name: string;
  115895. /**
  115896. * Gets or sets the list of animations
  115897. */
  115898. animations: Animation[];
  115899. private _scene;
  115900. private _positions;
  115901. private _normals;
  115902. private _tangents;
  115903. private _uvs;
  115904. private _influence;
  115905. private _uniqueId;
  115906. /**
  115907. * Observable raised when the influence changes
  115908. */
  115909. onInfluenceChanged: Observable<boolean>;
  115910. /** @hidden */
  115911. _onDataLayoutChanged: Observable<void>;
  115912. /**
  115913. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  115914. */
  115915. get influence(): number;
  115916. set influence(influence: number);
  115917. /**
  115918. * Gets or sets the id of the morph Target
  115919. */
  115920. id: string;
  115921. private _animationPropertiesOverride;
  115922. /**
  115923. * Gets or sets the animation properties override
  115924. */
  115925. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  115926. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  115927. /**
  115928. * Creates a new MorphTarget
  115929. * @param name defines the name of the target
  115930. * @param influence defines the influence to use
  115931. * @param scene defines the scene the morphtarget belongs to
  115932. */
  115933. constructor(
  115934. /** defines the name of the target */
  115935. name: string, influence?: number, scene?: Nullable<Scene>);
  115936. /**
  115937. * Gets the unique ID of this manager
  115938. */
  115939. get uniqueId(): number;
  115940. /**
  115941. * Gets a boolean defining if the target contains position data
  115942. */
  115943. get hasPositions(): boolean;
  115944. /**
  115945. * Gets a boolean defining if the target contains normal data
  115946. */
  115947. get hasNormals(): boolean;
  115948. /**
  115949. * Gets a boolean defining if the target contains tangent data
  115950. */
  115951. get hasTangents(): boolean;
  115952. /**
  115953. * Gets a boolean defining if the target contains texture coordinates data
  115954. */
  115955. get hasUVs(): boolean;
  115956. /**
  115957. * Affects position data to this target
  115958. * @param data defines the position data to use
  115959. */
  115960. setPositions(data: Nullable<FloatArray>): void;
  115961. /**
  115962. * Gets the position data stored in this target
  115963. * @returns a FloatArray containing the position data (or null if not present)
  115964. */
  115965. getPositions(): Nullable<FloatArray>;
  115966. /**
  115967. * Affects normal data to this target
  115968. * @param data defines the normal data to use
  115969. */
  115970. setNormals(data: Nullable<FloatArray>): void;
  115971. /**
  115972. * Gets the normal data stored in this target
  115973. * @returns a FloatArray containing the normal data (or null if not present)
  115974. */
  115975. getNormals(): Nullable<FloatArray>;
  115976. /**
  115977. * Affects tangent data to this target
  115978. * @param data defines the tangent data to use
  115979. */
  115980. setTangents(data: Nullable<FloatArray>): void;
  115981. /**
  115982. * Gets the tangent data stored in this target
  115983. * @returns a FloatArray containing the tangent data (or null if not present)
  115984. */
  115985. getTangents(): Nullable<FloatArray>;
  115986. /**
  115987. * Affects texture coordinates data to this target
  115988. * @param data defines the texture coordinates data to use
  115989. */
  115990. setUVs(data: Nullable<FloatArray>): void;
  115991. /**
  115992. * Gets the texture coordinates data stored in this target
  115993. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  115994. */
  115995. getUVs(): Nullable<FloatArray>;
  115996. /**
  115997. * Clone the current target
  115998. * @returns a new MorphTarget
  115999. */
  116000. clone(): MorphTarget;
  116001. /**
  116002. * Serializes the current target into a Serialization object
  116003. * @returns the serialized object
  116004. */
  116005. serialize(): any;
  116006. /**
  116007. * Returns the string "MorphTarget"
  116008. * @returns "MorphTarget"
  116009. */
  116010. getClassName(): string;
  116011. /**
  116012. * Creates a new target from serialized data
  116013. * @param serializationObject defines the serialized data to use
  116014. * @returns a new MorphTarget
  116015. */
  116016. static Parse(serializationObject: any): MorphTarget;
  116017. /**
  116018. * Creates a MorphTarget from mesh data
  116019. * @param mesh defines the source mesh
  116020. * @param name defines the name to use for the new target
  116021. * @param influence defines the influence to attach to the target
  116022. * @returns a new MorphTarget
  116023. */
  116024. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  116025. }
  116026. }
  116027. declare module BABYLON {
  116028. /**
  116029. * This class is used to deform meshes using morphing between different targets
  116030. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  116031. */
  116032. export class MorphTargetManager {
  116033. private _targets;
  116034. private _targetInfluenceChangedObservers;
  116035. private _targetDataLayoutChangedObservers;
  116036. private _activeTargets;
  116037. private _scene;
  116038. private _influences;
  116039. private _supportsNormals;
  116040. private _supportsTangents;
  116041. private _supportsUVs;
  116042. private _vertexCount;
  116043. private _uniqueId;
  116044. private _tempInfluences;
  116045. /**
  116046. * Gets or sets a boolean indicating if normals must be morphed
  116047. */
  116048. enableNormalMorphing: boolean;
  116049. /**
  116050. * Gets or sets a boolean indicating if tangents must be morphed
  116051. */
  116052. enableTangentMorphing: boolean;
  116053. /**
  116054. * Gets or sets a boolean indicating if UV must be morphed
  116055. */
  116056. enableUVMorphing: boolean;
  116057. /**
  116058. * Creates a new MorphTargetManager
  116059. * @param scene defines the current scene
  116060. */
  116061. constructor(scene?: Nullable<Scene>);
  116062. /**
  116063. * Gets the unique ID of this manager
  116064. */
  116065. get uniqueId(): number;
  116066. /**
  116067. * Gets the number of vertices handled by this manager
  116068. */
  116069. get vertexCount(): number;
  116070. /**
  116071. * Gets a boolean indicating if this manager supports morphing of normals
  116072. */
  116073. get supportsNormals(): boolean;
  116074. /**
  116075. * Gets a boolean indicating if this manager supports morphing of tangents
  116076. */
  116077. get supportsTangents(): boolean;
  116078. /**
  116079. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  116080. */
  116081. get supportsUVs(): boolean;
  116082. /**
  116083. * Gets the number of targets stored in this manager
  116084. */
  116085. get numTargets(): number;
  116086. /**
  116087. * Gets the number of influencers (ie. the number of targets with influences > 0)
  116088. */
  116089. get numInfluencers(): number;
  116090. /**
  116091. * Gets the list of influences (one per target)
  116092. */
  116093. get influences(): Float32Array;
  116094. /**
  116095. * Gets the active target at specified index. An active target is a target with an influence > 0
  116096. * @param index defines the index to check
  116097. * @returns the requested target
  116098. */
  116099. getActiveTarget(index: number): MorphTarget;
  116100. /**
  116101. * Gets the target at specified index
  116102. * @param index defines the index to check
  116103. * @returns the requested target
  116104. */
  116105. getTarget(index: number): MorphTarget;
  116106. /**
  116107. * Add a new target to this manager
  116108. * @param target defines the target to add
  116109. */
  116110. addTarget(target: MorphTarget): void;
  116111. /**
  116112. * Removes a target from the manager
  116113. * @param target defines the target to remove
  116114. */
  116115. removeTarget(target: MorphTarget): void;
  116116. /**
  116117. * Clone the current manager
  116118. * @returns a new MorphTargetManager
  116119. */
  116120. clone(): MorphTargetManager;
  116121. /**
  116122. * Serializes the current manager into a Serialization object
  116123. * @returns the serialized object
  116124. */
  116125. serialize(): any;
  116126. private _syncActiveTargets;
  116127. /**
  116128. * Syncrhonize the targets with all the meshes using this morph target manager
  116129. */
  116130. synchronize(): void;
  116131. /**
  116132. * Creates a new MorphTargetManager from serialized data
  116133. * @param serializationObject defines the serialized data
  116134. * @param scene defines the hosting scene
  116135. * @returns the new MorphTargetManager
  116136. */
  116137. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  116138. }
  116139. }
  116140. declare module BABYLON {
  116141. /**
  116142. * Class used to represent a specific level of detail of a mesh
  116143. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  116144. */
  116145. export class MeshLODLevel {
  116146. /** Defines the distance where this level should start being displayed */
  116147. distance: number;
  116148. /** Defines the mesh to use to render this level */
  116149. mesh: Nullable<Mesh>;
  116150. /**
  116151. * Creates a new LOD level
  116152. * @param distance defines the distance where this level should star being displayed
  116153. * @param mesh defines the mesh to use to render this level
  116154. */
  116155. constructor(
  116156. /** Defines the distance where this level should start being displayed */
  116157. distance: number,
  116158. /** Defines the mesh to use to render this level */
  116159. mesh: Nullable<Mesh>);
  116160. }
  116161. }
  116162. declare module BABYLON {
  116163. /**
  116164. * Helper class used to generate a canvas to manipulate images
  116165. */
  116166. export class CanvasGenerator {
  116167. /**
  116168. * Create a new canvas (or offscreen canvas depending on the context)
  116169. * @param width defines the expected width
  116170. * @param height defines the expected height
  116171. * @return a new canvas or offscreen canvas
  116172. */
  116173. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  116174. }
  116175. }
  116176. declare module BABYLON {
  116177. /**
  116178. * Mesh representing the gorund
  116179. */
  116180. export class GroundMesh extends Mesh {
  116181. /** If octree should be generated */
  116182. generateOctree: boolean;
  116183. private _heightQuads;
  116184. /** @hidden */
  116185. _subdivisionsX: number;
  116186. /** @hidden */
  116187. _subdivisionsY: number;
  116188. /** @hidden */
  116189. _width: number;
  116190. /** @hidden */
  116191. _height: number;
  116192. /** @hidden */
  116193. _minX: number;
  116194. /** @hidden */
  116195. _maxX: number;
  116196. /** @hidden */
  116197. _minZ: number;
  116198. /** @hidden */
  116199. _maxZ: number;
  116200. constructor(name: string, scene: Scene);
  116201. /**
  116202. * "GroundMesh"
  116203. * @returns "GroundMesh"
  116204. */
  116205. getClassName(): string;
  116206. /**
  116207. * The minimum of x and y subdivisions
  116208. */
  116209. get subdivisions(): number;
  116210. /**
  116211. * X subdivisions
  116212. */
  116213. get subdivisionsX(): number;
  116214. /**
  116215. * Y subdivisions
  116216. */
  116217. get subdivisionsY(): number;
  116218. /**
  116219. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  116220. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  116221. * @param chunksCount the number of subdivisions for x and y
  116222. * @param octreeBlocksSize (Default: 32)
  116223. */
  116224. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  116225. /**
  116226. * Returns a height (y) value in the Worl system :
  116227. * the ground altitude at the coordinates (x, z) expressed in the World system.
  116228. * @param x x coordinate
  116229. * @param z z coordinate
  116230. * @returns the ground y position if (x, z) are outside the ground surface.
  116231. */
  116232. getHeightAtCoordinates(x: number, z: number): number;
  116233. /**
  116234. * Returns a normalized vector (Vector3) orthogonal to the ground
  116235. * at the ground coordinates (x, z) expressed in the World system.
  116236. * @param x x coordinate
  116237. * @param z z coordinate
  116238. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  116239. */
  116240. getNormalAtCoordinates(x: number, z: number): Vector3;
  116241. /**
  116242. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  116243. * at the ground coordinates (x, z) expressed in the World system.
  116244. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  116245. * @param x x coordinate
  116246. * @param z z coordinate
  116247. * @param ref vector to store the result
  116248. * @returns the GroundMesh.
  116249. */
  116250. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  116251. /**
  116252. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  116253. * if the ground has been updated.
  116254. * This can be used in the render loop.
  116255. * @returns the GroundMesh.
  116256. */
  116257. updateCoordinateHeights(): GroundMesh;
  116258. private _getFacetAt;
  116259. private _initHeightQuads;
  116260. private _computeHeightQuads;
  116261. /**
  116262. * Serializes this ground mesh
  116263. * @param serializationObject object to write serialization to
  116264. */
  116265. serialize(serializationObject: any): void;
  116266. /**
  116267. * Parses a serialized ground mesh
  116268. * @param parsedMesh the serialized mesh
  116269. * @param scene the scene to create the ground mesh in
  116270. * @returns the created ground mesh
  116271. */
  116272. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  116273. }
  116274. }
  116275. declare module BABYLON {
  116276. /**
  116277. * Interface for Physics-Joint data
  116278. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116279. */
  116280. export interface PhysicsJointData {
  116281. /**
  116282. * The main pivot of the joint
  116283. */
  116284. mainPivot?: Vector3;
  116285. /**
  116286. * The connected pivot of the joint
  116287. */
  116288. connectedPivot?: Vector3;
  116289. /**
  116290. * The main axis of the joint
  116291. */
  116292. mainAxis?: Vector3;
  116293. /**
  116294. * The connected axis of the joint
  116295. */
  116296. connectedAxis?: Vector3;
  116297. /**
  116298. * The collision of the joint
  116299. */
  116300. collision?: boolean;
  116301. /**
  116302. * Native Oimo/Cannon/Energy data
  116303. */
  116304. nativeParams?: any;
  116305. }
  116306. /**
  116307. * This is a holder class for the physics joint created by the physics plugin
  116308. * It holds a set of functions to control the underlying joint
  116309. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116310. */
  116311. export class PhysicsJoint {
  116312. /**
  116313. * The type of the physics joint
  116314. */
  116315. type: number;
  116316. /**
  116317. * The data for the physics joint
  116318. */
  116319. jointData: PhysicsJointData;
  116320. private _physicsJoint;
  116321. protected _physicsPlugin: IPhysicsEnginePlugin;
  116322. /**
  116323. * Initializes the physics joint
  116324. * @param type The type of the physics joint
  116325. * @param jointData The data for the physics joint
  116326. */
  116327. constructor(
  116328. /**
  116329. * The type of the physics joint
  116330. */
  116331. type: number,
  116332. /**
  116333. * The data for the physics joint
  116334. */
  116335. jointData: PhysicsJointData);
  116336. /**
  116337. * Gets the physics joint
  116338. */
  116339. get physicsJoint(): any;
  116340. /**
  116341. * Sets the physics joint
  116342. */
  116343. set physicsJoint(newJoint: any);
  116344. /**
  116345. * Sets the physics plugin
  116346. */
  116347. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  116348. /**
  116349. * Execute a function that is physics-plugin specific.
  116350. * @param {Function} func the function that will be executed.
  116351. * It accepts two parameters: the physics world and the physics joint
  116352. */
  116353. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  116354. /**
  116355. * Distance-Joint type
  116356. */
  116357. static DistanceJoint: number;
  116358. /**
  116359. * Hinge-Joint type
  116360. */
  116361. static HingeJoint: number;
  116362. /**
  116363. * Ball-and-Socket joint type
  116364. */
  116365. static BallAndSocketJoint: number;
  116366. /**
  116367. * Wheel-Joint type
  116368. */
  116369. static WheelJoint: number;
  116370. /**
  116371. * Slider-Joint type
  116372. */
  116373. static SliderJoint: number;
  116374. /**
  116375. * Prismatic-Joint type
  116376. */
  116377. static PrismaticJoint: number;
  116378. /**
  116379. * Universal-Joint type
  116380. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  116381. */
  116382. static UniversalJoint: number;
  116383. /**
  116384. * Hinge-Joint 2 type
  116385. */
  116386. static Hinge2Joint: number;
  116387. /**
  116388. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  116389. */
  116390. static PointToPointJoint: number;
  116391. /**
  116392. * Spring-Joint type
  116393. */
  116394. static SpringJoint: number;
  116395. /**
  116396. * Lock-Joint type
  116397. */
  116398. static LockJoint: number;
  116399. }
  116400. /**
  116401. * A class representing a physics distance joint
  116402. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116403. */
  116404. export class DistanceJoint extends PhysicsJoint {
  116405. /**
  116406. *
  116407. * @param jointData The data for the Distance-Joint
  116408. */
  116409. constructor(jointData: DistanceJointData);
  116410. /**
  116411. * Update the predefined distance.
  116412. * @param maxDistance The maximum preferred distance
  116413. * @param minDistance The minimum preferred distance
  116414. */
  116415. updateDistance(maxDistance: number, minDistance?: number): void;
  116416. }
  116417. /**
  116418. * Represents a Motor-Enabled Joint
  116419. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116420. */
  116421. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  116422. /**
  116423. * Initializes the Motor-Enabled Joint
  116424. * @param type The type of the joint
  116425. * @param jointData The physica joint data for the joint
  116426. */
  116427. constructor(type: number, jointData: PhysicsJointData);
  116428. /**
  116429. * Set the motor values.
  116430. * Attention, this function is plugin specific. Engines won't react 100% the same.
  116431. * @param force the force to apply
  116432. * @param maxForce max force for this motor.
  116433. */
  116434. setMotor(force?: number, maxForce?: number): void;
  116435. /**
  116436. * Set the motor's limits.
  116437. * Attention, this function is plugin specific. Engines won't react 100% the same.
  116438. * @param upperLimit The upper limit of the motor
  116439. * @param lowerLimit The lower limit of the motor
  116440. */
  116441. setLimit(upperLimit: number, lowerLimit?: number): void;
  116442. }
  116443. /**
  116444. * This class represents a single physics Hinge-Joint
  116445. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116446. */
  116447. export class HingeJoint extends MotorEnabledJoint {
  116448. /**
  116449. * Initializes the Hinge-Joint
  116450. * @param jointData The joint data for the Hinge-Joint
  116451. */
  116452. constructor(jointData: PhysicsJointData);
  116453. /**
  116454. * Set the motor values.
  116455. * Attention, this function is plugin specific. Engines won't react 100% the same.
  116456. * @param {number} force the force to apply
  116457. * @param {number} maxForce max force for this motor.
  116458. */
  116459. setMotor(force?: number, maxForce?: number): void;
  116460. /**
  116461. * Set the motor's limits.
  116462. * Attention, this function is plugin specific. Engines won't react 100% the same.
  116463. * @param upperLimit The upper limit of the motor
  116464. * @param lowerLimit The lower limit of the motor
  116465. */
  116466. setLimit(upperLimit: number, lowerLimit?: number): void;
  116467. }
  116468. /**
  116469. * This class represents a dual hinge physics joint (same as wheel joint)
  116470. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116471. */
  116472. export class Hinge2Joint extends MotorEnabledJoint {
  116473. /**
  116474. * Initializes the Hinge2-Joint
  116475. * @param jointData The joint data for the Hinge2-Joint
  116476. */
  116477. constructor(jointData: PhysicsJointData);
  116478. /**
  116479. * Set the motor values.
  116480. * Attention, this function is plugin specific. Engines won't react 100% the same.
  116481. * @param {number} targetSpeed the speed the motor is to reach
  116482. * @param {number} maxForce max force for this motor.
  116483. * @param {motorIndex} the motor's index, 0 or 1.
  116484. */
  116485. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  116486. /**
  116487. * Set the motor limits.
  116488. * Attention, this function is plugin specific. Engines won't react 100% the same.
  116489. * @param {number} upperLimit the upper limit
  116490. * @param {number} lowerLimit lower limit
  116491. * @param {motorIndex} the motor's index, 0 or 1.
  116492. */
  116493. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  116494. }
  116495. /**
  116496. * Interface for a motor enabled joint
  116497. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116498. */
  116499. export interface IMotorEnabledJoint {
  116500. /**
  116501. * Physics joint
  116502. */
  116503. physicsJoint: any;
  116504. /**
  116505. * Sets the motor of the motor-enabled joint
  116506. * @param force The force of the motor
  116507. * @param maxForce The maximum force of the motor
  116508. * @param motorIndex The index of the motor
  116509. */
  116510. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  116511. /**
  116512. * Sets the limit of the motor
  116513. * @param upperLimit The upper limit of the motor
  116514. * @param lowerLimit The lower limit of the motor
  116515. * @param motorIndex The index of the motor
  116516. */
  116517. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  116518. }
  116519. /**
  116520. * Joint data for a Distance-Joint
  116521. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116522. */
  116523. export interface DistanceJointData extends PhysicsJointData {
  116524. /**
  116525. * Max distance the 2 joint objects can be apart
  116526. */
  116527. maxDistance: number;
  116528. }
  116529. /**
  116530. * Joint data from a spring joint
  116531. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116532. */
  116533. export interface SpringJointData extends PhysicsJointData {
  116534. /**
  116535. * Length of the spring
  116536. */
  116537. length: number;
  116538. /**
  116539. * Stiffness of the spring
  116540. */
  116541. stiffness: number;
  116542. /**
  116543. * Damping of the spring
  116544. */
  116545. damping: number;
  116546. /** this callback will be called when applying the force to the impostors. */
  116547. forceApplicationCallback: () => void;
  116548. }
  116549. }
  116550. declare module BABYLON {
  116551. /**
  116552. * Holds the data for the raycast result
  116553. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116554. */
  116555. export class PhysicsRaycastResult {
  116556. private _hasHit;
  116557. private _hitDistance;
  116558. private _hitNormalWorld;
  116559. private _hitPointWorld;
  116560. private _rayFromWorld;
  116561. private _rayToWorld;
  116562. /**
  116563. * Gets if there was a hit
  116564. */
  116565. get hasHit(): boolean;
  116566. /**
  116567. * Gets the distance from the hit
  116568. */
  116569. get hitDistance(): number;
  116570. /**
  116571. * Gets the hit normal/direction in the world
  116572. */
  116573. get hitNormalWorld(): Vector3;
  116574. /**
  116575. * Gets the hit point in the world
  116576. */
  116577. get hitPointWorld(): Vector3;
  116578. /**
  116579. * Gets the ray "start point" of the ray in the world
  116580. */
  116581. get rayFromWorld(): Vector3;
  116582. /**
  116583. * Gets the ray "end point" of the ray in the world
  116584. */
  116585. get rayToWorld(): Vector3;
  116586. /**
  116587. * Sets the hit data (normal & point in world space)
  116588. * @param hitNormalWorld defines the normal in world space
  116589. * @param hitPointWorld defines the point in world space
  116590. */
  116591. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  116592. /**
  116593. * Sets the distance from the start point to the hit point
  116594. * @param distance
  116595. */
  116596. setHitDistance(distance: number): void;
  116597. /**
  116598. * Calculates the distance manually
  116599. */
  116600. calculateHitDistance(): void;
  116601. /**
  116602. * Resets all the values to default
  116603. * @param from The from point on world space
  116604. * @param to The to point on world space
  116605. */
  116606. reset(from?: Vector3, to?: Vector3): void;
  116607. }
  116608. /**
  116609. * Interface for the size containing width and height
  116610. */
  116611. interface IXYZ {
  116612. /**
  116613. * X
  116614. */
  116615. x: number;
  116616. /**
  116617. * Y
  116618. */
  116619. y: number;
  116620. /**
  116621. * Z
  116622. */
  116623. z: number;
  116624. }
  116625. }
  116626. declare module BABYLON {
  116627. /**
  116628. * Interface used to describe a physics joint
  116629. */
  116630. export interface PhysicsImpostorJoint {
  116631. /** Defines the main impostor to which the joint is linked */
  116632. mainImpostor: PhysicsImpostor;
  116633. /** Defines the impostor that is connected to the main impostor using this joint */
  116634. connectedImpostor: PhysicsImpostor;
  116635. /** Defines the joint itself */
  116636. joint: PhysicsJoint;
  116637. }
  116638. /** @hidden */
  116639. export interface IPhysicsEnginePlugin {
  116640. world: any;
  116641. name: string;
  116642. setGravity(gravity: Vector3): void;
  116643. setTimeStep(timeStep: number): void;
  116644. getTimeStep(): number;
  116645. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  116646. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116647. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116648. generatePhysicsBody(impostor: PhysicsImpostor): void;
  116649. removePhysicsBody(impostor: PhysicsImpostor): void;
  116650. generateJoint(joint: PhysicsImpostorJoint): void;
  116651. removeJoint(joint: PhysicsImpostorJoint): void;
  116652. isSupported(): boolean;
  116653. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  116654. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  116655. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  116656. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  116657. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116658. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116659. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  116660. getBodyMass(impostor: PhysicsImpostor): number;
  116661. getBodyFriction(impostor: PhysicsImpostor): number;
  116662. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  116663. getBodyRestitution(impostor: PhysicsImpostor): number;
  116664. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  116665. getBodyPressure?(impostor: PhysicsImpostor): number;
  116666. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  116667. getBodyStiffness?(impostor: PhysicsImpostor): number;
  116668. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  116669. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  116670. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  116671. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  116672. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  116673. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  116674. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  116675. sleepBody(impostor: PhysicsImpostor): void;
  116676. wakeUpBody(impostor: PhysicsImpostor): void;
  116677. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116678. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  116679. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  116680. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  116681. getRadius(impostor: PhysicsImpostor): number;
  116682. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  116683. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  116684. dispose(): void;
  116685. }
  116686. /**
  116687. * Interface used to define a physics engine
  116688. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116689. */
  116690. export interface IPhysicsEngine {
  116691. /**
  116692. * Gets the gravity vector used by the simulation
  116693. */
  116694. gravity: Vector3;
  116695. /**
  116696. * Sets the gravity vector used by the simulation
  116697. * @param gravity defines the gravity vector to use
  116698. */
  116699. setGravity(gravity: Vector3): void;
  116700. /**
  116701. * Set the time step of the physics engine.
  116702. * Default is 1/60.
  116703. * To slow it down, enter 1/600 for example.
  116704. * To speed it up, 1/30
  116705. * @param newTimeStep the new timestep to apply to this world.
  116706. */
  116707. setTimeStep(newTimeStep: number): void;
  116708. /**
  116709. * Get the time step of the physics engine.
  116710. * @returns the current time step
  116711. */
  116712. getTimeStep(): number;
  116713. /**
  116714. * Set the sub time step of the physics engine.
  116715. * Default is 0 meaning there is no sub steps
  116716. * To increase physics resolution precision, set a small value (like 1 ms)
  116717. * @param subTimeStep defines the new sub timestep used for physics resolution.
  116718. */
  116719. setSubTimeStep(subTimeStep: number): void;
  116720. /**
  116721. * Get the sub time step of the physics engine.
  116722. * @returns the current sub time step
  116723. */
  116724. getSubTimeStep(): number;
  116725. /**
  116726. * Release all resources
  116727. */
  116728. dispose(): void;
  116729. /**
  116730. * Gets the name of the current physics plugin
  116731. * @returns the name of the plugin
  116732. */
  116733. getPhysicsPluginName(): string;
  116734. /**
  116735. * Adding a new impostor for the impostor tracking.
  116736. * This will be done by the impostor itself.
  116737. * @param impostor the impostor to add
  116738. */
  116739. addImpostor(impostor: PhysicsImpostor): void;
  116740. /**
  116741. * Remove an impostor from the engine.
  116742. * This impostor and its mesh will not longer be updated by the physics engine.
  116743. * @param impostor the impostor to remove
  116744. */
  116745. removeImpostor(impostor: PhysicsImpostor): void;
  116746. /**
  116747. * Add a joint to the physics engine
  116748. * @param mainImpostor defines the main impostor to which the joint is added.
  116749. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  116750. * @param joint defines the joint that will connect both impostors.
  116751. */
  116752. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  116753. /**
  116754. * Removes a joint from the simulation
  116755. * @param mainImpostor defines the impostor used with the joint
  116756. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  116757. * @param joint defines the joint to remove
  116758. */
  116759. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  116760. /**
  116761. * Gets the current plugin used to run the simulation
  116762. * @returns current plugin
  116763. */
  116764. getPhysicsPlugin(): IPhysicsEnginePlugin;
  116765. /**
  116766. * Gets the list of physic impostors
  116767. * @returns an array of PhysicsImpostor
  116768. */
  116769. getImpostors(): Array<PhysicsImpostor>;
  116770. /**
  116771. * Gets the impostor for a physics enabled object
  116772. * @param object defines the object impersonated by the impostor
  116773. * @returns the PhysicsImpostor or null if not found
  116774. */
  116775. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  116776. /**
  116777. * Gets the impostor for a physics body object
  116778. * @param body defines physics body used by the impostor
  116779. * @returns the PhysicsImpostor or null if not found
  116780. */
  116781. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  116782. /**
  116783. * Does a raycast in the physics world
  116784. * @param from when should the ray start?
  116785. * @param to when should the ray end?
  116786. * @returns PhysicsRaycastResult
  116787. */
  116788. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116789. /**
  116790. * Called by the scene. No need to call it.
  116791. * @param delta defines the timespam between frames
  116792. */
  116793. _step(delta: number): void;
  116794. }
  116795. }
  116796. declare module BABYLON {
  116797. /**
  116798. * The interface for the physics imposter parameters
  116799. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116800. */
  116801. export interface PhysicsImpostorParameters {
  116802. /**
  116803. * The mass of the physics imposter
  116804. */
  116805. mass: number;
  116806. /**
  116807. * The friction of the physics imposter
  116808. */
  116809. friction?: number;
  116810. /**
  116811. * The coefficient of restitution of the physics imposter
  116812. */
  116813. restitution?: number;
  116814. /**
  116815. * The native options of the physics imposter
  116816. */
  116817. nativeOptions?: any;
  116818. /**
  116819. * Specifies if the parent should be ignored
  116820. */
  116821. ignoreParent?: boolean;
  116822. /**
  116823. * Specifies if bi-directional transformations should be disabled
  116824. */
  116825. disableBidirectionalTransformation?: boolean;
  116826. /**
  116827. * The pressure inside the physics imposter, soft object only
  116828. */
  116829. pressure?: number;
  116830. /**
  116831. * The stiffness the physics imposter, soft object only
  116832. */
  116833. stiffness?: number;
  116834. /**
  116835. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  116836. */
  116837. velocityIterations?: number;
  116838. /**
  116839. * The number of iterations used in maintaining consistent vertex positions, soft object only
  116840. */
  116841. positionIterations?: number;
  116842. /**
  116843. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  116844. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  116845. * Add to fix multiple points
  116846. */
  116847. fixedPoints?: number;
  116848. /**
  116849. * The collision margin around a soft object
  116850. */
  116851. margin?: number;
  116852. /**
  116853. * The collision margin around a soft object
  116854. */
  116855. damping?: number;
  116856. /**
  116857. * The path for a rope based on an extrusion
  116858. */
  116859. path?: any;
  116860. /**
  116861. * The shape of an extrusion used for a rope based on an extrusion
  116862. */
  116863. shape?: any;
  116864. }
  116865. /**
  116866. * Interface for a physics-enabled object
  116867. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116868. */
  116869. export interface IPhysicsEnabledObject {
  116870. /**
  116871. * The position of the physics-enabled object
  116872. */
  116873. position: Vector3;
  116874. /**
  116875. * The rotation of the physics-enabled object
  116876. */
  116877. rotationQuaternion: Nullable<Quaternion>;
  116878. /**
  116879. * The scale of the physics-enabled object
  116880. */
  116881. scaling: Vector3;
  116882. /**
  116883. * The rotation of the physics-enabled object
  116884. */
  116885. rotation?: Vector3;
  116886. /**
  116887. * The parent of the physics-enabled object
  116888. */
  116889. parent?: any;
  116890. /**
  116891. * The bounding info of the physics-enabled object
  116892. * @returns The bounding info of the physics-enabled object
  116893. */
  116894. getBoundingInfo(): BoundingInfo;
  116895. /**
  116896. * Computes the world matrix
  116897. * @param force Specifies if the world matrix should be computed by force
  116898. * @returns A world matrix
  116899. */
  116900. computeWorldMatrix(force: boolean): Matrix;
  116901. /**
  116902. * Gets the world matrix
  116903. * @returns A world matrix
  116904. */
  116905. getWorldMatrix?(): Matrix;
  116906. /**
  116907. * Gets the child meshes
  116908. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  116909. * @returns An array of abstract meshes
  116910. */
  116911. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  116912. /**
  116913. * Gets the vertex data
  116914. * @param kind The type of vertex data
  116915. * @returns A nullable array of numbers, or a float32 array
  116916. */
  116917. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  116918. /**
  116919. * Gets the indices from the mesh
  116920. * @returns A nullable array of index arrays
  116921. */
  116922. getIndices?(): Nullable<IndicesArray>;
  116923. /**
  116924. * Gets the scene from the mesh
  116925. * @returns the indices array or null
  116926. */
  116927. getScene?(): Scene;
  116928. /**
  116929. * Gets the absolute position from the mesh
  116930. * @returns the absolute position
  116931. */
  116932. getAbsolutePosition(): Vector3;
  116933. /**
  116934. * Gets the absolute pivot point from the mesh
  116935. * @returns the absolute pivot point
  116936. */
  116937. getAbsolutePivotPoint(): Vector3;
  116938. /**
  116939. * Rotates the mesh
  116940. * @param axis The axis of rotation
  116941. * @param amount The amount of rotation
  116942. * @param space The space of the rotation
  116943. * @returns The rotation transform node
  116944. */
  116945. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  116946. /**
  116947. * Translates the mesh
  116948. * @param axis The axis of translation
  116949. * @param distance The distance of translation
  116950. * @param space The space of the translation
  116951. * @returns The transform node
  116952. */
  116953. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  116954. /**
  116955. * Sets the absolute position of the mesh
  116956. * @param absolutePosition The absolute position of the mesh
  116957. * @returns The transform node
  116958. */
  116959. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  116960. /**
  116961. * Gets the class name of the mesh
  116962. * @returns The class name
  116963. */
  116964. getClassName(): string;
  116965. }
  116966. /**
  116967. * Represents a physics imposter
  116968. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116969. */
  116970. export class PhysicsImpostor {
  116971. /**
  116972. * The physics-enabled object used as the physics imposter
  116973. */
  116974. object: IPhysicsEnabledObject;
  116975. /**
  116976. * The type of the physics imposter
  116977. */
  116978. type: number;
  116979. private _options;
  116980. private _scene?;
  116981. /**
  116982. * The default object size of the imposter
  116983. */
  116984. static DEFAULT_OBJECT_SIZE: Vector3;
  116985. /**
  116986. * The identity quaternion of the imposter
  116987. */
  116988. static IDENTITY_QUATERNION: Quaternion;
  116989. /** @hidden */
  116990. _pluginData: any;
  116991. private _physicsEngine;
  116992. private _physicsBody;
  116993. private _bodyUpdateRequired;
  116994. private _onBeforePhysicsStepCallbacks;
  116995. private _onAfterPhysicsStepCallbacks;
  116996. /** @hidden */
  116997. _onPhysicsCollideCallbacks: Array<{
  116998. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  116999. otherImpostors: Array<PhysicsImpostor>;
  117000. }>;
  117001. private _deltaPosition;
  117002. private _deltaRotation;
  117003. private _deltaRotationConjugated;
  117004. /** @hidden */
  117005. _isFromLine: boolean;
  117006. private _parent;
  117007. private _isDisposed;
  117008. private static _tmpVecs;
  117009. private static _tmpQuat;
  117010. /**
  117011. * Specifies if the physics imposter is disposed
  117012. */
  117013. get isDisposed(): boolean;
  117014. /**
  117015. * Gets the mass of the physics imposter
  117016. */
  117017. get mass(): number;
  117018. set mass(value: number);
  117019. /**
  117020. * Gets the coefficient of friction
  117021. */
  117022. get friction(): number;
  117023. /**
  117024. * Sets the coefficient of friction
  117025. */
  117026. set friction(value: number);
  117027. /**
  117028. * Gets the coefficient of restitution
  117029. */
  117030. get restitution(): number;
  117031. /**
  117032. * Sets the coefficient of restitution
  117033. */
  117034. set restitution(value: number);
  117035. /**
  117036. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  117037. */
  117038. get pressure(): number;
  117039. /**
  117040. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  117041. */
  117042. set pressure(value: number);
  117043. /**
  117044. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  117045. */
  117046. get stiffness(): number;
  117047. /**
  117048. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  117049. */
  117050. set stiffness(value: number);
  117051. /**
  117052. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  117053. */
  117054. get velocityIterations(): number;
  117055. /**
  117056. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  117057. */
  117058. set velocityIterations(value: number);
  117059. /**
  117060. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  117061. */
  117062. get positionIterations(): number;
  117063. /**
  117064. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  117065. */
  117066. set positionIterations(value: number);
  117067. /**
  117068. * The unique id of the physics imposter
  117069. * set by the physics engine when adding this impostor to the array
  117070. */
  117071. uniqueId: number;
  117072. /**
  117073. * @hidden
  117074. */
  117075. soft: boolean;
  117076. /**
  117077. * @hidden
  117078. */
  117079. segments: number;
  117080. private _joints;
  117081. /**
  117082. * Initializes the physics imposter
  117083. * @param object The physics-enabled object used as the physics imposter
  117084. * @param type The type of the physics imposter
  117085. * @param _options The options for the physics imposter
  117086. * @param _scene The Babylon scene
  117087. */
  117088. constructor(
  117089. /**
  117090. * The physics-enabled object used as the physics imposter
  117091. */
  117092. object: IPhysicsEnabledObject,
  117093. /**
  117094. * The type of the physics imposter
  117095. */
  117096. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  117097. /**
  117098. * This function will completly initialize this impostor.
  117099. * It will create a new body - but only if this mesh has no parent.
  117100. * If it has, this impostor will not be used other than to define the impostor
  117101. * of the child mesh.
  117102. * @hidden
  117103. */
  117104. _init(): void;
  117105. private _getPhysicsParent;
  117106. /**
  117107. * Should a new body be generated.
  117108. * @returns boolean specifying if body initialization is required
  117109. */
  117110. isBodyInitRequired(): boolean;
  117111. /**
  117112. * Sets the updated scaling
  117113. * @param updated Specifies if the scaling is updated
  117114. */
  117115. setScalingUpdated(): void;
  117116. /**
  117117. * Force a regeneration of this or the parent's impostor's body.
  117118. * Use under cautious - This will remove all joints already implemented.
  117119. */
  117120. forceUpdate(): void;
  117121. /**
  117122. * Gets the body that holds this impostor. Either its own, or its parent.
  117123. */
  117124. get physicsBody(): any;
  117125. /**
  117126. * Get the parent of the physics imposter
  117127. * @returns Physics imposter or null
  117128. */
  117129. get parent(): Nullable<PhysicsImpostor>;
  117130. /**
  117131. * Sets the parent of the physics imposter
  117132. */
  117133. set parent(value: Nullable<PhysicsImpostor>);
  117134. /**
  117135. * Set the physics body. Used mainly by the physics engine/plugin
  117136. */
  117137. set physicsBody(physicsBody: any);
  117138. /**
  117139. * Resets the update flags
  117140. */
  117141. resetUpdateFlags(): void;
  117142. /**
  117143. * Gets the object extend size
  117144. * @returns the object extend size
  117145. */
  117146. getObjectExtendSize(): Vector3;
  117147. /**
  117148. * Gets the object center
  117149. * @returns The object center
  117150. */
  117151. getObjectCenter(): Vector3;
  117152. /**
  117153. * Get a specific parameter from the options parameters
  117154. * @param paramName The object parameter name
  117155. * @returns The object parameter
  117156. */
  117157. getParam(paramName: string): any;
  117158. /**
  117159. * Sets a specific parameter in the options given to the physics plugin
  117160. * @param paramName The parameter name
  117161. * @param value The value of the parameter
  117162. */
  117163. setParam(paramName: string, value: number): void;
  117164. /**
  117165. * Specifically change the body's mass option. Won't recreate the physics body object
  117166. * @param mass The mass of the physics imposter
  117167. */
  117168. setMass(mass: number): void;
  117169. /**
  117170. * Gets the linear velocity
  117171. * @returns linear velocity or null
  117172. */
  117173. getLinearVelocity(): Nullable<Vector3>;
  117174. /**
  117175. * Sets the linear velocity
  117176. * @param velocity linear velocity or null
  117177. */
  117178. setLinearVelocity(velocity: Nullable<Vector3>): void;
  117179. /**
  117180. * Gets the angular velocity
  117181. * @returns angular velocity or null
  117182. */
  117183. getAngularVelocity(): Nullable<Vector3>;
  117184. /**
  117185. * Sets the angular velocity
  117186. * @param velocity The velocity or null
  117187. */
  117188. setAngularVelocity(velocity: Nullable<Vector3>): void;
  117189. /**
  117190. * Execute a function with the physics plugin native code
  117191. * Provide a function the will have two variables - the world object and the physics body object
  117192. * @param func The function to execute with the physics plugin native code
  117193. */
  117194. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  117195. /**
  117196. * Register a function that will be executed before the physics world is stepping forward
  117197. * @param func The function to execute before the physics world is stepped forward
  117198. */
  117199. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  117200. /**
  117201. * Unregister a function that will be executed before the physics world is stepping forward
  117202. * @param func The function to execute before the physics world is stepped forward
  117203. */
  117204. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  117205. /**
  117206. * Register a function that will be executed after the physics step
  117207. * @param func The function to execute after physics step
  117208. */
  117209. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  117210. /**
  117211. * Unregisters a function that will be executed after the physics step
  117212. * @param func The function to execute after physics step
  117213. */
  117214. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  117215. /**
  117216. * register a function that will be executed when this impostor collides against a different body
  117217. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  117218. * @param func Callback that is executed on collision
  117219. */
  117220. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  117221. /**
  117222. * Unregisters the physics imposter on contact
  117223. * @param collideAgainst The physics object to collide against
  117224. * @param func Callback to execute on collision
  117225. */
  117226. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  117227. private _tmpQuat;
  117228. private _tmpQuat2;
  117229. /**
  117230. * Get the parent rotation
  117231. * @returns The parent rotation
  117232. */
  117233. getParentsRotation(): Quaternion;
  117234. /**
  117235. * this function is executed by the physics engine.
  117236. */
  117237. beforeStep: () => void;
  117238. /**
  117239. * this function is executed by the physics engine
  117240. */
  117241. afterStep: () => void;
  117242. /**
  117243. * Legacy collision detection event support
  117244. */
  117245. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  117246. /**
  117247. * event and body object due to cannon's event-based architecture.
  117248. */
  117249. onCollide: (e: {
  117250. body: any;
  117251. point: Nullable<Vector3>;
  117252. }) => void;
  117253. /**
  117254. * Apply a force
  117255. * @param force The force to apply
  117256. * @param contactPoint The contact point for the force
  117257. * @returns The physics imposter
  117258. */
  117259. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  117260. /**
  117261. * Apply an impulse
  117262. * @param force The impulse force
  117263. * @param contactPoint The contact point for the impulse force
  117264. * @returns The physics imposter
  117265. */
  117266. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  117267. /**
  117268. * A help function to create a joint
  117269. * @param otherImpostor A physics imposter used to create a joint
  117270. * @param jointType The type of joint
  117271. * @param jointData The data for the joint
  117272. * @returns The physics imposter
  117273. */
  117274. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  117275. /**
  117276. * Add a joint to this impostor with a different impostor
  117277. * @param otherImpostor A physics imposter used to add a joint
  117278. * @param joint The joint to add
  117279. * @returns The physics imposter
  117280. */
  117281. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  117282. /**
  117283. * Add an anchor to a cloth impostor
  117284. * @param otherImpostor rigid impostor to anchor to
  117285. * @param width ratio across width from 0 to 1
  117286. * @param height ratio up height from 0 to 1
  117287. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  117288. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  117289. * @returns impostor the soft imposter
  117290. */
  117291. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  117292. /**
  117293. * Add a hook to a rope impostor
  117294. * @param otherImpostor rigid impostor to anchor to
  117295. * @param length ratio across rope from 0 to 1
  117296. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  117297. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  117298. * @returns impostor the rope imposter
  117299. */
  117300. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  117301. /**
  117302. * Will keep this body still, in a sleep mode.
  117303. * @returns the physics imposter
  117304. */
  117305. sleep(): PhysicsImpostor;
  117306. /**
  117307. * Wake the body up.
  117308. * @returns The physics imposter
  117309. */
  117310. wakeUp(): PhysicsImpostor;
  117311. /**
  117312. * Clones the physics imposter
  117313. * @param newObject The physics imposter clones to this physics-enabled object
  117314. * @returns A nullable physics imposter
  117315. */
  117316. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  117317. /**
  117318. * Disposes the physics imposter
  117319. */
  117320. dispose(): void;
  117321. /**
  117322. * Sets the delta position
  117323. * @param position The delta position amount
  117324. */
  117325. setDeltaPosition(position: Vector3): void;
  117326. /**
  117327. * Sets the delta rotation
  117328. * @param rotation The delta rotation amount
  117329. */
  117330. setDeltaRotation(rotation: Quaternion): void;
  117331. /**
  117332. * Gets the box size of the physics imposter and stores the result in the input parameter
  117333. * @param result Stores the box size
  117334. * @returns The physics imposter
  117335. */
  117336. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  117337. /**
  117338. * Gets the radius of the physics imposter
  117339. * @returns Radius of the physics imposter
  117340. */
  117341. getRadius(): number;
  117342. /**
  117343. * Sync a bone with this impostor
  117344. * @param bone The bone to sync to the impostor.
  117345. * @param boneMesh The mesh that the bone is influencing.
  117346. * @param jointPivot The pivot of the joint / bone in local space.
  117347. * @param distToJoint Optional distance from the impostor to the joint.
  117348. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  117349. */
  117350. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  117351. /**
  117352. * Sync impostor to a bone
  117353. * @param bone The bone that the impostor will be synced to.
  117354. * @param boneMesh The mesh that the bone is influencing.
  117355. * @param jointPivot The pivot of the joint / bone in local space.
  117356. * @param distToJoint Optional distance from the impostor to the joint.
  117357. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  117358. * @param boneAxis Optional vector3 axis the bone is aligned with
  117359. */
  117360. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  117361. /**
  117362. * No-Imposter type
  117363. */
  117364. static NoImpostor: number;
  117365. /**
  117366. * Sphere-Imposter type
  117367. */
  117368. static SphereImpostor: number;
  117369. /**
  117370. * Box-Imposter type
  117371. */
  117372. static BoxImpostor: number;
  117373. /**
  117374. * Plane-Imposter type
  117375. */
  117376. static PlaneImpostor: number;
  117377. /**
  117378. * Mesh-imposter type
  117379. */
  117380. static MeshImpostor: number;
  117381. /**
  117382. * Capsule-Impostor type (Ammo.js plugin only)
  117383. */
  117384. static CapsuleImpostor: number;
  117385. /**
  117386. * Cylinder-Imposter type
  117387. */
  117388. static CylinderImpostor: number;
  117389. /**
  117390. * Particle-Imposter type
  117391. */
  117392. static ParticleImpostor: number;
  117393. /**
  117394. * Heightmap-Imposter type
  117395. */
  117396. static HeightmapImpostor: number;
  117397. /**
  117398. * ConvexHull-Impostor type (Ammo.js plugin only)
  117399. */
  117400. static ConvexHullImpostor: number;
  117401. /**
  117402. * Custom-Imposter type (Ammo.js plugin only)
  117403. */
  117404. static CustomImpostor: number;
  117405. /**
  117406. * Rope-Imposter type
  117407. */
  117408. static RopeImpostor: number;
  117409. /**
  117410. * Cloth-Imposter type
  117411. */
  117412. static ClothImpostor: number;
  117413. /**
  117414. * Softbody-Imposter type
  117415. */
  117416. static SoftbodyImpostor: number;
  117417. }
  117418. }
  117419. declare module BABYLON {
  117420. /**
  117421. * @hidden
  117422. **/
  117423. export class _CreationDataStorage {
  117424. closePath?: boolean;
  117425. closeArray?: boolean;
  117426. idx: number[];
  117427. dashSize: number;
  117428. gapSize: number;
  117429. path3D: Path3D;
  117430. pathArray: Vector3[][];
  117431. arc: number;
  117432. radius: number;
  117433. cap: number;
  117434. tessellation: number;
  117435. }
  117436. /**
  117437. * @hidden
  117438. **/
  117439. class _InstanceDataStorage {
  117440. visibleInstances: any;
  117441. batchCache: _InstancesBatch;
  117442. instancesBufferSize: number;
  117443. instancesBuffer: Nullable<Buffer>;
  117444. instancesData: Float32Array;
  117445. overridenInstanceCount: number;
  117446. isFrozen: boolean;
  117447. previousBatch: Nullable<_InstancesBatch>;
  117448. hardwareInstancedRendering: boolean;
  117449. sideOrientation: number;
  117450. manualUpdate: boolean;
  117451. previousRenderId: number;
  117452. }
  117453. /**
  117454. * @hidden
  117455. **/
  117456. export class _InstancesBatch {
  117457. mustReturn: boolean;
  117458. visibleInstances: Nullable<InstancedMesh[]>[];
  117459. renderSelf: boolean[];
  117460. hardwareInstancedRendering: boolean[];
  117461. }
  117462. /**
  117463. * @hidden
  117464. **/
  117465. class _ThinInstanceDataStorage {
  117466. instancesCount: number;
  117467. matrixBuffer: Nullable<Buffer>;
  117468. matrixBufferSize: number;
  117469. matrixData: Nullable<Float32Array>;
  117470. boundingVectors: Array<Vector3>;
  117471. worldMatrices: Nullable<Matrix[]>;
  117472. }
  117473. /**
  117474. * Class used to represent renderable models
  117475. */
  117476. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  117477. /**
  117478. * Mesh side orientation : usually the external or front surface
  117479. */
  117480. static readonly FRONTSIDE: number;
  117481. /**
  117482. * Mesh side orientation : usually the internal or back surface
  117483. */
  117484. static readonly BACKSIDE: number;
  117485. /**
  117486. * Mesh side orientation : both internal and external or front and back surfaces
  117487. */
  117488. static readonly DOUBLESIDE: number;
  117489. /**
  117490. * Mesh side orientation : by default, `FRONTSIDE`
  117491. */
  117492. static readonly DEFAULTSIDE: number;
  117493. /**
  117494. * Mesh cap setting : no cap
  117495. */
  117496. static readonly NO_CAP: number;
  117497. /**
  117498. * Mesh cap setting : one cap at the beginning of the mesh
  117499. */
  117500. static readonly CAP_START: number;
  117501. /**
  117502. * Mesh cap setting : one cap at the end of the mesh
  117503. */
  117504. static readonly CAP_END: number;
  117505. /**
  117506. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  117507. */
  117508. static readonly CAP_ALL: number;
  117509. /**
  117510. * Mesh pattern setting : no flip or rotate
  117511. */
  117512. static readonly NO_FLIP: number;
  117513. /**
  117514. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  117515. */
  117516. static readonly FLIP_TILE: number;
  117517. /**
  117518. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  117519. */
  117520. static readonly ROTATE_TILE: number;
  117521. /**
  117522. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  117523. */
  117524. static readonly FLIP_ROW: number;
  117525. /**
  117526. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  117527. */
  117528. static readonly ROTATE_ROW: number;
  117529. /**
  117530. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  117531. */
  117532. static readonly FLIP_N_ROTATE_TILE: number;
  117533. /**
  117534. * Mesh pattern setting : rotate pattern and rotate
  117535. */
  117536. static readonly FLIP_N_ROTATE_ROW: number;
  117537. /**
  117538. * Mesh tile positioning : part tiles same on left/right or top/bottom
  117539. */
  117540. static readonly CENTER: number;
  117541. /**
  117542. * Mesh tile positioning : part tiles on left
  117543. */
  117544. static readonly LEFT: number;
  117545. /**
  117546. * Mesh tile positioning : part tiles on right
  117547. */
  117548. static readonly RIGHT: number;
  117549. /**
  117550. * Mesh tile positioning : part tiles on top
  117551. */
  117552. static readonly TOP: number;
  117553. /**
  117554. * Mesh tile positioning : part tiles on bottom
  117555. */
  117556. static readonly BOTTOM: number;
  117557. /**
  117558. * Gets the default side orientation.
  117559. * @param orientation the orientation to value to attempt to get
  117560. * @returns the default orientation
  117561. * @hidden
  117562. */
  117563. static _GetDefaultSideOrientation(orientation?: number): number;
  117564. private _internalMeshDataInfo;
  117565. get computeBonesUsingShaders(): boolean;
  117566. set computeBonesUsingShaders(value: boolean);
  117567. /**
  117568. * An event triggered before rendering the mesh
  117569. */
  117570. get onBeforeRenderObservable(): Observable<Mesh>;
  117571. /**
  117572. * An event triggered before binding the mesh
  117573. */
  117574. get onBeforeBindObservable(): Observable<Mesh>;
  117575. /**
  117576. * An event triggered after rendering the mesh
  117577. */
  117578. get onAfterRenderObservable(): Observable<Mesh>;
  117579. /**
  117580. * An event triggered before drawing the mesh
  117581. */
  117582. get onBeforeDrawObservable(): Observable<Mesh>;
  117583. private _onBeforeDrawObserver;
  117584. /**
  117585. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  117586. */
  117587. set onBeforeDraw(callback: () => void);
  117588. get hasInstances(): boolean;
  117589. get hasThinInstances(): boolean;
  117590. /**
  117591. * Gets the delay loading state of the mesh (when delay loading is turned on)
  117592. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  117593. */
  117594. delayLoadState: number;
  117595. /**
  117596. * Gets the list of instances created from this mesh
  117597. * it is not supposed to be modified manually.
  117598. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  117599. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  117600. */
  117601. instances: InstancedMesh[];
  117602. /**
  117603. * Gets the file containing delay loading data for this mesh
  117604. */
  117605. delayLoadingFile: string;
  117606. /** @hidden */
  117607. _binaryInfo: any;
  117608. /**
  117609. * User defined function used to change how LOD level selection is done
  117610. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  117611. */
  117612. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  117613. /**
  117614. * Gets or sets the morph target manager
  117615. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  117616. */
  117617. get morphTargetManager(): Nullable<MorphTargetManager>;
  117618. set morphTargetManager(value: Nullable<MorphTargetManager>);
  117619. /** @hidden */
  117620. _creationDataStorage: Nullable<_CreationDataStorage>;
  117621. /** @hidden */
  117622. _geometry: Nullable<Geometry>;
  117623. /** @hidden */
  117624. _delayInfo: Array<string>;
  117625. /** @hidden */
  117626. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  117627. /** @hidden */
  117628. _instanceDataStorage: _InstanceDataStorage;
  117629. /** @hidden */
  117630. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  117631. private _effectiveMaterial;
  117632. /** @hidden */
  117633. _shouldGenerateFlatShading: boolean;
  117634. /** @hidden */
  117635. _originalBuilderSideOrientation: number;
  117636. /**
  117637. * Use this property to change the original side orientation defined at construction time
  117638. */
  117639. overrideMaterialSideOrientation: Nullable<number>;
  117640. /**
  117641. * Gets the source mesh (the one used to clone this one from)
  117642. */
  117643. get source(): Nullable<Mesh>;
  117644. /**
  117645. * Gets the list of clones of this mesh
  117646. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  117647. * Note that useClonedMeshMap=true is the default setting
  117648. */
  117649. get cloneMeshMap(): Nullable<{
  117650. [id: string]: Mesh | undefined;
  117651. }>;
  117652. /**
  117653. * Gets or sets a boolean indicating that this mesh does not use index buffer
  117654. */
  117655. get isUnIndexed(): boolean;
  117656. set isUnIndexed(value: boolean);
  117657. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  117658. get worldMatrixInstancedBuffer(): Float32Array;
  117659. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  117660. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  117661. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  117662. /**
  117663. * @constructor
  117664. * @param name The value used by scene.getMeshByName() to do a lookup.
  117665. * @param scene The scene to add this mesh to.
  117666. * @param parent The parent of this mesh, if it has one
  117667. * @param source An optional Mesh from which geometry is shared, cloned.
  117668. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  117669. * When false, achieved by calling a clone(), also passing False.
  117670. * This will make creation of children, recursive.
  117671. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  117672. */
  117673. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  117674. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  117675. doNotInstantiate: boolean;
  117676. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  117677. /**
  117678. * Gets the class name
  117679. * @returns the string "Mesh".
  117680. */
  117681. getClassName(): string;
  117682. /** @hidden */
  117683. get _isMesh(): boolean;
  117684. /**
  117685. * Returns a description of this mesh
  117686. * @param fullDetails define if full details about this mesh must be used
  117687. * @returns a descriptive string representing this mesh
  117688. */
  117689. toString(fullDetails?: boolean): string;
  117690. /** @hidden */
  117691. _unBindEffect(): void;
  117692. /**
  117693. * Gets a boolean indicating if this mesh has LOD
  117694. */
  117695. get hasLODLevels(): boolean;
  117696. /**
  117697. * Gets the list of MeshLODLevel associated with the current mesh
  117698. * @returns an array of MeshLODLevel
  117699. */
  117700. getLODLevels(): MeshLODLevel[];
  117701. private _sortLODLevels;
  117702. /**
  117703. * Add a mesh as LOD level triggered at the given distance.
  117704. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  117705. * @param distance The distance from the center of the object to show this level
  117706. * @param mesh The mesh to be added as LOD level (can be null)
  117707. * @return This mesh (for chaining)
  117708. */
  117709. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  117710. /**
  117711. * Returns the LOD level mesh at the passed distance or null if not found.
  117712. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  117713. * @param distance The distance from the center of the object to show this level
  117714. * @returns a Mesh or `null`
  117715. */
  117716. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  117717. /**
  117718. * Remove a mesh from the LOD array
  117719. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  117720. * @param mesh defines the mesh to be removed
  117721. * @return This mesh (for chaining)
  117722. */
  117723. removeLODLevel(mesh: Mesh): Mesh;
  117724. /**
  117725. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  117726. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  117727. * @param camera defines the camera to use to compute distance
  117728. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  117729. * @return This mesh (for chaining)
  117730. */
  117731. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  117732. /**
  117733. * Gets the mesh internal Geometry object
  117734. */
  117735. get geometry(): Nullable<Geometry>;
  117736. /**
  117737. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  117738. * @returns the total number of vertices
  117739. */
  117740. getTotalVertices(): number;
  117741. /**
  117742. * Returns the content of an associated vertex buffer
  117743. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  117744. * - VertexBuffer.PositionKind
  117745. * - VertexBuffer.UVKind
  117746. * - VertexBuffer.UV2Kind
  117747. * - VertexBuffer.UV3Kind
  117748. * - VertexBuffer.UV4Kind
  117749. * - VertexBuffer.UV5Kind
  117750. * - VertexBuffer.UV6Kind
  117751. * - VertexBuffer.ColorKind
  117752. * - VertexBuffer.MatricesIndicesKind
  117753. * - VertexBuffer.MatricesIndicesExtraKind
  117754. * - VertexBuffer.MatricesWeightsKind
  117755. * - VertexBuffer.MatricesWeightsExtraKind
  117756. * @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
  117757. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  117758. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  117759. */
  117760. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  117761. /**
  117762. * Returns the mesh VertexBuffer object from the requested `kind`
  117763. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  117764. * - VertexBuffer.PositionKind
  117765. * - VertexBuffer.NormalKind
  117766. * - VertexBuffer.UVKind
  117767. * - VertexBuffer.UV2Kind
  117768. * - VertexBuffer.UV3Kind
  117769. * - VertexBuffer.UV4Kind
  117770. * - VertexBuffer.UV5Kind
  117771. * - VertexBuffer.UV6Kind
  117772. * - VertexBuffer.ColorKind
  117773. * - VertexBuffer.MatricesIndicesKind
  117774. * - VertexBuffer.MatricesIndicesExtraKind
  117775. * - VertexBuffer.MatricesWeightsKind
  117776. * - VertexBuffer.MatricesWeightsExtraKind
  117777. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  117778. */
  117779. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  117780. /**
  117781. * Tests if a specific vertex buffer is associated with this mesh
  117782. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  117783. * - VertexBuffer.PositionKind
  117784. * - VertexBuffer.NormalKind
  117785. * - VertexBuffer.UVKind
  117786. * - VertexBuffer.UV2Kind
  117787. * - VertexBuffer.UV3Kind
  117788. * - VertexBuffer.UV4Kind
  117789. * - VertexBuffer.UV5Kind
  117790. * - VertexBuffer.UV6Kind
  117791. * - VertexBuffer.ColorKind
  117792. * - VertexBuffer.MatricesIndicesKind
  117793. * - VertexBuffer.MatricesIndicesExtraKind
  117794. * - VertexBuffer.MatricesWeightsKind
  117795. * - VertexBuffer.MatricesWeightsExtraKind
  117796. * @returns a boolean
  117797. */
  117798. isVerticesDataPresent(kind: string): boolean;
  117799. /**
  117800. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  117801. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  117802. * - VertexBuffer.PositionKind
  117803. * - VertexBuffer.UVKind
  117804. * - VertexBuffer.UV2Kind
  117805. * - VertexBuffer.UV3Kind
  117806. * - VertexBuffer.UV4Kind
  117807. * - VertexBuffer.UV5Kind
  117808. * - VertexBuffer.UV6Kind
  117809. * - VertexBuffer.ColorKind
  117810. * - VertexBuffer.MatricesIndicesKind
  117811. * - VertexBuffer.MatricesIndicesExtraKind
  117812. * - VertexBuffer.MatricesWeightsKind
  117813. * - VertexBuffer.MatricesWeightsExtraKind
  117814. * @returns a boolean
  117815. */
  117816. isVertexBufferUpdatable(kind: string): boolean;
  117817. /**
  117818. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  117819. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  117820. * - VertexBuffer.PositionKind
  117821. * - VertexBuffer.NormalKind
  117822. * - VertexBuffer.UVKind
  117823. * - VertexBuffer.UV2Kind
  117824. * - VertexBuffer.UV3Kind
  117825. * - VertexBuffer.UV4Kind
  117826. * - VertexBuffer.UV5Kind
  117827. * - VertexBuffer.UV6Kind
  117828. * - VertexBuffer.ColorKind
  117829. * - VertexBuffer.MatricesIndicesKind
  117830. * - VertexBuffer.MatricesIndicesExtraKind
  117831. * - VertexBuffer.MatricesWeightsKind
  117832. * - VertexBuffer.MatricesWeightsExtraKind
  117833. * @returns an array of strings
  117834. */
  117835. getVerticesDataKinds(): string[];
  117836. /**
  117837. * Returns a positive integer : the total number of indices in this mesh geometry.
  117838. * @returns the numner of indices or zero if the mesh has no geometry.
  117839. */
  117840. getTotalIndices(): number;
  117841. /**
  117842. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  117843. * @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.
  117844. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  117845. * @returns the indices array or an empty array if the mesh has no geometry
  117846. */
  117847. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  117848. get isBlocked(): boolean;
  117849. /**
  117850. * Determine if the current mesh is ready to be rendered
  117851. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  117852. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  117853. * @returns true if all associated assets are ready (material, textures, shaders)
  117854. */
  117855. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  117856. /**
  117857. * 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.
  117858. */
  117859. get areNormalsFrozen(): boolean;
  117860. /**
  117861. * 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.
  117862. * @returns the current mesh
  117863. */
  117864. freezeNormals(): Mesh;
  117865. /**
  117866. * 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
  117867. * @returns the current mesh
  117868. */
  117869. unfreezeNormals(): Mesh;
  117870. /**
  117871. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  117872. */
  117873. set overridenInstanceCount(count: number);
  117874. /** @hidden */
  117875. _preActivate(): Mesh;
  117876. /** @hidden */
  117877. _preActivateForIntermediateRendering(renderId: number): Mesh;
  117878. /** @hidden */
  117879. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  117880. protected _afterComputeWorldMatrix(): void;
  117881. /** @hidden */
  117882. _postActivate(): void;
  117883. /**
  117884. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  117885. * This means the mesh underlying bounding box and sphere are recomputed.
  117886. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  117887. * @returns the current mesh
  117888. */
  117889. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  117890. /** @hidden */
  117891. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  117892. /**
  117893. * This function will subdivide the mesh into multiple submeshes
  117894. * @param count defines the expected number of submeshes
  117895. */
  117896. subdivide(count: number): void;
  117897. /**
  117898. * Copy a FloatArray into a specific associated vertex buffer
  117899. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  117900. * - VertexBuffer.PositionKind
  117901. * - VertexBuffer.UVKind
  117902. * - VertexBuffer.UV2Kind
  117903. * - VertexBuffer.UV3Kind
  117904. * - VertexBuffer.UV4Kind
  117905. * - VertexBuffer.UV5Kind
  117906. * - VertexBuffer.UV6Kind
  117907. * - VertexBuffer.ColorKind
  117908. * - VertexBuffer.MatricesIndicesKind
  117909. * - VertexBuffer.MatricesIndicesExtraKind
  117910. * - VertexBuffer.MatricesWeightsKind
  117911. * - VertexBuffer.MatricesWeightsExtraKind
  117912. * @param data defines the data source
  117913. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  117914. * @param stride defines the data stride size (can be null)
  117915. * @returns the current mesh
  117916. */
  117917. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  117918. /**
  117919. * Delete a vertex buffer associated with this mesh
  117920. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  117921. * - VertexBuffer.PositionKind
  117922. * - VertexBuffer.UVKind
  117923. * - VertexBuffer.UV2Kind
  117924. * - VertexBuffer.UV3Kind
  117925. * - VertexBuffer.UV4Kind
  117926. * - VertexBuffer.UV5Kind
  117927. * - VertexBuffer.UV6Kind
  117928. * - VertexBuffer.ColorKind
  117929. * - VertexBuffer.MatricesIndicesKind
  117930. * - VertexBuffer.MatricesIndicesExtraKind
  117931. * - VertexBuffer.MatricesWeightsKind
  117932. * - VertexBuffer.MatricesWeightsExtraKind
  117933. */
  117934. removeVerticesData(kind: string): void;
  117935. /**
  117936. * Flags an associated vertex buffer as updatable
  117937. * @param kind defines which buffer to use (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 updatable defines if the updated vertex buffer must be flagged as updatable
  117951. */
  117952. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  117953. /**
  117954. * Sets the mesh global Vertex Buffer
  117955. * @param buffer defines the buffer to use
  117956. * @returns the current mesh
  117957. */
  117958. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  117959. /**
  117960. * Update a specific associated vertex buffer
  117961. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  117962. * - VertexBuffer.PositionKind
  117963. * - VertexBuffer.UVKind
  117964. * - VertexBuffer.UV2Kind
  117965. * - VertexBuffer.UV3Kind
  117966. * - VertexBuffer.UV4Kind
  117967. * - VertexBuffer.UV5Kind
  117968. * - VertexBuffer.UV6Kind
  117969. * - VertexBuffer.ColorKind
  117970. * - VertexBuffer.MatricesIndicesKind
  117971. * - VertexBuffer.MatricesIndicesExtraKind
  117972. * - VertexBuffer.MatricesWeightsKind
  117973. * - VertexBuffer.MatricesWeightsExtraKind
  117974. * @param data defines the data source
  117975. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  117976. * @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)
  117977. * @returns the current mesh
  117978. */
  117979. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  117980. /**
  117981. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  117982. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  117983. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  117984. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  117985. * @returns the current mesh
  117986. */
  117987. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  117988. /**
  117989. * Creates a un-shared specific occurence of the geometry for the mesh.
  117990. * @returns the current mesh
  117991. */
  117992. makeGeometryUnique(): Mesh;
  117993. /**
  117994. * Set the index buffer of this mesh
  117995. * @param indices defines the source data
  117996. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  117997. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  117998. * @returns the current mesh
  117999. */
  118000. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  118001. /**
  118002. * Update the current index buffer
  118003. * @param indices defines the source data
  118004. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  118005. * @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)
  118006. * @returns the current mesh
  118007. */
  118008. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  118009. /**
  118010. * Invert the geometry to move from a right handed system to a left handed one.
  118011. * @returns the current mesh
  118012. */
  118013. toLeftHanded(): Mesh;
  118014. /** @hidden */
  118015. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  118016. /** @hidden */
  118017. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  118018. /**
  118019. * Registers for this mesh a javascript function called just before the rendering process
  118020. * @param func defines the function to call before rendering this mesh
  118021. * @returns the current mesh
  118022. */
  118023. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  118024. /**
  118025. * Disposes a previously registered javascript function called before the rendering
  118026. * @param func defines the function to remove
  118027. * @returns the current mesh
  118028. */
  118029. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  118030. /**
  118031. * Registers for this mesh a javascript function called just after the rendering is complete
  118032. * @param func defines the function to call after rendering this mesh
  118033. * @returns the current mesh
  118034. */
  118035. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  118036. /**
  118037. * Disposes a previously registered javascript function called after the rendering.
  118038. * @param func defines the function to remove
  118039. * @returns the current mesh
  118040. */
  118041. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  118042. /** @hidden */
  118043. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  118044. /** @hidden */
  118045. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  118046. /** @hidden */
  118047. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  118048. /** @hidden */
  118049. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  118050. /** @hidden */
  118051. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  118052. /** @hidden */
  118053. _rebuild(): void;
  118054. /** @hidden */
  118055. _freeze(): void;
  118056. /** @hidden */
  118057. _unFreeze(): void;
  118058. /**
  118059. * 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
  118060. * @param subMesh defines the subMesh to render
  118061. * @param enableAlphaMode defines if alpha mode can be changed
  118062. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  118063. * @returns the current mesh
  118064. */
  118065. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  118066. private _onBeforeDraw;
  118067. /**
  118068. * Renormalize the mesh and patch it up if there are no weights
  118069. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  118070. * However in the case of zero weights then we set just a single influence to 1.
  118071. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  118072. */
  118073. cleanMatrixWeights(): void;
  118074. private normalizeSkinFourWeights;
  118075. private normalizeSkinWeightsAndExtra;
  118076. /**
  118077. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  118078. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  118079. * the user know there was an issue with importing the mesh
  118080. * @returns a validation object with skinned, valid and report string
  118081. */
  118082. validateSkinning(): {
  118083. skinned: boolean;
  118084. valid: boolean;
  118085. report: string;
  118086. };
  118087. /** @hidden */
  118088. _checkDelayState(): Mesh;
  118089. private _queueLoad;
  118090. /**
  118091. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  118092. * A mesh is in the frustum if its bounding box intersects the frustum
  118093. * @param frustumPlanes defines the frustum to test
  118094. * @returns true if the mesh is in the frustum planes
  118095. */
  118096. isInFrustum(frustumPlanes: Plane[]): boolean;
  118097. /**
  118098. * Sets the mesh material by the material or multiMaterial `id` property
  118099. * @param id is a string identifying the material or the multiMaterial
  118100. * @returns the current mesh
  118101. */
  118102. setMaterialByID(id: string): Mesh;
  118103. /**
  118104. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  118105. * @returns an array of IAnimatable
  118106. */
  118107. getAnimatables(): IAnimatable[];
  118108. /**
  118109. * Modifies the mesh geometry according to the passed transformation matrix.
  118110. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  118111. * The mesh normals are modified using the same transformation.
  118112. * Note that, under the hood, this method sets a new VertexBuffer each call.
  118113. * @param transform defines the transform matrix to use
  118114. * @see https://doc.babylonjs.com/resources/baking_transformations
  118115. * @returns the current mesh
  118116. */
  118117. bakeTransformIntoVertices(transform: Matrix): Mesh;
  118118. /**
  118119. * Modifies the mesh geometry according to its own current World Matrix.
  118120. * The mesh World Matrix is then reset.
  118121. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  118122. * Note that, under the hood, this method sets a new VertexBuffer each call.
  118123. * @see https://doc.babylonjs.com/resources/baking_transformations
  118124. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  118125. * @returns the current mesh
  118126. */
  118127. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  118128. /** @hidden */
  118129. get _positions(): Nullable<Vector3[]>;
  118130. /** @hidden */
  118131. _resetPointsArrayCache(): Mesh;
  118132. /** @hidden */
  118133. _generatePointsArray(): boolean;
  118134. /**
  118135. * Returns a new Mesh object generated from the current mesh properties.
  118136. * This method must not get confused with createInstance()
  118137. * @param name is a string, the name given to the new mesh
  118138. * @param newParent can be any Node object (default `null`)
  118139. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  118140. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  118141. * @returns a new mesh
  118142. */
  118143. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  118144. /**
  118145. * Releases resources associated with this mesh.
  118146. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  118147. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  118148. */
  118149. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  118150. /** @hidden */
  118151. _disposeInstanceSpecificData(): void;
  118152. /** @hidden */
  118153. _disposeThinInstanceSpecificData(): void;
  118154. /**
  118155. * Modifies the mesh geometry according to a displacement map.
  118156. * 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.
  118157. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  118158. * @param url is a string, the URL from the image file is to be downloaded.
  118159. * @param minHeight is the lower limit of the displacement.
  118160. * @param maxHeight is the upper limit of the displacement.
  118161. * @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.
  118162. * @param uvOffset is an optional vector2 used to offset UV.
  118163. * @param uvScale is an optional vector2 used to scale UV.
  118164. * @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.
  118165. * @returns the Mesh.
  118166. */
  118167. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  118168. /**
  118169. * Modifies the mesh geometry according to a displacementMap buffer.
  118170. * 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.
  118171. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  118172. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  118173. * @param heightMapWidth is the width of the buffer image.
  118174. * @param heightMapHeight is the height of the buffer image.
  118175. * @param minHeight is the lower limit of the displacement.
  118176. * @param maxHeight is the upper limit of the displacement.
  118177. * @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.
  118178. * @param uvOffset is an optional vector2 used to offset UV.
  118179. * @param uvScale is an optional vector2 used to scale UV.
  118180. * @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.
  118181. * @returns the Mesh.
  118182. */
  118183. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  118184. /**
  118185. * Modify the mesh to get a flat shading rendering.
  118186. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  118187. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  118188. * @returns current mesh
  118189. */
  118190. convertToFlatShadedMesh(): Mesh;
  118191. /**
  118192. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  118193. * In other words, more vertices, no more indices and a single bigger VBO.
  118194. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  118195. * @returns current mesh
  118196. */
  118197. convertToUnIndexedMesh(): Mesh;
  118198. /**
  118199. * Inverses facet orientations.
  118200. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  118201. * @param flipNormals will also inverts the normals
  118202. * @returns current mesh
  118203. */
  118204. flipFaces(flipNormals?: boolean): Mesh;
  118205. /**
  118206. * Increase the number of facets and hence vertices in a mesh
  118207. * Vertex normals are interpolated from existing vertex normals
  118208. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  118209. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  118210. */
  118211. increaseVertices(numberPerEdge: number): void;
  118212. /**
  118213. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  118214. * This will undo any application of covertToFlatShadedMesh
  118215. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  118216. */
  118217. forceSharedVertices(): void;
  118218. /** @hidden */
  118219. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  118220. /** @hidden */
  118221. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  118222. /**
  118223. * Creates a new InstancedMesh object from the mesh model.
  118224. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  118225. * @param name defines the name of the new instance
  118226. * @returns a new InstancedMesh
  118227. */
  118228. createInstance(name: string): InstancedMesh;
  118229. /**
  118230. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  118231. * After this call, all the mesh instances have the same submeshes than the current mesh.
  118232. * @returns the current mesh
  118233. */
  118234. synchronizeInstances(): Mesh;
  118235. /**
  118236. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  118237. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  118238. * This should be used together with the simplification to avoid disappearing triangles.
  118239. * @param successCallback an optional success callback to be called after the optimization finished.
  118240. * @returns the current mesh
  118241. */
  118242. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  118243. /**
  118244. * Serialize current mesh
  118245. * @param serializationObject defines the object which will receive the serialization data
  118246. */
  118247. serialize(serializationObject: any): void;
  118248. /** @hidden */
  118249. _syncGeometryWithMorphTargetManager(): void;
  118250. /** @hidden */
  118251. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  118252. /**
  118253. * Returns a new Mesh object parsed from the source provided.
  118254. * @param parsedMesh is the source
  118255. * @param scene defines the hosting scene
  118256. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  118257. * @returns a new Mesh
  118258. */
  118259. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  118260. /**
  118261. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  118262. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118263. * @param name defines the name of the mesh to create
  118264. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  118265. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  118266. * @param closePath creates a seam between the first and the last points of each path of the path array
  118267. * @param offset is taken in account only if the `pathArray` is containing a single path
  118268. * @param scene defines the hosting scene
  118269. * @param updatable defines if the mesh must be flagged as updatable
  118270. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118271. * @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)
  118272. * @returns a new Mesh
  118273. */
  118274. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  118275. /**
  118276. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  118277. * @param name defines the name of the mesh to create
  118278. * @param radius sets the radius size (float) of the polygon (default 0.5)
  118279. * @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
  118280. * @param scene defines the hosting scene
  118281. * @param updatable defines if the mesh must be flagged as updatable
  118282. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118283. * @returns a new Mesh
  118284. */
  118285. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  118286. /**
  118287. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  118288. * @param name defines the name of the mesh to create
  118289. * @param size sets the size (float) of each box side (default 1)
  118290. * @param scene defines the hosting scene
  118291. * @param updatable defines if the mesh must be flagged as updatable
  118292. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118293. * @returns a new Mesh
  118294. */
  118295. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  118296. /**
  118297. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  118298. * @param name defines the name of the mesh to create
  118299. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  118300. * @param diameter sets the diameter size (float) of the sphere (default 1)
  118301. * @param scene defines the hosting scene
  118302. * @param updatable defines if the mesh must be flagged as updatable
  118303. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118304. * @returns a new Mesh
  118305. */
  118306. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  118307. /**
  118308. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  118309. * @param name defines the name of the mesh to create
  118310. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  118311. * @param diameter sets the diameter size (float) of the sphere (default 1)
  118312. * @param scene defines the hosting scene
  118313. * @returns a new Mesh
  118314. */
  118315. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  118316. /**
  118317. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  118318. * @param name defines the name of the mesh to create
  118319. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  118320. * @param diameterTop set the top cap diameter (floats, default 1)
  118321. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  118322. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  118323. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  118324. * @param scene defines the hosting scene
  118325. * @param updatable defines if the mesh must be flagged as updatable
  118326. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118327. * @returns a new Mesh
  118328. */
  118329. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  118330. /**
  118331. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  118332. * @param name defines the name of the mesh to create
  118333. * @param diameter sets the diameter size (float) of the torus (default 1)
  118334. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  118335. * @param tessellation sets the number of torus sides (postive integer, default 16)
  118336. * @param scene defines the hosting scene
  118337. * @param updatable defines if the mesh must be flagged as updatable
  118338. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118339. * @returns a new Mesh
  118340. */
  118341. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  118342. /**
  118343. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  118344. * @param name defines the name of the mesh to create
  118345. * @param radius sets the global radius size (float) of the torus knot (default 2)
  118346. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  118347. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  118348. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  118349. * @param p the number of windings on X axis (positive integers, default 2)
  118350. * @param q the number of windings on Y axis (positive integers, default 3)
  118351. * @param scene defines the hosting scene
  118352. * @param updatable defines if the mesh must be flagged as updatable
  118353. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118354. * @returns a new Mesh
  118355. */
  118356. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  118357. /**
  118358. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  118359. * @param name defines the name of the mesh to create
  118360. * @param points is an array successive Vector3
  118361. * @param scene defines the hosting scene
  118362. * @param updatable defines if the mesh must be flagged as updatable
  118363. * @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).
  118364. * @returns a new Mesh
  118365. */
  118366. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  118367. /**
  118368. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  118369. * @param name defines the name of the mesh to create
  118370. * @param points is an array successive Vector3
  118371. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  118372. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  118373. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  118374. * @param scene defines the hosting scene
  118375. * @param updatable defines if the mesh must be flagged as updatable
  118376. * @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)
  118377. * @returns a new Mesh
  118378. */
  118379. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  118380. /**
  118381. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  118382. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  118383. * 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.
  118384. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  118385. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118386. * Remember you can only change the shape positions, not their number when updating a polygon.
  118387. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  118388. * @param name defines the name of the mesh to create
  118389. * @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
  118390. * @param scene defines the hosting scene
  118391. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  118392. * @param updatable defines if the mesh must be flagged as updatable
  118393. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118394. * @param earcutInjection can be used to inject your own earcut reference
  118395. * @returns a new Mesh
  118396. */
  118397. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  118398. /**
  118399. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  118400. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  118401. * @param name defines the name of the mesh to create
  118402. * @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
  118403. * @param depth defines the height of extrusion
  118404. * @param scene defines the hosting scene
  118405. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  118406. * @param updatable defines if the mesh must be flagged as updatable
  118407. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118408. * @param earcutInjection can be used to inject your own earcut reference
  118409. * @returns a new Mesh
  118410. */
  118411. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  118412. /**
  118413. * Creates an extruded shape mesh.
  118414. * 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
  118415. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118416. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  118417. * @param name defines the name of the mesh to create
  118418. * @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
  118419. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  118420. * @param scale is the value to scale the shape
  118421. * @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
  118422. * @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
  118423. * @param scene defines the hosting scene
  118424. * @param updatable defines if the mesh must be flagged as updatable
  118425. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118426. * @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)
  118427. * @returns a new Mesh
  118428. */
  118429. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  118430. /**
  118431. * Creates an custom extruded shape mesh.
  118432. * The custom extrusion is a parametric shape.
  118433. * It has no predefined shape. Its final shape will depend on the input parameters.
  118434. * Please consider using the same method from the MeshBuilder class instead
  118435. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  118436. * @param name defines the name of the mesh to create
  118437. * @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
  118438. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  118439. * @param scaleFunction is a custom Javascript function called on each path point
  118440. * @param rotationFunction is a custom Javascript function called on each path point
  118441. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  118442. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  118443. * @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
  118444. * @param scene defines the hosting scene
  118445. * @param updatable defines if the mesh must be flagged as updatable
  118446. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118447. * @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)
  118448. * @returns a new Mesh
  118449. */
  118450. 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;
  118451. /**
  118452. * Creates lathe mesh.
  118453. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  118454. * Please consider using the same method from the MeshBuilder class instead
  118455. * @param name defines the name of the mesh to create
  118456. * @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
  118457. * @param radius is the radius value of the lathe
  118458. * @param tessellation is the side number of the lathe.
  118459. * @param scene defines the hosting scene
  118460. * @param updatable defines if the mesh must be flagged as updatable
  118461. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118462. * @returns a new Mesh
  118463. */
  118464. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  118465. /**
  118466. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  118467. * @param name defines the name of the mesh to create
  118468. * @param size sets the size (float) of both sides of the plane at once (default 1)
  118469. * @param scene defines the hosting scene
  118470. * @param updatable defines if the mesh must be flagged as updatable
  118471. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118472. * @returns a new Mesh
  118473. */
  118474. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  118475. /**
  118476. * Creates a ground mesh.
  118477. * Please consider using the same method from the MeshBuilder class instead
  118478. * @param name defines the name of the mesh to create
  118479. * @param width set the width of the ground
  118480. * @param height set the height of the ground
  118481. * @param subdivisions sets the number of subdivisions per side
  118482. * @param scene defines the hosting scene
  118483. * @param updatable defines if the mesh must be flagged as updatable
  118484. * @returns a new Mesh
  118485. */
  118486. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  118487. /**
  118488. * Creates a tiled ground mesh.
  118489. * Please consider using the same method from the MeshBuilder class instead
  118490. * @param name defines the name of the mesh to create
  118491. * @param xmin set the ground minimum X coordinate
  118492. * @param zmin set the ground minimum Y coordinate
  118493. * @param xmax set the ground maximum X coordinate
  118494. * @param zmax set the ground maximum Z coordinate
  118495. * @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
  118496. * @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
  118497. * @param scene defines the hosting scene
  118498. * @param updatable defines if the mesh must be flagged as updatable
  118499. * @returns a new Mesh
  118500. */
  118501. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  118502. w: number;
  118503. h: number;
  118504. }, precision: {
  118505. w: number;
  118506. h: number;
  118507. }, scene: Scene, updatable?: boolean): Mesh;
  118508. /**
  118509. * Creates a ground mesh from a height map.
  118510. * Please consider using the same method from the MeshBuilder class instead
  118511. * @see https://doc.babylonjs.com/babylon101/height_map
  118512. * @param name defines the name of the mesh to create
  118513. * @param url sets the URL of the height map image resource
  118514. * @param width set the ground width size
  118515. * @param height set the ground height size
  118516. * @param subdivisions sets the number of subdivision per side
  118517. * @param minHeight is the minimum altitude on the ground
  118518. * @param maxHeight is the maximum altitude on the ground
  118519. * @param scene defines the hosting scene
  118520. * @param updatable defines if the mesh must be flagged as updatable
  118521. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  118522. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  118523. * @returns a new Mesh
  118524. */
  118525. 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;
  118526. /**
  118527. * Creates a tube mesh.
  118528. * The tube is a parametric shape.
  118529. * It has no predefined shape. Its final shape will depend on the input parameters.
  118530. * Please consider using the same method from the MeshBuilder class instead
  118531. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118532. * @param name defines the name of the mesh to create
  118533. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  118534. * @param radius sets the tube radius size
  118535. * @param tessellation is the number of sides on the tubular surface
  118536. * @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
  118537. * @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
  118538. * @param scene defines the hosting scene
  118539. * @param updatable defines if the mesh must be flagged as updatable
  118540. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  118541. * @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)
  118542. * @returns a new Mesh
  118543. */
  118544. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  118545. (i: number, distance: number): number;
  118546. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  118547. /**
  118548. * Creates a polyhedron mesh.
  118549. * Please consider using the same method from the MeshBuilder class instead.
  118550. * * 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
  118551. * * The parameter `size` (positive float, default 1) sets the polygon size
  118552. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  118553. * * 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`
  118554. * * 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
  118555. * * 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)`)
  118556. * * 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
  118557. * * 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
  118558. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  118559. * * 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
  118560. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118561. * @param name defines the name of the mesh to create
  118562. * @param options defines the options used to create the mesh
  118563. * @param scene defines the hosting scene
  118564. * @returns a new Mesh
  118565. */
  118566. static CreatePolyhedron(name: string, options: {
  118567. type?: number;
  118568. size?: number;
  118569. sizeX?: number;
  118570. sizeY?: number;
  118571. sizeZ?: number;
  118572. custom?: any;
  118573. faceUV?: Vector4[];
  118574. faceColors?: Color4[];
  118575. updatable?: boolean;
  118576. sideOrientation?: number;
  118577. }, scene: Scene): Mesh;
  118578. /**
  118579. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  118580. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  118581. * * 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`)
  118582. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  118583. * * 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
  118584. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  118585. * * 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
  118586. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118587. * @param name defines the name of the mesh
  118588. * @param options defines the options used to create the mesh
  118589. * @param scene defines the hosting scene
  118590. * @returns a new Mesh
  118591. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  118592. */
  118593. static CreateIcoSphere(name: string, options: {
  118594. radius?: number;
  118595. flat?: boolean;
  118596. subdivisions?: number;
  118597. sideOrientation?: number;
  118598. updatable?: boolean;
  118599. }, scene: Scene): Mesh;
  118600. /**
  118601. * Creates a decal mesh.
  118602. * Please consider using the same method from the MeshBuilder class instead.
  118603. * A decal is a mesh usually applied as a model onto the surface of another mesh
  118604. * @param name defines the name of the mesh
  118605. * @param sourceMesh defines the mesh receiving the decal
  118606. * @param position sets the position of the decal in world coordinates
  118607. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  118608. * @param size sets the decal scaling
  118609. * @param angle sets the angle to rotate the decal
  118610. * @returns a new Mesh
  118611. */
  118612. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  118613. /** Creates a Capsule Mesh
  118614. * @param name defines the name of the mesh.
  118615. * @param options the constructors options used to shape the mesh.
  118616. * @param scene defines the scene the mesh is scoped to.
  118617. * @returns the capsule mesh
  118618. * @see https://doc.babylonjs.com/how_to/capsule_shape
  118619. */
  118620. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  118621. /**
  118622. * Prepare internal position array for software CPU skinning
  118623. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  118624. */
  118625. setPositionsForCPUSkinning(): Float32Array;
  118626. /**
  118627. * Prepare internal normal array for software CPU skinning
  118628. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  118629. */
  118630. setNormalsForCPUSkinning(): Float32Array;
  118631. /**
  118632. * Updates the vertex buffer by applying transformation from the bones
  118633. * @param skeleton defines the skeleton to apply to current mesh
  118634. * @returns the current mesh
  118635. */
  118636. applySkeleton(skeleton: Skeleton): Mesh;
  118637. /**
  118638. * 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
  118639. * @param meshes defines the list of meshes to scan
  118640. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  118641. */
  118642. static MinMax(meshes: AbstractMesh[]): {
  118643. min: Vector3;
  118644. max: Vector3;
  118645. };
  118646. /**
  118647. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  118648. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  118649. * @returns a vector3
  118650. */
  118651. static Center(meshesOrMinMaxVector: {
  118652. min: Vector3;
  118653. max: Vector3;
  118654. } | AbstractMesh[]): Vector3;
  118655. /**
  118656. * Merge the array of meshes into a single mesh for performance reasons.
  118657. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  118658. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  118659. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  118660. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  118661. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  118662. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  118663. * @returns a new mesh
  118664. */
  118665. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  118666. /** @hidden */
  118667. addInstance(instance: InstancedMesh): void;
  118668. /** @hidden */
  118669. removeInstance(instance: InstancedMesh): void;
  118670. }
  118671. }
  118672. declare module BABYLON {
  118673. /**
  118674. * The options Interface for creating a Capsule Mesh
  118675. */
  118676. export interface ICreateCapsuleOptions {
  118677. /** The Orientation of the capsule. Default : Vector3.Up() */
  118678. orientation?: Vector3;
  118679. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  118680. subdivisions: number;
  118681. /** Number of cylindrical segments on the capsule. */
  118682. tessellation: number;
  118683. /** Height or Length of the capsule. */
  118684. height: number;
  118685. /** Radius of the capsule. */
  118686. radius: number;
  118687. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  118688. capSubdivisions: number;
  118689. /** Overwrite for the top radius. */
  118690. radiusTop?: number;
  118691. /** Overwrite for the bottom radius. */
  118692. radiusBottom?: number;
  118693. /** Overwrite for the top capSubdivisions. */
  118694. topCapSubdivisions?: number;
  118695. /** Overwrite for the bottom capSubdivisions. */
  118696. bottomCapSubdivisions?: number;
  118697. }
  118698. /**
  118699. * Class containing static functions to help procedurally build meshes
  118700. */
  118701. export class CapsuleBuilder {
  118702. /**
  118703. * Creates a capsule or a pill mesh
  118704. * @param name defines the name of the mesh
  118705. * @param options The constructors options.
  118706. * @param scene The scene the mesh is scoped to.
  118707. * @returns Capsule Mesh
  118708. */
  118709. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  118710. }
  118711. }
  118712. declare module BABYLON {
  118713. /**
  118714. * Define an interface for all classes that will get and set the data on vertices
  118715. */
  118716. export interface IGetSetVerticesData {
  118717. /**
  118718. * Gets a boolean indicating if specific vertex data is present
  118719. * @param kind defines the vertex data kind to use
  118720. * @returns true is data kind is present
  118721. */
  118722. isVerticesDataPresent(kind: string): boolean;
  118723. /**
  118724. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  118725. * @param kind defines the data kind (Position, normal, etc...)
  118726. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  118727. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  118728. * @returns a float array containing vertex data
  118729. */
  118730. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  118731. /**
  118732. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  118733. * @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.
  118734. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  118735. * @returns the indices array or an empty array if the mesh has no geometry
  118736. */
  118737. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  118738. /**
  118739. * Set specific vertex data
  118740. * @param kind defines the data kind (Position, normal, etc...)
  118741. * @param data defines the vertex data to use
  118742. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  118743. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  118744. */
  118745. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  118746. /**
  118747. * Update a specific associated vertex buffer
  118748. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  118749. * - VertexBuffer.PositionKind
  118750. * - VertexBuffer.UVKind
  118751. * - VertexBuffer.UV2Kind
  118752. * - VertexBuffer.UV3Kind
  118753. * - VertexBuffer.UV4Kind
  118754. * - VertexBuffer.UV5Kind
  118755. * - VertexBuffer.UV6Kind
  118756. * - VertexBuffer.ColorKind
  118757. * - VertexBuffer.MatricesIndicesKind
  118758. * - VertexBuffer.MatricesIndicesExtraKind
  118759. * - VertexBuffer.MatricesWeightsKind
  118760. * - VertexBuffer.MatricesWeightsExtraKind
  118761. * @param data defines the data source
  118762. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  118763. * @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)
  118764. */
  118765. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  118766. /**
  118767. * Creates a new index buffer
  118768. * @param indices defines the indices to store in the index buffer
  118769. * @param totalVertices defines the total number of vertices (could be null)
  118770. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  118771. */
  118772. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  118773. }
  118774. /**
  118775. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  118776. */
  118777. export class VertexData {
  118778. /**
  118779. * Mesh side orientation : usually the external or front surface
  118780. */
  118781. static readonly FRONTSIDE: number;
  118782. /**
  118783. * Mesh side orientation : usually the internal or back surface
  118784. */
  118785. static readonly BACKSIDE: number;
  118786. /**
  118787. * Mesh side orientation : both internal and external or front and back surfaces
  118788. */
  118789. static readonly DOUBLESIDE: number;
  118790. /**
  118791. * Mesh side orientation : by default, `FRONTSIDE`
  118792. */
  118793. static readonly DEFAULTSIDE: number;
  118794. /**
  118795. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  118796. */
  118797. positions: Nullable<FloatArray>;
  118798. /**
  118799. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  118800. */
  118801. normals: Nullable<FloatArray>;
  118802. /**
  118803. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  118804. */
  118805. tangents: Nullable<FloatArray>;
  118806. /**
  118807. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  118808. */
  118809. uvs: Nullable<FloatArray>;
  118810. /**
  118811. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  118812. */
  118813. uvs2: Nullable<FloatArray>;
  118814. /**
  118815. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  118816. */
  118817. uvs3: Nullable<FloatArray>;
  118818. /**
  118819. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  118820. */
  118821. uvs4: Nullable<FloatArray>;
  118822. /**
  118823. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  118824. */
  118825. uvs5: Nullable<FloatArray>;
  118826. /**
  118827. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  118828. */
  118829. uvs6: Nullable<FloatArray>;
  118830. /**
  118831. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  118832. */
  118833. colors: Nullable<FloatArray>;
  118834. /**
  118835. * 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).
  118836. */
  118837. matricesIndices: Nullable<FloatArray>;
  118838. /**
  118839. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  118840. */
  118841. matricesWeights: Nullable<FloatArray>;
  118842. /**
  118843. * An array extending the number of possible indices
  118844. */
  118845. matricesIndicesExtra: Nullable<FloatArray>;
  118846. /**
  118847. * An array extending the number of possible weights when the number of indices is extended
  118848. */
  118849. matricesWeightsExtra: Nullable<FloatArray>;
  118850. /**
  118851. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  118852. */
  118853. indices: Nullable<IndicesArray>;
  118854. /**
  118855. * Uses the passed data array to set the set the values for the specified kind of data
  118856. * @param data a linear array of floating numbers
  118857. * @param kind the type of data that is being set, eg positions, colors etc
  118858. */
  118859. set(data: FloatArray, kind: string): void;
  118860. /**
  118861. * Associates the vertexData to the passed Mesh.
  118862. * Sets it as updatable or not (default `false`)
  118863. * @param mesh the mesh the vertexData is applied to
  118864. * @param updatable when used and having the value true allows new data to update the vertexData
  118865. * @returns the VertexData
  118866. */
  118867. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  118868. /**
  118869. * Associates the vertexData to the passed Geometry.
  118870. * Sets it as updatable or not (default `false`)
  118871. * @param geometry the geometry the vertexData is applied to
  118872. * @param updatable when used and having the value true allows new data to update the vertexData
  118873. * @returns VertexData
  118874. */
  118875. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  118876. /**
  118877. * Updates the associated mesh
  118878. * @param mesh the mesh to be updated
  118879. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  118880. * @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
  118881. * @returns VertexData
  118882. */
  118883. updateMesh(mesh: Mesh): VertexData;
  118884. /**
  118885. * Updates the associated geometry
  118886. * @param geometry the geometry to be updated
  118887. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  118888. * @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
  118889. * @returns VertexData.
  118890. */
  118891. updateGeometry(geometry: Geometry): VertexData;
  118892. private _applyTo;
  118893. private _update;
  118894. /**
  118895. * Transforms each position and each normal of the vertexData according to the passed Matrix
  118896. * @param matrix the transforming matrix
  118897. * @returns the VertexData
  118898. */
  118899. transform(matrix: Matrix): VertexData;
  118900. /**
  118901. * Merges the passed VertexData into the current one
  118902. * @param other the VertexData to be merged into the current one
  118903. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  118904. * @returns the modified VertexData
  118905. */
  118906. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  118907. private _mergeElement;
  118908. private _validate;
  118909. /**
  118910. * Serializes the VertexData
  118911. * @returns a serialized object
  118912. */
  118913. serialize(): any;
  118914. /**
  118915. * Extracts the vertexData from a mesh
  118916. * @param mesh the mesh from which to extract the VertexData
  118917. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  118918. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  118919. * @returns the object VertexData associated to the passed mesh
  118920. */
  118921. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  118922. /**
  118923. * Extracts the vertexData from the geometry
  118924. * @param geometry the geometry from which to extract the VertexData
  118925. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  118926. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  118927. * @returns the object VertexData associated to the passed mesh
  118928. */
  118929. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  118930. private static _ExtractFrom;
  118931. /**
  118932. * Creates the VertexData for a Ribbon
  118933. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  118934. * * pathArray array of paths, each of which an array of successive Vector3
  118935. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  118936. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  118937. * * 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
  118938. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  118939. * * 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)
  118940. * * 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)
  118941. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  118942. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  118943. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  118944. * @returns the VertexData of the ribbon
  118945. */
  118946. static CreateRibbon(options: {
  118947. pathArray: Vector3[][];
  118948. closeArray?: boolean;
  118949. closePath?: boolean;
  118950. offset?: number;
  118951. sideOrientation?: number;
  118952. frontUVs?: Vector4;
  118953. backUVs?: Vector4;
  118954. invertUV?: boolean;
  118955. uvs?: Vector2[];
  118956. colors?: Color4[];
  118957. }): VertexData;
  118958. /**
  118959. * Creates the VertexData for a box
  118960. * @param options an object used to set the following optional parameters for the box, required but can be empty
  118961. * * size sets the width, height and depth of the box to the value of size, optional default 1
  118962. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  118963. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  118964. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  118965. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  118966. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  118967. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  118968. * * 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)
  118969. * * 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)
  118970. * @returns the VertexData of the box
  118971. */
  118972. static CreateBox(options: {
  118973. size?: number;
  118974. width?: number;
  118975. height?: number;
  118976. depth?: number;
  118977. faceUV?: Vector4[];
  118978. faceColors?: Color4[];
  118979. sideOrientation?: number;
  118980. frontUVs?: Vector4;
  118981. backUVs?: Vector4;
  118982. }): VertexData;
  118983. /**
  118984. * Creates the VertexData for a tiled box
  118985. * @param options an object used to set the following optional parameters for the box, required but can be empty
  118986. * * faceTiles sets the pattern, tile size and number of tiles for a face
  118987. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  118988. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  118989. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  118990. * @returns the VertexData of the box
  118991. */
  118992. static CreateTiledBox(options: {
  118993. pattern?: number;
  118994. width?: number;
  118995. height?: number;
  118996. depth?: number;
  118997. tileSize?: number;
  118998. tileWidth?: number;
  118999. tileHeight?: number;
  119000. alignHorizontal?: number;
  119001. alignVertical?: number;
  119002. faceUV?: Vector4[];
  119003. faceColors?: Color4[];
  119004. sideOrientation?: number;
  119005. }): VertexData;
  119006. /**
  119007. * Creates the VertexData for a tiled plane
  119008. * @param options an object used to set the following optional parameters for the box, required but can be empty
  119009. * * pattern a limited pattern arrangement depending on the number
  119010. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  119011. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  119012. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  119013. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119014. * * 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)
  119015. * * 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)
  119016. * @returns the VertexData of the tiled plane
  119017. */
  119018. static CreateTiledPlane(options: {
  119019. pattern?: number;
  119020. tileSize?: number;
  119021. tileWidth?: number;
  119022. tileHeight?: number;
  119023. size?: number;
  119024. width?: number;
  119025. height?: number;
  119026. alignHorizontal?: number;
  119027. alignVertical?: number;
  119028. sideOrientation?: number;
  119029. frontUVs?: Vector4;
  119030. backUVs?: Vector4;
  119031. }): VertexData;
  119032. /**
  119033. * Creates the VertexData for an ellipsoid, defaults to a sphere
  119034. * @param options an object used to set the following optional parameters for the box, required but can be empty
  119035. * * segments sets the number of horizontal strips optional, default 32
  119036. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  119037. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  119038. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  119039. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  119040. * * 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
  119041. * * 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
  119042. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119043. * * 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)
  119044. * * 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)
  119045. * @returns the VertexData of the ellipsoid
  119046. */
  119047. static CreateSphere(options: {
  119048. segments?: number;
  119049. diameter?: number;
  119050. diameterX?: number;
  119051. diameterY?: number;
  119052. diameterZ?: number;
  119053. arc?: number;
  119054. slice?: number;
  119055. sideOrientation?: number;
  119056. frontUVs?: Vector4;
  119057. backUVs?: Vector4;
  119058. }): VertexData;
  119059. /**
  119060. * Creates the VertexData for a cylinder, cone or prism
  119061. * @param options an object used to set the following optional parameters for the box, required but can be empty
  119062. * * height sets the height (y direction) of the cylinder, optional, default 2
  119063. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  119064. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  119065. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  119066. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  119067. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  119068. * * 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
  119069. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  119070. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  119071. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  119072. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  119073. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119074. * * 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)
  119075. * * 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)
  119076. * @returns the VertexData of the cylinder, cone or prism
  119077. */
  119078. static CreateCylinder(options: {
  119079. height?: number;
  119080. diameterTop?: number;
  119081. diameterBottom?: number;
  119082. diameter?: number;
  119083. tessellation?: number;
  119084. subdivisions?: number;
  119085. arc?: number;
  119086. faceColors?: Color4[];
  119087. faceUV?: Vector4[];
  119088. hasRings?: boolean;
  119089. enclose?: boolean;
  119090. sideOrientation?: number;
  119091. frontUVs?: Vector4;
  119092. backUVs?: Vector4;
  119093. }): VertexData;
  119094. /**
  119095. * Creates the VertexData for a torus
  119096. * @param options an object used to set the following optional parameters for the box, required but can be empty
  119097. * * diameter the diameter of the torus, optional default 1
  119098. * * thickness the diameter of the tube forming the torus, optional default 0.5
  119099. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  119100. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119101. * * 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)
  119102. * * 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)
  119103. * @returns the VertexData of the torus
  119104. */
  119105. static CreateTorus(options: {
  119106. diameter?: number;
  119107. thickness?: number;
  119108. tessellation?: number;
  119109. sideOrientation?: number;
  119110. frontUVs?: Vector4;
  119111. backUVs?: Vector4;
  119112. }): VertexData;
  119113. /**
  119114. * Creates the VertexData of the LineSystem
  119115. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  119116. * - lines an array of lines, each line being an array of successive Vector3
  119117. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  119118. * @returns the VertexData of the LineSystem
  119119. */
  119120. static CreateLineSystem(options: {
  119121. lines: Vector3[][];
  119122. colors?: Nullable<Color4[][]>;
  119123. }): VertexData;
  119124. /**
  119125. * Create the VertexData for a DashedLines
  119126. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  119127. * - points an array successive Vector3
  119128. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  119129. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  119130. * - dashNb the intended total number of dashes, optional, default 200
  119131. * @returns the VertexData for the DashedLines
  119132. */
  119133. static CreateDashedLines(options: {
  119134. points: Vector3[];
  119135. dashSize?: number;
  119136. gapSize?: number;
  119137. dashNb?: number;
  119138. }): VertexData;
  119139. /**
  119140. * Creates the VertexData for a Ground
  119141. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  119142. * - width the width (x direction) of the ground, optional, default 1
  119143. * - height the height (z direction) of the ground, optional, default 1
  119144. * - subdivisions the number of subdivisions per side, optional, default 1
  119145. * @returns the VertexData of the Ground
  119146. */
  119147. static CreateGround(options: {
  119148. width?: number;
  119149. height?: number;
  119150. subdivisions?: number;
  119151. subdivisionsX?: number;
  119152. subdivisionsY?: number;
  119153. }): VertexData;
  119154. /**
  119155. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  119156. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  119157. * * xmin the ground minimum X coordinate, optional, default -1
  119158. * * zmin the ground minimum Z coordinate, optional, default -1
  119159. * * xmax the ground maximum X coordinate, optional, default 1
  119160. * * zmax the ground maximum Z coordinate, optional, default 1
  119161. * * 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}
  119162. * * 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}
  119163. * @returns the VertexData of the TiledGround
  119164. */
  119165. static CreateTiledGround(options: {
  119166. xmin: number;
  119167. zmin: number;
  119168. xmax: number;
  119169. zmax: number;
  119170. subdivisions?: {
  119171. w: number;
  119172. h: number;
  119173. };
  119174. precision?: {
  119175. w: number;
  119176. h: number;
  119177. };
  119178. }): VertexData;
  119179. /**
  119180. * Creates the VertexData of the Ground designed from a heightmap
  119181. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  119182. * * width the width (x direction) of the ground
  119183. * * height the height (z direction) of the ground
  119184. * * subdivisions the number of subdivisions per side
  119185. * * minHeight the minimum altitude on the ground, optional, default 0
  119186. * * maxHeight the maximum altitude on the ground, optional default 1
  119187. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  119188. * * buffer the array holding the image color data
  119189. * * bufferWidth the width of image
  119190. * * bufferHeight the height of image
  119191. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  119192. * @returns the VertexData of the Ground designed from a heightmap
  119193. */
  119194. static CreateGroundFromHeightMap(options: {
  119195. width: number;
  119196. height: number;
  119197. subdivisions: number;
  119198. minHeight: number;
  119199. maxHeight: number;
  119200. colorFilter: Color3;
  119201. buffer: Uint8Array;
  119202. bufferWidth: number;
  119203. bufferHeight: number;
  119204. alphaFilter: number;
  119205. }): VertexData;
  119206. /**
  119207. * Creates the VertexData for a Plane
  119208. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  119209. * * size sets the width and height of the plane to the value of size, optional default 1
  119210. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  119211. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  119212. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119213. * * 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)
  119214. * * 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)
  119215. * @returns the VertexData of the box
  119216. */
  119217. static CreatePlane(options: {
  119218. size?: number;
  119219. width?: number;
  119220. height?: number;
  119221. sideOrientation?: number;
  119222. frontUVs?: Vector4;
  119223. backUVs?: Vector4;
  119224. }): VertexData;
  119225. /**
  119226. * Creates the VertexData of the Disc or regular Polygon
  119227. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  119228. * * radius the radius of the disc, optional default 0.5
  119229. * * tessellation the number of polygon sides, optional, default 64
  119230. * * 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
  119231. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119232. * * 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)
  119233. * * 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)
  119234. * @returns the VertexData of the box
  119235. */
  119236. static CreateDisc(options: {
  119237. radius?: number;
  119238. tessellation?: number;
  119239. arc?: number;
  119240. sideOrientation?: number;
  119241. frontUVs?: Vector4;
  119242. backUVs?: Vector4;
  119243. }): VertexData;
  119244. /**
  119245. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  119246. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  119247. * @param polygon a mesh built from polygonTriangulation.build()
  119248. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119249. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  119250. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  119251. * @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)
  119252. * @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)
  119253. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  119254. * @returns the VertexData of the Polygon
  119255. */
  119256. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  119257. /**
  119258. * Creates the VertexData of the IcoSphere
  119259. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  119260. * * radius the radius of the IcoSphere, optional default 1
  119261. * * radiusX allows stretching in the x direction, optional, default radius
  119262. * * radiusY allows stretching in the y direction, optional, default radius
  119263. * * radiusZ allows stretching in the z direction, optional, default radius
  119264. * * flat when true creates a flat shaded mesh, optional, default true
  119265. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  119266. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119267. * * 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)
  119268. * * 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)
  119269. * @returns the VertexData of the IcoSphere
  119270. */
  119271. static CreateIcoSphere(options: {
  119272. radius?: number;
  119273. radiusX?: number;
  119274. radiusY?: number;
  119275. radiusZ?: number;
  119276. flat?: boolean;
  119277. subdivisions?: number;
  119278. sideOrientation?: number;
  119279. frontUVs?: Vector4;
  119280. backUVs?: Vector4;
  119281. }): VertexData;
  119282. /**
  119283. * Creates the VertexData for a Polyhedron
  119284. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  119285. * * type provided types are:
  119286. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  119287. * * 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)
  119288. * * size the size of the IcoSphere, optional default 1
  119289. * * sizeX allows stretching in the x direction, optional, default size
  119290. * * sizeY allows stretching in the y direction, optional, default size
  119291. * * sizeZ allows stretching in the z direction, optional, default size
  119292. * * 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
  119293. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  119294. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  119295. * * flat when true creates a flat shaded mesh, optional, default true
  119296. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  119297. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119298. * * 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)
  119299. * * 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)
  119300. * @returns the VertexData of the Polyhedron
  119301. */
  119302. static CreatePolyhedron(options: {
  119303. type?: number;
  119304. size?: number;
  119305. sizeX?: number;
  119306. sizeY?: number;
  119307. sizeZ?: number;
  119308. custom?: any;
  119309. faceUV?: Vector4[];
  119310. faceColors?: Color4[];
  119311. flat?: boolean;
  119312. sideOrientation?: number;
  119313. frontUVs?: Vector4;
  119314. backUVs?: Vector4;
  119315. }): VertexData;
  119316. /**
  119317. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  119318. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  119319. * @returns the VertexData of the Capsule
  119320. */
  119321. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  119322. /**
  119323. * Creates the VertexData for a TorusKnot
  119324. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  119325. * * radius the radius of the torus knot, optional, default 2
  119326. * * tube the thickness of the tube, optional, default 0.5
  119327. * * radialSegments the number of sides on each tube segments, optional, default 32
  119328. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  119329. * * p the number of windings around the z axis, optional, default 2
  119330. * * q the number of windings around the x axis, optional, default 3
  119331. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  119332. * * 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)
  119333. * * 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)
  119334. * @returns the VertexData of the Torus Knot
  119335. */
  119336. static CreateTorusKnot(options: {
  119337. radius?: number;
  119338. tube?: number;
  119339. radialSegments?: number;
  119340. tubularSegments?: number;
  119341. p?: number;
  119342. q?: number;
  119343. sideOrientation?: number;
  119344. frontUVs?: Vector4;
  119345. backUVs?: Vector4;
  119346. }): VertexData;
  119347. /**
  119348. * Compute normals for given positions and indices
  119349. * @param positions an array of vertex positions, [...., x, y, z, ......]
  119350. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  119351. * @param normals an array of vertex normals, [...., x, y, z, ......]
  119352. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  119353. * * facetNormals : optional array of facet normals (vector3)
  119354. * * facetPositions : optional array of facet positions (vector3)
  119355. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  119356. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  119357. * * bInfo : optional bounding info, required for facetPartitioning computation
  119358. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  119359. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  119360. * * useRightHandedSystem: optional boolean to for right handed system computation
  119361. * * depthSort : optional boolean to enable the facet depth sort computation
  119362. * * distanceTo : optional Vector3 to compute the facet depth from this location
  119363. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  119364. */
  119365. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  119366. facetNormals?: any;
  119367. facetPositions?: any;
  119368. facetPartitioning?: any;
  119369. ratio?: number;
  119370. bInfo?: any;
  119371. bbSize?: Vector3;
  119372. subDiv?: any;
  119373. useRightHandedSystem?: boolean;
  119374. depthSort?: boolean;
  119375. distanceTo?: Vector3;
  119376. depthSortedFacets?: any;
  119377. }): void;
  119378. /** @hidden */
  119379. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  119380. /**
  119381. * Applies VertexData created from the imported parameters to the geometry
  119382. * @param parsedVertexData the parsed data from an imported file
  119383. * @param geometry the geometry to apply the VertexData to
  119384. */
  119385. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  119386. }
  119387. }
  119388. declare module BABYLON {
  119389. /**
  119390. * Class containing static functions to help procedurally build meshes
  119391. */
  119392. export class DiscBuilder {
  119393. /**
  119394. * Creates a plane polygonal mesh. By default, this is a disc
  119395. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  119396. * * 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
  119397. * * 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
  119398. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119399. * * 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
  119400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119401. * @param name defines the name of the mesh
  119402. * @param options defines the options used to create the mesh
  119403. * @param scene defines the hosting scene
  119404. * @returns the plane polygonal mesh
  119405. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  119406. */
  119407. static CreateDisc(name: string, options: {
  119408. radius?: number;
  119409. tessellation?: number;
  119410. arc?: number;
  119411. updatable?: boolean;
  119412. sideOrientation?: number;
  119413. frontUVs?: Vector4;
  119414. backUVs?: Vector4;
  119415. }, scene?: Nullable<Scene>): Mesh;
  119416. }
  119417. }
  119418. declare module BABYLON {
  119419. /**
  119420. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  119421. *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.
  119422. * The SPS is also a particle system. It provides some methods to manage the particles.
  119423. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  119424. *
  119425. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  119426. */
  119427. export class SolidParticleSystem implements IDisposable {
  119428. /**
  119429. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  119430. * Example : var p = SPS.particles[i];
  119431. */
  119432. particles: SolidParticle[];
  119433. /**
  119434. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  119435. */
  119436. nbParticles: number;
  119437. /**
  119438. * If the particles must ever face the camera (default false). Useful for planar particles.
  119439. */
  119440. billboard: boolean;
  119441. /**
  119442. * Recompute normals when adding a shape
  119443. */
  119444. recomputeNormals: boolean;
  119445. /**
  119446. * This a counter ofr your own usage. It's not set by any SPS functions.
  119447. */
  119448. counter: number;
  119449. /**
  119450. * The SPS name. This name is also given to the underlying mesh.
  119451. */
  119452. name: string;
  119453. /**
  119454. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  119455. */
  119456. mesh: Mesh;
  119457. /**
  119458. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  119459. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  119460. */
  119461. vars: any;
  119462. /**
  119463. * This array is populated when the SPS is set as 'pickable'.
  119464. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  119465. * Each element of this array is an object `{idx: int, faceId: int}`.
  119466. * `idx` is the picked particle index in the `SPS.particles` array
  119467. * `faceId` is the picked face index counted within this particle.
  119468. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  119469. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  119470. * Use the method SPS.pickedParticle(pickingInfo) instead.
  119471. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  119472. */
  119473. pickedParticles: {
  119474. idx: number;
  119475. faceId: number;
  119476. }[];
  119477. /**
  119478. * This array is populated when the SPS is set as 'pickable'
  119479. * Each key of this array is a submesh index.
  119480. * Each element of this array is a second array defined like this :
  119481. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  119482. * Each element of this second array is an object `{idx: int, faceId: int}`.
  119483. * `idx` is the picked particle index in the `SPS.particles` array
  119484. * `faceId` is the picked face index counted within this particle.
  119485. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  119486. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  119487. */
  119488. pickedBySubMesh: {
  119489. idx: number;
  119490. faceId: number;
  119491. }[][];
  119492. /**
  119493. * This array is populated when `enableDepthSort` is set to true.
  119494. * Each element of this array is an instance of the class DepthSortedParticle.
  119495. */
  119496. depthSortedParticles: DepthSortedParticle[];
  119497. /**
  119498. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  119499. * @hidden
  119500. */
  119501. _bSphereOnly: boolean;
  119502. /**
  119503. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  119504. * @hidden
  119505. */
  119506. _bSphereRadiusFactor: number;
  119507. private _scene;
  119508. private _positions;
  119509. private _indices;
  119510. private _normals;
  119511. private _colors;
  119512. private _uvs;
  119513. private _indices32;
  119514. private _positions32;
  119515. private _normals32;
  119516. private _fixedNormal32;
  119517. private _colors32;
  119518. private _uvs32;
  119519. private _index;
  119520. private _updatable;
  119521. private _pickable;
  119522. private _isVisibilityBoxLocked;
  119523. private _alwaysVisible;
  119524. private _depthSort;
  119525. private _expandable;
  119526. private _shapeCounter;
  119527. private _copy;
  119528. private _color;
  119529. private _computeParticleColor;
  119530. private _computeParticleTexture;
  119531. private _computeParticleRotation;
  119532. private _computeParticleVertex;
  119533. private _computeBoundingBox;
  119534. private _depthSortParticles;
  119535. private _camera;
  119536. private _mustUnrotateFixedNormals;
  119537. private _particlesIntersect;
  119538. private _needs32Bits;
  119539. private _isNotBuilt;
  119540. private _lastParticleId;
  119541. private _idxOfId;
  119542. private _multimaterialEnabled;
  119543. private _useModelMaterial;
  119544. private _indicesByMaterial;
  119545. private _materialIndexes;
  119546. private _depthSortFunction;
  119547. private _materialSortFunction;
  119548. private _materials;
  119549. private _multimaterial;
  119550. private _materialIndexesById;
  119551. private _defaultMaterial;
  119552. private _autoUpdateSubMeshes;
  119553. private _tmpVertex;
  119554. /**
  119555. * Creates a SPS (Solid Particle System) object.
  119556. * @param name (String) is the SPS name, this will be the underlying mesh name.
  119557. * @param scene (Scene) is the scene in which the SPS is added.
  119558. * @param options defines the options of the sps e.g.
  119559. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  119560. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  119561. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  119562. * * 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.
  119563. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  119564. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  119565. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  119566. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  119567. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  119568. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  119569. */
  119570. constructor(name: string, scene: Scene, options?: {
  119571. updatable?: boolean;
  119572. isPickable?: boolean;
  119573. enableDepthSort?: boolean;
  119574. particleIntersection?: boolean;
  119575. boundingSphereOnly?: boolean;
  119576. bSphereRadiusFactor?: number;
  119577. expandable?: boolean;
  119578. useModelMaterial?: boolean;
  119579. enableMultiMaterial?: boolean;
  119580. });
  119581. /**
  119582. * Builds the SPS underlying mesh. Returns a standard Mesh.
  119583. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  119584. * @returns the created mesh
  119585. */
  119586. buildMesh(): Mesh;
  119587. /**
  119588. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  119589. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  119590. * Thus the particles generated from `digest()` have their property `position` set yet.
  119591. * @param mesh ( Mesh ) is the mesh to be digested
  119592. * @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
  119593. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  119594. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  119595. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  119596. * @returns the current SPS
  119597. */
  119598. digest(mesh: Mesh, options?: {
  119599. facetNb?: number;
  119600. number?: number;
  119601. delta?: number;
  119602. storage?: [];
  119603. }): SolidParticleSystem;
  119604. /**
  119605. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  119606. * @hidden
  119607. */
  119608. private _unrotateFixedNormals;
  119609. /**
  119610. * Resets the temporary working copy particle
  119611. * @hidden
  119612. */
  119613. private _resetCopy;
  119614. /**
  119615. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  119616. * @param p the current index in the positions array to be updated
  119617. * @param ind the current index in the indices array
  119618. * @param shape a Vector3 array, the shape geometry
  119619. * @param positions the positions array to be updated
  119620. * @param meshInd the shape indices array
  119621. * @param indices the indices array to be updated
  119622. * @param meshUV the shape uv array
  119623. * @param uvs the uv array to be updated
  119624. * @param meshCol the shape color array
  119625. * @param colors the color array to be updated
  119626. * @param meshNor the shape normals array
  119627. * @param normals the normals array to be updated
  119628. * @param idx the particle index
  119629. * @param idxInShape the particle index in its shape
  119630. * @param options the addShape() method passed options
  119631. * @model the particle model
  119632. * @hidden
  119633. */
  119634. private _meshBuilder;
  119635. /**
  119636. * Returns a shape Vector3 array from positions float array
  119637. * @param positions float array
  119638. * @returns a vector3 array
  119639. * @hidden
  119640. */
  119641. private _posToShape;
  119642. /**
  119643. * Returns a shapeUV array from a float uvs (array deep copy)
  119644. * @param uvs as a float array
  119645. * @returns a shapeUV array
  119646. * @hidden
  119647. */
  119648. private _uvsToShapeUV;
  119649. /**
  119650. * Adds a new particle object in the particles array
  119651. * @param idx particle index in particles array
  119652. * @param id particle id
  119653. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  119654. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  119655. * @param model particle ModelShape object
  119656. * @param shapeId model shape identifier
  119657. * @param idxInShape index of the particle in the current model
  119658. * @param bInfo model bounding info object
  119659. * @param storage target storage array, if any
  119660. * @hidden
  119661. */
  119662. private _addParticle;
  119663. /**
  119664. * Adds some particles to the SPS from the model shape. Returns the shape id.
  119665. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  119666. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  119667. * @param nb (positive integer) the number of particles to be created from this model
  119668. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  119669. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  119670. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  119671. * @returns the number of shapes in the system
  119672. */
  119673. addShape(mesh: Mesh, nb: number, options?: {
  119674. positionFunction?: any;
  119675. vertexFunction?: any;
  119676. storage?: [];
  119677. }): number;
  119678. /**
  119679. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  119680. * @hidden
  119681. */
  119682. private _rebuildParticle;
  119683. /**
  119684. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  119685. * @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.
  119686. * @returns the SPS.
  119687. */
  119688. rebuildMesh(reset?: boolean): SolidParticleSystem;
  119689. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  119690. * Returns an array with the removed particles.
  119691. * 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.
  119692. * The SPS can't be empty so at least one particle needs to remain in place.
  119693. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  119694. * @param start index of the first particle to remove
  119695. * @param end index of the last particle to remove (included)
  119696. * @returns an array populated with the removed particles
  119697. */
  119698. removeParticles(start: number, end: number): SolidParticle[];
  119699. /**
  119700. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  119701. * @param solidParticleArray an array populated with Solid Particles objects
  119702. * @returns the SPS
  119703. */
  119704. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  119705. /**
  119706. * Creates a new particle and modifies the SPS mesh geometry :
  119707. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  119708. * - calls _addParticle() to populate the particle array
  119709. * factorized code from addShape() and insertParticlesFromArray()
  119710. * @param idx particle index in the particles array
  119711. * @param i particle index in its shape
  119712. * @param modelShape particle ModelShape object
  119713. * @param shape shape vertex array
  119714. * @param meshInd shape indices array
  119715. * @param meshUV shape uv array
  119716. * @param meshCol shape color array
  119717. * @param meshNor shape normals array
  119718. * @param bbInfo shape bounding info
  119719. * @param storage target particle storage
  119720. * @options addShape() passed options
  119721. * @hidden
  119722. */
  119723. private _insertNewParticle;
  119724. /**
  119725. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  119726. * This method calls `updateParticle()` for each particle of the SPS.
  119727. * For an animated SPS, it is usually called within the render loop.
  119728. * 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.
  119729. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  119730. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  119731. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  119732. * @returns the SPS.
  119733. */
  119734. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  119735. /**
  119736. * Disposes the SPS.
  119737. */
  119738. dispose(): void;
  119739. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  119740. * idx is the particle index in the SPS
  119741. * faceId is the picked face index counted within this particle.
  119742. * Returns null if the pickInfo can't identify a picked particle.
  119743. * @param pickingInfo (PickingInfo object)
  119744. * @returns {idx: number, faceId: number} or null
  119745. */
  119746. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  119747. idx: number;
  119748. faceId: number;
  119749. }>;
  119750. /**
  119751. * Returns a SolidParticle object from its identifier : particle.id
  119752. * @param id (integer) the particle Id
  119753. * @returns the searched particle or null if not found in the SPS.
  119754. */
  119755. getParticleById(id: number): Nullable<SolidParticle>;
  119756. /**
  119757. * Returns a new array populated with the particles having the passed shapeId.
  119758. * @param shapeId (integer) the shape identifier
  119759. * @returns a new solid particle array
  119760. */
  119761. getParticlesByShapeId(shapeId: number): SolidParticle[];
  119762. /**
  119763. * Populates the passed array "ref" with the particles having the passed shapeId.
  119764. * @param shapeId the shape identifier
  119765. * @returns the SPS
  119766. * @param ref
  119767. */
  119768. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  119769. /**
  119770. * Computes the required SubMeshes according the materials assigned to the particles.
  119771. * @returns the solid particle system.
  119772. * Does nothing if called before the SPS mesh is built.
  119773. */
  119774. computeSubMeshes(): SolidParticleSystem;
  119775. /**
  119776. * Sorts the solid particles by material when MultiMaterial is enabled.
  119777. * Updates the indices32 array.
  119778. * Updates the indicesByMaterial array.
  119779. * Updates the mesh indices array.
  119780. * @returns the SPS
  119781. * @hidden
  119782. */
  119783. private _sortParticlesByMaterial;
  119784. /**
  119785. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  119786. * @hidden
  119787. */
  119788. private _setMaterialIndexesById;
  119789. /**
  119790. * Returns an array with unique values of Materials from the passed array
  119791. * @param array the material array to be checked and filtered
  119792. * @hidden
  119793. */
  119794. private _filterUniqueMaterialId;
  119795. /**
  119796. * Sets a new Standard Material as _defaultMaterial if not already set.
  119797. * @hidden
  119798. */
  119799. private _setDefaultMaterial;
  119800. /**
  119801. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  119802. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  119803. * @returns the SPS.
  119804. */
  119805. refreshVisibleSize(): SolidParticleSystem;
  119806. /**
  119807. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  119808. * @param size the size (float) of the visibility box
  119809. * note : this doesn't lock the SPS mesh bounding box.
  119810. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  119811. */
  119812. setVisibilityBox(size: number): void;
  119813. /**
  119814. * Gets whether the SPS as always visible or not
  119815. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  119816. */
  119817. get isAlwaysVisible(): boolean;
  119818. /**
  119819. * Sets the SPS as always visible or not
  119820. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  119821. */
  119822. set isAlwaysVisible(val: boolean);
  119823. /**
  119824. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  119825. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  119826. */
  119827. set isVisibilityBoxLocked(val: boolean);
  119828. /**
  119829. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  119830. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  119831. */
  119832. get isVisibilityBoxLocked(): boolean;
  119833. /**
  119834. * Tells to `setParticles()` to compute the particle rotations or not.
  119835. * Default value : true. The SPS is faster when it's set to false.
  119836. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  119837. */
  119838. set computeParticleRotation(val: boolean);
  119839. /**
  119840. * Tells to `setParticles()` to compute the particle colors or not.
  119841. * Default value : true. The SPS is faster when it's set to false.
  119842. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  119843. */
  119844. set computeParticleColor(val: boolean);
  119845. set computeParticleTexture(val: boolean);
  119846. /**
  119847. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  119848. * Default value : false. The SPS is faster when it's set to false.
  119849. * Note : the particle custom vertex positions aren't stored values.
  119850. */
  119851. set computeParticleVertex(val: boolean);
  119852. /**
  119853. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  119854. */
  119855. set computeBoundingBox(val: boolean);
  119856. /**
  119857. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  119858. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  119859. * Default : `true`
  119860. */
  119861. set depthSortParticles(val: boolean);
  119862. /**
  119863. * Gets if `setParticles()` computes the particle rotations or not.
  119864. * Default value : true. The SPS is faster when it's set to false.
  119865. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  119866. */
  119867. get computeParticleRotation(): boolean;
  119868. /**
  119869. * Gets if `setParticles()` computes the particle colors or not.
  119870. * Default value : true. The SPS is faster when it's set to false.
  119871. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  119872. */
  119873. get computeParticleColor(): boolean;
  119874. /**
  119875. * Gets if `setParticles()` computes the particle textures or not.
  119876. * Default value : true. The SPS is faster when it's set to false.
  119877. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  119878. */
  119879. get computeParticleTexture(): boolean;
  119880. /**
  119881. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  119882. * Default value : false. The SPS is faster when it's set to false.
  119883. * Note : the particle custom vertex positions aren't stored values.
  119884. */
  119885. get computeParticleVertex(): boolean;
  119886. /**
  119887. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  119888. */
  119889. get computeBoundingBox(): boolean;
  119890. /**
  119891. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  119892. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  119893. * Default : `true`
  119894. */
  119895. get depthSortParticles(): boolean;
  119896. /**
  119897. * Gets if the SPS is created as expandable at construction time.
  119898. * Default : `false`
  119899. */
  119900. get expandable(): boolean;
  119901. /**
  119902. * Gets if the SPS supports the Multi Materials
  119903. */
  119904. get multimaterialEnabled(): boolean;
  119905. /**
  119906. * Gets if the SPS uses the model materials for its own multimaterial.
  119907. */
  119908. get useModelMaterial(): boolean;
  119909. /**
  119910. * The SPS used material array.
  119911. */
  119912. get materials(): Material[];
  119913. /**
  119914. * Sets the SPS MultiMaterial from the passed materials.
  119915. * Note : the passed array is internally copied and not used then by reference.
  119916. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  119917. */
  119918. setMultiMaterial(materials: Material[]): void;
  119919. /**
  119920. * The SPS computed multimaterial object
  119921. */
  119922. get multimaterial(): MultiMaterial;
  119923. set multimaterial(mm: MultiMaterial);
  119924. /**
  119925. * If the subMeshes must be updated on the next call to setParticles()
  119926. */
  119927. get autoUpdateSubMeshes(): boolean;
  119928. set autoUpdateSubMeshes(val: boolean);
  119929. /**
  119930. * This function does nothing. It may be overwritten to set all the particle first values.
  119931. * The SPS doesn't call this function, you may have to call it by your own.
  119932. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  119933. */
  119934. initParticles(): void;
  119935. /**
  119936. * This function does nothing. It may be overwritten to recycle a particle.
  119937. * The SPS doesn't call this function, you may have to call it by your own.
  119938. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  119939. * @param particle The particle to recycle
  119940. * @returns the recycled particle
  119941. */
  119942. recycleParticle(particle: SolidParticle): SolidParticle;
  119943. /**
  119944. * Updates a particle : this function should be overwritten by the user.
  119945. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  119946. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  119947. * @example : just set a particle position or velocity and recycle conditions
  119948. * @param particle The particle to update
  119949. * @returns the updated particle
  119950. */
  119951. updateParticle(particle: SolidParticle): SolidParticle;
  119952. /**
  119953. * Updates a vertex of a particle : it can be overwritten by the user.
  119954. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  119955. * @param particle the current particle
  119956. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  119957. * @param pt the index of the current vertex in the particle shape
  119958. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  119959. * @example : just set a vertex particle position or color
  119960. * @returns the sps
  119961. */
  119962. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  119963. /**
  119964. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  119965. * This does nothing and may be overwritten by the user.
  119966. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  119967. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  119968. * @param update the boolean update value actually passed to setParticles()
  119969. */
  119970. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  119971. /**
  119972. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  119973. * This will be passed three parameters.
  119974. * This does nothing and may be overwritten by the user.
  119975. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  119976. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  119977. * @param update the boolean update value actually passed to setParticles()
  119978. */
  119979. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  119980. }
  119981. }
  119982. declare module BABYLON {
  119983. /**
  119984. * Represents one particle of a solid particle system.
  119985. */
  119986. export class SolidParticle {
  119987. /**
  119988. * particle global index
  119989. */
  119990. idx: number;
  119991. /**
  119992. * particle identifier
  119993. */
  119994. id: number;
  119995. /**
  119996. * The color of the particle
  119997. */
  119998. color: Nullable<Color4>;
  119999. /**
  120000. * The world space position of the particle.
  120001. */
  120002. position: Vector3;
  120003. /**
  120004. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  120005. */
  120006. rotation: Vector3;
  120007. /**
  120008. * The world space rotation quaternion of the particle.
  120009. */
  120010. rotationQuaternion: Nullable<Quaternion>;
  120011. /**
  120012. * The scaling of the particle.
  120013. */
  120014. scaling: Vector3;
  120015. /**
  120016. * The uvs of the particle.
  120017. */
  120018. uvs: Vector4;
  120019. /**
  120020. * The current speed of the particle.
  120021. */
  120022. velocity: Vector3;
  120023. /**
  120024. * The pivot point in the particle local space.
  120025. */
  120026. pivot: Vector3;
  120027. /**
  120028. * Must the particle be translated from its pivot point in its local space ?
  120029. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  120030. * Default : false
  120031. */
  120032. translateFromPivot: boolean;
  120033. /**
  120034. * Is the particle active or not ?
  120035. */
  120036. alive: boolean;
  120037. /**
  120038. * Is the particle visible or not ?
  120039. */
  120040. isVisible: boolean;
  120041. /**
  120042. * Index of this particle in the global "positions" array (Internal use)
  120043. * @hidden
  120044. */
  120045. _pos: number;
  120046. /**
  120047. * @hidden Index of this particle in the global "indices" array (Internal use)
  120048. */
  120049. _ind: number;
  120050. /**
  120051. * @hidden ModelShape of this particle (Internal use)
  120052. */
  120053. _model: ModelShape;
  120054. /**
  120055. * ModelShape id of this particle
  120056. */
  120057. shapeId: number;
  120058. /**
  120059. * Index of the particle in its shape id
  120060. */
  120061. idxInShape: number;
  120062. /**
  120063. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  120064. */
  120065. _modelBoundingInfo: BoundingInfo;
  120066. /**
  120067. * @hidden Particle BoundingInfo object (Internal use)
  120068. */
  120069. _boundingInfo: BoundingInfo;
  120070. /**
  120071. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  120072. */
  120073. _sps: SolidParticleSystem;
  120074. /**
  120075. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  120076. */
  120077. _stillInvisible: boolean;
  120078. /**
  120079. * @hidden Last computed particle rotation matrix
  120080. */
  120081. _rotationMatrix: number[];
  120082. /**
  120083. * Parent particle Id, if any.
  120084. * Default null.
  120085. */
  120086. parentId: Nullable<number>;
  120087. /**
  120088. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  120089. */
  120090. materialIndex: Nullable<number>;
  120091. /**
  120092. * Custom object or properties.
  120093. */
  120094. props: Nullable<any>;
  120095. /**
  120096. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  120097. * The possible values are :
  120098. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  120099. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  120100. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  120101. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  120102. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  120103. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  120104. * */
  120105. cullingStrategy: number;
  120106. /**
  120107. * @hidden Internal global position in the SPS.
  120108. */
  120109. _globalPosition: Vector3;
  120110. /**
  120111. * Creates a Solid Particle object.
  120112. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  120113. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  120114. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  120115. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  120116. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  120117. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  120118. * @param shapeId (integer) is the model shape identifier in the SPS.
  120119. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  120120. * @param sps defines the sps it is associated to
  120121. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  120122. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  120123. */
  120124. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  120125. /**
  120126. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  120127. * @param target the particle target
  120128. * @returns the current particle
  120129. */
  120130. copyToRef(target: SolidParticle): SolidParticle;
  120131. /**
  120132. * Legacy support, changed scale to scaling
  120133. */
  120134. get scale(): Vector3;
  120135. /**
  120136. * Legacy support, changed scale to scaling
  120137. */
  120138. set scale(scale: Vector3);
  120139. /**
  120140. * Legacy support, changed quaternion to rotationQuaternion
  120141. */
  120142. get quaternion(): Nullable<Quaternion>;
  120143. /**
  120144. * Legacy support, changed quaternion to rotationQuaternion
  120145. */
  120146. set quaternion(q: Nullable<Quaternion>);
  120147. /**
  120148. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  120149. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  120150. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  120151. * @returns true if it intersects
  120152. */
  120153. intersectsMesh(target: Mesh | SolidParticle): boolean;
  120154. /**
  120155. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  120156. * A particle is in the frustum if its bounding box intersects the frustum
  120157. * @param frustumPlanes defines the frustum to test
  120158. * @returns true if the particle is in the frustum planes
  120159. */
  120160. isInFrustum(frustumPlanes: Plane[]): boolean;
  120161. /**
  120162. * get the rotation matrix of the particle
  120163. * @hidden
  120164. */
  120165. getRotationMatrix(m: Matrix): void;
  120166. }
  120167. /**
  120168. * Represents the shape of the model used by one particle of a solid particle system.
  120169. * SPS internal tool, don't use it manually.
  120170. */
  120171. export class ModelShape {
  120172. /**
  120173. * The shape id
  120174. * @hidden
  120175. */
  120176. shapeID: number;
  120177. /**
  120178. * flat array of model positions (internal use)
  120179. * @hidden
  120180. */
  120181. _shape: Vector3[];
  120182. /**
  120183. * flat array of model UVs (internal use)
  120184. * @hidden
  120185. */
  120186. _shapeUV: number[];
  120187. /**
  120188. * color array of the model
  120189. * @hidden
  120190. */
  120191. _shapeColors: number[];
  120192. /**
  120193. * indices array of the model
  120194. * @hidden
  120195. */
  120196. _indices: number[];
  120197. /**
  120198. * normals array of the model
  120199. * @hidden
  120200. */
  120201. _normals: number[];
  120202. /**
  120203. * length of the shape in the model indices array (internal use)
  120204. * @hidden
  120205. */
  120206. _indicesLength: number;
  120207. /**
  120208. * Custom position function (internal use)
  120209. * @hidden
  120210. */
  120211. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  120212. /**
  120213. * Custom vertex function (internal use)
  120214. * @hidden
  120215. */
  120216. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  120217. /**
  120218. * Model material (internal use)
  120219. * @hidden
  120220. */
  120221. _material: Nullable<Material>;
  120222. /**
  120223. * 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.
  120224. * SPS internal tool, don't use it manually.
  120225. * @hidden
  120226. */
  120227. 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>);
  120228. }
  120229. /**
  120230. * Represents a Depth Sorted Particle in the solid particle system.
  120231. * @hidden
  120232. */
  120233. export class DepthSortedParticle {
  120234. /**
  120235. * Particle index
  120236. */
  120237. idx: number;
  120238. /**
  120239. * Index of the particle in the "indices" array
  120240. */
  120241. ind: number;
  120242. /**
  120243. * Length of the particle shape in the "indices" array
  120244. */
  120245. indicesLength: number;
  120246. /**
  120247. * Squared distance from the particle to the camera
  120248. */
  120249. sqDistance: number;
  120250. /**
  120251. * Material index when used with MultiMaterials
  120252. */
  120253. materialIndex: number;
  120254. /**
  120255. * Creates a new sorted particle
  120256. * @param materialIndex
  120257. */
  120258. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  120259. }
  120260. /**
  120261. * Represents a solid particle vertex
  120262. */
  120263. export class SolidParticleVertex {
  120264. /**
  120265. * Vertex position
  120266. */
  120267. position: Vector3;
  120268. /**
  120269. * Vertex color
  120270. */
  120271. color: Color4;
  120272. /**
  120273. * Vertex UV
  120274. */
  120275. uv: Vector2;
  120276. /**
  120277. * Creates a new solid particle vertex
  120278. */
  120279. constructor();
  120280. /** Vertex x coordinate */
  120281. get x(): number;
  120282. set x(val: number);
  120283. /** Vertex y coordinate */
  120284. get y(): number;
  120285. set y(val: number);
  120286. /** Vertex z coordinate */
  120287. get z(): number;
  120288. set z(val: number);
  120289. }
  120290. }
  120291. declare module BABYLON {
  120292. /**
  120293. * @hidden
  120294. */
  120295. export class _MeshCollisionData {
  120296. _checkCollisions: boolean;
  120297. _collisionMask: number;
  120298. _collisionGroup: number;
  120299. _surroundingMeshes: Nullable<AbstractMesh[]>;
  120300. _collider: Nullable<Collider>;
  120301. _oldPositionForCollisions: Vector3;
  120302. _diffPositionForCollisions: Vector3;
  120303. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  120304. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  120305. _collisionResponse: boolean;
  120306. }
  120307. }
  120308. declare module BABYLON {
  120309. /** @hidden */
  120310. class _FacetDataStorage {
  120311. facetPositions: Vector3[];
  120312. facetNormals: Vector3[];
  120313. facetPartitioning: number[][];
  120314. facetNb: number;
  120315. partitioningSubdivisions: number;
  120316. partitioningBBoxRatio: number;
  120317. facetDataEnabled: boolean;
  120318. facetParameters: any;
  120319. bbSize: Vector3;
  120320. subDiv: {
  120321. max: number;
  120322. X: number;
  120323. Y: number;
  120324. Z: number;
  120325. };
  120326. facetDepthSort: boolean;
  120327. facetDepthSortEnabled: boolean;
  120328. depthSortedIndices: IndicesArray;
  120329. depthSortedFacets: {
  120330. ind: number;
  120331. sqDistance: number;
  120332. }[];
  120333. facetDepthSortFunction: (f1: {
  120334. ind: number;
  120335. sqDistance: number;
  120336. }, f2: {
  120337. ind: number;
  120338. sqDistance: number;
  120339. }) => number;
  120340. facetDepthSortFrom: Vector3;
  120341. facetDepthSortOrigin: Vector3;
  120342. invertedMatrix: Matrix;
  120343. }
  120344. /**
  120345. * @hidden
  120346. **/
  120347. class _InternalAbstractMeshDataInfo {
  120348. _hasVertexAlpha: boolean;
  120349. _useVertexColors: boolean;
  120350. _numBoneInfluencers: number;
  120351. _applyFog: boolean;
  120352. _receiveShadows: boolean;
  120353. _facetData: _FacetDataStorage;
  120354. _visibility: number;
  120355. _skeleton: Nullable<Skeleton>;
  120356. _layerMask: number;
  120357. _computeBonesUsingShaders: boolean;
  120358. _isActive: boolean;
  120359. _onlyForInstances: boolean;
  120360. _isActiveIntermediate: boolean;
  120361. _onlyForInstancesIntermediate: boolean;
  120362. _actAsRegularMesh: boolean;
  120363. _currentLOD: Nullable<AbstractMesh>;
  120364. _currentLODIsUpToDate: boolean;
  120365. }
  120366. /**
  120367. * Class used to store all common mesh properties
  120368. */
  120369. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  120370. /** No occlusion */
  120371. static OCCLUSION_TYPE_NONE: number;
  120372. /** Occlusion set to optimisitic */
  120373. static OCCLUSION_TYPE_OPTIMISTIC: number;
  120374. /** Occlusion set to strict */
  120375. static OCCLUSION_TYPE_STRICT: number;
  120376. /** Use an accurante occlusion algorithm */
  120377. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  120378. /** Use a conservative occlusion algorithm */
  120379. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  120380. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  120381. * Test order :
  120382. * Is the bounding sphere outside the frustum ?
  120383. * If not, are the bounding box vertices outside the frustum ?
  120384. * It not, then the cullable object is in the frustum.
  120385. */
  120386. static readonly CULLINGSTRATEGY_STANDARD: number;
  120387. /** Culling strategy : Bounding Sphere Only.
  120388. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  120389. * It's also less accurate than the standard because some not visible objects can still be selected.
  120390. * Test : is the bounding sphere outside the frustum ?
  120391. * If not, then the cullable object is in the frustum.
  120392. */
  120393. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  120394. /** Culling strategy : Optimistic Inclusion.
  120395. * This in an inclusion test first, then the standard exclusion test.
  120396. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  120397. * 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.
  120398. * Anyway, it's as accurate as the standard strategy.
  120399. * Test :
  120400. * Is the cullable object bounding sphere center in the frustum ?
  120401. * If not, apply the default culling strategy.
  120402. */
  120403. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  120404. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  120405. * This in an inclusion test first, then the bounding sphere only exclusion test.
  120406. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  120407. * 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.
  120408. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  120409. * Test :
  120410. * Is the cullable object bounding sphere center in the frustum ?
  120411. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  120412. */
  120413. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  120414. /**
  120415. * No billboard
  120416. */
  120417. static get BILLBOARDMODE_NONE(): number;
  120418. /** Billboard on X axis */
  120419. static get BILLBOARDMODE_X(): number;
  120420. /** Billboard on Y axis */
  120421. static get BILLBOARDMODE_Y(): number;
  120422. /** Billboard on Z axis */
  120423. static get BILLBOARDMODE_Z(): number;
  120424. /** Billboard on all axes */
  120425. static get BILLBOARDMODE_ALL(): number;
  120426. /** Billboard on using position instead of orientation */
  120427. static get BILLBOARDMODE_USE_POSITION(): number;
  120428. /** @hidden */
  120429. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  120430. /**
  120431. * The culling strategy to use to check whether the mesh must be rendered or not.
  120432. * This value can be changed at any time and will be used on the next render mesh selection.
  120433. * The possible values are :
  120434. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  120435. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  120436. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  120437. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  120438. * Please read each static variable documentation to get details about the culling process.
  120439. * */
  120440. cullingStrategy: number;
  120441. /**
  120442. * Gets the number of facets in the mesh
  120443. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  120444. */
  120445. get facetNb(): number;
  120446. /**
  120447. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  120448. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  120449. */
  120450. get partitioningSubdivisions(): number;
  120451. set partitioningSubdivisions(nb: number);
  120452. /**
  120453. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  120454. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  120455. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  120456. */
  120457. get partitioningBBoxRatio(): number;
  120458. set partitioningBBoxRatio(ratio: number);
  120459. /**
  120460. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  120461. * Works only for updatable meshes.
  120462. * Doesn't work with multi-materials
  120463. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  120464. */
  120465. get mustDepthSortFacets(): boolean;
  120466. set mustDepthSortFacets(sort: boolean);
  120467. /**
  120468. * The location (Vector3) where the facet depth sort must be computed from.
  120469. * By default, the active camera position.
  120470. * Used only when facet depth sort is enabled
  120471. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  120472. */
  120473. get facetDepthSortFrom(): Vector3;
  120474. set facetDepthSortFrom(location: Vector3);
  120475. /**
  120476. * gets a boolean indicating if facetData is enabled
  120477. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  120478. */
  120479. get isFacetDataEnabled(): boolean;
  120480. /** @hidden */
  120481. _updateNonUniformScalingState(value: boolean): boolean;
  120482. /**
  120483. * An event triggered when this mesh collides with another one
  120484. */
  120485. onCollideObservable: Observable<AbstractMesh>;
  120486. /** Set a function to call when this mesh collides with another one */
  120487. set onCollide(callback: () => void);
  120488. /**
  120489. * An event triggered when the collision's position changes
  120490. */
  120491. onCollisionPositionChangeObservable: Observable<Vector3>;
  120492. /** Set a function to call when the collision's position changes */
  120493. set onCollisionPositionChange(callback: () => void);
  120494. /**
  120495. * An event triggered when material is changed
  120496. */
  120497. onMaterialChangedObservable: Observable<AbstractMesh>;
  120498. /**
  120499. * Gets or sets the orientation for POV movement & rotation
  120500. */
  120501. definedFacingForward: boolean;
  120502. /** @hidden */
  120503. _occlusionQuery: Nullable<WebGLQuery>;
  120504. /** @hidden */
  120505. _renderingGroup: Nullable<RenderingGroup>;
  120506. /**
  120507. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  120508. */
  120509. get visibility(): number;
  120510. /**
  120511. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  120512. */
  120513. set visibility(value: number);
  120514. /** Gets or sets the alpha index used to sort transparent meshes
  120515. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  120516. */
  120517. alphaIndex: number;
  120518. /**
  120519. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  120520. */
  120521. isVisible: boolean;
  120522. /**
  120523. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  120524. */
  120525. isPickable: boolean;
  120526. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  120527. showSubMeshesBoundingBox: boolean;
  120528. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  120529. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120530. */
  120531. isBlocker: boolean;
  120532. /**
  120533. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  120534. */
  120535. enablePointerMoveEvents: boolean;
  120536. private _renderingGroupId;
  120537. /**
  120538. * Specifies the rendering group id for this mesh (0 by default)
  120539. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  120540. */
  120541. get renderingGroupId(): number;
  120542. set renderingGroupId(value: number);
  120543. private _material;
  120544. /** Gets or sets current material */
  120545. get material(): Nullable<Material>;
  120546. set material(value: Nullable<Material>);
  120547. /**
  120548. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  120549. * @see https://doc.babylonjs.com/babylon101/shadows
  120550. */
  120551. get receiveShadows(): boolean;
  120552. set receiveShadows(value: boolean);
  120553. /** Defines color to use when rendering outline */
  120554. outlineColor: Color3;
  120555. /** Define width to use when rendering outline */
  120556. outlineWidth: number;
  120557. /** Defines color to use when rendering overlay */
  120558. overlayColor: Color3;
  120559. /** Defines alpha to use when rendering overlay */
  120560. overlayAlpha: number;
  120561. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  120562. get hasVertexAlpha(): boolean;
  120563. set hasVertexAlpha(value: boolean);
  120564. /** 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) */
  120565. get useVertexColors(): boolean;
  120566. set useVertexColors(value: boolean);
  120567. /**
  120568. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  120569. */
  120570. get computeBonesUsingShaders(): boolean;
  120571. set computeBonesUsingShaders(value: boolean);
  120572. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  120573. get numBoneInfluencers(): number;
  120574. set numBoneInfluencers(value: number);
  120575. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  120576. get applyFog(): boolean;
  120577. set applyFog(value: boolean);
  120578. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  120579. useOctreeForRenderingSelection: boolean;
  120580. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  120581. useOctreeForPicking: boolean;
  120582. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  120583. useOctreeForCollisions: boolean;
  120584. /**
  120585. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  120586. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  120587. */
  120588. get layerMask(): number;
  120589. set layerMask(value: number);
  120590. /**
  120591. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  120592. */
  120593. alwaysSelectAsActiveMesh: boolean;
  120594. /**
  120595. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  120596. */
  120597. doNotSyncBoundingInfo: boolean;
  120598. /**
  120599. * Gets or sets the current action manager
  120600. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  120601. */
  120602. actionManager: Nullable<AbstractActionManager>;
  120603. private _meshCollisionData;
  120604. /**
  120605. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  120606. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  120607. */
  120608. ellipsoid: Vector3;
  120609. /**
  120610. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  120611. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  120612. */
  120613. ellipsoidOffset: Vector3;
  120614. /**
  120615. * Gets or sets a collision mask used to mask collisions (default is -1).
  120616. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  120617. */
  120618. get collisionMask(): number;
  120619. set collisionMask(mask: number);
  120620. /**
  120621. * Gets or sets a collision response flag (default is true).
  120622. * when collisionResponse is false, events are still triggered but colliding entity has no response
  120623. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  120624. * to respond to the collision.
  120625. */
  120626. get collisionResponse(): boolean;
  120627. set collisionResponse(response: boolean);
  120628. /**
  120629. * Gets or sets the current collision group mask (-1 by default).
  120630. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  120631. */
  120632. get collisionGroup(): number;
  120633. set collisionGroup(mask: number);
  120634. /**
  120635. * Gets or sets current surrounding meshes (null by default).
  120636. *
  120637. * By default collision detection is tested against every mesh in the scene.
  120638. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  120639. * meshes will be tested for the collision.
  120640. *
  120641. * Note: if set to an empty array no collision will happen when this mesh is moved.
  120642. */
  120643. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  120644. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  120645. /**
  120646. * Defines edge width used when edgesRenderer is enabled
  120647. * @see https://www.babylonjs-playground.com/#10OJSG#13
  120648. */
  120649. edgesWidth: number;
  120650. /**
  120651. * Defines edge color used when edgesRenderer is enabled
  120652. * @see https://www.babylonjs-playground.com/#10OJSG#13
  120653. */
  120654. edgesColor: Color4;
  120655. /** @hidden */
  120656. _edgesRenderer: Nullable<IEdgesRenderer>;
  120657. /** @hidden */
  120658. _masterMesh: Nullable<AbstractMesh>;
  120659. /** @hidden */
  120660. _boundingInfo: Nullable<BoundingInfo>;
  120661. /** @hidden */
  120662. _renderId: number;
  120663. /**
  120664. * Gets or sets the list of subMeshes
  120665. * @see https://doc.babylonjs.com/how_to/multi_materials
  120666. */
  120667. subMeshes: SubMesh[];
  120668. /** @hidden */
  120669. _intersectionsInProgress: AbstractMesh[];
  120670. /** @hidden */
  120671. _unIndexed: boolean;
  120672. /** @hidden */
  120673. _lightSources: Light[];
  120674. /** Gets the list of lights affecting that mesh */
  120675. get lightSources(): Light[];
  120676. /** @hidden */
  120677. get _positions(): Nullable<Vector3[]>;
  120678. /** @hidden */
  120679. _waitingData: {
  120680. lods: Nullable<any>;
  120681. actions: Nullable<any>;
  120682. freezeWorldMatrix: Nullable<boolean>;
  120683. };
  120684. /** @hidden */
  120685. _bonesTransformMatrices: Nullable<Float32Array>;
  120686. /** @hidden */
  120687. _transformMatrixTexture: Nullable<RawTexture>;
  120688. /**
  120689. * Gets or sets a skeleton to apply skining transformations
  120690. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  120691. */
  120692. set skeleton(value: Nullable<Skeleton>);
  120693. get skeleton(): Nullable<Skeleton>;
  120694. /**
  120695. * An event triggered when the mesh is rebuilt.
  120696. */
  120697. onRebuildObservable: Observable<AbstractMesh>;
  120698. /**
  120699. * The current mesh unifom buffer.
  120700. * @hidden Internal use only.
  120701. */
  120702. _uniformBuffer: UniformBuffer;
  120703. /**
  120704. * Creates a new AbstractMesh
  120705. * @param name defines the name of the mesh
  120706. * @param scene defines the hosting scene
  120707. */
  120708. constructor(name: string, scene?: Nullable<Scene>);
  120709. protected _buildUniformLayout(): void;
  120710. /**
  120711. * Transfer the mesh values to its UBO.
  120712. * @param world The world matrix associated with the mesh
  120713. */
  120714. transferToEffect(world: Matrix): void;
  120715. /**
  120716. * Gets the mesh uniform buffer.
  120717. * @return the uniform buffer of the mesh.
  120718. */
  120719. getMeshUniformBuffer(): UniformBuffer;
  120720. /**
  120721. * Returns the string "AbstractMesh"
  120722. * @returns "AbstractMesh"
  120723. */
  120724. getClassName(): string;
  120725. /**
  120726. * Gets a string representation of the current mesh
  120727. * @param fullDetails defines a boolean indicating if full details must be included
  120728. * @returns a string representation of the current mesh
  120729. */
  120730. toString(fullDetails?: boolean): string;
  120731. /**
  120732. * @hidden
  120733. */
  120734. protected _getEffectiveParent(): Nullable<Node>;
  120735. /** @hidden */
  120736. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  120737. /** @hidden */
  120738. _rebuild(): void;
  120739. /** @hidden */
  120740. _resyncLightSources(): void;
  120741. /** @hidden */
  120742. _resyncLightSource(light: Light): void;
  120743. /** @hidden */
  120744. _unBindEffect(): void;
  120745. /** @hidden */
  120746. _removeLightSource(light: Light, dispose: boolean): void;
  120747. private _markSubMeshesAsDirty;
  120748. /** @hidden */
  120749. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  120750. /** @hidden */
  120751. _markSubMeshesAsAttributesDirty(): void;
  120752. /** @hidden */
  120753. _markSubMeshesAsMiscDirty(): void;
  120754. /**
  120755. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  120756. */
  120757. get scaling(): Vector3;
  120758. set scaling(newScaling: Vector3);
  120759. /**
  120760. * Returns true if the mesh is blocked. Implemented by child classes
  120761. */
  120762. get isBlocked(): boolean;
  120763. /**
  120764. * Returns the mesh itself by default. Implemented by child classes
  120765. * @param camera defines the camera to use to pick the right LOD level
  120766. * @returns the currentAbstractMesh
  120767. */
  120768. getLOD(camera: Camera): Nullable<AbstractMesh>;
  120769. /**
  120770. * Returns 0 by default. Implemented by child classes
  120771. * @returns an integer
  120772. */
  120773. getTotalVertices(): number;
  120774. /**
  120775. * Returns a positive integer : the total number of indices in this mesh geometry.
  120776. * @returns the numner of indices or zero if the mesh has no geometry.
  120777. */
  120778. getTotalIndices(): number;
  120779. /**
  120780. * Returns null by default. Implemented by child classes
  120781. * @returns null
  120782. */
  120783. getIndices(): Nullable<IndicesArray>;
  120784. /**
  120785. * Returns the array of the requested vertex data kind. Implemented by child classes
  120786. * @param kind defines the vertex data kind to use
  120787. * @returns null
  120788. */
  120789. getVerticesData(kind: string): Nullable<FloatArray>;
  120790. /**
  120791. * Sets the vertex data of the mesh geometry for the requested `kind`.
  120792. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  120793. * Note that a new underlying VertexBuffer object is created each call.
  120794. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  120795. * @param kind defines vertex data kind:
  120796. * * VertexBuffer.PositionKind
  120797. * * VertexBuffer.UVKind
  120798. * * VertexBuffer.UV2Kind
  120799. * * VertexBuffer.UV3Kind
  120800. * * VertexBuffer.UV4Kind
  120801. * * VertexBuffer.UV5Kind
  120802. * * VertexBuffer.UV6Kind
  120803. * * VertexBuffer.ColorKind
  120804. * * VertexBuffer.MatricesIndicesKind
  120805. * * VertexBuffer.MatricesIndicesExtraKind
  120806. * * VertexBuffer.MatricesWeightsKind
  120807. * * VertexBuffer.MatricesWeightsExtraKind
  120808. * @param data defines the data source
  120809. * @param updatable defines if the data must be flagged as updatable (or static)
  120810. * @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
  120811. * @returns the current mesh
  120812. */
  120813. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  120814. /**
  120815. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  120816. * If the mesh has no geometry, it is simply returned as it is.
  120817. * @param kind defines vertex data kind:
  120818. * * VertexBuffer.PositionKind
  120819. * * VertexBuffer.UVKind
  120820. * * VertexBuffer.UV2Kind
  120821. * * VertexBuffer.UV3Kind
  120822. * * VertexBuffer.UV4Kind
  120823. * * VertexBuffer.UV5Kind
  120824. * * VertexBuffer.UV6Kind
  120825. * * VertexBuffer.ColorKind
  120826. * * VertexBuffer.MatricesIndicesKind
  120827. * * VertexBuffer.MatricesIndicesExtraKind
  120828. * * VertexBuffer.MatricesWeightsKind
  120829. * * VertexBuffer.MatricesWeightsExtraKind
  120830. * @param data defines the data source
  120831. * @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
  120832. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  120833. * @returns the current mesh
  120834. */
  120835. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  120836. /**
  120837. * Sets the mesh indices,
  120838. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  120839. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  120840. * @param totalVertices Defines the total number of vertices
  120841. * @returns the current mesh
  120842. */
  120843. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  120844. /**
  120845. * Gets a boolean indicating if specific vertex data is present
  120846. * @param kind defines the vertex data kind to use
  120847. * @returns true is data kind is present
  120848. */
  120849. isVerticesDataPresent(kind: string): boolean;
  120850. /**
  120851. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  120852. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  120853. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  120854. * @returns a BoundingInfo
  120855. */
  120856. getBoundingInfo(): BoundingInfo;
  120857. /**
  120858. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  120859. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  120860. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  120861. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  120862. * @returns the current mesh
  120863. */
  120864. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  120865. /**
  120866. * Overwrite the current bounding info
  120867. * @param boundingInfo defines the new bounding info
  120868. * @returns the current mesh
  120869. */
  120870. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  120871. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  120872. get useBones(): boolean;
  120873. /** @hidden */
  120874. _preActivate(): void;
  120875. /** @hidden */
  120876. _preActivateForIntermediateRendering(renderId: number): void;
  120877. /** @hidden */
  120878. _activate(renderId: number, intermediateRendering: boolean): boolean;
  120879. /** @hidden */
  120880. _postActivate(): void;
  120881. /** @hidden */
  120882. _freeze(): void;
  120883. /** @hidden */
  120884. _unFreeze(): void;
  120885. /**
  120886. * Gets the current world matrix
  120887. * @returns a Matrix
  120888. */
  120889. getWorldMatrix(): Matrix;
  120890. /** @hidden */
  120891. _getWorldMatrixDeterminant(): number;
  120892. /**
  120893. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  120894. */
  120895. get isAnInstance(): boolean;
  120896. /**
  120897. * Gets a boolean indicating if this mesh has instances
  120898. */
  120899. get hasInstances(): boolean;
  120900. /**
  120901. * Gets a boolean indicating if this mesh has thin instances
  120902. */
  120903. get hasThinInstances(): boolean;
  120904. /**
  120905. * Perform relative position change from the point of view of behind the front of the mesh.
  120906. * This is performed taking into account the meshes current rotation, so you do not have to care.
  120907. * Supports definition of mesh facing forward or backward
  120908. * @param amountRight defines the distance on the right axis
  120909. * @param amountUp defines the distance on the up axis
  120910. * @param amountForward defines the distance on the forward axis
  120911. * @returns the current mesh
  120912. */
  120913. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  120914. /**
  120915. * Calculate relative position change from the point of view of behind the front of the mesh.
  120916. * This is performed taking into account the meshes current rotation, so you do not have to care.
  120917. * Supports definition of mesh facing forward or backward
  120918. * @param amountRight defines the distance on the right axis
  120919. * @param amountUp defines the distance on the up axis
  120920. * @param amountForward defines the distance on the forward axis
  120921. * @returns the new displacement vector
  120922. */
  120923. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  120924. /**
  120925. * Perform relative rotation change from the point of view of behind the front of the mesh.
  120926. * Supports definition of mesh facing forward or backward
  120927. * @param flipBack defines the flip
  120928. * @param twirlClockwise defines the twirl
  120929. * @param tiltRight defines the tilt
  120930. * @returns the current mesh
  120931. */
  120932. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  120933. /**
  120934. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  120935. * Supports definition of mesh facing forward or backward.
  120936. * @param flipBack defines the flip
  120937. * @param twirlClockwise defines the twirl
  120938. * @param tiltRight defines the tilt
  120939. * @returns the new rotation vector
  120940. */
  120941. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  120942. /**
  120943. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  120944. * This means the mesh underlying bounding box and sphere are recomputed.
  120945. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  120946. * @returns the current mesh
  120947. */
  120948. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  120949. /** @hidden */
  120950. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  120951. /** @hidden */
  120952. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  120953. /** @hidden */
  120954. _updateBoundingInfo(): AbstractMesh;
  120955. /** @hidden */
  120956. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  120957. /** @hidden */
  120958. protected _afterComputeWorldMatrix(): void;
  120959. /** @hidden */
  120960. get _effectiveMesh(): AbstractMesh;
  120961. /**
  120962. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  120963. * A mesh is in the frustum if its bounding box intersects the frustum
  120964. * @param frustumPlanes defines the frustum to test
  120965. * @returns true if the mesh is in the frustum planes
  120966. */
  120967. isInFrustum(frustumPlanes: Plane[]): boolean;
  120968. /**
  120969. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  120970. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  120971. * @param frustumPlanes defines the frustum to test
  120972. * @returns true if the mesh is completely in the frustum planes
  120973. */
  120974. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  120975. /**
  120976. * True if the mesh intersects another mesh or a SolidParticle object
  120977. * @param mesh defines a target mesh or SolidParticle to test
  120978. * @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)
  120979. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  120980. * @returns true if there is an intersection
  120981. */
  120982. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  120983. /**
  120984. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  120985. * @param point defines the point to test
  120986. * @returns true if there is an intersection
  120987. */
  120988. intersectsPoint(point: Vector3): boolean;
  120989. /**
  120990. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  120991. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  120992. */
  120993. get checkCollisions(): boolean;
  120994. set checkCollisions(collisionEnabled: boolean);
  120995. /**
  120996. * Gets Collider object used to compute collisions (not physics)
  120997. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  120998. */
  120999. get collider(): Nullable<Collider>;
  121000. /**
  121001. * Move the mesh using collision engine
  121002. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  121003. * @param displacement defines the requested displacement vector
  121004. * @returns the current mesh
  121005. */
  121006. moveWithCollisions(displacement: Vector3): AbstractMesh;
  121007. private _onCollisionPositionChange;
  121008. /** @hidden */
  121009. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  121010. /** @hidden */
  121011. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  121012. /** @hidden */
  121013. _checkCollision(collider: Collider): AbstractMesh;
  121014. /** @hidden */
  121015. _generatePointsArray(): boolean;
  121016. /**
  121017. * Checks if the passed Ray intersects with the mesh
  121018. * @param ray defines the ray to use
  121019. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  121020. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121021. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  121022. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  121023. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  121024. * @returns the picking info
  121025. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  121026. */
  121027. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  121028. /**
  121029. * Clones the current mesh
  121030. * @param name defines the mesh name
  121031. * @param newParent defines the new mesh parent
  121032. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  121033. * @returns the new mesh
  121034. */
  121035. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  121036. /**
  121037. * Disposes all the submeshes of the current meshnp
  121038. * @returns the current mesh
  121039. */
  121040. releaseSubMeshes(): AbstractMesh;
  121041. /**
  121042. * Releases resources associated with this abstract mesh.
  121043. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  121044. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  121045. */
  121046. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  121047. /**
  121048. * Adds the passed mesh as a child to the current mesh
  121049. * @param mesh defines the child mesh
  121050. * @returns the current mesh
  121051. */
  121052. addChild(mesh: AbstractMesh): AbstractMesh;
  121053. /**
  121054. * Removes the passed mesh from the current mesh children list
  121055. * @param mesh defines the child mesh
  121056. * @returns the current mesh
  121057. */
  121058. removeChild(mesh: AbstractMesh): AbstractMesh;
  121059. /** @hidden */
  121060. private _initFacetData;
  121061. /**
  121062. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  121063. * This method can be called within the render loop.
  121064. * 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
  121065. * @returns the current mesh
  121066. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121067. */
  121068. updateFacetData(): AbstractMesh;
  121069. /**
  121070. * Returns the facetLocalNormals array.
  121071. * The normals are expressed in the mesh local spac
  121072. * @returns an array of Vector3
  121073. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121074. */
  121075. getFacetLocalNormals(): Vector3[];
  121076. /**
  121077. * Returns the facetLocalPositions array.
  121078. * The facet positions are expressed in the mesh local space
  121079. * @returns an array of Vector3
  121080. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121081. */
  121082. getFacetLocalPositions(): Vector3[];
  121083. /**
  121084. * Returns the facetLocalPartioning array
  121085. * @returns an array of array of numbers
  121086. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121087. */
  121088. getFacetLocalPartitioning(): number[][];
  121089. /**
  121090. * Returns the i-th facet position in the world system.
  121091. * This method allocates a new Vector3 per call
  121092. * @param i defines the facet index
  121093. * @returns a new Vector3
  121094. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121095. */
  121096. getFacetPosition(i: number): Vector3;
  121097. /**
  121098. * Sets the reference Vector3 with the i-th facet position in the world system
  121099. * @param i defines the facet index
  121100. * @param ref defines the target vector
  121101. * @returns the current mesh
  121102. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121103. */
  121104. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  121105. /**
  121106. * Returns the i-th facet normal in the world system.
  121107. * This method allocates a new Vector3 per call
  121108. * @param i defines the facet index
  121109. * @returns a new Vector3
  121110. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121111. */
  121112. getFacetNormal(i: number): Vector3;
  121113. /**
  121114. * Sets the reference Vector3 with the i-th facet normal in the world system
  121115. * @param i defines the facet index
  121116. * @param ref defines the target vector
  121117. * @returns the current mesh
  121118. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121119. */
  121120. getFacetNormalToRef(i: number, ref: Vector3): this;
  121121. /**
  121122. * 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)
  121123. * @param x defines x coordinate
  121124. * @param y defines y coordinate
  121125. * @param z defines z coordinate
  121126. * @returns the array of facet indexes
  121127. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121128. */
  121129. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  121130. /**
  121131. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  121132. * @param projected sets as the (x,y,z) world projection on the facet
  121133. * @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
  121134. * @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
  121135. * @param x defines x coordinate
  121136. * @param y defines y coordinate
  121137. * @param z defines z coordinate
  121138. * @returns the face index if found (or null instead)
  121139. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121140. */
  121141. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  121142. /**
  121143. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  121144. * @param projected sets as the (x,y,z) local projection on the facet
  121145. * @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
  121146. * @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
  121147. * @param x defines x coordinate
  121148. * @param y defines y coordinate
  121149. * @param z defines z coordinate
  121150. * @returns the face index if found (or null instead)
  121151. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121152. */
  121153. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  121154. /**
  121155. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  121156. * @returns the parameters
  121157. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121158. */
  121159. getFacetDataParameters(): any;
  121160. /**
  121161. * Disables the feature FacetData and frees the related memory
  121162. * @returns the current mesh
  121163. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  121164. */
  121165. disableFacetData(): AbstractMesh;
  121166. /**
  121167. * Updates the AbstractMesh indices array
  121168. * @param indices defines the data source
  121169. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  121170. * @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)
  121171. * @returns the current mesh
  121172. */
  121173. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  121174. /**
  121175. * Creates new normals data for the mesh
  121176. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  121177. * @returns the current mesh
  121178. */
  121179. createNormals(updatable: boolean): AbstractMesh;
  121180. /**
  121181. * Align the mesh with a normal
  121182. * @param normal defines the normal to use
  121183. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  121184. * @returns the current mesh
  121185. */
  121186. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  121187. /** @hidden */
  121188. _checkOcclusionQuery(): boolean;
  121189. /**
  121190. * Disables the mesh edge rendering mode
  121191. * @returns the currentAbstractMesh
  121192. */
  121193. disableEdgesRendering(): AbstractMesh;
  121194. /**
  121195. * Enables the edge rendering mode on the mesh.
  121196. * This mode makes the mesh edges visible
  121197. * @param epsilon defines the maximal distance between two angles to detect a face
  121198. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  121199. * @param options options to the edge renderer
  121200. * @returns the currentAbstractMesh
  121201. * @see https://www.babylonjs-playground.com/#19O9TU#0
  121202. */
  121203. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  121204. /**
  121205. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  121206. * @returns an array of particle systems in the scene that use the mesh as an emitter
  121207. */
  121208. getConnectedParticleSystems(): IParticleSystem[];
  121209. }
  121210. }
  121211. declare module BABYLON {
  121212. /**
  121213. * Interface used to define ActionEvent
  121214. */
  121215. export interface IActionEvent {
  121216. /** The mesh or sprite that triggered the action */
  121217. source: any;
  121218. /** The X mouse cursor position at the time of the event */
  121219. pointerX: number;
  121220. /** The Y mouse cursor position at the time of the event */
  121221. pointerY: number;
  121222. /** The mesh that is currently pointed at (can be null) */
  121223. meshUnderPointer: Nullable<AbstractMesh>;
  121224. /** the original (browser) event that triggered the ActionEvent */
  121225. sourceEvent?: any;
  121226. /** additional data for the event */
  121227. additionalData?: any;
  121228. }
  121229. /**
  121230. * ActionEvent is the event being sent when an action is triggered.
  121231. */
  121232. export class ActionEvent implements IActionEvent {
  121233. /** The mesh or sprite that triggered the action */
  121234. source: any;
  121235. /** The X mouse cursor position at the time of the event */
  121236. pointerX: number;
  121237. /** The Y mouse cursor position at the time of the event */
  121238. pointerY: number;
  121239. /** The mesh that is currently pointed at (can be null) */
  121240. meshUnderPointer: Nullable<AbstractMesh>;
  121241. /** the original (browser) event that triggered the ActionEvent */
  121242. sourceEvent?: any;
  121243. /** additional data for the event */
  121244. additionalData?: any;
  121245. /**
  121246. * Creates a new ActionEvent
  121247. * @param source The mesh or sprite that triggered the action
  121248. * @param pointerX The X mouse cursor position at the time of the event
  121249. * @param pointerY The Y mouse cursor position at the time of the event
  121250. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  121251. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  121252. * @param additionalData additional data for the event
  121253. */
  121254. constructor(
  121255. /** The mesh or sprite that triggered the action */
  121256. source: any,
  121257. /** The X mouse cursor position at the time of the event */
  121258. pointerX: number,
  121259. /** The Y mouse cursor position at the time of the event */
  121260. pointerY: number,
  121261. /** The mesh that is currently pointed at (can be null) */
  121262. meshUnderPointer: Nullable<AbstractMesh>,
  121263. /** the original (browser) event that triggered the ActionEvent */
  121264. sourceEvent?: any,
  121265. /** additional data for the event */
  121266. additionalData?: any);
  121267. /**
  121268. * Helper function to auto-create an ActionEvent from a source mesh.
  121269. * @param source The source mesh that triggered the event
  121270. * @param evt The original (browser) event
  121271. * @param additionalData additional data for the event
  121272. * @returns the new ActionEvent
  121273. */
  121274. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  121275. /**
  121276. * Helper function to auto-create an ActionEvent from a source sprite
  121277. * @param source The source sprite that triggered the event
  121278. * @param scene Scene associated with the sprite
  121279. * @param evt The original (browser) event
  121280. * @param additionalData additional data for the event
  121281. * @returns the new ActionEvent
  121282. */
  121283. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  121284. /**
  121285. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  121286. * @param scene the scene where the event occurred
  121287. * @param evt The original (browser) event
  121288. * @returns the new ActionEvent
  121289. */
  121290. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  121291. /**
  121292. * Helper function to auto-create an ActionEvent from a primitive
  121293. * @param prim defines the target primitive
  121294. * @param pointerPos defines the pointer position
  121295. * @param evt The original (browser) event
  121296. * @param additionalData additional data for the event
  121297. * @returns the new ActionEvent
  121298. */
  121299. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  121300. }
  121301. }
  121302. declare module BABYLON {
  121303. /**
  121304. * Abstract class used to decouple action Manager from scene and meshes.
  121305. * Do not instantiate.
  121306. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  121307. */
  121308. export abstract class AbstractActionManager implements IDisposable {
  121309. /** Gets the list of active triggers */
  121310. static Triggers: {
  121311. [key: string]: number;
  121312. };
  121313. /** Gets the cursor to use when hovering items */
  121314. hoverCursor: string;
  121315. /** Gets the list of actions */
  121316. actions: IAction[];
  121317. /**
  121318. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  121319. */
  121320. isRecursive: boolean;
  121321. /**
  121322. * Releases all associated resources
  121323. */
  121324. abstract dispose(): void;
  121325. /**
  121326. * Does this action manager has pointer triggers
  121327. */
  121328. abstract get hasPointerTriggers(): boolean;
  121329. /**
  121330. * Does this action manager has pick triggers
  121331. */
  121332. abstract get hasPickTriggers(): boolean;
  121333. /**
  121334. * Process a specific trigger
  121335. * @param trigger defines the trigger to process
  121336. * @param evt defines the event details to be processed
  121337. */
  121338. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  121339. /**
  121340. * Does this action manager handles actions of any of the given triggers
  121341. * @param triggers defines the triggers to be tested
  121342. * @return a boolean indicating whether one (or more) of the triggers is handled
  121343. */
  121344. abstract hasSpecificTriggers(triggers: number[]): boolean;
  121345. /**
  121346. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  121347. * speed.
  121348. * @param triggerA defines the trigger to be tested
  121349. * @param triggerB defines the trigger to be tested
  121350. * @return a boolean indicating whether one (or more) of the triggers is handled
  121351. */
  121352. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  121353. /**
  121354. * Does this action manager handles actions of a given trigger
  121355. * @param trigger defines the trigger to be tested
  121356. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  121357. * @return whether the trigger is handled
  121358. */
  121359. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  121360. /**
  121361. * Serialize this manager to a JSON object
  121362. * @param name defines the property name to store this manager
  121363. * @returns a JSON representation of this manager
  121364. */
  121365. abstract serialize(name: string): any;
  121366. /**
  121367. * Registers an action to this action manager
  121368. * @param action defines the action to be registered
  121369. * @return the action amended (prepared) after registration
  121370. */
  121371. abstract registerAction(action: IAction): Nullable<IAction>;
  121372. /**
  121373. * Unregisters an action to this action manager
  121374. * @param action defines the action to be unregistered
  121375. * @return a boolean indicating whether the action has been unregistered
  121376. */
  121377. abstract unregisterAction(action: IAction): Boolean;
  121378. /**
  121379. * Does exist one action manager with at least one trigger
  121380. **/
  121381. static get HasTriggers(): boolean;
  121382. /**
  121383. * Does exist one action manager with at least one pick trigger
  121384. **/
  121385. static get HasPickTriggers(): boolean;
  121386. /**
  121387. * Does exist one action manager that handles actions of a given trigger
  121388. * @param trigger defines the trigger to be tested
  121389. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  121390. **/
  121391. static HasSpecificTrigger(trigger: number): boolean;
  121392. }
  121393. }
  121394. declare module BABYLON {
  121395. /**
  121396. * Defines how a node can be built from a string name.
  121397. */
  121398. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  121399. /**
  121400. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  121401. */
  121402. export class Node implements IBehaviorAware<Node> {
  121403. /** @hidden */
  121404. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  121405. private static _NodeConstructors;
  121406. /**
  121407. * Add a new node constructor
  121408. * @param type defines the type name of the node to construct
  121409. * @param constructorFunc defines the constructor function
  121410. */
  121411. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  121412. /**
  121413. * Returns a node constructor based on type name
  121414. * @param type defines the type name
  121415. * @param name defines the new node name
  121416. * @param scene defines the hosting scene
  121417. * @param options defines optional options to transmit to constructors
  121418. * @returns the new constructor or null
  121419. */
  121420. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  121421. /**
  121422. * Gets or sets the name of the node
  121423. */
  121424. name: string;
  121425. /**
  121426. * Gets or sets the id of the node
  121427. */
  121428. id: string;
  121429. /**
  121430. * Gets or sets the unique id of the node
  121431. */
  121432. uniqueId: number;
  121433. /**
  121434. * Gets or sets a string used to store user defined state for the node
  121435. */
  121436. state: string;
  121437. /**
  121438. * Gets or sets an object used to store user defined information for the node
  121439. */
  121440. metadata: any;
  121441. /**
  121442. * For internal use only. Please do not use.
  121443. */
  121444. reservedDataStore: any;
  121445. /**
  121446. * List of inspectable custom properties (used by the Inspector)
  121447. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  121448. */
  121449. inspectableCustomProperties: IInspectable[];
  121450. private _doNotSerialize;
  121451. /**
  121452. * Gets or sets a boolean used to define if the node must be serialized
  121453. */
  121454. get doNotSerialize(): boolean;
  121455. set doNotSerialize(value: boolean);
  121456. /** @hidden */
  121457. _isDisposed: boolean;
  121458. /**
  121459. * Gets a list of Animations associated with the node
  121460. */
  121461. animations: Animation[];
  121462. protected _ranges: {
  121463. [name: string]: Nullable<AnimationRange>;
  121464. };
  121465. /**
  121466. * Callback raised when the node is ready to be used
  121467. */
  121468. onReady: Nullable<(node: Node) => void>;
  121469. private _isEnabled;
  121470. private _isParentEnabled;
  121471. private _isReady;
  121472. /** @hidden */
  121473. _currentRenderId: number;
  121474. private _parentUpdateId;
  121475. /** @hidden */
  121476. _childUpdateId: number;
  121477. /** @hidden */
  121478. _waitingParentId: Nullable<string>;
  121479. /** @hidden */
  121480. _scene: Scene;
  121481. /** @hidden */
  121482. _cache: any;
  121483. private _parentNode;
  121484. private _children;
  121485. /** @hidden */
  121486. _worldMatrix: Matrix;
  121487. /** @hidden */
  121488. _worldMatrixDeterminant: number;
  121489. /** @hidden */
  121490. _worldMatrixDeterminantIsDirty: boolean;
  121491. /** @hidden */
  121492. private _sceneRootNodesIndex;
  121493. /**
  121494. * Gets a boolean indicating if the node has been disposed
  121495. * @returns true if the node was disposed
  121496. */
  121497. isDisposed(): boolean;
  121498. /**
  121499. * Gets or sets the parent of the node (without keeping the current position in the scene)
  121500. * @see https://doc.babylonjs.com/how_to/parenting
  121501. */
  121502. set parent(parent: Nullable<Node>);
  121503. get parent(): Nullable<Node>;
  121504. /** @hidden */
  121505. _addToSceneRootNodes(): void;
  121506. /** @hidden */
  121507. _removeFromSceneRootNodes(): void;
  121508. private _animationPropertiesOverride;
  121509. /**
  121510. * Gets or sets the animation properties override
  121511. */
  121512. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  121513. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  121514. /**
  121515. * Gets a string identifying the name of the class
  121516. * @returns "Node" string
  121517. */
  121518. getClassName(): string;
  121519. /** @hidden */
  121520. readonly _isNode: boolean;
  121521. /**
  121522. * An event triggered when the mesh is disposed
  121523. */
  121524. onDisposeObservable: Observable<Node>;
  121525. private _onDisposeObserver;
  121526. /**
  121527. * Sets a callback that will be raised when the node will be disposed
  121528. */
  121529. set onDispose(callback: () => void);
  121530. /**
  121531. * Creates a new Node
  121532. * @param name the name and id to be given to this node
  121533. * @param scene the scene this node will be added to
  121534. */
  121535. constructor(name: string, scene?: Nullable<Scene>);
  121536. /**
  121537. * Gets the scene of the node
  121538. * @returns a scene
  121539. */
  121540. getScene(): Scene;
  121541. /**
  121542. * Gets the engine of the node
  121543. * @returns a Engine
  121544. */
  121545. getEngine(): Engine;
  121546. private _behaviors;
  121547. /**
  121548. * Attach a behavior to the node
  121549. * @see https://doc.babylonjs.com/features/behaviour
  121550. * @param behavior defines the behavior to attach
  121551. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  121552. * @returns the current Node
  121553. */
  121554. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  121555. /**
  121556. * Remove an attached behavior
  121557. * @see https://doc.babylonjs.com/features/behaviour
  121558. * @param behavior defines the behavior to attach
  121559. * @returns the current Node
  121560. */
  121561. removeBehavior(behavior: Behavior<Node>): Node;
  121562. /**
  121563. * Gets the list of attached behaviors
  121564. * @see https://doc.babylonjs.com/features/behaviour
  121565. */
  121566. get behaviors(): Behavior<Node>[];
  121567. /**
  121568. * Gets an attached behavior by name
  121569. * @param name defines the name of the behavior to look for
  121570. * @see https://doc.babylonjs.com/features/behaviour
  121571. * @returns null if behavior was not found else the requested behavior
  121572. */
  121573. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  121574. /**
  121575. * Returns the latest update of the World matrix
  121576. * @returns a Matrix
  121577. */
  121578. getWorldMatrix(): Matrix;
  121579. /** @hidden */
  121580. _getWorldMatrixDeterminant(): number;
  121581. /**
  121582. * Returns directly the latest state of the mesh World matrix.
  121583. * A Matrix is returned.
  121584. */
  121585. get worldMatrixFromCache(): Matrix;
  121586. /** @hidden */
  121587. _initCache(): void;
  121588. /** @hidden */
  121589. updateCache(force?: boolean): void;
  121590. /** @hidden */
  121591. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  121592. /** @hidden */
  121593. _updateCache(ignoreParentClass?: boolean): void;
  121594. /** @hidden */
  121595. _isSynchronized(): boolean;
  121596. /** @hidden */
  121597. _markSyncedWithParent(): void;
  121598. /** @hidden */
  121599. isSynchronizedWithParent(): boolean;
  121600. /** @hidden */
  121601. isSynchronized(): boolean;
  121602. /**
  121603. * Is this node ready to be used/rendered
  121604. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  121605. * @return true if the node is ready
  121606. */
  121607. isReady(completeCheck?: boolean): boolean;
  121608. /**
  121609. * Is this node enabled?
  121610. * 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
  121611. * @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
  121612. * @return whether this node (and its parent) is enabled
  121613. */
  121614. isEnabled(checkAncestors?: boolean): boolean;
  121615. /** @hidden */
  121616. protected _syncParentEnabledState(): void;
  121617. /**
  121618. * Set the enabled state of this node
  121619. * @param value defines the new enabled state
  121620. */
  121621. setEnabled(value: boolean): void;
  121622. /**
  121623. * Is this node a descendant of the given node?
  121624. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  121625. * @param ancestor defines the parent node to inspect
  121626. * @returns a boolean indicating if this node is a descendant of the given node
  121627. */
  121628. isDescendantOf(ancestor: Node): boolean;
  121629. /** @hidden */
  121630. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  121631. /**
  121632. * Will return all nodes that have this node as ascendant
  121633. * @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
  121634. * @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
  121635. * @return all children nodes of all types
  121636. */
  121637. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  121638. /**
  121639. * Get all child-meshes of this node
  121640. * @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)
  121641. * @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
  121642. * @returns an array of AbstractMesh
  121643. */
  121644. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  121645. /**
  121646. * Get all direct children of this node
  121647. * @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
  121648. * @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)
  121649. * @returns an array of Node
  121650. */
  121651. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  121652. /** @hidden */
  121653. _setReady(state: boolean): void;
  121654. /**
  121655. * Get an animation by name
  121656. * @param name defines the name of the animation to look for
  121657. * @returns null if not found else the requested animation
  121658. */
  121659. getAnimationByName(name: string): Nullable<Animation>;
  121660. /**
  121661. * Creates an animation range for this node
  121662. * @param name defines the name of the range
  121663. * @param from defines the starting key
  121664. * @param to defines the end key
  121665. */
  121666. createAnimationRange(name: string, from: number, to: number): void;
  121667. /**
  121668. * Delete a specific animation range
  121669. * @param name defines the name of the range to delete
  121670. * @param deleteFrames defines if animation frames from the range must be deleted as well
  121671. */
  121672. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  121673. /**
  121674. * Get an animation range by name
  121675. * @param name defines the name of the animation range to look for
  121676. * @returns null if not found else the requested animation range
  121677. */
  121678. getAnimationRange(name: string): Nullable<AnimationRange>;
  121679. /**
  121680. * Gets the list of all animation ranges defined on this node
  121681. * @returns an array
  121682. */
  121683. getAnimationRanges(): Nullable<AnimationRange>[];
  121684. /**
  121685. * Will start the animation sequence
  121686. * @param name defines the range frames for animation sequence
  121687. * @param loop defines if the animation should loop (false by default)
  121688. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  121689. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  121690. * @returns the object created for this animation. If range does not exist, it will return null
  121691. */
  121692. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  121693. /**
  121694. * Serialize animation ranges into a JSON compatible object
  121695. * @returns serialization object
  121696. */
  121697. serializeAnimationRanges(): any;
  121698. /**
  121699. * Computes the world matrix of the node
  121700. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  121701. * @returns the world matrix
  121702. */
  121703. computeWorldMatrix(force?: boolean): Matrix;
  121704. /**
  121705. * Releases resources associated with this node.
  121706. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  121707. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  121708. */
  121709. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  121710. /**
  121711. * Parse animation range data from a serialization object and store them into a given node
  121712. * @param node defines where to store the animation ranges
  121713. * @param parsedNode defines the serialization object to read data from
  121714. * @param scene defines the hosting scene
  121715. */
  121716. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  121717. /**
  121718. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  121719. * @param includeDescendants Include bounding info from descendants as well (true by default)
  121720. * @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
  121721. * @returns the new bounding vectors
  121722. */
  121723. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  121724. min: Vector3;
  121725. max: Vector3;
  121726. };
  121727. }
  121728. }
  121729. declare module BABYLON {
  121730. /**
  121731. * @hidden
  121732. */
  121733. export class _IAnimationState {
  121734. key: number;
  121735. repeatCount: number;
  121736. workValue?: any;
  121737. loopMode?: number;
  121738. offsetValue?: any;
  121739. highLimitValue?: any;
  121740. }
  121741. /**
  121742. * Class used to store any kind of animation
  121743. */
  121744. export class Animation {
  121745. /**Name of the animation */
  121746. name: string;
  121747. /**Property to animate */
  121748. targetProperty: string;
  121749. /**The frames per second of the animation */
  121750. framePerSecond: number;
  121751. /**The data type of the animation */
  121752. dataType: number;
  121753. /**The loop mode of the animation */
  121754. loopMode?: number | undefined;
  121755. /**Specifies if blending should be enabled */
  121756. enableBlending?: boolean | undefined;
  121757. /**
  121758. * Use matrix interpolation instead of using direct key value when animating matrices
  121759. */
  121760. static AllowMatricesInterpolation: boolean;
  121761. /**
  121762. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  121763. */
  121764. static AllowMatrixDecomposeForInterpolation: boolean;
  121765. /** Define the Url to load snippets */
  121766. static SnippetUrl: string;
  121767. /** Snippet ID if the animation was created from the snippet server */
  121768. snippetId: string;
  121769. /**
  121770. * Stores the key frames of the animation
  121771. */
  121772. private _keys;
  121773. /**
  121774. * Stores the easing function of the animation
  121775. */
  121776. private _easingFunction;
  121777. /**
  121778. * @hidden Internal use only
  121779. */
  121780. _runtimeAnimations: RuntimeAnimation[];
  121781. /**
  121782. * The set of event that will be linked to this animation
  121783. */
  121784. private _events;
  121785. /**
  121786. * Stores an array of target property paths
  121787. */
  121788. targetPropertyPath: string[];
  121789. /**
  121790. * Stores the blending speed of the animation
  121791. */
  121792. blendingSpeed: number;
  121793. /**
  121794. * Stores the animation ranges for the animation
  121795. */
  121796. private _ranges;
  121797. /**
  121798. * @hidden Internal use
  121799. */
  121800. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  121801. /**
  121802. * Sets up an animation
  121803. * @param property The property to animate
  121804. * @param animationType The animation type to apply
  121805. * @param framePerSecond The frames per second of the animation
  121806. * @param easingFunction The easing function used in the animation
  121807. * @returns The created animation
  121808. */
  121809. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  121810. /**
  121811. * Create and start an animation on a node
  121812. * @param name defines the name of the global animation that will be run on all nodes
  121813. * @param node defines the root node where the animation will take place
  121814. * @param targetProperty defines property to animate
  121815. * @param framePerSecond defines the number of frame per second yo use
  121816. * @param totalFrame defines the number of frames in total
  121817. * @param from defines the initial value
  121818. * @param to defines the final value
  121819. * @param loopMode defines which loop mode you want to use (off by default)
  121820. * @param easingFunction defines the easing function to use (linear by default)
  121821. * @param onAnimationEnd defines the callback to call when animation end
  121822. * @returns the animatable created for this animation
  121823. */
  121824. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  121825. /**
  121826. * Create and start an animation on a node and its descendants
  121827. * @param name defines the name of the global animation that will be run on all nodes
  121828. * @param node defines the root node where the animation will take place
  121829. * @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
  121830. * @param targetProperty defines property to animate
  121831. * @param framePerSecond defines the number of frame per second to use
  121832. * @param totalFrame defines the number of frames in total
  121833. * @param from defines the initial value
  121834. * @param to defines the final value
  121835. * @param loopMode defines which loop mode you want to use (off by default)
  121836. * @param easingFunction defines the easing function to use (linear by default)
  121837. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  121838. * @returns the list of animatables created for all nodes
  121839. * @example https://www.babylonjs-playground.com/#MH0VLI
  121840. */
  121841. 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[]>;
  121842. /**
  121843. * Creates a new animation, merges it with the existing animations and starts it
  121844. * @param name Name of the animation
  121845. * @param node Node which contains the scene that begins the animations
  121846. * @param targetProperty Specifies which property to animate
  121847. * @param framePerSecond The frames per second of the animation
  121848. * @param totalFrame The total number of frames
  121849. * @param from The frame at the beginning of the animation
  121850. * @param to The frame at the end of the animation
  121851. * @param loopMode Specifies the loop mode of the animation
  121852. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  121853. * @param onAnimationEnd Callback to run once the animation is complete
  121854. * @returns Nullable animation
  121855. */
  121856. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  121857. /**
  121858. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  121859. * @param sourceAnimation defines the Animation containing keyframes to convert
  121860. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  121861. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  121862. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  121863. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  121864. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  121865. */
  121866. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  121867. /**
  121868. * Transition property of an host to the target Value
  121869. * @param property The property to transition
  121870. * @param targetValue The target Value of the property
  121871. * @param host The object where the property to animate belongs
  121872. * @param scene Scene used to run the animation
  121873. * @param frameRate Framerate (in frame/s) to use
  121874. * @param transition The transition type we want to use
  121875. * @param duration The duration of the animation, in milliseconds
  121876. * @param onAnimationEnd Callback trigger at the end of the animation
  121877. * @returns Nullable animation
  121878. */
  121879. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  121880. /**
  121881. * Return the array of runtime animations currently using this animation
  121882. */
  121883. get runtimeAnimations(): RuntimeAnimation[];
  121884. /**
  121885. * Specifies if any of the runtime animations are currently running
  121886. */
  121887. get hasRunningRuntimeAnimations(): boolean;
  121888. /**
  121889. * Initializes the animation
  121890. * @param name Name of the animation
  121891. * @param targetProperty Property to animate
  121892. * @param framePerSecond The frames per second of the animation
  121893. * @param dataType The data type of the animation
  121894. * @param loopMode The loop mode of the animation
  121895. * @param enableBlending Specifies if blending should be enabled
  121896. */
  121897. constructor(
  121898. /**Name of the animation */
  121899. name: string,
  121900. /**Property to animate */
  121901. targetProperty: string,
  121902. /**The frames per second of the animation */
  121903. framePerSecond: number,
  121904. /**The data type of the animation */
  121905. dataType: number,
  121906. /**The loop mode of the animation */
  121907. loopMode?: number | undefined,
  121908. /**Specifies if blending should be enabled */
  121909. enableBlending?: boolean | undefined);
  121910. /**
  121911. * Converts the animation to a string
  121912. * @param fullDetails support for multiple levels of logging within scene loading
  121913. * @returns String form of the animation
  121914. */
  121915. toString(fullDetails?: boolean): string;
  121916. /**
  121917. * Add an event to this animation
  121918. * @param event Event to add
  121919. */
  121920. addEvent(event: AnimationEvent): void;
  121921. /**
  121922. * Remove all events found at the given frame
  121923. * @param frame The frame to remove events from
  121924. */
  121925. removeEvents(frame: number): void;
  121926. /**
  121927. * Retrieves all the events from the animation
  121928. * @returns Events from the animation
  121929. */
  121930. getEvents(): AnimationEvent[];
  121931. /**
  121932. * Creates an animation range
  121933. * @param name Name of the animation range
  121934. * @param from Starting frame of the animation range
  121935. * @param to Ending frame of the animation
  121936. */
  121937. createRange(name: string, from: number, to: number): void;
  121938. /**
  121939. * Deletes an animation range by name
  121940. * @param name Name of the animation range to delete
  121941. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  121942. */
  121943. deleteRange(name: string, deleteFrames?: boolean): void;
  121944. /**
  121945. * Gets the animation range by name, or null if not defined
  121946. * @param name Name of the animation range
  121947. * @returns Nullable animation range
  121948. */
  121949. getRange(name: string): Nullable<AnimationRange>;
  121950. /**
  121951. * Gets the key frames from the animation
  121952. * @returns The key frames of the animation
  121953. */
  121954. getKeys(): Array<IAnimationKey>;
  121955. /**
  121956. * Gets the highest frame rate of the animation
  121957. * @returns Highest frame rate of the animation
  121958. */
  121959. getHighestFrame(): number;
  121960. /**
  121961. * Gets the easing function of the animation
  121962. * @returns Easing function of the animation
  121963. */
  121964. getEasingFunction(): IEasingFunction;
  121965. /**
  121966. * Sets the easing function of the animation
  121967. * @param easingFunction A custom mathematical formula for animation
  121968. */
  121969. setEasingFunction(easingFunction: EasingFunction): void;
  121970. /**
  121971. * Interpolates a scalar linearly
  121972. * @param startValue Start value of the animation curve
  121973. * @param endValue End value of the animation curve
  121974. * @param gradient Scalar amount to interpolate
  121975. * @returns Interpolated scalar value
  121976. */
  121977. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  121978. /**
  121979. * Interpolates a scalar cubically
  121980. * @param startValue Start value of the animation curve
  121981. * @param outTangent End tangent of the animation
  121982. * @param endValue End value of the animation curve
  121983. * @param inTangent Start tangent of the animation curve
  121984. * @param gradient Scalar amount to interpolate
  121985. * @returns Interpolated scalar value
  121986. */
  121987. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  121988. /**
  121989. * Interpolates a quaternion using a spherical linear interpolation
  121990. * @param startValue Start value of the animation curve
  121991. * @param endValue End value of the animation curve
  121992. * @param gradient Scalar amount to interpolate
  121993. * @returns Interpolated quaternion value
  121994. */
  121995. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  121996. /**
  121997. * Interpolates a quaternion cubically
  121998. * @param startValue Start value of the animation curve
  121999. * @param outTangent End tangent of the animation curve
  122000. * @param endValue End value of the animation curve
  122001. * @param inTangent Start tangent of the animation curve
  122002. * @param gradient Scalar amount to interpolate
  122003. * @returns Interpolated quaternion value
  122004. */
  122005. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  122006. /**
  122007. * Interpolates a Vector3 linearl
  122008. * @param startValue Start value of the animation curve
  122009. * @param endValue End value of the animation curve
  122010. * @param gradient Scalar amount to interpolate
  122011. * @returns Interpolated scalar value
  122012. */
  122013. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  122014. /**
  122015. * Interpolates a Vector3 cubically
  122016. * @param startValue Start value of the animation curve
  122017. * @param outTangent End tangent of the animation
  122018. * @param endValue End value of the animation curve
  122019. * @param inTangent Start tangent of the animation curve
  122020. * @param gradient Scalar amount to interpolate
  122021. * @returns InterpolatedVector3 value
  122022. */
  122023. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  122024. /**
  122025. * Interpolates a Vector2 linearly
  122026. * @param startValue Start value of the animation curve
  122027. * @param endValue End value of the animation curve
  122028. * @param gradient Scalar amount to interpolate
  122029. * @returns Interpolated Vector2 value
  122030. */
  122031. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  122032. /**
  122033. * Interpolates a Vector2 cubically
  122034. * @param startValue Start value of the animation curve
  122035. * @param outTangent End tangent of the animation
  122036. * @param endValue End value of the animation curve
  122037. * @param inTangent Start tangent of the animation curve
  122038. * @param gradient Scalar amount to interpolate
  122039. * @returns Interpolated Vector2 value
  122040. */
  122041. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  122042. /**
  122043. * Interpolates a size linearly
  122044. * @param startValue Start value of the animation curve
  122045. * @param endValue End value of the animation curve
  122046. * @param gradient Scalar amount to interpolate
  122047. * @returns Interpolated Size value
  122048. */
  122049. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  122050. /**
  122051. * Interpolates a Color3 linearly
  122052. * @param startValue Start value of the animation curve
  122053. * @param endValue End value of the animation curve
  122054. * @param gradient Scalar amount to interpolate
  122055. * @returns Interpolated Color3 value
  122056. */
  122057. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  122058. /**
  122059. * Interpolates a Color4 linearly
  122060. * @param startValue Start value of the animation curve
  122061. * @param endValue End value of the animation curve
  122062. * @param gradient Scalar amount to interpolate
  122063. * @returns Interpolated Color3 value
  122064. */
  122065. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  122066. /**
  122067. * @hidden Internal use only
  122068. */
  122069. _getKeyValue(value: any): any;
  122070. /**
  122071. * @hidden Internal use only
  122072. */
  122073. _interpolate(currentFrame: number, state: _IAnimationState): any;
  122074. /**
  122075. * Defines the function to use to interpolate matrices
  122076. * @param startValue defines the start matrix
  122077. * @param endValue defines the end matrix
  122078. * @param gradient defines the gradient between both matrices
  122079. * @param result defines an optional target matrix where to store the interpolation
  122080. * @returns the interpolated matrix
  122081. */
  122082. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  122083. /**
  122084. * Makes a copy of the animation
  122085. * @returns Cloned animation
  122086. */
  122087. clone(): Animation;
  122088. /**
  122089. * Sets the key frames of the animation
  122090. * @param values The animation key frames to set
  122091. */
  122092. setKeys(values: Array<IAnimationKey>): void;
  122093. /**
  122094. * Serializes the animation to an object
  122095. * @returns Serialized object
  122096. */
  122097. serialize(): any;
  122098. /**
  122099. * Float animation type
  122100. */
  122101. static readonly ANIMATIONTYPE_FLOAT: number;
  122102. /**
  122103. * Vector3 animation type
  122104. */
  122105. static readonly ANIMATIONTYPE_VECTOR3: number;
  122106. /**
  122107. * Quaternion animation type
  122108. */
  122109. static readonly ANIMATIONTYPE_QUATERNION: number;
  122110. /**
  122111. * Matrix animation type
  122112. */
  122113. static readonly ANIMATIONTYPE_MATRIX: number;
  122114. /**
  122115. * Color3 animation type
  122116. */
  122117. static readonly ANIMATIONTYPE_COLOR3: number;
  122118. /**
  122119. * Color3 animation type
  122120. */
  122121. static readonly ANIMATIONTYPE_COLOR4: number;
  122122. /**
  122123. * Vector2 animation type
  122124. */
  122125. static readonly ANIMATIONTYPE_VECTOR2: number;
  122126. /**
  122127. * Size animation type
  122128. */
  122129. static readonly ANIMATIONTYPE_SIZE: number;
  122130. /**
  122131. * Relative Loop Mode
  122132. */
  122133. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  122134. /**
  122135. * Cycle Loop Mode
  122136. */
  122137. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  122138. /**
  122139. * Constant Loop Mode
  122140. */
  122141. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  122142. /** @hidden */
  122143. static _UniversalLerp(left: any, right: any, amount: number): any;
  122144. /**
  122145. * Parses an animation object and creates an animation
  122146. * @param parsedAnimation Parsed animation object
  122147. * @returns Animation object
  122148. */
  122149. static Parse(parsedAnimation: any): Animation;
  122150. /**
  122151. * Appends the serialized animations from the source animations
  122152. * @param source Source containing the animations
  122153. * @param destination Target to store the animations
  122154. */
  122155. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  122156. /**
  122157. * Creates a new animation or an array of animations from a snippet saved in a remote file
  122158. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  122159. * @param url defines the url to load from
  122160. * @returns a promise that will resolve to the new animation or an array of animations
  122161. */
  122162. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  122163. /**
  122164. * Creates an animation or an array of animations from a snippet saved by the Inspector
  122165. * @param snippetId defines the snippet to load
  122166. * @returns a promise that will resolve to the new animation or a new array of animations
  122167. */
  122168. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  122169. }
  122170. }
  122171. declare module BABYLON {
  122172. /**
  122173. * Interface containing an array of animations
  122174. */
  122175. export interface IAnimatable {
  122176. /**
  122177. * Array of animations
  122178. */
  122179. animations: Nullable<Array<Animation>>;
  122180. }
  122181. }
  122182. declare module BABYLON {
  122183. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  122184. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122185. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122186. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122187. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122188. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122189. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122190. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122191. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122192. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122193. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122194. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122195. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122196. /**
  122197. * Decorator used to define property that can be serialized as reference to a camera
  122198. * @param sourceName defines the name of the property to decorate
  122199. */
  122200. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  122201. /**
  122202. * Class used to help serialization objects
  122203. */
  122204. export class SerializationHelper {
  122205. /** @hidden */
  122206. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  122207. /** @hidden */
  122208. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  122209. /** @hidden */
  122210. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  122211. /** @hidden */
  122212. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  122213. /**
  122214. * Appends the serialized animations from the source animations
  122215. * @param source Source containing the animations
  122216. * @param destination Target to store the animations
  122217. */
  122218. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  122219. /**
  122220. * Static function used to serialized a specific entity
  122221. * @param entity defines the entity to serialize
  122222. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  122223. * @returns a JSON compatible object representing the serialization of the entity
  122224. */
  122225. static Serialize<T>(entity: T, serializationObject?: any): any;
  122226. /**
  122227. * Creates a new entity from a serialization data object
  122228. * @param creationFunction defines a function used to instanciated the new entity
  122229. * @param source defines the source serialization data
  122230. * @param scene defines the hosting scene
  122231. * @param rootUrl defines the root url for resources
  122232. * @returns a new entity
  122233. */
  122234. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  122235. /**
  122236. * Clones an object
  122237. * @param creationFunction defines the function used to instanciate the new object
  122238. * @param source defines the source object
  122239. * @returns the cloned object
  122240. */
  122241. static Clone<T>(creationFunction: () => T, source: T): T;
  122242. /**
  122243. * Instanciates a new object based on a source one (some data will be shared between both object)
  122244. * @param creationFunction defines the function used to instanciate the new object
  122245. * @param source defines the source object
  122246. * @returns the new object
  122247. */
  122248. static Instanciate<T>(creationFunction: () => T, source: T): T;
  122249. }
  122250. }
  122251. declare module BABYLON {
  122252. /**
  122253. * This is the base class of all the camera used in the application.
  122254. * @see https://doc.babylonjs.com/features/cameras
  122255. */
  122256. export class Camera extends Node {
  122257. /** @hidden */
  122258. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  122259. /**
  122260. * This is the default projection mode used by the cameras.
  122261. * It helps recreating a feeling of perspective and better appreciate depth.
  122262. * This is the best way to simulate real life cameras.
  122263. */
  122264. static readonly PERSPECTIVE_CAMERA: number;
  122265. /**
  122266. * This helps creating camera with an orthographic mode.
  122267. * 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.
  122268. */
  122269. static readonly ORTHOGRAPHIC_CAMERA: number;
  122270. /**
  122271. * This is the default FOV mode for perspective cameras.
  122272. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  122273. */
  122274. static readonly FOVMODE_VERTICAL_FIXED: number;
  122275. /**
  122276. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  122277. */
  122278. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  122279. /**
  122280. * This specifies ther is no need for a camera rig.
  122281. * Basically only one eye is rendered corresponding to the camera.
  122282. */
  122283. static readonly RIG_MODE_NONE: number;
  122284. /**
  122285. * Simulates a camera Rig with one blue eye and one red eye.
  122286. * This can be use with 3d blue and red glasses.
  122287. */
  122288. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  122289. /**
  122290. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  122291. */
  122292. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  122293. /**
  122294. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  122295. */
  122296. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  122297. /**
  122298. * Defines that both eyes of the camera will be rendered over under each other.
  122299. */
  122300. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  122301. /**
  122302. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  122303. */
  122304. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  122305. /**
  122306. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  122307. */
  122308. static readonly RIG_MODE_VR: number;
  122309. /**
  122310. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  122311. */
  122312. static readonly RIG_MODE_WEBVR: number;
  122313. /**
  122314. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  122315. */
  122316. static readonly RIG_MODE_CUSTOM: number;
  122317. /**
  122318. * Defines if by default attaching controls should prevent the default javascript event to continue.
  122319. */
  122320. static ForceAttachControlToAlwaysPreventDefault: boolean;
  122321. /**
  122322. * Define the input manager associated with the camera.
  122323. */
  122324. inputs: CameraInputsManager<Camera>;
  122325. /** @hidden */
  122326. _position: Vector3;
  122327. /**
  122328. * Define the current local position of the camera in the scene
  122329. */
  122330. get position(): Vector3;
  122331. set position(newPosition: Vector3);
  122332. protected _upVector: Vector3;
  122333. /**
  122334. * The vector the camera should consider as up.
  122335. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  122336. */
  122337. set upVector(vec: Vector3);
  122338. get upVector(): Vector3;
  122339. /**
  122340. * Define the current limit on the left side for an orthographic camera
  122341. * In scene unit
  122342. */
  122343. orthoLeft: Nullable<number>;
  122344. /**
  122345. * Define the current limit on the right side for an orthographic camera
  122346. * In scene unit
  122347. */
  122348. orthoRight: Nullable<number>;
  122349. /**
  122350. * Define the current limit on the bottom side for an orthographic camera
  122351. * In scene unit
  122352. */
  122353. orthoBottom: Nullable<number>;
  122354. /**
  122355. * Define the current limit on the top side for an orthographic camera
  122356. * In scene unit
  122357. */
  122358. orthoTop: Nullable<number>;
  122359. /**
  122360. * Field Of View is set in Radians. (default is 0.8)
  122361. */
  122362. fov: number;
  122363. /**
  122364. * Define the minimum distance the camera can see from.
  122365. * This is important to note that the depth buffer are not infinite and the closer it starts
  122366. * the more your scene might encounter depth fighting issue.
  122367. */
  122368. minZ: number;
  122369. /**
  122370. * Define the maximum distance the camera can see to.
  122371. * This is important to note that the depth buffer are not infinite and the further it end
  122372. * the more your scene might encounter depth fighting issue.
  122373. */
  122374. maxZ: number;
  122375. /**
  122376. * Define the default inertia of the camera.
  122377. * This helps giving a smooth feeling to the camera movement.
  122378. */
  122379. inertia: number;
  122380. /**
  122381. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  122382. */
  122383. mode: number;
  122384. /**
  122385. * Define whether the camera is intermediate.
  122386. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  122387. */
  122388. isIntermediate: boolean;
  122389. /**
  122390. * Define the viewport of the camera.
  122391. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  122392. */
  122393. viewport: Viewport;
  122394. /**
  122395. * Restricts the camera to viewing objects with the same layerMask.
  122396. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  122397. */
  122398. layerMask: number;
  122399. /**
  122400. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  122401. */
  122402. fovMode: number;
  122403. /**
  122404. * Rig mode of the camera.
  122405. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  122406. * This is normally controlled byt the camera themselves as internal use.
  122407. */
  122408. cameraRigMode: number;
  122409. /**
  122410. * Defines the distance between both "eyes" in case of a RIG
  122411. */
  122412. interaxialDistance: number;
  122413. /**
  122414. * Defines if stereoscopic rendering is done side by side or over under.
  122415. */
  122416. isStereoscopicSideBySide: boolean;
  122417. /**
  122418. * 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
  122419. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  122420. * else in the scene. (Eg. security camera)
  122421. *
  122422. * 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)
  122423. */
  122424. customRenderTargets: RenderTargetTexture[];
  122425. /**
  122426. * When set, the camera will render to this render target instead of the default canvas
  122427. *
  122428. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  122429. */
  122430. outputRenderTarget: Nullable<RenderTargetTexture>;
  122431. /**
  122432. * Observable triggered when the camera view matrix has changed.
  122433. */
  122434. onViewMatrixChangedObservable: Observable<Camera>;
  122435. /**
  122436. * Observable triggered when the camera Projection matrix has changed.
  122437. */
  122438. onProjectionMatrixChangedObservable: Observable<Camera>;
  122439. /**
  122440. * Observable triggered when the inputs have been processed.
  122441. */
  122442. onAfterCheckInputsObservable: Observable<Camera>;
  122443. /**
  122444. * Observable triggered when reset has been called and applied to the camera.
  122445. */
  122446. onRestoreStateObservable: Observable<Camera>;
  122447. /**
  122448. * Is this camera a part of a rig system?
  122449. */
  122450. isRigCamera: boolean;
  122451. /**
  122452. * If isRigCamera set to true this will be set with the parent camera.
  122453. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  122454. */
  122455. rigParent?: Camera;
  122456. /** @hidden */
  122457. _cameraRigParams: any;
  122458. /** @hidden */
  122459. _rigCameras: Camera[];
  122460. /** @hidden */
  122461. _rigPostProcess: Nullable<PostProcess>;
  122462. protected _webvrViewMatrix: Matrix;
  122463. /** @hidden */
  122464. _skipRendering: boolean;
  122465. /** @hidden */
  122466. _projectionMatrix: Matrix;
  122467. /** @hidden */
  122468. _postProcesses: Nullable<PostProcess>[];
  122469. /** @hidden */
  122470. _activeMeshes: SmartArray<AbstractMesh>;
  122471. protected _globalPosition: Vector3;
  122472. /** @hidden */
  122473. _computedViewMatrix: Matrix;
  122474. private _doNotComputeProjectionMatrix;
  122475. private _transformMatrix;
  122476. private _frustumPlanes;
  122477. private _refreshFrustumPlanes;
  122478. private _storedFov;
  122479. private _stateStored;
  122480. /**
  122481. * Instantiates a new camera object.
  122482. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  122483. * @see https://doc.babylonjs.com/features/cameras
  122484. * @param name Defines the name of the camera in the scene
  122485. * @param position Defines the position of the camera
  122486. * @param scene Defines the scene the camera belongs too
  122487. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  122488. */
  122489. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  122490. /**
  122491. * Store current camera state (fov, position, etc..)
  122492. * @returns the camera
  122493. */
  122494. storeState(): Camera;
  122495. /**
  122496. * Restores the camera state values if it has been stored. You must call storeState() first
  122497. */
  122498. protected _restoreStateValues(): boolean;
  122499. /**
  122500. * Restored camera state. You must call storeState() first.
  122501. * @returns true if restored and false otherwise
  122502. */
  122503. restoreState(): boolean;
  122504. /**
  122505. * Gets the class name of the camera.
  122506. * @returns the class name
  122507. */
  122508. getClassName(): string;
  122509. /** @hidden */
  122510. readonly _isCamera: boolean;
  122511. /**
  122512. * Gets a string representation of the camera useful for debug purpose.
  122513. * @param fullDetails Defines that a more verboe level of logging is required
  122514. * @returns the string representation
  122515. */
  122516. toString(fullDetails?: boolean): string;
  122517. /**
  122518. * Gets the current world space position of the camera.
  122519. */
  122520. get globalPosition(): Vector3;
  122521. /**
  122522. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  122523. * @returns the active meshe list
  122524. */
  122525. getActiveMeshes(): SmartArray<AbstractMesh>;
  122526. /**
  122527. * Check whether a mesh is part of the current active mesh list of the camera
  122528. * @param mesh Defines the mesh to check
  122529. * @returns true if active, false otherwise
  122530. */
  122531. isActiveMesh(mesh: Mesh): boolean;
  122532. /**
  122533. * Is this camera ready to be used/rendered
  122534. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  122535. * @return true if the camera is ready
  122536. */
  122537. isReady(completeCheck?: boolean): boolean;
  122538. /** @hidden */
  122539. _initCache(): void;
  122540. /** @hidden */
  122541. _updateCache(ignoreParentClass?: boolean): void;
  122542. /** @hidden */
  122543. _isSynchronized(): boolean;
  122544. /** @hidden */
  122545. _isSynchronizedViewMatrix(): boolean;
  122546. /** @hidden */
  122547. _isSynchronizedProjectionMatrix(): boolean;
  122548. /**
  122549. * Attach the input controls to a specific dom element to get the input from.
  122550. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122551. */
  122552. attachControl(noPreventDefault?: boolean): void;
  122553. /**
  122554. * Attach the input controls to a specific dom element to get the input from.
  122555. * @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
  122556. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122557. * BACK COMPAT SIGNATURE ONLY.
  122558. */
  122559. attachControl(ignored: any, noPreventDefault?: boolean): void;
  122560. /**
  122561. * Detach the current controls from the specified dom element.
  122562. */
  122563. detachControl(): void;
  122564. /**
  122565. * Detach the current controls from the specified dom element.
  122566. * @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
  122567. */
  122568. detachControl(ignored: any): void;
  122569. /**
  122570. * Update the camera state according to the different inputs gathered during the frame.
  122571. */
  122572. update(): void;
  122573. /** @hidden */
  122574. _checkInputs(): void;
  122575. /** @hidden */
  122576. get rigCameras(): Camera[];
  122577. /**
  122578. * Gets the post process used by the rig cameras
  122579. */
  122580. get rigPostProcess(): Nullable<PostProcess>;
  122581. /**
  122582. * Internal, gets the first post proces.
  122583. * @returns the first post process to be run on this camera.
  122584. */
  122585. _getFirstPostProcess(): Nullable<PostProcess>;
  122586. private _cascadePostProcessesToRigCams;
  122587. /**
  122588. * Attach a post process to the camera.
  122589. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  122590. * @param postProcess The post process to attach to the camera
  122591. * @param insertAt The position of the post process in case several of them are in use in the scene
  122592. * @returns the position the post process has been inserted at
  122593. */
  122594. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  122595. /**
  122596. * Detach a post process to the camera.
  122597. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  122598. * @param postProcess The post process to detach from the camera
  122599. */
  122600. detachPostProcess(postProcess: PostProcess): void;
  122601. /**
  122602. * Gets the current world matrix of the camera
  122603. */
  122604. getWorldMatrix(): Matrix;
  122605. /** @hidden */
  122606. _getViewMatrix(): Matrix;
  122607. /**
  122608. * Gets the current view matrix of the camera.
  122609. * @param force forces the camera to recompute the matrix without looking at the cached state
  122610. * @returns the view matrix
  122611. */
  122612. getViewMatrix(force?: boolean): Matrix;
  122613. /**
  122614. * Freeze the projection matrix.
  122615. * It will prevent the cache check of the camera projection compute and can speed up perf
  122616. * if no parameter of the camera are meant to change
  122617. * @param projection Defines manually a projection if necessary
  122618. */
  122619. freezeProjectionMatrix(projection?: Matrix): void;
  122620. /**
  122621. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  122622. */
  122623. unfreezeProjectionMatrix(): void;
  122624. /**
  122625. * Gets the current projection matrix of the camera.
  122626. * @param force forces the camera to recompute the matrix without looking at the cached state
  122627. * @returns the projection matrix
  122628. */
  122629. getProjectionMatrix(force?: boolean): Matrix;
  122630. /**
  122631. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  122632. * @returns a Matrix
  122633. */
  122634. getTransformationMatrix(): Matrix;
  122635. private _updateFrustumPlanes;
  122636. /**
  122637. * Checks if a cullable object (mesh...) is in the camera frustum
  122638. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  122639. * @param target The object to check
  122640. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  122641. * @returns true if the object is in frustum otherwise false
  122642. */
  122643. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  122644. /**
  122645. * Checks if a cullable object (mesh...) is in the camera frustum
  122646. * Unlike isInFrustum this cheks the full bounding box
  122647. * @param target The object to check
  122648. * @returns true if the object is in frustum otherwise false
  122649. */
  122650. isCompletelyInFrustum(target: ICullable): boolean;
  122651. /**
  122652. * Gets a ray in the forward direction from the camera.
  122653. * @param length Defines the length of the ray to create
  122654. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  122655. * @param origin Defines the start point of the ray which defaults to the camera position
  122656. * @returns the forward ray
  122657. */
  122658. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  122659. /**
  122660. * Gets a ray in the forward direction from the camera.
  122661. * @param refRay the ray to (re)use when setting the values
  122662. * @param length Defines the length of the ray to create
  122663. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  122664. * @param origin Defines the start point of the ray which defaults to the camera position
  122665. * @returns the forward ray
  122666. */
  122667. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  122668. /**
  122669. * Releases resources associated with this node.
  122670. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  122671. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  122672. */
  122673. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  122674. /** @hidden */
  122675. _isLeftCamera: boolean;
  122676. /**
  122677. * Gets the left camera of a rig setup in case of Rigged Camera
  122678. */
  122679. get isLeftCamera(): boolean;
  122680. /** @hidden */
  122681. _isRightCamera: boolean;
  122682. /**
  122683. * Gets the right camera of a rig setup in case of Rigged Camera
  122684. */
  122685. get isRightCamera(): boolean;
  122686. /**
  122687. * Gets the left camera of a rig setup in case of Rigged Camera
  122688. */
  122689. get leftCamera(): Nullable<FreeCamera>;
  122690. /**
  122691. * Gets the right camera of a rig setup in case of Rigged Camera
  122692. */
  122693. get rightCamera(): Nullable<FreeCamera>;
  122694. /**
  122695. * Gets the left camera target of a rig setup in case of Rigged Camera
  122696. * @returns the target position
  122697. */
  122698. getLeftTarget(): Nullable<Vector3>;
  122699. /**
  122700. * Gets the right camera target of a rig setup in case of Rigged Camera
  122701. * @returns the target position
  122702. */
  122703. getRightTarget(): Nullable<Vector3>;
  122704. /**
  122705. * @hidden
  122706. */
  122707. setCameraRigMode(mode: number, rigParams: any): void;
  122708. /** @hidden */
  122709. static _setStereoscopicRigMode(camera: Camera): void;
  122710. /** @hidden */
  122711. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  122712. /** @hidden */
  122713. static _setVRRigMode(camera: Camera, rigParams: any): void;
  122714. /** @hidden */
  122715. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  122716. /** @hidden */
  122717. _getVRProjectionMatrix(): Matrix;
  122718. protected _updateCameraRotationMatrix(): void;
  122719. protected _updateWebVRCameraRotationMatrix(): void;
  122720. /**
  122721. * This function MUST be overwritten by the different WebVR cameras available.
  122722. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  122723. * @hidden
  122724. */
  122725. _getWebVRProjectionMatrix(): Matrix;
  122726. /**
  122727. * This function MUST be overwritten by the different WebVR cameras available.
  122728. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  122729. * @hidden
  122730. */
  122731. _getWebVRViewMatrix(): Matrix;
  122732. /** @hidden */
  122733. setCameraRigParameter(name: string, value: any): void;
  122734. /**
  122735. * needs to be overridden by children so sub has required properties to be copied
  122736. * @hidden
  122737. */
  122738. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  122739. /**
  122740. * May need to be overridden by children
  122741. * @hidden
  122742. */
  122743. _updateRigCameras(): void;
  122744. /** @hidden */
  122745. _setupInputs(): void;
  122746. /**
  122747. * Serialiaze the camera setup to a json represention
  122748. * @returns the JSON representation
  122749. */
  122750. serialize(): any;
  122751. /**
  122752. * Clones the current camera.
  122753. * @param name The cloned camera name
  122754. * @returns the cloned camera
  122755. */
  122756. clone(name: string): Camera;
  122757. /**
  122758. * Gets the direction of the camera relative to a given local axis.
  122759. * @param localAxis Defines the reference axis to provide a relative direction.
  122760. * @return the direction
  122761. */
  122762. getDirection(localAxis: Vector3): Vector3;
  122763. /**
  122764. * Returns the current camera absolute rotation
  122765. */
  122766. get absoluteRotation(): Quaternion;
  122767. /**
  122768. * Gets the direction of the camera relative to a given local axis into a passed vector.
  122769. * @param localAxis Defines the reference axis to provide a relative direction.
  122770. * @param result Defines the vector to store the result in
  122771. */
  122772. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  122773. /**
  122774. * Gets a camera constructor for a given camera type
  122775. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  122776. * @param name The name of the camera the result will be able to instantiate
  122777. * @param scene The scene the result will construct the camera in
  122778. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  122779. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  122780. * @returns a factory method to construc the camera
  122781. */
  122782. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  122783. /**
  122784. * Compute the world matrix of the camera.
  122785. * @returns the camera world matrix
  122786. */
  122787. computeWorldMatrix(): Matrix;
  122788. /**
  122789. * Parse a JSON and creates the camera from the parsed information
  122790. * @param parsedCamera The JSON to parse
  122791. * @param scene The scene to instantiate the camera in
  122792. * @returns the newly constructed camera
  122793. */
  122794. static Parse(parsedCamera: any, scene: Scene): Camera;
  122795. }
  122796. }
  122797. declare module BABYLON {
  122798. /**
  122799. * PostProcessManager is used to manage one or more post processes or post process pipelines
  122800. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  122801. */
  122802. export class PostProcessManager {
  122803. private _scene;
  122804. private _indexBuffer;
  122805. private _vertexBuffers;
  122806. /**
  122807. * Creates a new instance PostProcess
  122808. * @param scene The scene that the post process is associated with.
  122809. */
  122810. constructor(scene: Scene);
  122811. private _prepareBuffers;
  122812. private _buildIndexBuffer;
  122813. /**
  122814. * Rebuilds the vertex buffers of the manager.
  122815. * @hidden
  122816. */
  122817. _rebuild(): void;
  122818. /**
  122819. * Prepares a frame to be run through a post process.
  122820. * @param sourceTexture The input texture to the post procesess. (default: null)
  122821. * @param postProcesses An array of post processes to be run. (default: null)
  122822. * @returns True if the post processes were able to be run.
  122823. * @hidden
  122824. */
  122825. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  122826. /**
  122827. * Manually render a set of post processes to a texture.
  122828. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  122829. * @param postProcesses An array of post processes to be run.
  122830. * @param targetTexture The target texture to render to.
  122831. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  122832. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  122833. * @param lodLevel defines which lod of the texture to render to
  122834. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  122835. */
  122836. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  122837. /**
  122838. * Finalize the result of the output of the postprocesses.
  122839. * @param doNotPresent If true the result will not be displayed to the screen.
  122840. * @param targetTexture The target texture to render to.
  122841. * @param faceIndex The index of the face to bind the target texture to.
  122842. * @param postProcesses The array of post processes to render.
  122843. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  122844. * @hidden
  122845. */
  122846. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  122847. /**
  122848. * Disposes of the post process manager.
  122849. */
  122850. dispose(): void;
  122851. }
  122852. }
  122853. declare module BABYLON {
  122854. /**
  122855. * This Helps creating a texture that will be created from a camera in your scene.
  122856. * It is basically a dynamic texture that could be used to create special effects for instance.
  122857. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  122858. */
  122859. export class RenderTargetTexture extends Texture {
  122860. /**
  122861. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  122862. */
  122863. static readonly REFRESHRATE_RENDER_ONCE: number;
  122864. /**
  122865. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  122866. */
  122867. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  122868. /**
  122869. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  122870. * the central point of your effect and can save a lot of performances.
  122871. */
  122872. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  122873. /**
  122874. * Use this predicate to dynamically define the list of mesh you want to render.
  122875. * If set, the renderList property will be overwritten.
  122876. */
  122877. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  122878. private _renderList;
  122879. /**
  122880. * Use this list to define the list of mesh you want to render.
  122881. */
  122882. get renderList(): Nullable<Array<AbstractMesh>>;
  122883. set renderList(value: Nullable<Array<AbstractMesh>>);
  122884. /**
  122885. * Use this function to overload the renderList array at rendering time.
  122886. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  122887. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  122888. * the cube (if the RTT is a cube, else layerOrFace=0).
  122889. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  122890. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  122891. * hold dummy elements!
  122892. */
  122893. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  122894. private _hookArray;
  122895. /**
  122896. * Define if particles should be rendered in your texture.
  122897. */
  122898. renderParticles: boolean;
  122899. /**
  122900. * Define if sprites should be rendered in your texture.
  122901. */
  122902. renderSprites: boolean;
  122903. /**
  122904. * Define the camera used to render the texture.
  122905. */
  122906. activeCamera: Nullable<Camera>;
  122907. /**
  122908. * Override the mesh isReady function with your own one.
  122909. */
  122910. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  122911. /**
  122912. * Override the render function of the texture with your own one.
  122913. */
  122914. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  122915. /**
  122916. * Define if camera post processes should be use while rendering the texture.
  122917. */
  122918. useCameraPostProcesses: boolean;
  122919. /**
  122920. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  122921. */
  122922. ignoreCameraViewport: boolean;
  122923. private _postProcessManager;
  122924. private _postProcesses;
  122925. private _resizeObserver;
  122926. /**
  122927. * An event triggered when the texture is unbind.
  122928. */
  122929. onBeforeBindObservable: Observable<RenderTargetTexture>;
  122930. /**
  122931. * An event triggered when the texture is unbind.
  122932. */
  122933. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  122934. private _onAfterUnbindObserver;
  122935. /**
  122936. * Set a after unbind callback in the texture.
  122937. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  122938. */
  122939. set onAfterUnbind(callback: () => void);
  122940. /**
  122941. * An event triggered before rendering the texture
  122942. */
  122943. onBeforeRenderObservable: Observable<number>;
  122944. private _onBeforeRenderObserver;
  122945. /**
  122946. * Set a before render callback in the texture.
  122947. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  122948. */
  122949. set onBeforeRender(callback: (faceIndex: number) => void);
  122950. /**
  122951. * An event triggered after rendering the texture
  122952. */
  122953. onAfterRenderObservable: Observable<number>;
  122954. private _onAfterRenderObserver;
  122955. /**
  122956. * Set a after render callback in the texture.
  122957. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  122958. */
  122959. set onAfterRender(callback: (faceIndex: number) => void);
  122960. /**
  122961. * An event triggered after the texture clear
  122962. */
  122963. onClearObservable: Observable<Engine>;
  122964. private _onClearObserver;
  122965. /**
  122966. * Set a clear callback in the texture.
  122967. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  122968. */
  122969. set onClear(callback: (Engine: Engine) => void);
  122970. /**
  122971. * An event triggered when the texture is resized.
  122972. */
  122973. onResizeObservable: Observable<RenderTargetTexture>;
  122974. /**
  122975. * Define the clear color of the Render Target if it should be different from the scene.
  122976. */
  122977. clearColor: Color4;
  122978. protected _size: number | {
  122979. width: number;
  122980. height: number;
  122981. layers?: number;
  122982. };
  122983. protected _initialSizeParameter: number | {
  122984. width: number;
  122985. height: number;
  122986. } | {
  122987. ratio: number;
  122988. };
  122989. protected _sizeRatio: Nullable<number>;
  122990. /** @hidden */
  122991. _generateMipMaps: boolean;
  122992. protected _renderingManager: RenderingManager;
  122993. /** @hidden */
  122994. _waitingRenderList?: string[];
  122995. protected _doNotChangeAspectRatio: boolean;
  122996. protected _currentRefreshId: number;
  122997. protected _refreshRate: number;
  122998. protected _textureMatrix: Matrix;
  122999. protected _samples: number;
  123000. protected _renderTargetOptions: RenderTargetCreationOptions;
  123001. /**
  123002. * Gets render target creation options that were used.
  123003. */
  123004. get renderTargetOptions(): RenderTargetCreationOptions;
  123005. protected _onRatioRescale(): void;
  123006. /**
  123007. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  123008. * It must define where the camera used to render the texture is set
  123009. */
  123010. boundingBoxPosition: Vector3;
  123011. private _boundingBoxSize;
  123012. /**
  123013. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  123014. * When defined, the cubemap will switch to local mode
  123015. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  123016. * @example https://www.babylonjs-playground.com/#RNASML
  123017. */
  123018. set boundingBoxSize(value: Vector3);
  123019. get boundingBoxSize(): Vector3;
  123020. /**
  123021. * In case the RTT has been created with a depth texture, get the associated
  123022. * depth texture.
  123023. * Otherwise, return null.
  123024. */
  123025. get depthStencilTexture(): Nullable<InternalTexture>;
  123026. /**
  123027. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  123028. * or used a shadow, depth texture...
  123029. * @param name The friendly name of the texture
  123030. * @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)
  123031. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  123032. * @param generateMipMaps True if mip maps need to be generated after render.
  123033. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  123034. * @param type The type of the buffer in the RTT (int, half float, float...)
  123035. * @param isCube True if a cube texture needs to be created
  123036. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  123037. * @param generateDepthBuffer True to generate a depth buffer
  123038. * @param generateStencilBuffer True to generate a stencil buffer
  123039. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  123040. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  123041. * @param delayAllocation if the texture allocation should be delayed (default: false)
  123042. * @param samples sample count to use when creating the RTT
  123043. */
  123044. constructor(name: string, size: number | {
  123045. width: number;
  123046. height: number;
  123047. layers?: number;
  123048. } | {
  123049. ratio: number;
  123050. }, 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);
  123051. /**
  123052. * Creates a depth stencil texture.
  123053. * This is only available in WebGL 2 or with the depth texture extension available.
  123054. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  123055. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  123056. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  123057. * @param samples sample count of the depth/stencil texture
  123058. */
  123059. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean, samples?: number): void;
  123060. private _processSizeParameter;
  123061. /**
  123062. * Define the number of samples to use in case of MSAA.
  123063. * It defaults to one meaning no MSAA has been enabled.
  123064. */
  123065. get samples(): number;
  123066. set samples(value: number);
  123067. /**
  123068. * Resets the refresh counter of the texture and start bak from scratch.
  123069. * Could be useful to regenerate the texture if it is setup to render only once.
  123070. */
  123071. resetRefreshCounter(): void;
  123072. /**
  123073. * Define the refresh rate of the texture or the rendering frequency.
  123074. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  123075. */
  123076. get refreshRate(): number;
  123077. set refreshRate(value: number);
  123078. /**
  123079. * Adds a post process to the render target rendering passes.
  123080. * @param postProcess define the post process to add
  123081. */
  123082. addPostProcess(postProcess: PostProcess): void;
  123083. /**
  123084. * Clear all the post processes attached to the render target
  123085. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  123086. */
  123087. clearPostProcesses(dispose?: boolean): void;
  123088. /**
  123089. * Remove one of the post process from the list of attached post processes to the texture
  123090. * @param postProcess define the post process to remove from the list
  123091. */
  123092. removePostProcess(postProcess: PostProcess): void;
  123093. /** @hidden */
  123094. _shouldRender(): boolean;
  123095. /**
  123096. * Gets the actual render size of the texture.
  123097. * @returns the width of the render size
  123098. */
  123099. getRenderSize(): number;
  123100. /**
  123101. * Gets the actual render width of the texture.
  123102. * @returns the width of the render size
  123103. */
  123104. getRenderWidth(): number;
  123105. /**
  123106. * Gets the actual render height of the texture.
  123107. * @returns the height of the render size
  123108. */
  123109. getRenderHeight(): number;
  123110. /**
  123111. * Gets the actual number of layers of the texture.
  123112. * @returns the number of layers
  123113. */
  123114. getRenderLayers(): number;
  123115. /**
  123116. * Get if the texture can be rescaled or not.
  123117. */
  123118. get canRescale(): boolean;
  123119. /**
  123120. * Resize the texture using a ratio.
  123121. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  123122. */
  123123. scale(ratio: number): void;
  123124. /**
  123125. * Get the texture reflection matrix used to rotate/transform the reflection.
  123126. * @returns the reflection matrix
  123127. */
  123128. getReflectionTextureMatrix(): Matrix;
  123129. /**
  123130. * Resize the texture to a new desired size.
  123131. * Be carrefull as it will recreate all the data in the new texture.
  123132. * @param size Define the new size. It can be:
  123133. * - a number for squared texture,
  123134. * - an object containing { width: number, height: number }
  123135. * - or an object containing a ratio { ratio: number }
  123136. */
  123137. resize(size: number | {
  123138. width: number;
  123139. height: number;
  123140. } | {
  123141. ratio: number;
  123142. }): void;
  123143. private _defaultRenderListPrepared;
  123144. /**
  123145. * Renders all the objects from the render list into the texture.
  123146. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  123147. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  123148. */
  123149. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  123150. private _bestReflectionRenderTargetDimension;
  123151. private _prepareRenderingManager;
  123152. /**
  123153. * @hidden
  123154. * @param faceIndex face index to bind to if this is a cubetexture
  123155. * @param layer defines the index of the texture to bind in the array
  123156. */
  123157. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  123158. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  123159. private renderToTarget;
  123160. /**
  123161. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  123162. * This allowed control for front to back rendering or reversly depending of the special needs.
  123163. *
  123164. * @param renderingGroupId The rendering group id corresponding to its index
  123165. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  123166. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  123167. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  123168. */
  123169. 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;
  123170. /**
  123171. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  123172. *
  123173. * @param renderingGroupId The rendering group id corresponding to its index
  123174. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  123175. */
  123176. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  123177. /**
  123178. * Clones the texture.
  123179. * @returns the cloned texture
  123180. */
  123181. clone(): RenderTargetTexture;
  123182. /**
  123183. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  123184. * @returns The JSON representation of the texture
  123185. */
  123186. serialize(): any;
  123187. /**
  123188. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  123189. */
  123190. disposeFramebufferObjects(): void;
  123191. /**
  123192. * Dispose the texture and release its associated resources.
  123193. */
  123194. dispose(): void;
  123195. /** @hidden */
  123196. _rebuild(): void;
  123197. /**
  123198. * Clear the info related to rendering groups preventing retention point in material dispose.
  123199. */
  123200. freeRenderingGroups(): void;
  123201. /**
  123202. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  123203. * @returns the view count
  123204. */
  123205. getViewCount(): number;
  123206. }
  123207. }
  123208. declare module BABYLON {
  123209. /**
  123210. * Options to be used when creating an effect.
  123211. */
  123212. export interface IEffectCreationOptions {
  123213. /**
  123214. * Atrributes that will be used in the shader.
  123215. */
  123216. attributes: string[];
  123217. /**
  123218. * Uniform varible names that will be set in the shader.
  123219. */
  123220. uniformsNames: string[];
  123221. /**
  123222. * Uniform buffer variable names that will be set in the shader.
  123223. */
  123224. uniformBuffersNames: string[];
  123225. /**
  123226. * Sampler texture variable names that will be set in the shader.
  123227. */
  123228. samplers: string[];
  123229. /**
  123230. * Define statements that will be set in the shader.
  123231. */
  123232. defines: any;
  123233. /**
  123234. * Possible fallbacks for this effect to improve performance when needed.
  123235. */
  123236. fallbacks: Nullable<IEffectFallbacks>;
  123237. /**
  123238. * Callback that will be called when the shader is compiled.
  123239. */
  123240. onCompiled: Nullable<(effect: Effect) => void>;
  123241. /**
  123242. * Callback that will be called if an error occurs during shader compilation.
  123243. */
  123244. onError: Nullable<(effect: Effect, errors: string) => void>;
  123245. /**
  123246. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  123247. */
  123248. indexParameters?: any;
  123249. /**
  123250. * Max number of lights that can be used in the shader.
  123251. */
  123252. maxSimultaneousLights?: number;
  123253. /**
  123254. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  123255. */
  123256. transformFeedbackVaryings?: Nullable<string[]>;
  123257. /**
  123258. * 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
  123259. */
  123260. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  123261. /**
  123262. * Is this effect rendering to several color attachments ?
  123263. */
  123264. multiTarget?: boolean;
  123265. }
  123266. /**
  123267. * Effect containing vertex and fragment shader that can be executed on an object.
  123268. */
  123269. export class Effect implements IDisposable {
  123270. /**
  123271. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  123272. */
  123273. static ShadersRepository: string;
  123274. /**
  123275. * Enable logging of the shader code when a compilation error occurs
  123276. */
  123277. static LogShaderCodeOnCompilationError: boolean;
  123278. /**
  123279. * Name of the effect.
  123280. */
  123281. name: any;
  123282. /**
  123283. * String container all the define statements that should be set on the shader.
  123284. */
  123285. defines: string;
  123286. /**
  123287. * Callback that will be called when the shader is compiled.
  123288. */
  123289. onCompiled: Nullable<(effect: Effect) => void>;
  123290. /**
  123291. * Callback that will be called if an error occurs during shader compilation.
  123292. */
  123293. onError: Nullable<(effect: Effect, errors: string) => void>;
  123294. /**
  123295. * Callback that will be called when effect is bound.
  123296. */
  123297. onBind: Nullable<(effect: Effect) => void>;
  123298. /**
  123299. * Unique ID of the effect.
  123300. */
  123301. uniqueId: number;
  123302. /**
  123303. * Observable that will be called when the shader is compiled.
  123304. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  123305. */
  123306. onCompileObservable: Observable<Effect>;
  123307. /**
  123308. * Observable that will be called if an error occurs during shader compilation.
  123309. */
  123310. onErrorObservable: Observable<Effect>;
  123311. /** @hidden */
  123312. _onBindObservable: Nullable<Observable<Effect>>;
  123313. /**
  123314. * @hidden
  123315. * Specifies if the effect was previously ready
  123316. */
  123317. _wasPreviouslyReady: boolean;
  123318. /**
  123319. * Observable that will be called when effect is bound.
  123320. */
  123321. get onBindObservable(): Observable<Effect>;
  123322. /** @hidden */
  123323. _bonesComputationForcedToCPU: boolean;
  123324. /** @hidden */
  123325. _uniformBuffersNames: {
  123326. [key: string]: number;
  123327. };
  123328. /** @hidden */
  123329. _samplerList: string[];
  123330. /** @hidden */
  123331. _multiTarget: boolean;
  123332. private static _uniqueIdSeed;
  123333. private _engine;
  123334. private _uniformBuffersNamesList;
  123335. private _uniformsNames;
  123336. private _samplers;
  123337. private _isReady;
  123338. private _compilationError;
  123339. private _allFallbacksProcessed;
  123340. private _attributesNames;
  123341. private _attributes;
  123342. private _attributeLocationByName;
  123343. private _uniforms;
  123344. /**
  123345. * Key for the effect.
  123346. * @hidden
  123347. */
  123348. _key: string;
  123349. private _indexParameters;
  123350. private _fallbacks;
  123351. private _vertexSourceCodeOverride;
  123352. private _fragmentSourceCodeOverride;
  123353. private _transformFeedbackVaryings;
  123354. /**
  123355. * Compiled shader to webGL program.
  123356. * @hidden
  123357. */
  123358. _pipelineContext: Nullable<IPipelineContext>;
  123359. /** @hidden */
  123360. _vertexSourceCode: string;
  123361. /** @hidden */
  123362. _fragmentSourceCode: string;
  123363. /** @hidden */
  123364. private _rawVertexSourceCode;
  123365. /** @hidden */
  123366. private _rawFragmentSourceCode;
  123367. private static _baseCache;
  123368. private _processingContext;
  123369. /**
  123370. * Instantiates an effect.
  123371. * An effect can be used to create/manage/execute vertex and fragment shaders.
  123372. * @param baseName Name of the effect.
  123373. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  123374. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  123375. * @param samplers List of sampler variables that will be passed to the shader.
  123376. * @param engine Engine to be used to render the effect
  123377. * @param defines Define statements to be added to the shader.
  123378. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  123379. * @param onCompiled Callback that will be called when the shader is compiled.
  123380. * @param onError Callback that will be called if an error occurs during shader compilation.
  123381. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  123382. * @param key Effect Key identifying uniquely compiled shader variants
  123383. */
  123384. 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);
  123385. private _useFinalCode;
  123386. /**
  123387. * Unique key for this effect
  123388. */
  123389. get key(): string;
  123390. /**
  123391. * If the effect has been compiled and prepared.
  123392. * @returns if the effect is compiled and prepared.
  123393. */
  123394. isReady(): boolean;
  123395. private _isReadyInternal;
  123396. /**
  123397. * The engine the effect was initialized with.
  123398. * @returns the engine.
  123399. */
  123400. getEngine(): Engine;
  123401. /**
  123402. * The pipeline context for this effect
  123403. * @returns the associated pipeline context
  123404. */
  123405. getPipelineContext(): Nullable<IPipelineContext>;
  123406. /**
  123407. * The set of names of attribute variables for the shader.
  123408. * @returns An array of attribute names.
  123409. */
  123410. getAttributesNames(): string[];
  123411. /**
  123412. * Returns the attribute at the given index.
  123413. * @param index The index of the attribute.
  123414. * @returns The location of the attribute.
  123415. */
  123416. getAttributeLocation(index: number): number;
  123417. /**
  123418. * Returns the attribute based on the name of the variable.
  123419. * @param name of the attribute to look up.
  123420. * @returns the attribute location.
  123421. */
  123422. getAttributeLocationByName(name: string): number;
  123423. /**
  123424. * The number of attributes.
  123425. * @returns the numnber of attributes.
  123426. */
  123427. getAttributesCount(): number;
  123428. /**
  123429. * Gets the index of a uniform variable.
  123430. * @param uniformName of the uniform to look up.
  123431. * @returns the index.
  123432. */
  123433. getUniformIndex(uniformName: string): number;
  123434. /**
  123435. * Returns the attribute based on the name of the variable.
  123436. * @param uniformName of the uniform to look up.
  123437. * @returns the location of the uniform.
  123438. */
  123439. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  123440. /**
  123441. * Returns an array of sampler variable names
  123442. * @returns The array of sampler variable names.
  123443. */
  123444. getSamplers(): string[];
  123445. /**
  123446. * Returns an array of uniform variable names
  123447. * @returns The array of uniform variable names.
  123448. */
  123449. getUniformNames(): string[];
  123450. /**
  123451. * Returns an array of uniform buffer variable names
  123452. * @returns The array of uniform buffer variable names.
  123453. */
  123454. getUniformBuffersNames(): string[];
  123455. /**
  123456. * Returns the index parameters used to create the effect
  123457. * @returns The index parameters object
  123458. */
  123459. getIndexParameters(): any;
  123460. /**
  123461. * The error from the last compilation.
  123462. * @returns the error string.
  123463. */
  123464. getCompilationError(): string;
  123465. /**
  123466. * Gets a boolean indicating that all fallbacks were used during compilation
  123467. * @returns true if all fallbacks were used
  123468. */
  123469. allFallbacksProcessed(): boolean;
  123470. /**
  123471. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  123472. * @param func The callback to be used.
  123473. */
  123474. executeWhenCompiled(func: (effect: Effect) => void): void;
  123475. private _checkIsReady;
  123476. private _loadShader;
  123477. /**
  123478. * Gets the vertex shader source code of this effect
  123479. */
  123480. get vertexSourceCode(): string;
  123481. /**
  123482. * Gets the fragment shader source code of this effect
  123483. */
  123484. get fragmentSourceCode(): string;
  123485. /**
  123486. * Gets the vertex shader source code before it has been processed by the preprocessor
  123487. */
  123488. get rawVertexSourceCode(): string;
  123489. /**
  123490. * Gets the fragment shader source code before it has been processed by the preprocessor
  123491. */
  123492. get rawFragmentSourceCode(): string;
  123493. /**
  123494. * Recompiles the webGL program
  123495. * @param vertexSourceCode The source code for the vertex shader.
  123496. * @param fragmentSourceCode The source code for the fragment shader.
  123497. * @param onCompiled Callback called when completed.
  123498. * @param onError Callback called on error.
  123499. * @hidden
  123500. */
  123501. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  123502. /**
  123503. * Prepares the effect
  123504. * @hidden
  123505. */
  123506. _prepareEffect(): void;
  123507. private _getShaderCodeAndErrorLine;
  123508. private _processCompilationErrors;
  123509. /**
  123510. * Checks if the effect is supported. (Must be called after compilation)
  123511. */
  123512. get isSupported(): boolean;
  123513. /**
  123514. * Binds a texture to the engine to be used as output of the shader.
  123515. * @param channel Name of the output variable.
  123516. * @param texture Texture to bind.
  123517. * @hidden
  123518. */
  123519. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  123520. /**
  123521. * Sets a texture on the engine to be used in the shader.
  123522. * @param channel Name of the sampler variable.
  123523. * @param texture Texture to set.
  123524. */
  123525. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  123526. /**
  123527. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  123528. * @param channel Name of the sampler variable.
  123529. * @param texture Texture to set.
  123530. */
  123531. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  123532. /**
  123533. * Sets an array of textures on the engine to be used in the shader.
  123534. * @param channel Name of the variable.
  123535. * @param textures Textures to set.
  123536. */
  123537. setTextureArray(channel: string, textures: ThinTexture[]): void;
  123538. /**
  123539. * 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)
  123540. * @param channel Name of the sampler variable.
  123541. * @param postProcess Post process to get the input texture from.
  123542. */
  123543. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  123544. /**
  123545. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  123546. * 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)
  123547. * @param channel Name of the sampler variable.
  123548. * @param postProcess Post process to get the output texture from.
  123549. */
  123550. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  123551. /**
  123552. * Binds a buffer to a uniform.
  123553. * @param buffer Buffer to bind.
  123554. * @param name Name of the uniform variable to bind to.
  123555. */
  123556. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  123557. /**
  123558. * Binds block to a uniform.
  123559. * @param blockName Name of the block to bind.
  123560. * @param index Index to bind.
  123561. */
  123562. bindUniformBlock(blockName: string, index: number): void;
  123563. /**
  123564. * Sets an interger value on a uniform variable.
  123565. * @param uniformName Name of the variable.
  123566. * @param value Value to be set.
  123567. * @returns this effect.
  123568. */
  123569. setInt(uniformName: string, value: number): Effect;
  123570. /**
  123571. * Sets an int2 value on a uniform variable.
  123572. * @param uniformName Name of the variable.
  123573. * @param x First int in int2.
  123574. * @param y Second int in int2.
  123575. * @returns this effect.
  123576. */
  123577. setInt2(uniformName: string, x: number, y: number): Effect;
  123578. /**
  123579. * Sets an int3 value on a uniform variable.
  123580. * @param uniformName Name of the variable.
  123581. * @param x First int in int3.
  123582. * @param y Second int in int3.
  123583. * @param z Third int in int3.
  123584. * @returns this effect.
  123585. */
  123586. setInt3(uniformName: string, x: number, y: number, z: number): Effect;
  123587. /**
  123588. * Sets an int4 value on a uniform variable.
  123589. * @param uniformName Name of the variable.
  123590. * @param x First int in int4.
  123591. * @param y Second int in int4.
  123592. * @param z Third int in int4.
  123593. * @param w Fourth int in int4.
  123594. * @returns this effect.
  123595. */
  123596. setInt4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  123597. /**
  123598. * Sets an int array on a uniform variable.
  123599. * @param uniformName Name of the variable.
  123600. * @param array array to be set.
  123601. * @returns this effect.
  123602. */
  123603. setIntArray(uniformName: string, array: Int32Array): Effect;
  123604. /**
  123605. * 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)
  123606. * @param uniformName Name of the variable.
  123607. * @param array array to be set.
  123608. * @returns this effect.
  123609. */
  123610. setIntArray2(uniformName: string, array: Int32Array): Effect;
  123611. /**
  123612. * 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)
  123613. * @param uniformName Name of the variable.
  123614. * @param array array to be set.
  123615. * @returns this effect.
  123616. */
  123617. setIntArray3(uniformName: string, array: Int32Array): Effect;
  123618. /**
  123619. * 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)
  123620. * @param uniformName Name of the variable.
  123621. * @param array array to be set.
  123622. * @returns this effect.
  123623. */
  123624. setIntArray4(uniformName: string, array: Int32Array): Effect;
  123625. /**
  123626. * Sets an float array on a uniform variable.
  123627. * @param uniformName Name of the variable.
  123628. * @param array array to be set.
  123629. * @returns this effect.
  123630. */
  123631. setFloatArray(uniformName: string, array: FloatArray): Effect;
  123632. /**
  123633. * 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)
  123634. * @param uniformName Name of the variable.
  123635. * @param array array to be set.
  123636. * @returns this effect.
  123637. */
  123638. setFloatArray2(uniformName: string, array: FloatArray): Effect;
  123639. /**
  123640. * 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)
  123641. * @param uniformName Name of the variable.
  123642. * @param array array to be set.
  123643. * @returns this effect.
  123644. */
  123645. setFloatArray3(uniformName: string, array: FloatArray): Effect;
  123646. /**
  123647. * 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)
  123648. * @param uniformName Name of the variable.
  123649. * @param array array to be set.
  123650. * @returns this effect.
  123651. */
  123652. setFloatArray4(uniformName: string, array: FloatArray): Effect;
  123653. /**
  123654. * Sets an array on a uniform variable.
  123655. * @param uniformName Name of the variable.
  123656. * @param array array to be set.
  123657. * @returns this effect.
  123658. */
  123659. setArray(uniformName: string, array: number[]): Effect;
  123660. /**
  123661. * 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)
  123662. * @param uniformName Name of the variable.
  123663. * @param array array to be set.
  123664. * @returns this effect.
  123665. */
  123666. setArray2(uniformName: string, array: number[]): Effect;
  123667. /**
  123668. * 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)
  123669. * @param uniformName Name of the variable.
  123670. * @param array array to be set.
  123671. * @returns this effect.
  123672. */
  123673. setArray3(uniformName: string, array: number[]): Effect;
  123674. /**
  123675. * 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)
  123676. * @param uniformName Name of the variable.
  123677. * @param array array to be set.
  123678. * @returns this effect.
  123679. */
  123680. setArray4(uniformName: string, array: number[]): Effect;
  123681. /**
  123682. * Sets matrices on a uniform variable.
  123683. * @param uniformName Name of the variable.
  123684. * @param matrices matrices to be set.
  123685. * @returns this effect.
  123686. */
  123687. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  123688. /**
  123689. * Sets matrix on a uniform variable.
  123690. * @param uniformName Name of the variable.
  123691. * @param matrix matrix to be set.
  123692. * @returns this effect.
  123693. */
  123694. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  123695. /**
  123696. * 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)
  123697. * @param uniformName Name of the variable.
  123698. * @param matrix matrix to be set.
  123699. * @returns this effect.
  123700. */
  123701. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  123702. /**
  123703. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  123704. * @param uniformName Name of the variable.
  123705. * @param matrix matrix to be set.
  123706. * @returns this effect.
  123707. */
  123708. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  123709. /**
  123710. * Sets a float on a uniform variable.
  123711. * @param uniformName Name of the variable.
  123712. * @param value value to be set.
  123713. * @returns this effect.
  123714. */
  123715. setFloat(uniformName: string, value: number): Effect;
  123716. /**
  123717. * Sets a boolean on a uniform variable.
  123718. * @param uniformName Name of the variable.
  123719. * @param bool value to be set.
  123720. * @returns this effect.
  123721. */
  123722. setBool(uniformName: string, bool: boolean): Effect;
  123723. /**
  123724. * Sets a Vector2 on a uniform variable.
  123725. * @param uniformName Name of the variable.
  123726. * @param vector2 vector2 to be set.
  123727. * @returns this effect.
  123728. */
  123729. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  123730. /**
  123731. * Sets a float2 on a uniform variable.
  123732. * @param uniformName Name of the variable.
  123733. * @param x First float in float2.
  123734. * @param y Second float in float2.
  123735. * @returns this effect.
  123736. */
  123737. setFloat2(uniformName: string, x: number, y: number): Effect;
  123738. /**
  123739. * Sets a Vector3 on a uniform variable.
  123740. * @param uniformName Name of the variable.
  123741. * @param vector3 Value to be set.
  123742. * @returns this effect.
  123743. */
  123744. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  123745. /**
  123746. * Sets a float3 on a uniform variable.
  123747. * @param uniformName Name of the variable.
  123748. * @param x First float in float3.
  123749. * @param y Second float in float3.
  123750. * @param z Third float in float3.
  123751. * @returns this effect.
  123752. */
  123753. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  123754. /**
  123755. * Sets a Vector4 on a uniform variable.
  123756. * @param uniformName Name of the variable.
  123757. * @param vector4 Value to be set.
  123758. * @returns this effect.
  123759. */
  123760. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  123761. /**
  123762. * Sets a float4 on a uniform variable.
  123763. * @param uniformName Name of the variable.
  123764. * @param x First float in float4.
  123765. * @param y Second float in float4.
  123766. * @param z Third float in float4.
  123767. * @param w Fourth float in float4.
  123768. * @returns this effect.
  123769. */
  123770. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  123771. /**
  123772. * Sets a Color3 on a uniform variable.
  123773. * @param uniformName Name of the variable.
  123774. * @param color3 Value to be set.
  123775. * @returns this effect.
  123776. */
  123777. setColor3(uniformName: string, color3: IColor3Like): Effect;
  123778. /**
  123779. * Sets a Color4 on a uniform variable.
  123780. * @param uniformName Name of the variable.
  123781. * @param color3 Value to be set.
  123782. * @param alpha Alpha value to be set.
  123783. * @returns this effect.
  123784. */
  123785. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  123786. /**
  123787. * Sets a Color4 on a uniform variable
  123788. * @param uniformName defines the name of the variable
  123789. * @param color4 defines the value to be set
  123790. * @returns this effect.
  123791. */
  123792. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  123793. /**
  123794. * Release all associated resources.
  123795. **/
  123796. dispose(): void;
  123797. /**
  123798. * This function will add a new shader to the shader store
  123799. * @param name the name of the shader
  123800. * @param pixelShader optional pixel shader content
  123801. * @param vertexShader optional vertex shader content
  123802. */
  123803. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  123804. /**
  123805. * Store of each shader (The can be looked up using effect.key)
  123806. */
  123807. static ShadersStore: {
  123808. [key: string]: string;
  123809. };
  123810. /**
  123811. * Store of each included file for a shader (The can be looked up using effect.key)
  123812. */
  123813. static IncludesShadersStore: {
  123814. [key: string]: string;
  123815. };
  123816. /**
  123817. * Resets the cache of effects.
  123818. */
  123819. static ResetCache(): void;
  123820. }
  123821. }
  123822. declare module BABYLON {
  123823. /**
  123824. * Interface used to describe the capabilities of the engine relatively to the current browser
  123825. */
  123826. export interface EngineCapabilities {
  123827. /** Maximum textures units per fragment shader */
  123828. maxTexturesImageUnits: number;
  123829. /** Maximum texture units per vertex shader */
  123830. maxVertexTextureImageUnits: number;
  123831. /** Maximum textures units in the entire pipeline */
  123832. maxCombinedTexturesImageUnits: number;
  123833. /** Maximum texture size */
  123834. maxTextureSize: number;
  123835. /** Maximum texture samples */
  123836. maxSamples?: number;
  123837. /** Maximum cube texture size */
  123838. maxCubemapTextureSize: number;
  123839. /** Maximum render texture size */
  123840. maxRenderTextureSize: number;
  123841. /** Maximum number of vertex attributes */
  123842. maxVertexAttribs: number;
  123843. /** Maximum number of varyings */
  123844. maxVaryingVectors: number;
  123845. /** Maximum number of uniforms per vertex shader */
  123846. maxVertexUniformVectors: number;
  123847. /** Maximum number of uniforms per fragment shader */
  123848. maxFragmentUniformVectors: number;
  123849. /** Defines if standard derivates (dx/dy) are supported */
  123850. standardDerivatives: boolean;
  123851. /** Defines if s3tc texture compression is supported */
  123852. s3tc?: WEBGL_compressed_texture_s3tc;
  123853. /** Defines if pvrtc texture compression is supported */
  123854. pvrtc: any;
  123855. /** Defines if etc1 texture compression is supported */
  123856. etc1: any;
  123857. /** Defines if etc2 texture compression is supported */
  123858. etc2: any;
  123859. /** Defines if astc texture compression is supported */
  123860. astc: any;
  123861. /** Defines if bptc texture compression is supported */
  123862. bptc: any;
  123863. /** Defines if float textures are supported */
  123864. textureFloat: boolean;
  123865. /** Defines if vertex array objects are supported */
  123866. vertexArrayObject: boolean;
  123867. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  123868. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  123869. /** Gets the maximum level of anisotropy supported */
  123870. maxAnisotropy: number;
  123871. /** Defines if instancing is supported */
  123872. instancedArrays: boolean;
  123873. /** Defines if 32 bits indices are supported */
  123874. uintIndices: boolean;
  123875. /** Defines if high precision shaders are supported */
  123876. highPrecisionShaderSupported: boolean;
  123877. /** Defines if depth reading in the fragment shader is supported */
  123878. fragmentDepthSupported: boolean;
  123879. /** Defines if float texture linear filtering is supported*/
  123880. textureFloatLinearFiltering: boolean;
  123881. /** Defines if rendering to float textures is supported */
  123882. textureFloatRender: boolean;
  123883. /** Defines if half float textures are supported*/
  123884. textureHalfFloat: boolean;
  123885. /** Defines if half float texture linear filtering is supported*/
  123886. textureHalfFloatLinearFiltering: boolean;
  123887. /** Defines if rendering to half float textures is supported */
  123888. textureHalfFloatRender: boolean;
  123889. /** Defines if textureLOD shader command is supported */
  123890. textureLOD: boolean;
  123891. /** Defines if draw buffers extension is supported */
  123892. drawBuffersExtension: boolean;
  123893. /** Defines if depth textures are supported */
  123894. depthTextureExtension: boolean;
  123895. /** Defines if float color buffer are supported */
  123896. colorBufferFloat: boolean;
  123897. /** Gets disjoint timer query extension (null if not supported) */
  123898. timerQuery?: EXT_disjoint_timer_query;
  123899. /** Defines if timestamp can be used with timer query */
  123900. canUseTimestampForTimerQuery: boolean;
  123901. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  123902. multiview?: any;
  123903. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  123904. oculusMultiview?: any;
  123905. /** Function used to let the system compiles shaders in background */
  123906. parallelShaderCompile?: {
  123907. COMPLETION_STATUS_KHR: number;
  123908. };
  123909. /** Max number of texture samples for MSAA */
  123910. maxMSAASamples: number;
  123911. /** Defines if the blend min max extension is supported */
  123912. blendMinMax: boolean;
  123913. /** 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 */
  123914. canUseGLInstanceID: boolean;
  123915. }
  123916. }
  123917. declare module BABYLON {
  123918. /**
  123919. * @hidden
  123920. **/
  123921. export class DepthCullingState {
  123922. private _isDepthTestDirty;
  123923. private _isDepthMaskDirty;
  123924. private _isDepthFuncDirty;
  123925. private _isCullFaceDirty;
  123926. private _isCullDirty;
  123927. private _isZOffsetDirty;
  123928. private _isFrontFaceDirty;
  123929. private _depthTest;
  123930. private _depthMask;
  123931. private _depthFunc;
  123932. private _cull;
  123933. private _cullFace;
  123934. private _zOffset;
  123935. private _frontFace;
  123936. /**
  123937. * Initializes the state.
  123938. */
  123939. constructor();
  123940. get isDirty(): boolean;
  123941. get zOffset(): number;
  123942. set zOffset(value: number);
  123943. get cullFace(): Nullable<number>;
  123944. set cullFace(value: Nullable<number>);
  123945. get cull(): Nullable<boolean>;
  123946. set cull(value: Nullable<boolean>);
  123947. get depthFunc(): Nullable<number>;
  123948. set depthFunc(value: Nullable<number>);
  123949. get depthMask(): boolean;
  123950. set depthMask(value: boolean);
  123951. get depthTest(): boolean;
  123952. set depthTest(value: boolean);
  123953. get frontFace(): Nullable<number>;
  123954. set frontFace(value: Nullable<number>);
  123955. reset(): void;
  123956. apply(gl: WebGLRenderingContext): void;
  123957. }
  123958. }
  123959. declare module BABYLON {
  123960. /**
  123961. * @hidden
  123962. **/
  123963. export class StencilState {
  123964. /** 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 */
  123965. static readonly ALWAYS: number;
  123966. /** Passed to stencilOperation to specify that stencil value must be kept */
  123967. static readonly KEEP: number;
  123968. /** Passed to stencilOperation to specify that stencil value must be replaced */
  123969. static readonly REPLACE: number;
  123970. private _isStencilTestDirty;
  123971. private _isStencilMaskDirty;
  123972. private _isStencilFuncDirty;
  123973. private _isStencilOpDirty;
  123974. private _stencilTest;
  123975. private _stencilMask;
  123976. private _stencilFunc;
  123977. private _stencilFuncRef;
  123978. private _stencilFuncMask;
  123979. private _stencilOpStencilFail;
  123980. private _stencilOpDepthFail;
  123981. private _stencilOpStencilDepthPass;
  123982. get isDirty(): boolean;
  123983. get stencilFunc(): number;
  123984. set stencilFunc(value: number);
  123985. get stencilFuncRef(): number;
  123986. set stencilFuncRef(value: number);
  123987. get stencilFuncMask(): number;
  123988. set stencilFuncMask(value: number);
  123989. get stencilOpStencilFail(): number;
  123990. set stencilOpStencilFail(value: number);
  123991. get stencilOpDepthFail(): number;
  123992. set stencilOpDepthFail(value: number);
  123993. get stencilOpStencilDepthPass(): number;
  123994. set stencilOpStencilDepthPass(value: number);
  123995. get stencilMask(): number;
  123996. set stencilMask(value: number);
  123997. get stencilTest(): boolean;
  123998. set stencilTest(value: boolean);
  123999. constructor();
  124000. reset(): void;
  124001. apply(gl: WebGLRenderingContext): void;
  124002. }
  124003. }
  124004. declare module BABYLON {
  124005. /**
  124006. * @hidden
  124007. **/
  124008. export class AlphaState {
  124009. _blendFunctionParameters: Nullable<number>[];
  124010. _blendEquationParameters: Nullable<number>[];
  124011. _blendConstants: Nullable<number>[];
  124012. _isBlendConstantsDirty: boolean;
  124013. private _alphaBlend;
  124014. private _isAlphaBlendDirty;
  124015. private _isBlendFunctionParametersDirty;
  124016. private _isBlendEquationParametersDirty;
  124017. /**
  124018. * Initializes the state.
  124019. */
  124020. constructor();
  124021. get isDirty(): boolean;
  124022. get alphaBlend(): boolean;
  124023. set alphaBlend(value: boolean);
  124024. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  124025. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  124026. setAlphaEquationParameters(rgb: number, alpha: number): void;
  124027. reset(): void;
  124028. apply(gl: WebGLRenderingContext): void;
  124029. }
  124030. }
  124031. declare module BABYLON {
  124032. /** @hidden */
  124033. export class WebGLShaderProcessor implements IShaderProcessor {
  124034. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  124035. }
  124036. }
  124037. declare module BABYLON {
  124038. /** @hidden */
  124039. export class WebGL2ShaderProcessor implements IShaderProcessor {
  124040. attributeProcessor(attribute: string): string;
  124041. varyingProcessor(varying: string, isFragment: boolean): string;
  124042. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  124043. }
  124044. }
  124045. declare module BABYLON {
  124046. /**
  124047. * Interface for attribute information associated with buffer instanciation
  124048. */
  124049. export interface InstancingAttributeInfo {
  124050. /**
  124051. * Name of the GLSL attribute
  124052. * if attribute index is not specified, this is used to retrieve the index from the effect
  124053. */
  124054. attributeName: string;
  124055. /**
  124056. * Index/offset of the attribute in the vertex shader
  124057. * if not specified, this will be computes from the name.
  124058. */
  124059. index?: number;
  124060. /**
  124061. * size of the attribute, 1, 2, 3 or 4
  124062. */
  124063. attributeSize: number;
  124064. /**
  124065. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  124066. */
  124067. offset: number;
  124068. /**
  124069. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  124070. * default to 1
  124071. */
  124072. divisor?: number;
  124073. /**
  124074. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  124075. * default is FLOAT
  124076. */
  124077. attributeType?: number;
  124078. /**
  124079. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  124080. */
  124081. normalized?: boolean;
  124082. }
  124083. }
  124084. declare module BABYLON {
  124085. /** @hidden */
  124086. export interface EngineFeatures {
  124087. /** Force using Bitmap when Bitmap or HTMLImageElement can be used */
  124088. forceBitmapOverHTMLImageElement: boolean;
  124089. /** Indicates that the engine support rendering to as well as copying to lod float textures */
  124090. supportRenderAndCopyToLodForFloatTextures: boolean;
  124091. /** Indicates that the engine support handling depth/stencil textures */
  124092. supportDepthStencilTexture: boolean;
  124093. /** Indicates that the engine support shadow samplers */
  124094. supportShadowSamplers: boolean;
  124095. /** 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 */
  124096. uniformBufferHardCheckMatrix: boolean;
  124097. /** Indicates that prefiltered mipmaps can be generated in some processes (for eg when loading an HDR cube texture) */
  124098. allowTexturePrefiltering: boolean;
  124099. /** Indicates to track the usage of ubos and to create new ones as necessary during a frame duration */
  124100. trackUbosInFrame: boolean;
  124101. /** Indicates that the Cascaded Shadow Map technic is supported */
  124102. supportCSM: boolean;
  124103. /** Indicates that the textures transcoded by the basis transcoder must have power of 2 width and height */
  124104. basisNeedsPOT: boolean;
  124105. /** Indicates that the engine supports 3D textures */
  124106. support3DTextures: boolean;
  124107. /** Indicates that constants need a type suffix in shaders (used by realtime filtering...) */
  124108. needTypeSuffixInShaderConstants: boolean;
  124109. /** Indicates that MSAA is supported */
  124110. supportMSAA: boolean;
  124111. /** Indicates that SSAO2 is supported */
  124112. supportSSAO2: boolean;
  124113. /** Indicates that some additional texture formats are supported (like TEXTUREFORMAT_R for eg) */
  124114. supportExtendedTextureFormats: boolean;
  124115. /** Indicates that the switch/case construct is supported in shaders */
  124116. supportSwitchCaseInShader: boolean;
  124117. /** @hidden */
  124118. _collectUbosUpdatedInFrame: boolean;
  124119. }
  124120. }
  124121. declare module BABYLON {
  124122. /** @hidden */
  124123. export class WebGLHardwareTexture implements HardwareTextureWrapper {
  124124. private _webGLTexture;
  124125. private _context;
  124126. get underlyingResource(): Nullable<WebGLTexture>;
  124127. constructor(existingTexture: WebGLTexture | null | undefined, context: WebGLRenderingContext);
  124128. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  124129. set(hardwareTexture: WebGLTexture): void;
  124130. reset(): void;
  124131. release(): void;
  124132. }
  124133. }
  124134. declare module BABYLON {
  124135. interface ThinEngine {
  124136. /**
  124137. * Update a video texture
  124138. * @param texture defines the texture to update
  124139. * @param video defines the video element to use
  124140. * @param invertY defines if data must be stored with Y axis inverted
  124141. */
  124142. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  124143. }
  124144. }
  124145. declare module BABYLON {
  124146. interface ThinEngine {
  124147. /**
  124148. * Creates a dynamic texture
  124149. * @param width defines the width of the texture
  124150. * @param height defines the height of the texture
  124151. * @param generateMipMaps defines if the engine should generate the mip levels
  124152. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  124153. * @returns the dynamic texture inside an InternalTexture
  124154. */
  124155. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  124156. /**
  124157. * Update the content of a dynamic texture
  124158. * @param texture defines the texture to update
  124159. * @param source defines the source containing the data
  124160. * @param invertY defines if data must be stored with Y axis inverted
  124161. * @param premulAlpha defines if alpha is stored as premultiplied
  124162. * @param format defines the format of the data
  124163. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  124164. */
  124165. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  124166. }
  124167. }
  124168. declare module BABYLON {
  124169. /**
  124170. * Settings for finer control over video usage
  124171. */
  124172. export interface VideoTextureSettings {
  124173. /**
  124174. * Applies `autoplay` to video, if specified
  124175. */
  124176. autoPlay?: boolean;
  124177. /**
  124178. * Applies `muted` to video, if specified
  124179. */
  124180. muted?: boolean;
  124181. /**
  124182. * Applies `loop` to video, if specified
  124183. */
  124184. loop?: boolean;
  124185. /**
  124186. * Automatically updates internal texture from video at every frame in the render loop
  124187. */
  124188. autoUpdateTexture: boolean;
  124189. /**
  124190. * Image src displayed during the video loading or until the user interacts with the video.
  124191. */
  124192. poster?: string;
  124193. }
  124194. /**
  124195. * If you want to display a video in your scene, this is the special texture for that.
  124196. * This special texture works similar to other textures, with the exception of a few parameters.
  124197. * @see https://doc.babylonjs.com/how_to/video_texture
  124198. */
  124199. export class VideoTexture extends Texture {
  124200. /**
  124201. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  124202. */
  124203. readonly autoUpdateTexture: boolean;
  124204. /**
  124205. * The video instance used by the texture internally
  124206. */
  124207. readonly video: HTMLVideoElement;
  124208. private _onUserActionRequestedObservable;
  124209. /**
  124210. * Event triggerd when a dom action is required by the user to play the video.
  124211. * This happens due to recent changes in browser policies preventing video to auto start.
  124212. */
  124213. get onUserActionRequestedObservable(): Observable<Texture>;
  124214. private _generateMipMaps;
  124215. private _stillImageCaptured;
  124216. private _displayingPosterTexture;
  124217. private _settings;
  124218. private _createInternalTextureOnEvent;
  124219. private _frameId;
  124220. private _currentSrc;
  124221. /**
  124222. * Creates a video texture.
  124223. * If you want to display a video in your scene, this is the special texture for that.
  124224. * This special texture works similar to other textures, with the exception of a few parameters.
  124225. * @see https://doc.babylonjs.com/how_to/video_texture
  124226. * @param name optional name, will detect from video source, if not defined
  124227. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  124228. * @param scene is obviously the current scene.
  124229. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  124230. * @param invertY is false by default but can be used to invert video on Y axis
  124231. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  124232. * @param settings allows finer control over video usage
  124233. */
  124234. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  124235. private _getName;
  124236. private _getVideo;
  124237. private _createInternalTexture;
  124238. private reset;
  124239. /**
  124240. * @hidden Internal method to initiate `update`.
  124241. */
  124242. _rebuild(): void;
  124243. /**
  124244. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  124245. */
  124246. update(): void;
  124247. /**
  124248. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  124249. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  124250. */
  124251. updateTexture(isVisible: boolean): void;
  124252. protected _updateInternalTexture: () => void;
  124253. /**
  124254. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  124255. * @param url New url.
  124256. */
  124257. updateURL(url: string): void;
  124258. /**
  124259. * Clones the texture.
  124260. * @returns the cloned texture
  124261. */
  124262. clone(): VideoTexture;
  124263. /**
  124264. * Dispose the texture and release its associated resources.
  124265. */
  124266. dispose(): void;
  124267. /**
  124268. * Creates a video texture straight from a stream.
  124269. * @param scene Define the scene the texture should be created in
  124270. * @param stream Define the stream the texture should be created from
  124271. * @returns The created video texture as a promise
  124272. */
  124273. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  124274. /**
  124275. * Creates a video texture straight from your WebCam video feed.
  124276. * @param scene Define the scene the texture should be created in
  124277. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  124278. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  124279. * @returns The created video texture as a promise
  124280. */
  124281. static CreateFromWebCamAsync(scene: Scene, constraints: {
  124282. minWidth: number;
  124283. maxWidth: number;
  124284. minHeight: number;
  124285. maxHeight: number;
  124286. deviceId: string;
  124287. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  124288. /**
  124289. * Creates a video texture straight from your WebCam video feed.
  124290. * @param scene Define the scene the texture should be created in
  124291. * @param onReady Define a callback to triggered once the texture will be ready
  124292. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  124293. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  124294. */
  124295. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  124296. minWidth: number;
  124297. maxWidth: number;
  124298. minHeight: number;
  124299. maxHeight: number;
  124300. deviceId: string;
  124301. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  124302. }
  124303. }
  124304. declare module BABYLON {
  124305. /**
  124306. * Defines the interface used by objects working like Scene
  124307. * @hidden
  124308. */
  124309. export interface ISceneLike {
  124310. _addPendingData(data: any): void;
  124311. _removePendingData(data: any): void;
  124312. offlineProvider: IOfflineProvider;
  124313. }
  124314. /**
  124315. * Information about the current host
  124316. */
  124317. export interface HostInformation {
  124318. /**
  124319. * Defines if the current host is a mobile
  124320. */
  124321. isMobile: boolean;
  124322. }
  124323. /** Interface defining initialization parameters for Engine class */
  124324. export interface EngineOptions extends WebGLContextAttributes {
  124325. /**
  124326. * Defines if the engine should no exceed a specified device ratio
  124327. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  124328. */
  124329. limitDeviceRatio?: number;
  124330. /**
  124331. * Defines if webvr should be enabled automatically
  124332. * @see https://doc.babylonjs.com/how_to/webvr_camera
  124333. */
  124334. autoEnableWebVR?: boolean;
  124335. /**
  124336. * Defines if webgl2 should be turned off even if supported
  124337. * @see https://doc.babylonjs.com/features/webgl2
  124338. */
  124339. disableWebGL2Support?: boolean;
  124340. /**
  124341. * Defines if webaudio should be initialized as well
  124342. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  124343. */
  124344. audioEngine?: boolean;
  124345. /**
  124346. * Defines if animations should run using a deterministic lock step
  124347. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  124348. */
  124349. deterministicLockstep?: boolean;
  124350. /** Defines the maximum steps to use with deterministic lock step mode */
  124351. lockstepMaxSteps?: number;
  124352. /** Defines the seconds between each deterministic lock step */
  124353. timeStep?: number;
  124354. /**
  124355. * Defines that engine should ignore context lost events
  124356. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  124357. */
  124358. doNotHandleContextLost?: boolean;
  124359. /**
  124360. * Defines that engine should ignore modifying touch action attribute and style
  124361. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  124362. */
  124363. doNotHandleTouchAction?: boolean;
  124364. /**
  124365. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  124366. */
  124367. useHighPrecisionFloats?: boolean;
  124368. /**
  124369. * Make the canvas XR Compatible for XR sessions
  124370. */
  124371. xrCompatible?: boolean;
  124372. /**
  124373. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  124374. */
  124375. useHighPrecisionMatrix?: boolean;
  124376. /**
  124377. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  124378. */
  124379. failIfMajorPerformanceCaveat?: boolean;
  124380. }
  124381. /**
  124382. * The base engine class (root of all engines)
  124383. */
  124384. export class ThinEngine {
  124385. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  124386. static ExceptionList: ({
  124387. key: string;
  124388. capture: string;
  124389. captureConstraint: number;
  124390. targets: string[];
  124391. } | {
  124392. key: string;
  124393. capture: null;
  124394. captureConstraint: null;
  124395. targets: string[];
  124396. })[];
  124397. /** @hidden */
  124398. static _TextureLoaders: IInternalTextureLoader[];
  124399. /**
  124400. * Returns the current npm package of the sdk
  124401. */
  124402. static get NpmPackage(): string;
  124403. /**
  124404. * Returns the current version of the framework
  124405. */
  124406. static get Version(): string;
  124407. /**
  124408. * Returns a string describing the current engine
  124409. */
  124410. get description(): string;
  124411. /**
  124412. * Returns the name of the engine
  124413. */
  124414. get name(): string;
  124415. /**
  124416. * Returns the version of the engine
  124417. */
  124418. get version(): number;
  124419. /**
  124420. * Gets or sets the epsilon value used by collision engine
  124421. */
  124422. static CollisionsEpsilon: number;
  124423. /**
  124424. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  124425. */
  124426. static get ShadersRepository(): string;
  124427. static set ShadersRepository(value: string);
  124428. /** @hidden */
  124429. _shaderProcessor: Nullable<IShaderProcessor>;
  124430. /**
  124431. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  124432. */
  124433. forcePOTTextures: boolean;
  124434. /**
  124435. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  124436. */
  124437. isFullscreen: boolean;
  124438. /**
  124439. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  124440. */
  124441. cullBackFaces: boolean;
  124442. /**
  124443. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  124444. */
  124445. renderEvenInBackground: boolean;
  124446. /**
  124447. * Gets or sets a boolean indicating that cache can be kept between frames
  124448. */
  124449. preventCacheWipeBetweenFrames: boolean;
  124450. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  124451. validateShaderPrograms: boolean;
  124452. /**
  124453. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  124454. * This can provide greater z depth for distant objects.
  124455. */
  124456. useReverseDepthBuffer: boolean;
  124457. /**
  124458. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  124459. */
  124460. disableUniformBuffers: boolean;
  124461. private _frameId;
  124462. /**
  124463. * Gets the current frame id
  124464. */
  124465. get frameId(): number;
  124466. /** @hidden */
  124467. _uniformBuffers: UniformBuffer[];
  124468. /**
  124469. * Gets a boolean indicating that the engine supports uniform buffers
  124470. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  124471. */
  124472. get supportsUniformBuffers(): boolean;
  124473. /** @hidden */
  124474. _gl: WebGLRenderingContext;
  124475. /** @hidden */
  124476. _webGLVersion: number;
  124477. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  124478. protected _windowIsBackground: boolean;
  124479. protected _creationOptions: EngineOptions;
  124480. protected _highPrecisionShadersAllowed: boolean;
  124481. /** @hidden */
  124482. get _shouldUseHighPrecisionShader(): boolean;
  124483. /**
  124484. * Gets a boolean indicating that only power of 2 textures are supported
  124485. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  124486. */
  124487. get needPOTTextures(): boolean;
  124488. /** @hidden */
  124489. _badOS: boolean;
  124490. /** @hidden */
  124491. _badDesktopOS: boolean;
  124492. protected _hardwareScalingLevel: number;
  124493. /** @hidden */
  124494. _caps: EngineCapabilities;
  124495. /** @hidden */
  124496. _features: EngineFeatures;
  124497. protected _isStencilEnable: boolean;
  124498. private _glVersion;
  124499. private _glRenderer;
  124500. private _glVendor;
  124501. /** @hidden */
  124502. _videoTextureSupported: boolean;
  124503. protected _renderingQueueLaunched: boolean;
  124504. protected _activeRenderLoops: (() => void)[];
  124505. /**
  124506. * Observable signaled when a context lost event is raised
  124507. */
  124508. onContextLostObservable: Observable<ThinEngine>;
  124509. /**
  124510. * Observable signaled when a context restored event is raised
  124511. */
  124512. onContextRestoredObservable: Observable<ThinEngine>;
  124513. private _onContextLost;
  124514. private _onContextRestored;
  124515. protected _contextWasLost: boolean;
  124516. /** @hidden */
  124517. _doNotHandleContextLost: boolean;
  124518. /**
  124519. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  124520. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  124521. */
  124522. get doNotHandleContextLost(): boolean;
  124523. set doNotHandleContextLost(value: boolean);
  124524. /**
  124525. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  124526. */
  124527. disableVertexArrayObjects: boolean;
  124528. /** @hidden */
  124529. protected _colorWrite: boolean;
  124530. /** @hidden */
  124531. protected _colorWriteChanged: boolean;
  124532. /** @hidden */
  124533. protected _depthCullingState: DepthCullingState;
  124534. /** @hidden */
  124535. protected _stencilState: StencilState;
  124536. /** @hidden */
  124537. _alphaState: AlphaState;
  124538. /** @hidden */
  124539. _alphaMode: number;
  124540. /** @hidden */
  124541. _alphaEquation: number;
  124542. /** @hidden */
  124543. _internalTexturesCache: InternalTexture[];
  124544. /** @hidden */
  124545. protected _activeChannel: number;
  124546. private _currentTextureChannel;
  124547. /** @hidden */
  124548. protected _boundTexturesCache: {
  124549. [key: string]: Nullable<InternalTexture>;
  124550. };
  124551. /** @hidden */
  124552. protected _currentEffect: Nullable<Effect>;
  124553. /** @hidden */
  124554. protected _currentProgram: Nullable<WebGLProgram>;
  124555. protected _compiledEffects: {
  124556. [key: string]: Effect;
  124557. };
  124558. private _vertexAttribArraysEnabled;
  124559. /** @hidden */
  124560. protected _cachedViewport: Nullable<IViewportLike>;
  124561. private _cachedVertexArrayObject;
  124562. /** @hidden */
  124563. protected _cachedVertexBuffers: any;
  124564. /** @hidden */
  124565. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  124566. /** @hidden */
  124567. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  124568. /** @hidden */
  124569. _currentRenderTarget: Nullable<InternalTexture>;
  124570. private _uintIndicesCurrentlySet;
  124571. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  124572. /** @hidden */
  124573. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  124574. /** @hidden */
  124575. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  124576. private _currentBufferPointers;
  124577. private _currentInstanceLocations;
  124578. private _currentInstanceBuffers;
  124579. private _textureUnits;
  124580. /** @hidden */
  124581. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  124582. /** @hidden */
  124583. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  124584. /** @hidden */
  124585. _boundRenderFunction: any;
  124586. private _vaoRecordInProgress;
  124587. private _mustWipeVertexAttributes;
  124588. private _emptyTexture;
  124589. private _emptyCubeTexture;
  124590. private _emptyTexture3D;
  124591. private _emptyTexture2DArray;
  124592. /** @hidden */
  124593. _frameHandler: number;
  124594. private _nextFreeTextureSlots;
  124595. private _maxSimultaneousTextures;
  124596. private _activeRequests;
  124597. /** @hidden */
  124598. _transformTextureUrl: Nullable<(url: string) => string>;
  124599. /**
  124600. * Gets information about the current host
  124601. */
  124602. hostInformation: HostInformation;
  124603. protected get _supportsHardwareTextureRescaling(): boolean;
  124604. private _framebufferDimensionsObject;
  124605. /**
  124606. * sets the object from which width and height will be taken from when getting render width and height
  124607. * Will fallback to the gl object
  124608. * @param dimensions the framebuffer width and height that will be used.
  124609. */
  124610. set framebufferDimensionsObject(dimensions: Nullable<{
  124611. framebufferWidth: number;
  124612. framebufferHeight: number;
  124613. }>);
  124614. /**
  124615. * Gets the current viewport
  124616. */
  124617. get currentViewport(): Nullable<IViewportLike>;
  124618. /**
  124619. * Gets the default empty texture
  124620. */
  124621. get emptyTexture(): InternalTexture;
  124622. /**
  124623. * Gets the default empty 3D texture
  124624. */
  124625. get emptyTexture3D(): InternalTexture;
  124626. /**
  124627. * Gets the default empty 2D array texture
  124628. */
  124629. get emptyTexture2DArray(): InternalTexture;
  124630. /**
  124631. * Gets the default empty cube texture
  124632. */
  124633. get emptyCubeTexture(): InternalTexture;
  124634. /**
  124635. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  124636. */
  124637. premultipliedAlpha: boolean;
  124638. /**
  124639. * Observable event triggered before each texture is initialized
  124640. */
  124641. onBeforeTextureInitObservable: Observable<Texture>;
  124642. /** @hidden */
  124643. protected _isWebGPU: boolean;
  124644. /**
  124645. * Gets a boolean indicating if the engine runs in WebGPU or not.
  124646. */
  124647. get isWebGPU(): boolean;
  124648. /** @hidden */
  124649. protected _shaderPlatformName: string;
  124650. /**
  124651. * Gets the shader platfrom name used by the effects.
  124652. */
  124653. get shaderPlatformName(): string;
  124654. /**
  124655. * Creates a new engine
  124656. * @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
  124657. * @param antialias defines enable antialiasing (default: false)
  124658. * @param options defines further options to be sent to the getContext() function
  124659. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  124660. */
  124661. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  124662. /**
  124663. * @hidden
  124664. */
  124665. _debugPushGroup(groupName: string, targetObject?: number): void;
  124666. /**
  124667. * @hidden
  124668. */
  124669. _debugPopGroup(targetObject?: number): void;
  124670. /**
  124671. * @hidden
  124672. */
  124673. _debugInsertMarker(text: string, targetObject?: number): void;
  124674. /**
  124675. * Shared initialization across engines types.
  124676. * @param canvas The canvas associated with this instance of the engine.
  124677. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  124678. * @param audioEngine Defines if an audio engine should be created by default
  124679. */
  124680. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  124681. /**
  124682. * Gets a shader processor implementation fitting with the current engine type.
  124683. * @returns The shader processor implementation.
  124684. */
  124685. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  124686. /** @hidden */
  124687. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  124688. private _rebuildInternalTextures;
  124689. private _rebuildEffects;
  124690. /**
  124691. * Gets a boolean indicating if all created effects are ready
  124692. * @returns true if all effects are ready
  124693. */
  124694. areAllEffectsReady(): boolean;
  124695. protected _rebuildBuffers(): void;
  124696. protected _initGLContext(): void;
  124697. protected _initFeatures(): void;
  124698. /**
  124699. * Gets version of the current webGL context
  124700. * Keep it for back compat - use version instead
  124701. */
  124702. get webGLVersion(): number;
  124703. /**
  124704. * Gets a string identifying the name of the class
  124705. * @returns "Engine" string
  124706. */
  124707. getClassName(): string;
  124708. /**
  124709. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  124710. */
  124711. get isStencilEnable(): boolean;
  124712. /** @hidden */
  124713. _prepareWorkingCanvas(): void;
  124714. /**
  124715. * Reset the texture cache to empty state
  124716. */
  124717. resetTextureCache(): void;
  124718. /**
  124719. * Gets an object containing information about the current webGL context
  124720. * @returns an object containing the vender, the renderer and the version of the current webGL context
  124721. */
  124722. getGlInfo(): {
  124723. vendor: string;
  124724. renderer: string;
  124725. version: string;
  124726. };
  124727. /**
  124728. * Defines the hardware scaling level.
  124729. * By default the hardware scaling level is computed from the window device ratio.
  124730. * 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.
  124731. * @param level defines the level to use
  124732. */
  124733. setHardwareScalingLevel(level: number): void;
  124734. /**
  124735. * Gets the current hardware scaling level.
  124736. * By default the hardware scaling level is computed from the window device ratio.
  124737. * 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.
  124738. * @returns a number indicating the current hardware scaling level
  124739. */
  124740. getHardwareScalingLevel(): number;
  124741. /**
  124742. * Gets the list of loaded textures
  124743. * @returns an array containing all loaded textures
  124744. */
  124745. getLoadedTexturesCache(): InternalTexture[];
  124746. /**
  124747. * Gets the object containing all engine capabilities
  124748. * @returns the EngineCapabilities object
  124749. */
  124750. getCaps(): EngineCapabilities;
  124751. /**
  124752. * stop executing a render loop function and remove it from the execution array
  124753. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  124754. */
  124755. stopRenderLoop(renderFunction?: () => void): void;
  124756. /** @hidden */
  124757. _renderLoop(): void;
  124758. /**
  124759. * Gets the HTML canvas attached with the current webGL context
  124760. * @returns a HTML canvas
  124761. */
  124762. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  124763. /**
  124764. * Gets host window
  124765. * @returns the host window object
  124766. */
  124767. getHostWindow(): Nullable<Window>;
  124768. /**
  124769. * Gets the current render width
  124770. * @param useScreen defines if screen size must be used (or the current render target if any)
  124771. * @returns a number defining the current render width
  124772. */
  124773. getRenderWidth(useScreen?: boolean): number;
  124774. /**
  124775. * Gets the current render height
  124776. * @param useScreen defines if screen size must be used (or the current render target if any)
  124777. * @returns a number defining the current render height
  124778. */
  124779. getRenderHeight(useScreen?: boolean): number;
  124780. /**
  124781. * Can be used to override the current requestAnimationFrame requester.
  124782. * @hidden
  124783. */
  124784. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  124785. /**
  124786. * Register and execute a render loop. The engine can have more than one render function
  124787. * @param renderFunction defines the function to continuously execute
  124788. */
  124789. runRenderLoop(renderFunction: () => void): void;
  124790. /**
  124791. * Clear the current render buffer or the current render target (if any is set up)
  124792. * @param color defines the color to use
  124793. * @param backBuffer defines if the back buffer must be cleared
  124794. * @param depth defines if the depth buffer must be cleared
  124795. * @param stencil defines if the stencil buffer must be cleared
  124796. */
  124797. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  124798. protected _viewportCached: {
  124799. x: number;
  124800. y: number;
  124801. z: number;
  124802. w: number;
  124803. };
  124804. /** @hidden */
  124805. _viewport(x: number, y: number, width: number, height: number): void;
  124806. /**
  124807. * Set the WebGL's viewport
  124808. * @param viewport defines the viewport element to be used
  124809. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  124810. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  124811. */
  124812. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  124813. /**
  124814. * Begin a new frame
  124815. */
  124816. beginFrame(): void;
  124817. /**
  124818. * Enf the current frame
  124819. */
  124820. endFrame(): void;
  124821. /**
  124822. * Resize the view according to the canvas' size
  124823. * @param forceSetSize true to force setting the sizes of the underlying canvas
  124824. */
  124825. resize(forceSetSize?: boolean): void;
  124826. /**
  124827. * Force a specific size of the canvas
  124828. * @param width defines the new canvas' width
  124829. * @param height defines the new canvas' height
  124830. * @param forceSetSize true to force setting the sizes of the underlying canvas
  124831. * @returns true if the size was changed
  124832. */
  124833. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  124834. /**
  124835. * Binds the frame buffer to the specified texture.
  124836. * @param texture The texture to render to or null for the default canvas
  124837. * @param faceIndex The face of the texture to render to in case of cube texture
  124838. * @param requiredWidth The width of the target to render to
  124839. * @param requiredHeight The height of the target to render to
  124840. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  124841. * @param lodLevel defines the lod level to bind to the frame buffer
  124842. * @param layer defines the 2d array index to bind to frame buffer to
  124843. */
  124844. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  124845. /** @hidden */
  124846. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  124847. /**
  124848. * Unbind the current render target texture from the webGL context
  124849. * @param texture defines the render target texture to unbind
  124850. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  124851. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  124852. */
  124853. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  124854. /**
  124855. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  124856. */
  124857. flushFramebuffer(): void;
  124858. /**
  124859. * Unbind the current render target and bind the default framebuffer
  124860. */
  124861. restoreDefaultFramebuffer(): void;
  124862. /** @hidden */
  124863. protected _resetVertexBufferBinding(): void;
  124864. /**
  124865. * Creates a vertex buffer
  124866. * @param data the data for the vertex buffer
  124867. * @returns the new WebGL static buffer
  124868. */
  124869. createVertexBuffer(data: DataArray): DataBuffer;
  124870. private _createVertexBuffer;
  124871. /**
  124872. * Creates a dynamic vertex buffer
  124873. * @param data the data for the dynamic vertex buffer
  124874. * @returns the new WebGL dynamic buffer
  124875. */
  124876. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  124877. protected _resetIndexBufferBinding(): void;
  124878. /**
  124879. * Creates a new index buffer
  124880. * @param indices defines the content of the index buffer
  124881. * @param updatable defines if the index buffer must be updatable
  124882. * @returns a new webGL buffer
  124883. */
  124884. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  124885. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  124886. /**
  124887. * Bind a webGL buffer to the webGL context
  124888. * @param buffer defines the buffer to bind
  124889. */
  124890. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  124891. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  124892. private bindBuffer;
  124893. /**
  124894. * update the bound buffer with the given data
  124895. * @param data defines the data to update
  124896. */
  124897. updateArrayBuffer(data: Float32Array): void;
  124898. private _vertexAttribPointer;
  124899. /** @hidden */
  124900. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  124901. private _bindVertexBuffersAttributes;
  124902. /**
  124903. * Records a vertex array object
  124904. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  124905. * @param vertexBuffers defines the list of vertex buffers to store
  124906. * @param indexBuffer defines the index buffer to store
  124907. * @param effect defines the effect to store
  124908. * @returns the new vertex array object
  124909. */
  124910. recordVertexArrayObject(vertexBuffers: {
  124911. [key: string]: VertexBuffer;
  124912. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  124913. /**
  124914. * Bind a specific vertex array object
  124915. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  124916. * @param vertexArrayObject defines the vertex array object to bind
  124917. * @param indexBuffer defines the index buffer to bind
  124918. */
  124919. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  124920. /**
  124921. * Bind webGl buffers directly to the webGL context
  124922. * @param vertexBuffer defines the vertex buffer to bind
  124923. * @param indexBuffer defines the index buffer to bind
  124924. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  124925. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  124926. * @param effect defines the effect associated with the vertex buffer
  124927. */
  124928. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  124929. private _unbindVertexArrayObject;
  124930. /**
  124931. * Bind a list of vertex buffers to the webGL context
  124932. * @param vertexBuffers defines the list of vertex buffers to bind
  124933. * @param indexBuffer defines the index buffer to bind
  124934. * @param effect defines the effect associated with the vertex buffers
  124935. */
  124936. bindBuffers(vertexBuffers: {
  124937. [key: string]: Nullable<VertexBuffer>;
  124938. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  124939. /**
  124940. * Unbind all instance attributes
  124941. */
  124942. unbindInstanceAttributes(): void;
  124943. /**
  124944. * Release and free the memory of a vertex array object
  124945. * @param vao defines the vertex array object to delete
  124946. */
  124947. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  124948. /** @hidden */
  124949. _releaseBuffer(buffer: DataBuffer): boolean;
  124950. protected _deleteBuffer(buffer: DataBuffer): void;
  124951. /**
  124952. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  124953. * @param instancesBuffer defines the webGL buffer to update and bind
  124954. * @param data defines the data to store in the buffer
  124955. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  124956. */
  124957. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  124958. /**
  124959. * Bind the content of a webGL buffer used with instantiation
  124960. * @param instancesBuffer defines the webGL buffer to bind
  124961. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  124962. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  124963. */
  124964. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  124965. /**
  124966. * Disable the instance attribute corresponding to the name in parameter
  124967. * @param name defines the name of the attribute to disable
  124968. */
  124969. disableInstanceAttributeByName(name: string): void;
  124970. /**
  124971. * Disable the instance attribute corresponding to the location in parameter
  124972. * @param attributeLocation defines the attribute location of the attribute to disable
  124973. */
  124974. disableInstanceAttribute(attributeLocation: number): void;
  124975. /**
  124976. * Disable the attribute corresponding to the location in parameter
  124977. * @param attributeLocation defines the attribute location of the attribute to disable
  124978. */
  124979. disableAttributeByIndex(attributeLocation: number): void;
  124980. /**
  124981. * Send a draw order
  124982. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  124983. * @param indexStart defines the starting index
  124984. * @param indexCount defines the number of index to draw
  124985. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  124986. */
  124987. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  124988. /**
  124989. * Draw a list of points
  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. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  124995. /**
  124996. * Draw a list of unindexed primitives
  124997. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  124998. * @param verticesStart defines the index of first vertex to draw
  124999. * @param verticesCount defines the count of vertices to draw
  125000. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  125001. */
  125002. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  125003. /**
  125004. * Draw a list of indexed primitives
  125005. * @param fillMode defines the primitive to use
  125006. * @param indexStart defines the starting index
  125007. * @param indexCount defines the number of index to draw
  125008. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  125009. */
  125010. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  125011. /**
  125012. * Draw a list of unindexed primitives
  125013. * @param fillMode defines the primitive to use
  125014. * @param verticesStart defines the index of first vertex to draw
  125015. * @param verticesCount defines the count of vertices to draw
  125016. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  125017. */
  125018. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  125019. private _drawMode;
  125020. /** @hidden */
  125021. protected _reportDrawCall(): void;
  125022. /** @hidden */
  125023. _releaseEffect(effect: Effect): void;
  125024. /** @hidden */
  125025. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  125026. /**
  125027. * Create a new effect (used to store vertex/fragment shaders)
  125028. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  125029. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  125030. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  125031. * @param samplers defines an array of string used to represent textures
  125032. * @param defines defines the string containing the defines to use to compile the shaders
  125033. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  125034. * @param onCompiled defines a function to call when the effect creation is successful
  125035. * @param onError defines a function to call when the effect creation has failed
  125036. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  125037. * @returns the new Effect
  125038. */
  125039. 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;
  125040. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  125041. private _compileShader;
  125042. private _compileRawShader;
  125043. /** @hidden */
  125044. _getShaderSource(shader: WebGLShader): Nullable<string>;
  125045. /**
  125046. * Directly creates a webGL program
  125047. * @param pipelineContext defines the pipeline context to attach to
  125048. * @param vertexCode defines the vertex shader code to use
  125049. * @param fragmentCode defines the fragment shader code to use
  125050. * @param context defines the webGL context to use (if not set, the current one will be used)
  125051. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  125052. * @returns the new webGL program
  125053. */
  125054. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  125055. /**
  125056. * Creates a webGL program
  125057. * @param pipelineContext defines the pipeline context to attach to
  125058. * @param vertexCode defines the vertex shader code to use
  125059. * @param fragmentCode defines the fragment shader code to use
  125060. * @param defines defines the string containing the defines to use to compile the shaders
  125061. * @param context defines the webGL context to use (if not set, the current one will be used)
  125062. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  125063. * @returns the new webGL program
  125064. */
  125065. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  125066. /**
  125067. * Creates a new pipeline context
  125068. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  125069. * @returns the new pipeline
  125070. */
  125071. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  125072. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  125073. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  125074. /** @hidden */
  125075. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  125076. /** @hidden */
  125077. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  125078. /** @hidden */
  125079. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  125080. /**
  125081. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  125082. * @param pipelineContext defines the pipeline context to use
  125083. * @param uniformsNames defines the list of uniform names
  125084. * @returns an array of webGL uniform locations
  125085. */
  125086. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  125087. /**
  125088. * Gets the list of active attributes for a given webGL program
  125089. * @param pipelineContext defines the pipeline context to use
  125090. * @param attributesNames defines the list of attribute names to get
  125091. * @returns an array of indices indicating the offset of each attribute
  125092. */
  125093. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  125094. /**
  125095. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  125096. * @param effect defines the effect to activate
  125097. */
  125098. enableEffect(effect: Nullable<Effect>): void;
  125099. /**
  125100. * Set the value of an uniform to a number (int)
  125101. * @param uniform defines the webGL uniform location where to store the value
  125102. * @param value defines the int number to store
  125103. * @returns true if the value was set
  125104. */
  125105. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  125106. /**
  125107. * Set the value of an uniform to a int2
  125108. * @param uniform defines the webGL uniform location where to store the value
  125109. * @param x defines the 1st component of the value
  125110. * @param y defines the 2nd component of the value
  125111. * @returns true if the value was set
  125112. */
  125113. setInt2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  125114. /**
  125115. * Set the value of an uniform to a int3
  125116. * @param uniform defines the webGL uniform location where to store the value
  125117. * @param x defines the 1st component of the value
  125118. * @param y defines the 2nd component of the value
  125119. * @param z defines the 3rd component of the value
  125120. * @returns true if the value was set
  125121. */
  125122. setInt3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  125123. /**
  125124. * Set the value of an uniform to a int4
  125125. * @param uniform defines the webGL uniform location where to store the value
  125126. * @param x defines the 1st component of the value
  125127. * @param y defines the 2nd component of the value
  125128. * @param z defines the 3rd component of the value
  125129. * @param w defines the 4th component of the value
  125130. * @returns true if the value was set
  125131. */
  125132. setInt4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  125133. /**
  125134. * Set the value of an uniform to an array of int32
  125135. * @param uniform defines the webGL uniform location where to store the value
  125136. * @param array defines the array of int32 to store
  125137. * @returns true if the value was set
  125138. */
  125139. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  125140. /**
  125141. * Set the value of an uniform to an array of int32 (stored as vec2)
  125142. * @param uniform defines the webGL uniform location where to store the value
  125143. * @param array defines the array of int32 to store
  125144. * @returns true if the value was set
  125145. */
  125146. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  125147. /**
  125148. * Set the value of an uniform to an array of int32 (stored as vec3)
  125149. * @param uniform defines the webGL uniform location where to store the value
  125150. * @param array defines the array of int32 to store
  125151. * @returns true if the value was set
  125152. */
  125153. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  125154. /**
  125155. * Set the value of an uniform to an array of int32 (stored as vec4)
  125156. * @param uniform defines the webGL uniform location where to store the value
  125157. * @param array defines the array of int32 to store
  125158. * @returns true if the value was set
  125159. */
  125160. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  125161. /**
  125162. * Set the value of an uniform to an array of number
  125163. * @param uniform defines the webGL uniform location where to store the value
  125164. * @param array defines the array of number to store
  125165. * @returns true if the value was set
  125166. */
  125167. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  125168. /**
  125169. * Set the value of an uniform to an array of number (stored as vec2)
  125170. * @param uniform defines the webGL uniform location where to store the value
  125171. * @param array defines the array of number to store
  125172. * @returns true if the value was set
  125173. */
  125174. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  125175. /**
  125176. * Set the value of an uniform to an array of number (stored as vec3)
  125177. * @param uniform defines the webGL uniform location where to store the value
  125178. * @param array defines the array of number to store
  125179. * @returns true if the value was set
  125180. */
  125181. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  125182. /**
  125183. * Set the value of an uniform to an array of number (stored as vec4)
  125184. * @param uniform defines the webGL uniform location where to store the value
  125185. * @param array defines the array of number to store
  125186. * @returns true if the value was set
  125187. */
  125188. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  125189. /**
  125190. * Set the value of an uniform to an array of float32 (stored as matrices)
  125191. * @param uniform defines the webGL uniform location where to store the value
  125192. * @param matrices defines the array of float32 to store
  125193. * @returns true if the value was set
  125194. */
  125195. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  125196. /**
  125197. * Set the value of an uniform to a matrix (3x3)
  125198. * @param uniform defines the webGL uniform location where to store the value
  125199. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  125200. * @returns true if the value was set
  125201. */
  125202. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  125203. /**
  125204. * Set the value of an uniform to a matrix (2x2)
  125205. * @param uniform defines the webGL uniform location where to store the value
  125206. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  125207. * @returns true if the value was set
  125208. */
  125209. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  125210. /**
  125211. * Set the value of an uniform to a number (float)
  125212. * @param uniform defines the webGL uniform location where to store the value
  125213. * @param value defines the float number to store
  125214. * @returns true if the value was transfered
  125215. */
  125216. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  125217. /**
  125218. * Set the value of an uniform to a vec2
  125219. * @param uniform defines the webGL uniform location where to store the value
  125220. * @param x defines the 1st component of the value
  125221. * @param y defines the 2nd component of the value
  125222. * @returns true if the value was set
  125223. */
  125224. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  125225. /**
  125226. * Set the value of an uniform to a vec3
  125227. * @param uniform defines the webGL uniform location where to store the value
  125228. * @param x defines the 1st component of the value
  125229. * @param y defines the 2nd component of the value
  125230. * @param z defines the 3rd component of the value
  125231. * @returns true if the value was set
  125232. */
  125233. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  125234. /**
  125235. * Set the value of an uniform to a vec4
  125236. * @param uniform defines the webGL uniform location where to store the value
  125237. * @param x defines the 1st component of the value
  125238. * @param y defines the 2nd component of the value
  125239. * @param z defines the 3rd component of the value
  125240. * @param w defines the 4th component of the value
  125241. * @returns true if the value was set
  125242. */
  125243. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  125244. /**
  125245. * Apply all cached states (depth, culling, stencil and alpha)
  125246. */
  125247. applyStates(): void;
  125248. /**
  125249. * Enable or disable color writing
  125250. * @param enable defines the state to set
  125251. */
  125252. setColorWrite(enable: boolean): void;
  125253. /**
  125254. * Gets a boolean indicating if color writing is enabled
  125255. * @returns the current color writing state
  125256. */
  125257. getColorWrite(): boolean;
  125258. /**
  125259. * Gets the depth culling state manager
  125260. */
  125261. get depthCullingState(): DepthCullingState;
  125262. /**
  125263. * Gets the alpha state manager
  125264. */
  125265. get alphaState(): AlphaState;
  125266. /**
  125267. * Gets the stencil state manager
  125268. */
  125269. get stencilState(): StencilState;
  125270. /**
  125271. * Clears the list of texture accessible through engine.
  125272. * This can help preventing texture load conflict due to name collision.
  125273. */
  125274. clearInternalTexturesCache(): void;
  125275. /**
  125276. * Force the entire cache to be cleared
  125277. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  125278. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  125279. */
  125280. wipeCaches(bruteForce?: boolean): void;
  125281. /** @hidden */
  125282. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  125283. min: number;
  125284. mag: number;
  125285. };
  125286. /** @hidden */
  125287. protected _createTexture(): WebGLTexture;
  125288. /** @hidden */
  125289. _createHardwareTexture(): HardwareTextureWrapper;
  125290. 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 | {
  125291. width: number;
  125292. height: number;
  125293. }, invertY: boolean, noMipmap: boolean, isCompressed: boolean, processFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  125294. width: number;
  125295. height: number;
  125296. }, extension: string, texture: InternalTexture, continuationCallback: () => void) => boolean, samplingMode: number) => void, prepareTextureProcessFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  125297. width: number;
  125298. height: number;
  125299. }, 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;
  125300. /**
  125301. * Usually called from Texture.ts.
  125302. * Passed information to create a WebGLTexture
  125303. * @param url defines a value which contains one of the following:
  125304. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  125305. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  125306. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  125307. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  125308. * @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)
  125309. * @param scene needed for loading to the correct scene
  125310. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  125311. * @param onLoad optional callback to be called upon successful completion
  125312. * @param onError optional callback to be called upon failure
  125313. * @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
  125314. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  125315. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  125316. * @param forcedExtension defines the extension to use to pick the right loader
  125317. * @param mimeType defines an optional mime type
  125318. * @param loaderOptions options to be passed to the loader
  125319. * @returns a InternalTexture for assignment back into BABYLON.Texture
  125320. */
  125321. 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;
  125322. /**
  125323. * Loads an image as an HTMLImageElement.
  125324. * @param input url string, ArrayBuffer, or Blob to load
  125325. * @param onLoad callback called when the image successfully loads
  125326. * @param onError callback called when the image fails to load
  125327. * @param offlineProvider offline provider for caching
  125328. * @param mimeType optional mime type
  125329. * @returns the HTMLImageElement of the loaded image
  125330. * @hidden
  125331. */
  125332. 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>;
  125333. /**
  125334. * @hidden
  125335. */
  125336. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  125337. private _unpackFlipYCached;
  125338. /**
  125339. * In case you are sharing the context with other applications, it might
  125340. * be interested to not cache the unpack flip y state to ensure a consistent
  125341. * value would be set.
  125342. */
  125343. enableUnpackFlipYCached: boolean;
  125344. /** @hidden */
  125345. _unpackFlipY(value: boolean): void;
  125346. /** @hidden */
  125347. _getUnpackAlignement(): number;
  125348. private _getTextureTarget;
  125349. /**
  125350. * Update the sampling mode of a given texture
  125351. * @param samplingMode defines the required sampling mode
  125352. * @param texture defines the texture to update
  125353. * @param generateMipMaps defines whether to generate mipmaps for the texture
  125354. */
  125355. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  125356. /**
  125357. * Update the dimensions of a texture
  125358. * @param texture texture to update
  125359. * @param width new width of the texture
  125360. * @param height new height of the texture
  125361. * @param depth new depth of the texture
  125362. */
  125363. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  125364. /**
  125365. * Update the sampling mode of a given texture
  125366. * @param texture defines the texture to update
  125367. * @param wrapU defines the texture wrap mode of the u coordinates
  125368. * @param wrapV defines the texture wrap mode of the v coordinates
  125369. * @param wrapR defines the texture wrap mode of the r coordinates
  125370. */
  125371. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  125372. /** @hidden */
  125373. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  125374. width: number;
  125375. height: number;
  125376. layers?: number;
  125377. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  125378. /** @hidden */
  125379. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  125380. /** @hidden */
  125381. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  125382. /**
  125383. * Update a portion of an internal texture
  125384. * @param texture defines the texture to update
  125385. * @param imageData defines the data to store into the texture
  125386. * @param xOffset defines the x coordinates of the update rectangle
  125387. * @param yOffset defines the y coordinates of the update rectangle
  125388. * @param width defines the width of the update rectangle
  125389. * @param height defines the height of the update rectangle
  125390. * @param faceIndex defines the face index if texture is a cube (0 by default)
  125391. * @param lod defines the lod level to update (0 by default)
  125392. */
  125393. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  125394. /** @hidden */
  125395. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  125396. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  125397. private _prepareWebGLTexture;
  125398. /** @hidden */
  125399. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  125400. private _getDepthStencilBuffer;
  125401. /** @hidden */
  125402. _releaseFramebufferObjects(texture: InternalTexture): void;
  125403. /** @hidden */
  125404. _releaseTexture(texture: InternalTexture): void;
  125405. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  125406. protected _setProgram(program: WebGLProgram): void;
  125407. protected _boundUniforms: {
  125408. [key: number]: WebGLUniformLocation;
  125409. };
  125410. /**
  125411. * Binds an effect to the webGL context
  125412. * @param effect defines the effect to bind
  125413. */
  125414. bindSamplers(effect: Effect): void;
  125415. private _activateCurrentTexture;
  125416. /** @hidden */
  125417. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  125418. /** @hidden */
  125419. _bindTexture(channel: number, texture: Nullable<InternalTexture>, name: string): void;
  125420. /**
  125421. * Unbind all textures from the webGL context
  125422. */
  125423. unbindAllTextures(): void;
  125424. /**
  125425. * Sets a texture to the according uniform.
  125426. * @param channel The texture channel
  125427. * @param uniform The uniform to set
  125428. * @param texture The texture to apply
  125429. * @param name The name of the uniform in the effect
  125430. */
  125431. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>, name: string): void;
  125432. private _bindSamplerUniformToChannel;
  125433. private _getTextureWrapMode;
  125434. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string): boolean;
  125435. /**
  125436. * Sets an array of texture to the webGL context
  125437. * @param channel defines the channel where the texture array must be set
  125438. * @param uniform defines the associated uniform location
  125439. * @param textures defines the array of textures to bind
  125440. * @param name name of the channel
  125441. */
  125442. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[], name: string): void;
  125443. /** @hidden */
  125444. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  125445. private _setTextureParameterFloat;
  125446. private _setTextureParameterInteger;
  125447. /**
  125448. * Unbind all vertex attributes from the webGL context
  125449. */
  125450. unbindAllAttributes(): void;
  125451. /**
  125452. * 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
  125453. */
  125454. releaseEffects(): void;
  125455. /**
  125456. * Dispose and release all associated resources
  125457. */
  125458. dispose(): void;
  125459. /**
  125460. * Attach a new callback raised when context lost event is fired
  125461. * @param callback defines the callback to call
  125462. */
  125463. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  125464. /**
  125465. * Attach a new callback raised when context restored event is fired
  125466. * @param callback defines the callback to call
  125467. */
  125468. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  125469. /**
  125470. * Get the current error code of the webGL context
  125471. * @returns the error code
  125472. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  125473. */
  125474. getError(): number;
  125475. private _canRenderToFloatFramebuffer;
  125476. private _canRenderToHalfFloatFramebuffer;
  125477. private _canRenderToFramebuffer;
  125478. /** @hidden */
  125479. _getWebGLTextureType(type: number): number;
  125480. /** @hidden */
  125481. _getInternalFormat(format: number): number;
  125482. /** @hidden */
  125483. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  125484. /** @hidden */
  125485. _getRGBAMultiSampleBufferFormat(type: number): number;
  125486. /** @hidden */
  125487. _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;
  125488. /**
  125489. * Loads a file from a url
  125490. * @param url url to load
  125491. * @param onSuccess callback called when the file successfully loads
  125492. * @param onProgress callback called while file is loading (if the server supports this mode)
  125493. * @param offlineProvider defines the offline provider for caching
  125494. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  125495. * @param onError callback called when the file fails to load
  125496. * @returns a file request object
  125497. * @hidden
  125498. */
  125499. 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;
  125500. /**
  125501. * Reads pixels from the current frame buffer. Please note that this function can be slow
  125502. * @param x defines the x coordinate of the rectangle where pixels must be read
  125503. * @param y defines the y coordinate of the rectangle where pixels must be read
  125504. * @param width defines the width of the rectangle where pixels must be read
  125505. * @param height defines the height of the rectangle where pixels must be read
  125506. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  125507. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  125508. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  125509. */
  125510. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  125511. private static _IsSupported;
  125512. private static _HasMajorPerformanceCaveat;
  125513. /**
  125514. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  125515. */
  125516. static get IsSupported(): boolean;
  125517. /**
  125518. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  125519. * @returns true if the engine can be created
  125520. * @ignorenaming
  125521. */
  125522. static isSupported(): boolean;
  125523. /**
  125524. * 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)
  125525. */
  125526. static get HasMajorPerformanceCaveat(): boolean;
  125527. /**
  125528. * Find the next highest power of two.
  125529. * @param x Number to start search from.
  125530. * @return Next highest power of two.
  125531. */
  125532. static CeilingPOT(x: number): number;
  125533. /**
  125534. * Find the next lowest power of two.
  125535. * @param x Number to start search from.
  125536. * @return Next lowest power of two.
  125537. */
  125538. static FloorPOT(x: number): number;
  125539. /**
  125540. * Find the nearest power of two.
  125541. * @param x Number to start search from.
  125542. * @return Next nearest power of two.
  125543. */
  125544. static NearestPOT(x: number): number;
  125545. /**
  125546. * Get the closest exponent of two
  125547. * @param value defines the value to approximate
  125548. * @param max defines the maximum value to return
  125549. * @param mode defines how to define the closest value
  125550. * @returns closest exponent of two of the given value
  125551. */
  125552. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  125553. /**
  125554. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  125555. * @param func - the function to be called
  125556. * @param requester - the object that will request the next frame. Falls back to window.
  125557. * @returns frame number
  125558. */
  125559. static QueueNewFrame(func: () => void, requester?: any): number;
  125560. /**
  125561. * Gets host document
  125562. * @returns the host document object
  125563. */
  125564. getHostDocument(): Nullable<Document>;
  125565. }
  125566. }
  125567. declare module BABYLON {
  125568. /**
  125569. * Defines the source of the internal texture
  125570. */
  125571. export enum InternalTextureSource {
  125572. /**
  125573. * The source of the texture data is unknown
  125574. */
  125575. Unknown = 0,
  125576. /**
  125577. * Texture data comes from an URL
  125578. */
  125579. Url = 1,
  125580. /**
  125581. * Texture data is only used for temporary storage
  125582. */
  125583. Temp = 2,
  125584. /**
  125585. * Texture data comes from raw data (ArrayBuffer)
  125586. */
  125587. Raw = 3,
  125588. /**
  125589. * Texture content is dynamic (video or dynamic texture)
  125590. */
  125591. Dynamic = 4,
  125592. /**
  125593. * Texture content is generated by rendering to it
  125594. */
  125595. RenderTarget = 5,
  125596. /**
  125597. * Texture content is part of a multi render target process
  125598. */
  125599. MultiRenderTarget = 6,
  125600. /**
  125601. * Texture data comes from a cube data file
  125602. */
  125603. Cube = 7,
  125604. /**
  125605. * Texture data comes from a raw cube data
  125606. */
  125607. CubeRaw = 8,
  125608. /**
  125609. * Texture data come from a prefiltered cube data file
  125610. */
  125611. CubePrefiltered = 9,
  125612. /**
  125613. * Texture content is raw 3D data
  125614. */
  125615. Raw3D = 10,
  125616. /**
  125617. * Texture content is raw 2D array data
  125618. */
  125619. Raw2DArray = 11,
  125620. /**
  125621. * Texture content is a depth texture
  125622. */
  125623. Depth = 12,
  125624. /**
  125625. * Texture data comes from a raw cube data encoded with RGBD
  125626. */
  125627. CubeRawRGBD = 13
  125628. }
  125629. /**
  125630. * Class used to store data associated with WebGL texture data for the engine
  125631. * This class should not be used directly
  125632. */
  125633. export class InternalTexture {
  125634. /** @hidden */
  125635. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  125636. /**
  125637. * Defines if the texture is ready
  125638. */
  125639. isReady: boolean;
  125640. /**
  125641. * Defines if the texture is a cube texture
  125642. */
  125643. isCube: boolean;
  125644. /**
  125645. * Defines if the texture contains 3D data
  125646. */
  125647. is3D: boolean;
  125648. /**
  125649. * Defines if the texture contains 2D array data
  125650. */
  125651. is2DArray: boolean;
  125652. /**
  125653. * Defines if the texture contains multiview data
  125654. */
  125655. isMultiview: boolean;
  125656. /**
  125657. * Gets the URL used to load this texture
  125658. */
  125659. url: string;
  125660. /** @hidden */
  125661. _originalUrl: string;
  125662. /**
  125663. * Gets the sampling mode of the texture
  125664. */
  125665. samplingMode: number;
  125666. /**
  125667. * Gets a boolean indicating if the texture needs mipmaps generation
  125668. */
  125669. generateMipMaps: boolean;
  125670. /**
  125671. * Gets the number of samples used by the texture (WebGL2+ only)
  125672. */
  125673. samples: number;
  125674. /**
  125675. * Gets the type of the texture (int, float...)
  125676. */
  125677. type: number;
  125678. /**
  125679. * Gets the format of the texture (RGB, RGBA...)
  125680. */
  125681. format: number;
  125682. /**
  125683. * Observable called when the texture is loaded
  125684. */
  125685. onLoadedObservable: Observable<InternalTexture>;
  125686. /**
  125687. * Gets the width of the texture
  125688. */
  125689. width: number;
  125690. /**
  125691. * Gets the height of the texture
  125692. */
  125693. height: number;
  125694. /**
  125695. * Gets the depth of the texture
  125696. */
  125697. depth: number;
  125698. /**
  125699. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  125700. */
  125701. baseWidth: number;
  125702. /**
  125703. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  125704. */
  125705. baseHeight: number;
  125706. /**
  125707. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  125708. */
  125709. baseDepth: number;
  125710. /**
  125711. * Gets a boolean indicating if the texture is inverted on Y axis
  125712. */
  125713. invertY: boolean;
  125714. /** @hidden */
  125715. _invertVScale: boolean;
  125716. /** @hidden */
  125717. _associatedChannel: number;
  125718. /** @hidden */
  125719. _source: InternalTextureSource;
  125720. /** @hidden */
  125721. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  125722. /** @hidden */
  125723. _bufferView: Nullable<ArrayBufferView>;
  125724. /** @hidden */
  125725. _bufferViewArray: Nullable<ArrayBufferView[]>;
  125726. /** @hidden */
  125727. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  125728. /** @hidden */
  125729. _size: number;
  125730. /** @hidden */
  125731. _extension: string;
  125732. /** @hidden */
  125733. _files: Nullable<string[]>;
  125734. /** @hidden */
  125735. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  125736. /** @hidden */
  125737. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  125738. /** @hidden */
  125739. _framebuffer: Nullable<WebGLFramebuffer>;
  125740. /** @hidden */
  125741. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  125742. /** @hidden */
  125743. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  125744. /** @hidden */
  125745. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  125746. /** @hidden */
  125747. _attachments: Nullable<number[]>;
  125748. /** @hidden */
  125749. _textureArray: Nullable<InternalTexture[]>;
  125750. /** @hidden */
  125751. _cachedCoordinatesMode: Nullable<number>;
  125752. /** @hidden */
  125753. _cachedWrapU: Nullable<number>;
  125754. /** @hidden */
  125755. _cachedWrapV: Nullable<number>;
  125756. /** @hidden */
  125757. _cachedWrapR: Nullable<number>;
  125758. /** @hidden */
  125759. _cachedAnisotropicFilteringLevel: Nullable<number>;
  125760. /** @hidden */
  125761. _isDisabled: boolean;
  125762. /** @hidden */
  125763. _compression: Nullable<string>;
  125764. /** @hidden */
  125765. _generateStencilBuffer: boolean;
  125766. /** @hidden */
  125767. _generateDepthBuffer: boolean;
  125768. /** @hidden */
  125769. _comparisonFunction: number;
  125770. /** @hidden */
  125771. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  125772. /** @hidden */
  125773. _sphericalPolynomialPromise: Nullable<Promise<SphericalPolynomial>>;
  125774. /** @hidden */
  125775. _sphericalPolynomialComputed: boolean;
  125776. /** @hidden */
  125777. _lodGenerationScale: number;
  125778. /** @hidden */
  125779. _lodGenerationOffset: number;
  125780. /** @hidden */
  125781. _depthStencilTexture: Nullable<InternalTexture>;
  125782. /** @hidden */
  125783. _colorTextureArray: Nullable<WebGLTexture>;
  125784. /** @hidden */
  125785. _depthStencilTextureArray: Nullable<WebGLTexture>;
  125786. /** @hidden */
  125787. _lodTextureHigh: Nullable<BaseTexture>;
  125788. /** @hidden */
  125789. _lodTextureMid: Nullable<BaseTexture>;
  125790. /** @hidden */
  125791. _lodTextureLow: Nullable<BaseTexture>;
  125792. /** @hidden */
  125793. _isRGBD: boolean;
  125794. /** @hidden */
  125795. _linearSpecularLOD: boolean;
  125796. /** @hidden */
  125797. _irradianceTexture: Nullable<BaseTexture>;
  125798. /** @hidden */
  125799. _hardwareTexture: Nullable<HardwareTextureWrapper>;
  125800. /** @hidden */
  125801. _references: number;
  125802. /** @hidden */
  125803. _gammaSpace: Nullable<boolean>;
  125804. private _engine;
  125805. private _uniqueId;
  125806. private static _Counter;
  125807. /** Gets the unique id of the internal texture */
  125808. get uniqueId(): number;
  125809. /**
  125810. * Gets the Engine the texture belongs to.
  125811. * @returns The babylon engine
  125812. */
  125813. getEngine(): ThinEngine;
  125814. /**
  125815. * Gets the data source type of the texture
  125816. */
  125817. get source(): InternalTextureSource;
  125818. /**
  125819. * Creates a new InternalTexture
  125820. * @param engine defines the engine to use
  125821. * @param source defines the type of data that will be used
  125822. * @param delayAllocation if the texture allocation should be delayed (default: false)
  125823. */
  125824. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  125825. /**
  125826. * Increments the number of references (ie. the number of Texture that point to it)
  125827. */
  125828. incrementReferences(): void;
  125829. /**
  125830. * Change the size of the texture (not the size of the content)
  125831. * @param width defines the new width
  125832. * @param height defines the new height
  125833. * @param depth defines the new depth (1 by default)
  125834. */
  125835. updateSize(width: int, height: int, depth?: int): void;
  125836. /** @hidden */
  125837. _rebuild(): void;
  125838. /** @hidden */
  125839. _swapAndDie(target: InternalTexture): void;
  125840. /**
  125841. * Dispose the current allocated resources
  125842. */
  125843. dispose(): void;
  125844. }
  125845. }
  125846. declare module BABYLON {
  125847. /**
  125848. * Interface used to present a loading screen while loading a scene
  125849. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  125850. */
  125851. export interface ILoadingScreen {
  125852. /**
  125853. * Function called to display the loading screen
  125854. */
  125855. displayLoadingUI: () => void;
  125856. /**
  125857. * Function called to hide the loading screen
  125858. */
  125859. hideLoadingUI: () => void;
  125860. /**
  125861. * Gets or sets the color to use for the background
  125862. */
  125863. loadingUIBackgroundColor: string;
  125864. /**
  125865. * Gets or sets the text to display while loading
  125866. */
  125867. loadingUIText: string;
  125868. }
  125869. /**
  125870. * Class used for the default loading screen
  125871. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  125872. */
  125873. export class DefaultLoadingScreen implements ILoadingScreen {
  125874. private _renderingCanvas;
  125875. private _loadingText;
  125876. private _loadingDivBackgroundColor;
  125877. private _loadingDiv;
  125878. private _loadingTextDiv;
  125879. /** Gets or sets the logo url to use for the default loading screen */
  125880. static DefaultLogoUrl: string;
  125881. /** Gets or sets the spinner url to use for the default loading screen */
  125882. static DefaultSpinnerUrl: string;
  125883. /**
  125884. * Creates a new default loading screen
  125885. * @param _renderingCanvas defines the canvas used to render the scene
  125886. * @param _loadingText defines the default text to display
  125887. * @param _loadingDivBackgroundColor defines the default background color
  125888. */
  125889. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  125890. /**
  125891. * Function called to display the loading screen
  125892. */
  125893. displayLoadingUI(): void;
  125894. /**
  125895. * Function called to hide the loading screen
  125896. */
  125897. hideLoadingUI(): void;
  125898. /**
  125899. * Gets or sets the text to display while loading
  125900. */
  125901. set loadingUIText(text: string);
  125902. get loadingUIText(): string;
  125903. /**
  125904. * Gets or sets the color to use for the background
  125905. */
  125906. get loadingUIBackgroundColor(): string;
  125907. set loadingUIBackgroundColor(color: string);
  125908. private _resizeLoadingUI;
  125909. }
  125910. }
  125911. declare module BABYLON {
  125912. /**
  125913. * Interface for any object that can request an animation frame
  125914. */
  125915. export interface ICustomAnimationFrameRequester {
  125916. /**
  125917. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  125918. */
  125919. renderFunction?: Function;
  125920. /**
  125921. * Called to request the next frame to render to
  125922. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  125923. */
  125924. requestAnimationFrame: Function;
  125925. /**
  125926. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  125927. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  125928. */
  125929. requestID?: number;
  125930. }
  125931. }
  125932. declare module BABYLON {
  125933. /**
  125934. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  125935. */
  125936. export class PerformanceMonitor {
  125937. private _enabled;
  125938. private _rollingFrameTime;
  125939. private _lastFrameTimeMs;
  125940. /**
  125941. * constructor
  125942. * @param frameSampleSize The number of samples required to saturate the sliding window
  125943. */
  125944. constructor(frameSampleSize?: number);
  125945. /**
  125946. * Samples current frame
  125947. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  125948. */
  125949. sampleFrame(timeMs?: number): void;
  125950. /**
  125951. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  125952. */
  125953. get averageFrameTime(): number;
  125954. /**
  125955. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  125956. */
  125957. get averageFrameTimeVariance(): number;
  125958. /**
  125959. * Returns the frame time of the most recent frame
  125960. */
  125961. get instantaneousFrameTime(): number;
  125962. /**
  125963. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  125964. */
  125965. get averageFPS(): number;
  125966. /**
  125967. * Returns the average framerate in frames per second using the most recent frame time
  125968. */
  125969. get instantaneousFPS(): number;
  125970. /**
  125971. * Returns true if enough samples have been taken to completely fill the sliding window
  125972. */
  125973. get isSaturated(): boolean;
  125974. /**
  125975. * Enables contributions to the sliding window sample set
  125976. */
  125977. enable(): void;
  125978. /**
  125979. * Disables contributions to the sliding window sample set
  125980. * Samples will not be interpolated over the disabled period
  125981. */
  125982. disable(): void;
  125983. /**
  125984. * Returns true if sampling is enabled
  125985. */
  125986. get isEnabled(): boolean;
  125987. /**
  125988. * Resets performance monitor
  125989. */
  125990. reset(): void;
  125991. }
  125992. /**
  125993. * RollingAverage
  125994. *
  125995. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  125996. */
  125997. export class RollingAverage {
  125998. /**
  125999. * Current average
  126000. */
  126001. average: number;
  126002. /**
  126003. * Current variance
  126004. */
  126005. variance: number;
  126006. protected _samples: Array<number>;
  126007. protected _sampleCount: number;
  126008. protected _pos: number;
  126009. protected _m2: number;
  126010. /**
  126011. * constructor
  126012. * @param length The number of samples required to saturate the sliding window
  126013. */
  126014. constructor(length: number);
  126015. /**
  126016. * Adds a sample to the sample set
  126017. * @param v The sample value
  126018. */
  126019. add(v: number): void;
  126020. /**
  126021. * Returns previously added values or null if outside of history or outside the sliding window domain
  126022. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  126023. * @return Value previously recorded with add() or null if outside of range
  126024. */
  126025. history(i: number): number;
  126026. /**
  126027. * Returns true if enough samples have been taken to completely fill the sliding window
  126028. * @return true if sample-set saturated
  126029. */
  126030. isSaturated(): boolean;
  126031. /**
  126032. * Resets the rolling average (equivalent to 0 samples taken so far)
  126033. */
  126034. reset(): void;
  126035. /**
  126036. * Wraps a value around the sample range boundaries
  126037. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  126038. * @return Wrapped position in sample range
  126039. */
  126040. protected _wrapPosition(i: number): number;
  126041. }
  126042. }
  126043. declare module BABYLON {
  126044. /**
  126045. * This class is used to track a performance counter which is number based.
  126046. * The user has access to many properties which give statistics of different nature.
  126047. *
  126048. * The implementer can track two kinds of Performance Counter: time and count.
  126049. * 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.
  126050. * 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.
  126051. */
  126052. export class PerfCounter {
  126053. /**
  126054. * Gets or sets a global boolean to turn on and off all the counters
  126055. */
  126056. static Enabled: boolean;
  126057. /**
  126058. * Returns the smallest value ever
  126059. */
  126060. get min(): number;
  126061. /**
  126062. * Returns the biggest value ever
  126063. */
  126064. get max(): number;
  126065. /**
  126066. * Returns the average value since the performance counter is running
  126067. */
  126068. get average(): number;
  126069. /**
  126070. * Returns the average value of the last second the counter was monitored
  126071. */
  126072. get lastSecAverage(): number;
  126073. /**
  126074. * Returns the current value
  126075. */
  126076. get current(): number;
  126077. /**
  126078. * Gets the accumulated total
  126079. */
  126080. get total(): number;
  126081. /**
  126082. * Gets the total value count
  126083. */
  126084. get count(): number;
  126085. /**
  126086. * Creates a new counter
  126087. */
  126088. constructor();
  126089. /**
  126090. * Call this method to start monitoring a new frame.
  126091. * 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.
  126092. */
  126093. fetchNewFrame(): void;
  126094. /**
  126095. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  126096. * @param newCount the count value to add to the monitored count
  126097. * @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.
  126098. */
  126099. addCount(newCount: number, fetchResult: boolean): void;
  126100. /**
  126101. * Start monitoring this performance counter
  126102. */
  126103. beginMonitoring(): void;
  126104. /**
  126105. * Compute the time lapsed since the previous beginMonitoring() call.
  126106. * @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
  126107. */
  126108. endMonitoring(newFrame?: boolean): void;
  126109. private _fetchResult;
  126110. private _startMonitoringTime;
  126111. private _min;
  126112. private _max;
  126113. private _average;
  126114. private _current;
  126115. private _totalValueCount;
  126116. private _totalAccumulated;
  126117. private _lastSecAverage;
  126118. private _lastSecAccumulated;
  126119. private _lastSecTime;
  126120. private _lastSecValueCount;
  126121. }
  126122. }
  126123. declare module BABYLON {
  126124. interface ThinEngine {
  126125. /** @hidden */
  126126. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  126127. }
  126128. }
  126129. declare module BABYLON {
  126130. /**
  126131. * Class used to work with sound analyzer using fast fourier transform (FFT)
  126132. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  126133. */
  126134. export class Analyser {
  126135. /**
  126136. * Gets or sets the smoothing
  126137. * @ignorenaming
  126138. */
  126139. SMOOTHING: number;
  126140. /**
  126141. * Gets or sets the FFT table size
  126142. * @ignorenaming
  126143. */
  126144. FFT_SIZE: number;
  126145. /**
  126146. * Gets or sets the bar graph amplitude
  126147. * @ignorenaming
  126148. */
  126149. BARGRAPHAMPLITUDE: number;
  126150. /**
  126151. * Gets or sets the position of the debug canvas
  126152. * @ignorenaming
  126153. */
  126154. DEBUGCANVASPOS: {
  126155. x: number;
  126156. y: number;
  126157. };
  126158. /**
  126159. * Gets or sets the debug canvas size
  126160. * @ignorenaming
  126161. */
  126162. DEBUGCANVASSIZE: {
  126163. width: number;
  126164. height: number;
  126165. };
  126166. private _byteFreqs;
  126167. private _byteTime;
  126168. private _floatFreqs;
  126169. private _webAudioAnalyser;
  126170. private _debugCanvas;
  126171. private _debugCanvasContext;
  126172. private _scene;
  126173. private _registerFunc;
  126174. private _audioEngine;
  126175. /**
  126176. * Creates a new analyser
  126177. * @param scene defines hosting scene
  126178. */
  126179. constructor(scene: Scene);
  126180. /**
  126181. * Get the number of data values you will have to play with for the visualization
  126182. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  126183. * @returns a number
  126184. */
  126185. getFrequencyBinCount(): number;
  126186. /**
  126187. * Gets the current frequency data as a byte array
  126188. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  126189. * @returns a Uint8Array
  126190. */
  126191. getByteFrequencyData(): Uint8Array;
  126192. /**
  126193. * Gets the current waveform as a byte array
  126194. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  126195. * @returns a Uint8Array
  126196. */
  126197. getByteTimeDomainData(): Uint8Array;
  126198. /**
  126199. * Gets the current frequency data as a float array
  126200. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  126201. * @returns a Float32Array
  126202. */
  126203. getFloatFrequencyData(): Float32Array;
  126204. /**
  126205. * Renders the debug canvas
  126206. */
  126207. drawDebugCanvas(): void;
  126208. /**
  126209. * Stops rendering the debug canvas and removes it
  126210. */
  126211. stopDebugCanvas(): void;
  126212. /**
  126213. * Connects two audio nodes
  126214. * @param inputAudioNode defines first node to connect
  126215. * @param outputAudioNode defines second node to connect
  126216. */
  126217. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  126218. /**
  126219. * Releases all associated resources
  126220. */
  126221. dispose(): void;
  126222. }
  126223. }
  126224. declare module BABYLON {
  126225. /**
  126226. * This represents an audio engine and it is responsible
  126227. * to play, synchronize and analyse sounds throughout the application.
  126228. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  126229. */
  126230. export interface IAudioEngine extends IDisposable {
  126231. /**
  126232. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  126233. */
  126234. readonly canUseWebAudio: boolean;
  126235. /**
  126236. * Gets the current AudioContext if available.
  126237. */
  126238. readonly audioContext: Nullable<AudioContext>;
  126239. /**
  126240. * The master gain node defines the global audio volume of your audio engine.
  126241. */
  126242. readonly masterGain: GainNode;
  126243. /**
  126244. * Gets whether or not mp3 are supported by your browser.
  126245. */
  126246. readonly isMP3supported: boolean;
  126247. /**
  126248. * Gets whether or not ogg are supported by your browser.
  126249. */
  126250. readonly isOGGsupported: boolean;
  126251. /**
  126252. * Defines if Babylon should emit a warning if WebAudio is not supported.
  126253. * @ignoreNaming
  126254. */
  126255. WarnedWebAudioUnsupported: boolean;
  126256. /**
  126257. * Defines if the audio engine relies on a custom unlocked button.
  126258. * In this case, the embedded button will not be displayed.
  126259. */
  126260. useCustomUnlockedButton: boolean;
  126261. /**
  126262. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  126263. */
  126264. readonly unlocked: boolean;
  126265. /**
  126266. * Event raised when audio has been unlocked on the browser.
  126267. */
  126268. onAudioUnlockedObservable: Observable<IAudioEngine>;
  126269. /**
  126270. * Event raised when audio has been locked on the browser.
  126271. */
  126272. onAudioLockedObservable: Observable<IAudioEngine>;
  126273. /**
  126274. * Flags the audio engine in Locked state.
  126275. * This happens due to new browser policies preventing audio to autoplay.
  126276. */
  126277. lock(): void;
  126278. /**
  126279. * Unlocks the audio engine once a user action has been done on the dom.
  126280. * This is helpful to resume play once browser policies have been satisfied.
  126281. */
  126282. unlock(): void;
  126283. /**
  126284. * Gets the global volume sets on the master gain.
  126285. * @returns the global volume if set or -1 otherwise
  126286. */
  126287. getGlobalVolume(): number;
  126288. /**
  126289. * Sets the global volume of your experience (sets on the master gain).
  126290. * @param newVolume Defines the new global volume of the application
  126291. */
  126292. setGlobalVolume(newVolume: number): void;
  126293. /**
  126294. * Connect the audio engine to an audio analyser allowing some amazing
  126295. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  126296. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  126297. * @param analyser The analyser to connect to the engine
  126298. */
  126299. connectToAnalyser(analyser: Analyser): void;
  126300. }
  126301. }
  126302. declare module BABYLON {
  126303. /**
  126304. * Defines the interface used by display changed events
  126305. */
  126306. export interface IDisplayChangedEventArgs {
  126307. /** Gets the vrDisplay object (if any) */
  126308. vrDisplay: Nullable<any>;
  126309. /** Gets a boolean indicating if webVR is supported */
  126310. vrSupported: boolean;
  126311. }
  126312. /**
  126313. * Defines the interface used by objects containing a viewport (like a camera)
  126314. */
  126315. interface IViewportOwnerLike {
  126316. /**
  126317. * Gets or sets the viewport
  126318. */
  126319. viewport: IViewportLike;
  126320. }
  126321. /**
  126322. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  126323. */
  126324. export class Engine extends ThinEngine {
  126325. /** Defines that alpha blending is disabled */
  126326. static readonly ALPHA_DISABLE: number;
  126327. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  126328. static readonly ALPHA_ADD: number;
  126329. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  126330. static readonly ALPHA_COMBINE: number;
  126331. /** Defines that alpha blending to DEST - SRC * DEST */
  126332. static readonly ALPHA_SUBTRACT: number;
  126333. /** Defines that alpha blending to SRC * DEST */
  126334. static readonly ALPHA_MULTIPLY: number;
  126335. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  126336. static readonly ALPHA_MAXIMIZED: number;
  126337. /** Defines that alpha blending to SRC + DEST */
  126338. static readonly ALPHA_ONEONE: number;
  126339. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  126340. static readonly ALPHA_PREMULTIPLIED: number;
  126341. /**
  126342. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  126343. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  126344. */
  126345. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  126346. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  126347. static readonly ALPHA_INTERPOLATE: number;
  126348. /**
  126349. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  126350. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  126351. */
  126352. static readonly ALPHA_SCREENMODE: number;
  126353. /** Defines that the ressource is not delayed*/
  126354. static readonly DELAYLOADSTATE_NONE: number;
  126355. /** Defines that the ressource was successfully delay loaded */
  126356. static readonly DELAYLOADSTATE_LOADED: number;
  126357. /** Defines that the ressource is currently delay loading */
  126358. static readonly DELAYLOADSTATE_LOADING: number;
  126359. /** Defines that the ressource is delayed and has not started loading */
  126360. static readonly DELAYLOADSTATE_NOTLOADED: number;
  126361. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  126362. static readonly NEVER: number;
  126363. /** 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 */
  126364. static readonly ALWAYS: number;
  126365. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  126366. static readonly LESS: number;
  126367. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  126368. static readonly EQUAL: number;
  126369. /** 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 */
  126370. static readonly LEQUAL: number;
  126371. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  126372. static readonly GREATER: number;
  126373. /** 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 */
  126374. static readonly GEQUAL: number;
  126375. /** 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 */
  126376. static readonly NOTEQUAL: number;
  126377. /** Passed to stencilOperation to specify that stencil value must be kept */
  126378. static readonly KEEP: number;
  126379. /** Passed to stencilOperation to specify that stencil value must be replaced */
  126380. static readonly REPLACE: number;
  126381. /** Passed to stencilOperation to specify that stencil value must be incremented */
  126382. static readonly INCR: number;
  126383. /** Passed to stencilOperation to specify that stencil value must be decremented */
  126384. static readonly DECR: number;
  126385. /** Passed to stencilOperation to specify that stencil value must be inverted */
  126386. static readonly INVERT: number;
  126387. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  126388. static readonly INCR_WRAP: number;
  126389. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  126390. static readonly DECR_WRAP: number;
  126391. /** Texture is not repeating outside of 0..1 UVs */
  126392. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  126393. /** Texture is repeating outside of 0..1 UVs */
  126394. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  126395. /** Texture is repeating and mirrored */
  126396. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  126397. /** ALPHA */
  126398. static readonly TEXTUREFORMAT_ALPHA: number;
  126399. /** LUMINANCE */
  126400. static readonly TEXTUREFORMAT_LUMINANCE: number;
  126401. /** LUMINANCE_ALPHA */
  126402. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  126403. /** RGB */
  126404. static readonly TEXTUREFORMAT_RGB: number;
  126405. /** RGBA */
  126406. static readonly TEXTUREFORMAT_RGBA: number;
  126407. /** RED */
  126408. static readonly TEXTUREFORMAT_RED: number;
  126409. /** RED (2nd reference) */
  126410. static readonly TEXTUREFORMAT_R: number;
  126411. /** RG */
  126412. static readonly TEXTUREFORMAT_RG: number;
  126413. /** RED_INTEGER */
  126414. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  126415. /** RED_INTEGER (2nd reference) */
  126416. static readonly TEXTUREFORMAT_R_INTEGER: number;
  126417. /** RG_INTEGER */
  126418. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  126419. /** RGB_INTEGER */
  126420. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  126421. /** RGBA_INTEGER */
  126422. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  126423. /** UNSIGNED_BYTE */
  126424. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  126425. /** UNSIGNED_BYTE (2nd reference) */
  126426. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  126427. /** FLOAT */
  126428. static readonly TEXTURETYPE_FLOAT: number;
  126429. /** HALF_FLOAT */
  126430. static readonly TEXTURETYPE_HALF_FLOAT: number;
  126431. /** BYTE */
  126432. static readonly TEXTURETYPE_BYTE: number;
  126433. /** SHORT */
  126434. static readonly TEXTURETYPE_SHORT: number;
  126435. /** UNSIGNED_SHORT */
  126436. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  126437. /** INT */
  126438. static readonly TEXTURETYPE_INT: number;
  126439. /** UNSIGNED_INT */
  126440. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  126441. /** UNSIGNED_SHORT_4_4_4_4 */
  126442. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  126443. /** UNSIGNED_SHORT_5_5_5_1 */
  126444. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  126445. /** UNSIGNED_SHORT_5_6_5 */
  126446. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  126447. /** UNSIGNED_INT_2_10_10_10_REV */
  126448. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  126449. /** UNSIGNED_INT_24_8 */
  126450. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  126451. /** UNSIGNED_INT_10F_11F_11F_REV */
  126452. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  126453. /** UNSIGNED_INT_5_9_9_9_REV */
  126454. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  126455. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  126456. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  126457. /** nearest is mag = nearest and min = nearest and mip = none */
  126458. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  126459. /** Bilinear is mag = linear and min = linear and mip = nearest */
  126460. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  126461. /** Trilinear is mag = linear and min = linear and mip = linear */
  126462. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  126463. /** nearest is mag = nearest and min = nearest and mip = linear */
  126464. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  126465. /** Bilinear is mag = linear and min = linear and mip = nearest */
  126466. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  126467. /** Trilinear is mag = linear and min = linear and mip = linear */
  126468. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  126469. /** mag = nearest and min = nearest and mip = nearest */
  126470. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  126471. /** mag = nearest and min = linear and mip = nearest */
  126472. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  126473. /** mag = nearest and min = linear and mip = linear */
  126474. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  126475. /** mag = nearest and min = linear and mip = none */
  126476. static readonly TEXTURE_NEAREST_LINEAR: number;
  126477. /** mag = nearest and min = nearest and mip = none */
  126478. static readonly TEXTURE_NEAREST_NEAREST: number;
  126479. /** mag = linear and min = nearest and mip = nearest */
  126480. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  126481. /** mag = linear and min = nearest and mip = linear */
  126482. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  126483. /** mag = linear and min = linear and mip = none */
  126484. static readonly TEXTURE_LINEAR_LINEAR: number;
  126485. /** mag = linear and min = nearest and mip = none */
  126486. static readonly TEXTURE_LINEAR_NEAREST: number;
  126487. /** Explicit coordinates mode */
  126488. static readonly TEXTURE_EXPLICIT_MODE: number;
  126489. /** Spherical coordinates mode */
  126490. static readonly TEXTURE_SPHERICAL_MODE: number;
  126491. /** Planar coordinates mode */
  126492. static readonly TEXTURE_PLANAR_MODE: number;
  126493. /** Cubic coordinates mode */
  126494. static readonly TEXTURE_CUBIC_MODE: number;
  126495. /** Projection coordinates mode */
  126496. static readonly TEXTURE_PROJECTION_MODE: number;
  126497. /** Skybox coordinates mode */
  126498. static readonly TEXTURE_SKYBOX_MODE: number;
  126499. /** Inverse Cubic coordinates mode */
  126500. static readonly TEXTURE_INVCUBIC_MODE: number;
  126501. /** Equirectangular coordinates mode */
  126502. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  126503. /** Equirectangular Fixed coordinates mode */
  126504. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  126505. /** Equirectangular Fixed Mirrored coordinates mode */
  126506. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  126507. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  126508. static readonly SCALEMODE_FLOOR: number;
  126509. /** Defines that texture rescaling will look for the nearest power of 2 size */
  126510. static readonly SCALEMODE_NEAREST: number;
  126511. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  126512. static readonly SCALEMODE_CEILING: number;
  126513. /**
  126514. * Returns the current npm package of the sdk
  126515. */
  126516. static get NpmPackage(): string;
  126517. /**
  126518. * Returns the current version of the framework
  126519. */
  126520. static get Version(): string;
  126521. /** Gets the list of created engines */
  126522. static get Instances(): Engine[];
  126523. /**
  126524. * Gets the latest created engine
  126525. */
  126526. static get LastCreatedEngine(): Nullable<Engine>;
  126527. /**
  126528. * Gets the latest created scene
  126529. */
  126530. static get LastCreatedScene(): Nullable<Scene>;
  126531. /**
  126532. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  126533. * @param flag defines which part of the materials must be marked as dirty
  126534. * @param predicate defines a predicate used to filter which materials should be affected
  126535. */
  126536. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  126537. /**
  126538. * Method called to create the default loading screen.
  126539. * This can be overriden in your own app.
  126540. * @param canvas The rendering canvas element
  126541. * @returns The loading screen
  126542. */
  126543. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  126544. /**
  126545. * Method called to create the default rescale post process on each engine.
  126546. */
  126547. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  126548. /**
  126549. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  126550. **/
  126551. enableOfflineSupport: boolean;
  126552. /**
  126553. * 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)
  126554. **/
  126555. disableManifestCheck: boolean;
  126556. /**
  126557. * Gets the list of created scenes
  126558. */
  126559. scenes: Scene[];
  126560. /**
  126561. * Event raised when a new scene is created
  126562. */
  126563. onNewSceneAddedObservable: Observable<Scene>;
  126564. /**
  126565. * Gets the list of created postprocesses
  126566. */
  126567. postProcesses: PostProcess[];
  126568. /**
  126569. * Gets a boolean indicating if the pointer is currently locked
  126570. */
  126571. isPointerLock: boolean;
  126572. /**
  126573. * Observable event triggered each time the rendering canvas is resized
  126574. */
  126575. onResizeObservable: Observable<Engine>;
  126576. /**
  126577. * Observable event triggered each time the canvas loses focus
  126578. */
  126579. onCanvasBlurObservable: Observable<Engine>;
  126580. /**
  126581. * Observable event triggered each time the canvas gains focus
  126582. */
  126583. onCanvasFocusObservable: Observable<Engine>;
  126584. /**
  126585. * Observable event triggered each time the canvas receives pointerout event
  126586. */
  126587. onCanvasPointerOutObservable: Observable<PointerEvent>;
  126588. /**
  126589. * Observable raised when the engine begins a new frame
  126590. */
  126591. onBeginFrameObservable: Observable<Engine>;
  126592. /**
  126593. * If set, will be used to request the next animation frame for the render loop
  126594. */
  126595. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  126596. /**
  126597. * Observable raised when the engine ends the current frame
  126598. */
  126599. onEndFrameObservable: Observable<Engine>;
  126600. /**
  126601. * Observable raised when the engine is about to compile a shader
  126602. */
  126603. onBeforeShaderCompilationObservable: Observable<Engine>;
  126604. /**
  126605. * Observable raised when the engine has jsut compiled a shader
  126606. */
  126607. onAfterShaderCompilationObservable: Observable<Engine>;
  126608. /**
  126609. * Gets the audio engine
  126610. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  126611. * @ignorenaming
  126612. */
  126613. static audioEngine: IAudioEngine;
  126614. /**
  126615. * Default AudioEngine factory responsible of creating the Audio Engine.
  126616. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  126617. */
  126618. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  126619. /**
  126620. * Default offline support factory responsible of creating a tool used to store data locally.
  126621. * By default, this will create a Database object if the workload has been embedded.
  126622. */
  126623. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  126624. private _loadingScreen;
  126625. private _pointerLockRequested;
  126626. private _rescalePostProcess;
  126627. protected _deterministicLockstep: boolean;
  126628. protected _lockstepMaxSteps: number;
  126629. protected _timeStep: number;
  126630. protected get _supportsHardwareTextureRescaling(): boolean;
  126631. private _fps;
  126632. private _deltaTime;
  126633. /** @hidden */
  126634. _drawCalls: PerfCounter;
  126635. /** 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 */
  126636. canvasTabIndex: number;
  126637. /**
  126638. * Turn this value on if you want to pause FPS computation when in background
  126639. */
  126640. disablePerformanceMonitorInBackground: boolean;
  126641. private _performanceMonitor;
  126642. /**
  126643. * Gets the performance monitor attached to this engine
  126644. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  126645. */
  126646. get performanceMonitor(): PerformanceMonitor;
  126647. private _onFocus;
  126648. private _onBlur;
  126649. private _onCanvasPointerOut;
  126650. private _onCanvasBlur;
  126651. private _onCanvasFocus;
  126652. private _onFullscreenChange;
  126653. private _onPointerLockChange;
  126654. /**
  126655. * Gets the HTML element used to attach event listeners
  126656. * @returns a HTML element
  126657. */
  126658. getInputElement(): Nullable<HTMLElement>;
  126659. /**
  126660. * Creates a new engine
  126661. * @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
  126662. * @param antialias defines enable antialiasing (default: false)
  126663. * @param options defines further options to be sent to the getContext() function
  126664. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  126665. */
  126666. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  126667. /**
  126668. * Shared initialization across engines types.
  126669. * @param canvas The canvas associated with this instance of the engine.
  126670. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  126671. * @param audioEngine Defines if an audio engine should be created by default
  126672. */
  126673. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  126674. /**
  126675. * Gets current aspect ratio
  126676. * @param viewportOwner defines the camera to use to get the aspect ratio
  126677. * @param useScreen defines if screen size must be used (or the current render target if any)
  126678. * @returns a number defining the aspect ratio
  126679. */
  126680. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  126681. /**
  126682. * Gets current screen aspect ratio
  126683. * @returns a number defining the aspect ratio
  126684. */
  126685. getScreenAspectRatio(): number;
  126686. /**
  126687. * Gets the client rect of the HTML canvas attached with the current webGL context
  126688. * @returns a client rectanglee
  126689. */
  126690. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  126691. /**
  126692. * Gets the client rect of the HTML element used for events
  126693. * @returns a client rectanglee
  126694. */
  126695. getInputElementClientRect(): Nullable<ClientRect>;
  126696. /**
  126697. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  126698. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  126699. * @returns true if engine is in deterministic lock step mode
  126700. */
  126701. isDeterministicLockStep(): boolean;
  126702. /**
  126703. * Gets the max steps when engine is running in deterministic lock step
  126704. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  126705. * @returns the max steps
  126706. */
  126707. getLockstepMaxSteps(): number;
  126708. /**
  126709. * Returns the time in ms between steps when using deterministic lock step.
  126710. * @returns time step in (ms)
  126711. */
  126712. getTimeStep(): number;
  126713. /**
  126714. * Force the mipmap generation for the given render target texture
  126715. * @param texture defines the render target texture to use
  126716. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  126717. */
  126718. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  126719. /** States */
  126720. /**
  126721. * Set various states to the webGL context
  126722. * @param culling defines backface culling state
  126723. * @param zOffset defines the value to apply to zOffset (0 by default)
  126724. * @param force defines if states must be applied even if cache is up to date
  126725. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  126726. */
  126727. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  126728. /**
  126729. * Set the z offset to apply to current rendering
  126730. * @param value defines the offset to apply
  126731. */
  126732. setZOffset(value: number): void;
  126733. /**
  126734. * Gets the current value of the zOffset
  126735. * @returns the current zOffset state
  126736. */
  126737. getZOffset(): number;
  126738. /**
  126739. * Gets a boolean indicating if depth testing is enabled
  126740. * @returns the current state
  126741. */
  126742. getDepthBuffer(): boolean;
  126743. /**
  126744. * Enable or disable depth buffering
  126745. * @param enable defines the state to set
  126746. */
  126747. setDepthBuffer(enable: boolean): void;
  126748. /**
  126749. * Gets a boolean indicating if depth writing is enabled
  126750. * @returns the current depth writing state
  126751. */
  126752. getDepthWrite(): boolean;
  126753. /**
  126754. * Enable or disable depth writing
  126755. * @param enable defines the state to set
  126756. */
  126757. setDepthWrite(enable: boolean): void;
  126758. /**
  126759. * Gets a boolean indicating if stencil buffer is enabled
  126760. * @returns the current stencil buffer state
  126761. */
  126762. getStencilBuffer(): boolean;
  126763. /**
  126764. * Enable or disable the stencil buffer
  126765. * @param enable defines if the stencil buffer must be enabled or disabled
  126766. */
  126767. setStencilBuffer(enable: boolean): void;
  126768. /**
  126769. * Gets the current stencil mask
  126770. * @returns a number defining the new stencil mask to use
  126771. */
  126772. getStencilMask(): number;
  126773. /**
  126774. * Sets the current stencil mask
  126775. * @param mask defines the new stencil mask to use
  126776. */
  126777. setStencilMask(mask: number): void;
  126778. /**
  126779. * Gets the current stencil function
  126780. * @returns a number defining the stencil function to use
  126781. */
  126782. getStencilFunction(): number;
  126783. /**
  126784. * Gets the current stencil reference value
  126785. * @returns a number defining the stencil reference value to use
  126786. */
  126787. getStencilFunctionReference(): number;
  126788. /**
  126789. * Gets the current stencil mask
  126790. * @returns a number defining the stencil mask to use
  126791. */
  126792. getStencilFunctionMask(): number;
  126793. /**
  126794. * Sets the current stencil function
  126795. * @param stencilFunc defines the new stencil function to use
  126796. */
  126797. setStencilFunction(stencilFunc: number): void;
  126798. /**
  126799. * Sets the current stencil reference
  126800. * @param reference defines the new stencil reference to use
  126801. */
  126802. setStencilFunctionReference(reference: number): void;
  126803. /**
  126804. * Sets the current stencil mask
  126805. * @param mask defines the new stencil mask to use
  126806. */
  126807. setStencilFunctionMask(mask: number): void;
  126808. /**
  126809. * Gets the current stencil operation when stencil fails
  126810. * @returns a number defining stencil operation to use when stencil fails
  126811. */
  126812. getStencilOperationFail(): number;
  126813. /**
  126814. * Gets the current stencil operation when depth fails
  126815. * @returns a number defining stencil operation to use when depth fails
  126816. */
  126817. getStencilOperationDepthFail(): number;
  126818. /**
  126819. * Gets the current stencil operation when stencil passes
  126820. * @returns a number defining stencil operation to use when stencil passes
  126821. */
  126822. getStencilOperationPass(): number;
  126823. /**
  126824. * Sets the stencil operation to use when stencil fails
  126825. * @param operation defines the stencil operation to use when stencil fails
  126826. */
  126827. setStencilOperationFail(operation: number): void;
  126828. /**
  126829. * Sets the stencil operation to use when depth fails
  126830. * @param operation defines the stencil operation to use when depth fails
  126831. */
  126832. setStencilOperationDepthFail(operation: number): void;
  126833. /**
  126834. * Sets the stencil operation to use when stencil passes
  126835. * @param operation defines the stencil operation to use when stencil passes
  126836. */
  126837. setStencilOperationPass(operation: number): void;
  126838. /**
  126839. * Sets a boolean indicating if the dithering state is enabled or disabled
  126840. * @param value defines the dithering state
  126841. */
  126842. setDitheringState(value: boolean): void;
  126843. /**
  126844. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  126845. * @param value defines the rasterizer state
  126846. */
  126847. setRasterizerState(value: boolean): void;
  126848. /**
  126849. * Gets the current depth function
  126850. * @returns a number defining the depth function
  126851. */
  126852. getDepthFunction(): Nullable<number>;
  126853. /**
  126854. * Sets the current depth function
  126855. * @param depthFunc defines the function to use
  126856. */
  126857. setDepthFunction(depthFunc: number): void;
  126858. /**
  126859. * Sets the current depth function to GREATER
  126860. */
  126861. setDepthFunctionToGreater(): void;
  126862. /**
  126863. * Sets the current depth function to GEQUAL
  126864. */
  126865. setDepthFunctionToGreaterOrEqual(): void;
  126866. /**
  126867. * Sets the current depth function to LESS
  126868. */
  126869. setDepthFunctionToLess(): void;
  126870. /**
  126871. * Sets the current depth function to LEQUAL
  126872. */
  126873. setDepthFunctionToLessOrEqual(): void;
  126874. private _cachedStencilBuffer;
  126875. private _cachedStencilFunction;
  126876. private _cachedStencilMask;
  126877. private _cachedStencilOperationPass;
  126878. private _cachedStencilOperationFail;
  126879. private _cachedStencilOperationDepthFail;
  126880. private _cachedStencilReference;
  126881. /**
  126882. * Caches the the state of the stencil buffer
  126883. */
  126884. cacheStencilState(): void;
  126885. /**
  126886. * Restores the state of the stencil buffer
  126887. */
  126888. restoreStencilState(): void;
  126889. /**
  126890. * Directly set the WebGL Viewport
  126891. * @param x defines the x coordinate of the viewport (in screen space)
  126892. * @param y defines the y coordinate of the viewport (in screen space)
  126893. * @param width defines the width of the viewport (in screen space)
  126894. * @param height defines the height of the viewport (in screen space)
  126895. * @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
  126896. */
  126897. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  126898. /**
  126899. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  126900. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  126901. * @param y defines the y-coordinate of the corner of the clear rectangle
  126902. * @param width defines the width of the clear rectangle
  126903. * @param height defines the height of the clear rectangle
  126904. * @param clearColor defines the clear color
  126905. */
  126906. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  126907. /**
  126908. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  126909. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  126910. * @param y defines the y-coordinate of the corner of the clear rectangle
  126911. * @param width defines the width of the clear rectangle
  126912. * @param height defines the height of the clear rectangle
  126913. */
  126914. enableScissor(x: number, y: number, width: number, height: number): void;
  126915. /**
  126916. * Disable previously set scissor test rectangle
  126917. */
  126918. disableScissor(): void;
  126919. protected _reportDrawCall(): void;
  126920. /**
  126921. * Initializes a webVR display and starts listening to display change events
  126922. * The onVRDisplayChangedObservable will be notified upon these changes
  126923. * @returns The onVRDisplayChangedObservable
  126924. */
  126925. initWebVR(): Observable<IDisplayChangedEventArgs>;
  126926. /** @hidden */
  126927. _prepareVRComponent(): void;
  126928. /** @hidden */
  126929. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  126930. /** @hidden */
  126931. _submitVRFrame(): void;
  126932. /**
  126933. * Call this function to leave webVR mode
  126934. * Will do nothing if webVR is not supported or if there is no webVR device
  126935. * @see https://doc.babylonjs.com/how_to/webvr_camera
  126936. */
  126937. disableVR(): void;
  126938. /**
  126939. * Gets a boolean indicating that the system is in VR mode and is presenting
  126940. * @returns true if VR mode is engaged
  126941. */
  126942. isVRPresenting(): boolean;
  126943. /** @hidden */
  126944. _requestVRFrame(): void;
  126945. /** @hidden */
  126946. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  126947. /**
  126948. * Gets the source code of the vertex shader associated with a specific webGL program
  126949. * @param program defines the program to use
  126950. * @returns a string containing the source code of the vertex shader associated with the program
  126951. */
  126952. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  126953. /**
  126954. * Gets the source code of the fragment shader associated with a specific webGL program
  126955. * @param program defines the program to use
  126956. * @returns a string containing the source code of the fragment shader associated with the program
  126957. */
  126958. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  126959. /**
  126960. * Sets a depth stencil texture from a render target to the according uniform.
  126961. * @param channel The texture channel
  126962. * @param uniform The uniform to set
  126963. * @param texture The render target texture containing the depth stencil texture to apply
  126964. * @param name The texture name
  126965. */
  126966. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>, name?: string): void;
  126967. /**
  126968. * Sets a texture to the webGL context from a postprocess
  126969. * @param channel defines the channel to use
  126970. * @param postProcess defines the source postprocess
  126971. * @param name name of the channel
  126972. */
  126973. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  126974. /**
  126975. * Binds the output of the passed in post process to the texture channel specified
  126976. * @param channel The channel the texture should be bound to
  126977. * @param postProcess The post process which's output should be bound
  126978. * @param name name of the channel
  126979. */
  126980. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  126981. protected _rebuildBuffers(): void;
  126982. /** @hidden */
  126983. _renderFrame(): void;
  126984. _renderLoop(): void;
  126985. /** @hidden */
  126986. _renderViews(): boolean;
  126987. /**
  126988. * Toggle full screen mode
  126989. * @param requestPointerLock defines if a pointer lock should be requested from the user
  126990. */
  126991. switchFullscreen(requestPointerLock: boolean): void;
  126992. /**
  126993. * Enters full screen mode
  126994. * @param requestPointerLock defines if a pointer lock should be requested from the user
  126995. */
  126996. enterFullscreen(requestPointerLock: boolean): void;
  126997. /**
  126998. * Exits full screen mode
  126999. */
  127000. exitFullscreen(): void;
  127001. /**
  127002. * Enters Pointerlock mode
  127003. */
  127004. enterPointerlock(): void;
  127005. /**
  127006. * Exits Pointerlock mode
  127007. */
  127008. exitPointerlock(): void;
  127009. /**
  127010. * Begin a new frame
  127011. */
  127012. beginFrame(): void;
  127013. /**
  127014. * End the current frame
  127015. */
  127016. endFrame(): void;
  127017. /**
  127018. * Resize the view according to the canvas' size
  127019. * @param forceSetSize true to force setting the sizes of the underlying canvas
  127020. */
  127021. resize(forceSetSize?: boolean): void;
  127022. /**
  127023. * Force a specific size of the canvas
  127024. * @param width defines the new canvas' width
  127025. * @param height defines the new canvas' height
  127026. * @param forceSetSize true to force setting the sizes of the underlying canvas
  127027. * @returns true if the size was changed
  127028. */
  127029. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  127030. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  127031. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  127032. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  127033. _releaseTexture(texture: InternalTexture): void;
  127034. /**
  127035. * @hidden
  127036. * Rescales a texture
  127037. * @param source input texutre
  127038. * @param destination destination texture
  127039. * @param scene scene to use to render the resize
  127040. * @param internalFormat format to use when resizing
  127041. * @param onComplete callback to be called when resize has completed
  127042. */
  127043. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  127044. /**
  127045. * Gets the current framerate
  127046. * @returns a number representing the framerate
  127047. */
  127048. getFps(): number;
  127049. /**
  127050. * Gets the time spent between current and previous frame
  127051. * @returns a number representing the delta time in ms
  127052. */
  127053. getDeltaTime(): number;
  127054. private _measureFps;
  127055. /** @hidden */
  127056. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  127057. /**
  127058. * Updates the sample count of a render target texture
  127059. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  127060. * @param texture defines the texture to update
  127061. * @param samples defines the sample count to set
  127062. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  127063. */
  127064. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  127065. /**
  127066. * Updates a depth texture Comparison Mode and Function.
  127067. * If the comparison Function is equal to 0, the mode will be set to none.
  127068. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  127069. * @param texture The texture to set the comparison function for
  127070. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  127071. */
  127072. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  127073. /**
  127074. * Creates a webGL buffer to use with instanciation
  127075. * @param capacity defines the size of the buffer
  127076. * @returns the webGL buffer
  127077. */
  127078. createInstancesBuffer(capacity: number): DataBuffer;
  127079. /**
  127080. * Delete a webGL buffer used with instanciation
  127081. * @param buffer defines the webGL buffer to delete
  127082. */
  127083. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  127084. private _clientWaitAsync;
  127085. /** @hidden */
  127086. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Nullable<Promise<ArrayBufferView>>;
  127087. dispose(): void;
  127088. private _disableTouchAction;
  127089. /**
  127090. * Display the loading screen
  127091. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  127092. */
  127093. displayLoadingUI(): void;
  127094. /**
  127095. * Hide the loading screen
  127096. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  127097. */
  127098. hideLoadingUI(): void;
  127099. /**
  127100. * Gets the current loading screen object
  127101. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  127102. */
  127103. get loadingScreen(): ILoadingScreen;
  127104. /**
  127105. * Sets the current loading screen object
  127106. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  127107. */
  127108. set loadingScreen(loadingScreen: ILoadingScreen);
  127109. /**
  127110. * Sets the current loading screen text
  127111. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  127112. */
  127113. set loadingUIText(text: string);
  127114. /**
  127115. * Sets the current loading screen background color
  127116. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  127117. */
  127118. set loadingUIBackgroundColor(color: string);
  127119. /** Pointerlock and fullscreen */
  127120. /**
  127121. * Ask the browser to promote the current element to pointerlock mode
  127122. * @param element defines the DOM element to promote
  127123. */
  127124. static _RequestPointerlock(element: HTMLElement): void;
  127125. /**
  127126. * Asks the browser to exit pointerlock mode
  127127. */
  127128. static _ExitPointerlock(): void;
  127129. /**
  127130. * Ask the browser to promote the current element to fullscreen rendering mode
  127131. * @param element defines the DOM element to promote
  127132. */
  127133. static _RequestFullscreen(element: HTMLElement): void;
  127134. /**
  127135. * Asks the browser to exit fullscreen mode
  127136. */
  127137. static _ExitFullscreen(): void;
  127138. }
  127139. }
  127140. declare module BABYLON {
  127141. /**
  127142. * The engine store class is responsible to hold all the instances of Engine and Scene created
  127143. * during the life time of the application.
  127144. */
  127145. export class EngineStore {
  127146. /** Gets the list of created engines */
  127147. static Instances: Engine[];
  127148. /** @hidden */
  127149. static _LastCreatedScene: Nullable<Scene>;
  127150. /**
  127151. * Gets the latest created engine
  127152. */
  127153. static get LastCreatedEngine(): Nullable<Engine>;
  127154. /**
  127155. * Gets the latest created scene
  127156. */
  127157. static get LastCreatedScene(): Nullable<Scene>;
  127158. /**
  127159. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  127160. * @ignorenaming
  127161. */
  127162. static UseFallbackTexture: boolean;
  127163. /**
  127164. * Texture content used if a texture cannot loaded
  127165. * @ignorenaming
  127166. */
  127167. static FallbackTexture: string;
  127168. }
  127169. }
  127170. declare module BABYLON {
  127171. /**
  127172. * Helper class that provides a small promise polyfill
  127173. */
  127174. export class PromisePolyfill {
  127175. /**
  127176. * Static function used to check if the polyfill is required
  127177. * If this is the case then the function will inject the polyfill to window.Promise
  127178. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  127179. */
  127180. static Apply(force?: boolean): void;
  127181. }
  127182. }
  127183. declare module BABYLON {
  127184. /**
  127185. * Interface for screenshot methods with describe argument called `size` as object with options
  127186. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  127187. */
  127188. export interface IScreenshotSize {
  127189. /**
  127190. * number in pixels for canvas height
  127191. */
  127192. height?: number;
  127193. /**
  127194. * multiplier allowing render at a higher or lower resolution
  127195. * If value is defined then height and width will be ignored and taken from camera
  127196. */
  127197. precision?: number;
  127198. /**
  127199. * number in pixels for canvas width
  127200. */
  127201. width?: number;
  127202. }
  127203. }
  127204. declare module BABYLON {
  127205. interface IColor4Like {
  127206. r: float;
  127207. g: float;
  127208. b: float;
  127209. a: float;
  127210. }
  127211. /**
  127212. * Class containing a set of static utilities functions
  127213. */
  127214. export class Tools {
  127215. /**
  127216. * Gets or sets the base URL to use to load assets
  127217. */
  127218. static get BaseUrl(): string;
  127219. static set BaseUrl(value: string);
  127220. /**
  127221. * Enable/Disable Custom HTTP Request Headers globally.
  127222. * default = false
  127223. * @see CustomRequestHeaders
  127224. */
  127225. static UseCustomRequestHeaders: boolean;
  127226. /**
  127227. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  127228. * i.e. when loading files, where the server/service expects an Authorization header
  127229. */
  127230. static CustomRequestHeaders: {
  127231. [key: string]: string;
  127232. };
  127233. /**
  127234. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  127235. */
  127236. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  127237. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  127238. /**
  127239. * Default behaviour for cors in the application.
  127240. * It can be a string if the expected behavior is identical in the entire app.
  127241. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  127242. */
  127243. static get CorsBehavior(): string | ((url: string | string[]) => string);
  127244. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  127245. /**
  127246. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  127247. * @ignorenaming
  127248. */
  127249. static get UseFallbackTexture(): boolean;
  127250. static set UseFallbackTexture(value: boolean);
  127251. /**
  127252. * Use this object to register external classes like custom textures or material
  127253. * to allow the laoders to instantiate them
  127254. */
  127255. static get RegisteredExternalClasses(): {
  127256. [key: string]: Object;
  127257. };
  127258. static set RegisteredExternalClasses(classes: {
  127259. [key: string]: Object;
  127260. });
  127261. /**
  127262. * Texture content used if a texture cannot loaded
  127263. * @ignorenaming
  127264. */
  127265. static get fallbackTexture(): string;
  127266. static set fallbackTexture(value: string);
  127267. /**
  127268. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  127269. * @param u defines the coordinate on X axis
  127270. * @param v defines the coordinate on Y axis
  127271. * @param width defines the width of the source data
  127272. * @param height defines the height of the source data
  127273. * @param pixels defines the source byte array
  127274. * @param color defines the output color
  127275. */
  127276. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  127277. /**
  127278. * Interpolates between a and b via alpha
  127279. * @param a The lower value (returned when alpha = 0)
  127280. * @param b The upper value (returned when alpha = 1)
  127281. * @param alpha The interpolation-factor
  127282. * @return The mixed value
  127283. */
  127284. static Mix(a: number, b: number, alpha: number): number;
  127285. /**
  127286. * Tries to instantiate a new object from a given class name
  127287. * @param className defines the class name to instantiate
  127288. * @returns the new object or null if the system was not able to do the instantiation
  127289. */
  127290. static Instantiate(className: string): any;
  127291. /**
  127292. * Provides a slice function that will work even on IE
  127293. * @param data defines the array to slice
  127294. * @param start defines the start of the data (optional)
  127295. * @param end defines the end of the data (optional)
  127296. * @returns the new sliced array
  127297. */
  127298. static Slice<T>(data: T, start?: number, end?: number): T;
  127299. /**
  127300. * Provides a slice function that will work even on IE
  127301. * The difference between this and Slice is that this will force-convert to array
  127302. * @param data defines the array to slice
  127303. * @param start defines the start of the data (optional)
  127304. * @param end defines the end of the data (optional)
  127305. * @returns the new sliced array
  127306. */
  127307. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  127308. /**
  127309. * Polyfill for setImmediate
  127310. * @param action defines the action to execute after the current execution block
  127311. */
  127312. static SetImmediate(action: () => void): void;
  127313. /**
  127314. * Function indicating if a number is an exponent of 2
  127315. * @param value defines the value to test
  127316. * @returns true if the value is an exponent of 2
  127317. */
  127318. static IsExponentOfTwo(value: number): boolean;
  127319. private static _tmpFloatArray;
  127320. /**
  127321. * Returns the nearest 32-bit single precision float representation of a Number
  127322. * @param value A Number. If the parameter is of a different type, it will get converted
  127323. * to a number or to NaN if it cannot be converted
  127324. * @returns number
  127325. */
  127326. static FloatRound(value: number): number;
  127327. /**
  127328. * Extracts the filename from a path
  127329. * @param path defines the path to use
  127330. * @returns the filename
  127331. */
  127332. static GetFilename(path: string): string;
  127333. /**
  127334. * Extracts the "folder" part of a path (everything before the filename).
  127335. * @param uri The URI to extract the info from
  127336. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  127337. * @returns The "folder" part of the path
  127338. */
  127339. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  127340. /**
  127341. * Extracts text content from a DOM element hierarchy
  127342. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  127343. */
  127344. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  127345. /**
  127346. * Convert an angle in radians to degrees
  127347. * @param angle defines the angle to convert
  127348. * @returns the angle in degrees
  127349. */
  127350. static ToDegrees(angle: number): number;
  127351. /**
  127352. * Convert an angle in degrees to radians
  127353. * @param angle defines the angle to convert
  127354. * @returns the angle in radians
  127355. */
  127356. static ToRadians(angle: number): number;
  127357. /**
  127358. * Returns an array if obj is not an array
  127359. * @param obj defines the object to evaluate as an array
  127360. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  127361. * @returns either obj directly if obj is an array or a new array containing obj
  127362. */
  127363. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  127364. /**
  127365. * Gets the pointer prefix to use
  127366. * @param engine defines the engine we are finding the prefix for
  127367. * @returns "pointer" if touch is enabled. Else returns "mouse"
  127368. */
  127369. static GetPointerPrefix(engine: Engine): string;
  127370. /**
  127371. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  127372. * @param url define the url we are trying
  127373. * @param element define the dom element where to configure the cors policy
  127374. */
  127375. static SetCorsBehavior(url: string | string[], element: {
  127376. crossOrigin: string | null;
  127377. }): void;
  127378. /**
  127379. * Removes unwanted characters from an url
  127380. * @param url defines the url to clean
  127381. * @returns the cleaned url
  127382. */
  127383. static CleanUrl(url: string): string;
  127384. /**
  127385. * Gets or sets a function used to pre-process url before using them to load assets
  127386. */
  127387. static get PreprocessUrl(): (url: string) => string;
  127388. static set PreprocessUrl(processor: (url: string) => string);
  127389. /**
  127390. * Loads an image as an HTMLImageElement.
  127391. * @param input url string, ArrayBuffer, or Blob to load
  127392. * @param onLoad callback called when the image successfully loads
  127393. * @param onError callback called when the image fails to load
  127394. * @param offlineProvider offline provider for caching
  127395. * @param mimeType optional mime type
  127396. * @returns the HTMLImageElement of the loaded image
  127397. */
  127398. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  127399. /**
  127400. * Loads a file from a url
  127401. * @param url url string, ArrayBuffer, or Blob to load
  127402. * @param onSuccess callback called when the file successfully loads
  127403. * @param onProgress callback called while file is loading (if the server supports this mode)
  127404. * @param offlineProvider defines the offline provider for caching
  127405. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  127406. * @param onError callback called when the file fails to load
  127407. * @returns a file request object
  127408. */
  127409. 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;
  127410. /**
  127411. * Loads a file from a url
  127412. * @param url the file url to load
  127413. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  127414. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  127415. */
  127416. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  127417. /**
  127418. * Load a script (identified by an url). When the url returns, the
  127419. * content of this file is added into a new script element, attached to the DOM (body element)
  127420. * @param scriptUrl defines the url of the script to laod
  127421. * @param onSuccess defines the callback called when the script is loaded
  127422. * @param onError defines the callback to call if an error occurs
  127423. * @param scriptId defines the id of the script element
  127424. */
  127425. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  127426. /**
  127427. * Load an asynchronous script (identified by an url). When the url returns, the
  127428. * content of this file is added into a new script element, attached to the DOM (body element)
  127429. * @param scriptUrl defines the url of the script to laod
  127430. * @param scriptId defines the id of the script element
  127431. * @returns a promise request object
  127432. */
  127433. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  127434. /**
  127435. * Loads a file from a blob
  127436. * @param fileToLoad defines the blob to use
  127437. * @param callback defines the callback to call when data is loaded
  127438. * @param progressCallback defines the callback to call during loading process
  127439. * @returns a file request object
  127440. */
  127441. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  127442. /**
  127443. * Reads a file from a File object
  127444. * @param file defines the file to load
  127445. * @param onSuccess defines the callback to call when data is loaded
  127446. * @param onProgress defines the callback to call during loading process
  127447. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  127448. * @param onError defines the callback to call when an error occurs
  127449. * @returns a file request object
  127450. */
  127451. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  127452. /**
  127453. * Creates a data url from a given string content
  127454. * @param content defines the content to convert
  127455. * @returns the new data url link
  127456. */
  127457. static FileAsURL(content: string): string;
  127458. /**
  127459. * Format the given number to a specific decimal format
  127460. * @param value defines the number to format
  127461. * @param decimals defines the number of decimals to use
  127462. * @returns the formatted string
  127463. */
  127464. static Format(value: number, decimals?: number): string;
  127465. /**
  127466. * Tries to copy an object by duplicating every property
  127467. * @param source defines the source object
  127468. * @param destination defines the target object
  127469. * @param doNotCopyList defines a list of properties to avoid
  127470. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  127471. */
  127472. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  127473. /**
  127474. * Gets a boolean indicating if the given object has no own property
  127475. * @param obj defines the object to test
  127476. * @returns true if object has no own property
  127477. */
  127478. static IsEmpty(obj: any): boolean;
  127479. /**
  127480. * Function used to register events at window level
  127481. * @param windowElement defines the Window object to use
  127482. * @param events defines the events to register
  127483. */
  127484. static RegisterTopRootEvents(windowElement: Window, events: {
  127485. name: string;
  127486. handler: Nullable<(e: FocusEvent) => any>;
  127487. }[]): void;
  127488. /**
  127489. * Function used to unregister events from window level
  127490. * @param windowElement defines the Window object to use
  127491. * @param events defines the events to unregister
  127492. */
  127493. static UnregisterTopRootEvents(windowElement: Window, events: {
  127494. name: string;
  127495. handler: Nullable<(e: FocusEvent) => any>;
  127496. }[]): void;
  127497. /**
  127498. * @ignore
  127499. */
  127500. static _ScreenshotCanvas: HTMLCanvasElement;
  127501. /**
  127502. * Dumps the current bound framebuffer
  127503. * @param width defines the rendering width
  127504. * @param height defines the rendering height
  127505. * @param engine defines the hosting engine
  127506. * @param successCallback defines the callback triggered once the data are available
  127507. * @param mimeType defines the mime type of the result
  127508. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  127509. * @return a void promise
  127510. */
  127511. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): Promise<void>;
  127512. /**
  127513. * Dumps an array buffer
  127514. * @param width defines the rendering width
  127515. * @param height defines the rendering height
  127516. * @param data the data array
  127517. * @param successCallback defines the callback triggered once the data are available
  127518. * @param mimeType defines the mime type of the result
  127519. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  127520. * @param invertY true to invert the picture in the Y dimension
  127521. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  127522. */
  127523. static DumpData(width: number, height: number, data: ArrayBufferView, successCallback?: (data: string | ArrayBuffer) => void, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): void;
  127524. /**
  127525. * Dumps an array buffer
  127526. * @param width defines the rendering width
  127527. * @param height defines the rendering height
  127528. * @param data the data array
  127529. * @param successCallback defines the callback triggered once the data are available
  127530. * @param mimeType defines the mime type of the result
  127531. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  127532. * @param invertY true to invert the picture in the Y dimension
  127533. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  127534. * @return a promise that resolve to the final data
  127535. */
  127536. static DumpDataAsync(width: number, height: number, data: ArrayBufferView, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  127537. /**
  127538. * Converts the canvas data to blob.
  127539. * This acts as a polyfill for browsers not supporting the to blob function.
  127540. * @param canvas Defines the canvas to extract the data from
  127541. * @param successCallback Defines the callback triggered once the data are available
  127542. * @param mimeType Defines the mime type of the result
  127543. */
  127544. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  127545. /**
  127546. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  127547. * @param successCallback defines the callback triggered once the data are available
  127548. * @param mimeType defines the mime type of the result
  127549. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  127550. * @param canvas canvas to get the data from. If not provided, use the default screenshot canvas
  127551. */
  127552. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string, canvas?: HTMLCanvasElement): void;
  127553. /**
  127554. * Downloads a blob in the browser
  127555. * @param blob defines the blob to download
  127556. * @param fileName defines the name of the downloaded file
  127557. */
  127558. static Download(blob: Blob, fileName: string): void;
  127559. /**
  127560. * Will return the right value of the noPreventDefault variable
  127561. * Needed to keep backwards compatibility to the old API.
  127562. *
  127563. * @param args arguments passed to the attachControl function
  127564. * @returns the correct value for noPreventDefault
  127565. */
  127566. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  127567. /**
  127568. * Captures a screenshot of the current rendering
  127569. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  127570. * @param engine defines the rendering engine
  127571. * @param camera defines the source camera
  127572. * @param size This parameter can be set to a single number or to an object with the
  127573. * following (optional) properties: precision, width, height. If a single number is passed,
  127574. * it will be used for both width and height. If an object is passed, the screenshot size
  127575. * will be derived from the parameters. The precision property is a multiplier allowing
  127576. * rendering at a higher or lower resolution
  127577. * @param successCallback defines the callback receives a single parameter which contains the
  127578. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  127579. * src parameter of an <img> to display it
  127580. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  127581. * Check your browser for supported MIME types
  127582. */
  127583. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  127584. /**
  127585. * Captures a screenshot of the current rendering
  127586. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  127587. * @param engine defines the rendering engine
  127588. * @param camera defines the source camera
  127589. * @param size This parameter can be set to a single number or to an object with the
  127590. * following (optional) properties: precision, width, height. If a single number is passed,
  127591. * it will be used for both width and height. If an object is passed, the screenshot size
  127592. * will be derived from the parameters. The precision property is a multiplier allowing
  127593. * rendering at a higher or lower resolution
  127594. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  127595. * Check your browser for supported MIME types
  127596. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  127597. * to the src parameter of an <img> to display it
  127598. */
  127599. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  127600. /**
  127601. * Generates an image screenshot from the specified camera.
  127602. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  127603. * @param engine The engine to use for rendering
  127604. * @param camera The camera to use for rendering
  127605. * @param size This parameter can be set to a single number or to an object with the
  127606. * following (optional) properties: precision, width, height. If a single number is passed,
  127607. * it will be used for both width and height. If an object is passed, the screenshot size
  127608. * will be derived from the parameters. The precision property is a multiplier allowing
  127609. * rendering at a higher or lower resolution
  127610. * @param successCallback The callback receives a single parameter which contains the
  127611. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  127612. * src parameter of an <img> to display it
  127613. * @param mimeType The MIME type of the screenshot image (default: image/png).
  127614. * Check your browser for supported MIME types
  127615. * @param samples Texture samples (default: 1)
  127616. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  127617. * @param fileName A name for for the downloaded file.
  127618. */
  127619. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  127620. /**
  127621. * Generates an image screenshot from the specified camera.
  127622. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  127623. * @param engine The engine to use for rendering
  127624. * @param camera The camera to use for rendering
  127625. * @param size This parameter can be set to a single number or to an object with the
  127626. * following (optional) properties: precision, width, height. If a single number is passed,
  127627. * it will be used for both width and height. If an object is passed, the screenshot size
  127628. * will be derived from the parameters. The precision property is a multiplier allowing
  127629. * rendering at a higher or lower resolution
  127630. * @param mimeType The MIME type of the screenshot image (default: image/png).
  127631. * Check your browser for supported MIME types
  127632. * @param samples Texture samples (default: 1)
  127633. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  127634. * @param fileName A name for for the downloaded file.
  127635. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  127636. * to the src parameter of an <img> to display it
  127637. */
  127638. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  127639. /**
  127640. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  127641. * Be aware Math.random() could cause collisions, but:
  127642. * "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"
  127643. * @returns a pseudo random id
  127644. */
  127645. static RandomId(): string;
  127646. /**
  127647. * Test if the given uri is a base64 string
  127648. * @param uri The uri to test
  127649. * @return True if the uri is a base64 string or false otherwise
  127650. */
  127651. static IsBase64(uri: string): boolean;
  127652. /**
  127653. * Decode the given base64 uri.
  127654. * @param uri The uri to decode
  127655. * @return The decoded base64 data.
  127656. */
  127657. static DecodeBase64(uri: string): ArrayBuffer;
  127658. /**
  127659. * Gets the absolute url.
  127660. * @param url the input url
  127661. * @return the absolute url
  127662. */
  127663. static GetAbsoluteUrl(url: string): string;
  127664. /**
  127665. * No log
  127666. */
  127667. static readonly NoneLogLevel: number;
  127668. /**
  127669. * Only message logs
  127670. */
  127671. static readonly MessageLogLevel: number;
  127672. /**
  127673. * Only warning logs
  127674. */
  127675. static readonly WarningLogLevel: number;
  127676. /**
  127677. * Only error logs
  127678. */
  127679. static readonly ErrorLogLevel: number;
  127680. /**
  127681. * All logs
  127682. */
  127683. static readonly AllLogLevel: number;
  127684. /**
  127685. * Gets a value indicating the number of loading errors
  127686. * @ignorenaming
  127687. */
  127688. static get errorsCount(): number;
  127689. /**
  127690. * Callback called when a new log is added
  127691. */
  127692. static OnNewCacheEntry: (entry: string) => void;
  127693. /**
  127694. * Log a message to the console
  127695. * @param message defines the message to log
  127696. */
  127697. static Log(message: string): void;
  127698. /**
  127699. * Write a warning message to the console
  127700. * @param message defines the message to log
  127701. */
  127702. static Warn(message: string): void;
  127703. /**
  127704. * Write an error message to the console
  127705. * @param message defines the message to log
  127706. */
  127707. static Error(message: string): void;
  127708. /**
  127709. * Gets current log cache (list of logs)
  127710. */
  127711. static get LogCache(): string;
  127712. /**
  127713. * Clears the log cache
  127714. */
  127715. static ClearLogCache(): void;
  127716. /**
  127717. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  127718. */
  127719. static set LogLevels(level: number);
  127720. /**
  127721. * Checks if the window object exists
  127722. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  127723. */
  127724. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  127725. /**
  127726. * No performance log
  127727. */
  127728. static readonly PerformanceNoneLogLevel: number;
  127729. /**
  127730. * Use user marks to log performance
  127731. */
  127732. static readonly PerformanceUserMarkLogLevel: number;
  127733. /**
  127734. * Log performance to the console
  127735. */
  127736. static readonly PerformanceConsoleLogLevel: number;
  127737. private static _performance;
  127738. /**
  127739. * Sets the current performance log level
  127740. */
  127741. static set PerformanceLogLevel(level: number);
  127742. private static _StartPerformanceCounterDisabled;
  127743. private static _EndPerformanceCounterDisabled;
  127744. private static _StartUserMark;
  127745. private static _EndUserMark;
  127746. private static _StartPerformanceConsole;
  127747. private static _EndPerformanceConsole;
  127748. /**
  127749. * Starts a performance counter
  127750. */
  127751. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  127752. /**
  127753. * Ends a specific performance coutner
  127754. */
  127755. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  127756. /**
  127757. * Gets either window.performance.now() if supported or Date.now() else
  127758. */
  127759. static get Now(): number;
  127760. /**
  127761. * This method will return the name of the class used to create the instance of the given object.
  127762. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  127763. * @param object the object to get the class name from
  127764. * @param isType defines if the object is actually a type
  127765. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  127766. */
  127767. static GetClassName(object: any, isType?: boolean): string;
  127768. /**
  127769. * Gets the first element of an array satisfying a given predicate
  127770. * @param array defines the array to browse
  127771. * @param predicate defines the predicate to use
  127772. * @returns null if not found or the element
  127773. */
  127774. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  127775. /**
  127776. * This method will return the name of the full name of the class, including its owning module (if any).
  127777. * 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).
  127778. * @param object the object to get the class name from
  127779. * @param isType defines if the object is actually a type
  127780. * @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.
  127781. * @ignorenaming
  127782. */
  127783. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  127784. /**
  127785. * Returns a promise that resolves after the given amount of time.
  127786. * @param delay Number of milliseconds to delay
  127787. * @returns Promise that resolves after the given amount of time
  127788. */
  127789. static DelayAsync(delay: number): Promise<void>;
  127790. /**
  127791. * Utility function to detect if the current user agent is Safari
  127792. * @returns whether or not the current user agent is safari
  127793. */
  127794. static IsSafari(): boolean;
  127795. }
  127796. /**
  127797. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  127798. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  127799. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  127800. * @param name The name of the class, case should be preserved
  127801. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  127802. */
  127803. export function className(name: string, module?: string): (target: Object) => void;
  127804. /**
  127805. * An implementation of a loop for asynchronous functions.
  127806. */
  127807. export class AsyncLoop {
  127808. /**
  127809. * Defines the number of iterations for the loop
  127810. */
  127811. iterations: number;
  127812. /**
  127813. * Defines the current index of the loop.
  127814. */
  127815. index: number;
  127816. private _done;
  127817. private _fn;
  127818. private _successCallback;
  127819. /**
  127820. * Constructor.
  127821. * @param iterations the number of iterations.
  127822. * @param func the function to run each iteration
  127823. * @param successCallback the callback that will be called upon succesful execution
  127824. * @param offset starting offset.
  127825. */
  127826. constructor(
  127827. /**
  127828. * Defines the number of iterations for the loop
  127829. */
  127830. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  127831. /**
  127832. * Execute the next iteration. Must be called after the last iteration was finished.
  127833. */
  127834. executeNext(): void;
  127835. /**
  127836. * Break the loop and run the success callback.
  127837. */
  127838. breakLoop(): void;
  127839. /**
  127840. * Create and run an async loop.
  127841. * @param iterations the number of iterations.
  127842. * @param fn the function to run each iteration
  127843. * @param successCallback the callback that will be called upon succesful execution
  127844. * @param offset starting offset.
  127845. * @returns the created async loop object
  127846. */
  127847. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  127848. /**
  127849. * A for-loop that will run a given number of iterations synchronous and the rest async.
  127850. * @param iterations total number of iterations
  127851. * @param syncedIterations number of synchronous iterations in each async iteration.
  127852. * @param fn the function to call each iteration.
  127853. * @param callback a success call back that will be called when iterating stops.
  127854. * @param breakFunction a break condition (optional)
  127855. * @param timeout timeout settings for the setTimeout function. default - 0.
  127856. * @returns the created async loop object
  127857. */
  127858. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  127859. }
  127860. }
  127861. declare module BABYLON {
  127862. /**
  127863. * This class implement a typical dictionary using a string as key and the generic type T as value.
  127864. * The underlying implementation relies on an associative array to ensure the best performances.
  127865. * The value can be anything including 'null' but except 'undefined'
  127866. */
  127867. export class StringDictionary<T> {
  127868. /**
  127869. * This will clear this dictionary and copy the content from the 'source' one.
  127870. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  127871. * @param source the dictionary to take the content from and copy to this dictionary
  127872. */
  127873. copyFrom(source: StringDictionary<T>): void;
  127874. /**
  127875. * Get a value based from its key
  127876. * @param key the given key to get the matching value from
  127877. * @return the value if found, otherwise undefined is returned
  127878. */
  127879. get(key: string): T | undefined;
  127880. /**
  127881. * Get a value from its key or add it if it doesn't exist.
  127882. * This method will ensure you that a given key/data will be present in the dictionary.
  127883. * @param key the given key to get the matching value from
  127884. * @param factory the factory that will create the value if the key is not present in the dictionary.
  127885. * The factory will only be invoked if there's no data for the given key.
  127886. * @return the value corresponding to the key.
  127887. */
  127888. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  127889. /**
  127890. * Get a value from its key if present in the dictionary otherwise add it
  127891. * @param key the key to get the value from
  127892. * @param val if there's no such key/value pair in the dictionary add it with this value
  127893. * @return the value corresponding to the key
  127894. */
  127895. getOrAdd(key: string, val: T): T;
  127896. /**
  127897. * Check if there's a given key in the dictionary
  127898. * @param key the key to check for
  127899. * @return true if the key is present, false otherwise
  127900. */
  127901. contains(key: string): boolean;
  127902. /**
  127903. * Add a new key and its corresponding value
  127904. * @param key the key to add
  127905. * @param value the value corresponding to the key
  127906. * @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
  127907. */
  127908. add(key: string, value: T): boolean;
  127909. /**
  127910. * Update a specific value associated to a key
  127911. * @param key defines the key to use
  127912. * @param value defines the value to store
  127913. * @returns true if the value was updated (or false if the key was not found)
  127914. */
  127915. set(key: string, value: T): boolean;
  127916. /**
  127917. * Get the element of the given key and remove it from the dictionary
  127918. * @param key defines the key to search
  127919. * @returns the value associated with the key or null if not found
  127920. */
  127921. getAndRemove(key: string): Nullable<T>;
  127922. /**
  127923. * Remove a key/value from the dictionary.
  127924. * @param key the key to remove
  127925. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  127926. */
  127927. remove(key: string): boolean;
  127928. /**
  127929. * Clear the whole content of the dictionary
  127930. */
  127931. clear(): void;
  127932. /**
  127933. * Gets the current count
  127934. */
  127935. get count(): number;
  127936. /**
  127937. * Execute a callback on each key/val of the dictionary.
  127938. * Note that you can remove any element in this dictionary in the callback implementation
  127939. * @param callback the callback to execute on a given key/value pair
  127940. */
  127941. forEach(callback: (key: string, val: T) => void): void;
  127942. /**
  127943. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  127944. * If the callback returns null or undefined the method will iterate to the next key/value pair
  127945. * Note that you can remove any element in this dictionary in the callback implementation
  127946. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  127947. * @returns the first item
  127948. */
  127949. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  127950. private _count;
  127951. private _data;
  127952. }
  127953. }
  127954. declare module BABYLON {
  127955. /** @hidden */
  127956. export interface ICollisionCoordinator {
  127957. createCollider(): Collider;
  127958. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  127959. init(scene: Scene): void;
  127960. }
  127961. /** @hidden */
  127962. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  127963. private _scene;
  127964. private _scaledPosition;
  127965. private _scaledVelocity;
  127966. private _finalPosition;
  127967. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  127968. createCollider(): Collider;
  127969. init(scene: Scene): void;
  127970. private _collideWithWorld;
  127971. }
  127972. }
  127973. declare module BABYLON {
  127974. /**
  127975. * Class used to manage all inputs for the scene.
  127976. */
  127977. export class InputManager {
  127978. /** The distance in pixel that you have to move to prevent some events */
  127979. static DragMovementThreshold: number;
  127980. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  127981. static LongPressDelay: number;
  127982. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  127983. static DoubleClickDelay: number;
  127984. /** If you need to check double click without raising a single click at first click, enable this flag */
  127985. static ExclusiveDoubleClickMode: boolean;
  127986. /** 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. */
  127987. private _alreadyAttached;
  127988. private _alreadyAttachedTo;
  127989. private _wheelEventName;
  127990. private _onPointerMove;
  127991. private _onPointerDown;
  127992. private _onPointerUp;
  127993. private _initClickEvent;
  127994. private _initActionManager;
  127995. private _delayedSimpleClick;
  127996. private _delayedSimpleClickTimeout;
  127997. private _previousDelayedSimpleClickTimeout;
  127998. private _meshPickProceed;
  127999. private _previousButtonPressed;
  128000. private _currentPickResult;
  128001. private _previousPickResult;
  128002. private _totalPointersPressed;
  128003. private _doubleClickOccured;
  128004. private _pointerOverMesh;
  128005. private _pickedDownMesh;
  128006. private _pickedUpMesh;
  128007. private _pointerX;
  128008. private _pointerY;
  128009. private _unTranslatedPointerX;
  128010. private _unTranslatedPointerY;
  128011. private _startingPointerPosition;
  128012. private _previousStartingPointerPosition;
  128013. private _startingPointerTime;
  128014. private _previousStartingPointerTime;
  128015. private _pointerCaptures;
  128016. private _meshUnderPointerId;
  128017. private _onKeyDown;
  128018. private _onKeyUp;
  128019. private _keyboardIsAttached;
  128020. private _onCanvasFocusObserver;
  128021. private _onCanvasBlurObserver;
  128022. private _scene;
  128023. /**
  128024. * Creates a new InputManager
  128025. * @param scene defines the hosting scene
  128026. */
  128027. constructor(scene: Scene);
  128028. /**
  128029. * Gets the mesh that is currently under the pointer
  128030. */
  128031. get meshUnderPointer(): Nullable<AbstractMesh>;
  128032. /**
  128033. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  128034. * @param pointerId the pointer id to use
  128035. * @returns The mesh under this pointer id or null if not found
  128036. */
  128037. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  128038. /**
  128039. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  128040. */
  128041. get unTranslatedPointer(): Vector2;
  128042. /**
  128043. * Gets or sets the current on-screen X position of the pointer
  128044. */
  128045. get pointerX(): number;
  128046. set pointerX(value: number);
  128047. /**
  128048. * Gets or sets the current on-screen Y position of the pointer
  128049. */
  128050. get pointerY(): number;
  128051. set pointerY(value: number);
  128052. private _updatePointerPosition;
  128053. private _processPointerMove;
  128054. private _setRayOnPointerInfo;
  128055. private _checkPrePointerObservable;
  128056. /**
  128057. * Use this method to simulate a pointer move on a mesh
  128058. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  128059. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  128060. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  128061. */
  128062. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  128063. /**
  128064. * Use this method to simulate a pointer down on a mesh
  128065. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  128066. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  128067. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  128068. */
  128069. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  128070. private _processPointerDown;
  128071. /** @hidden */
  128072. _isPointerSwiping(): boolean;
  128073. /**
  128074. * Use this method to simulate a pointer up on a mesh
  128075. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  128076. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  128077. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  128078. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  128079. */
  128080. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  128081. private _processPointerUp;
  128082. /**
  128083. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  128084. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  128085. * @returns true if the pointer was captured
  128086. */
  128087. isPointerCaptured(pointerId?: number): boolean;
  128088. /**
  128089. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  128090. * @param attachUp defines if you want to attach events to pointerup
  128091. * @param attachDown defines if you want to attach events to pointerdown
  128092. * @param attachMove defines if you want to attach events to pointermove
  128093. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  128094. */
  128095. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  128096. /**
  128097. * Detaches all event handlers
  128098. */
  128099. detachControl(): void;
  128100. /**
  128101. * Force the value of meshUnderPointer
  128102. * @param mesh defines the mesh to use
  128103. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  128104. */
  128105. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  128106. /**
  128107. * Gets the mesh under the pointer
  128108. * @returns a Mesh or null if no mesh is under the pointer
  128109. */
  128110. getPointerOverMesh(): Nullable<AbstractMesh>;
  128111. }
  128112. }
  128113. declare module BABYLON {
  128114. /**
  128115. * This class defines the direct association between an animation and a target
  128116. */
  128117. export class TargetedAnimation {
  128118. /**
  128119. * Animation to perform
  128120. */
  128121. animation: Animation;
  128122. /**
  128123. * Target to animate
  128124. */
  128125. target: any;
  128126. /**
  128127. * Returns the string "TargetedAnimation"
  128128. * @returns "TargetedAnimation"
  128129. */
  128130. getClassName(): string;
  128131. /**
  128132. * Serialize the object
  128133. * @returns the JSON object representing the current entity
  128134. */
  128135. serialize(): any;
  128136. }
  128137. /**
  128138. * Use this class to create coordinated animations on multiple targets
  128139. */
  128140. export class AnimationGroup implements IDisposable {
  128141. /** The name of the animation group */
  128142. name: string;
  128143. private _scene;
  128144. private _targetedAnimations;
  128145. private _animatables;
  128146. private _from;
  128147. private _to;
  128148. private _isStarted;
  128149. private _isPaused;
  128150. private _speedRatio;
  128151. private _loopAnimation;
  128152. private _isAdditive;
  128153. /**
  128154. * Gets or sets the unique id of the node
  128155. */
  128156. uniqueId: number;
  128157. /**
  128158. * This observable will notify when one animation have ended
  128159. */
  128160. onAnimationEndObservable: Observable<TargetedAnimation>;
  128161. /**
  128162. * Observer raised when one animation loops
  128163. */
  128164. onAnimationLoopObservable: Observable<TargetedAnimation>;
  128165. /**
  128166. * Observer raised when all animations have looped
  128167. */
  128168. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  128169. /**
  128170. * This observable will notify when all animations have ended.
  128171. */
  128172. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  128173. /**
  128174. * This observable will notify when all animations have paused.
  128175. */
  128176. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  128177. /**
  128178. * This observable will notify when all animations are playing.
  128179. */
  128180. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  128181. /**
  128182. * Gets the first frame
  128183. */
  128184. get from(): number;
  128185. /**
  128186. * Gets the last frame
  128187. */
  128188. get to(): number;
  128189. /**
  128190. * Define if the animations are started
  128191. */
  128192. get isStarted(): boolean;
  128193. /**
  128194. * Gets a value indicating that the current group is playing
  128195. */
  128196. get isPlaying(): boolean;
  128197. /**
  128198. * Gets or sets the speed ratio to use for all animations
  128199. */
  128200. get speedRatio(): number;
  128201. /**
  128202. * Gets or sets the speed ratio to use for all animations
  128203. */
  128204. set speedRatio(value: number);
  128205. /**
  128206. * Gets or sets if all animations should loop or not
  128207. */
  128208. get loopAnimation(): boolean;
  128209. set loopAnimation(value: boolean);
  128210. /**
  128211. * Gets or sets if all animations should be evaluated additively
  128212. */
  128213. get isAdditive(): boolean;
  128214. set isAdditive(value: boolean);
  128215. /**
  128216. * Gets the targeted animations for this animation group
  128217. */
  128218. get targetedAnimations(): Array<TargetedAnimation>;
  128219. /**
  128220. * returning the list of animatables controlled by this animation group.
  128221. */
  128222. get animatables(): Array<Animatable>;
  128223. /**
  128224. * Gets the list of target animations
  128225. */
  128226. get children(): TargetedAnimation[];
  128227. /**
  128228. * Instantiates a new Animation Group.
  128229. * This helps managing several animations at once.
  128230. * @see https://doc.babylonjs.com/how_to/group
  128231. * @param name Defines the name of the group
  128232. * @param scene Defines the scene the group belongs to
  128233. */
  128234. constructor(
  128235. /** The name of the animation group */
  128236. name: string, scene?: Nullable<Scene>);
  128237. /**
  128238. * Add an animation (with its target) in the group
  128239. * @param animation defines the animation we want to add
  128240. * @param target defines the target of the animation
  128241. * @returns the TargetedAnimation object
  128242. */
  128243. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  128244. /**
  128245. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  128246. * It can add constant keys at begin or end
  128247. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  128248. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  128249. * @returns the animation group
  128250. */
  128251. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  128252. private _animationLoopCount;
  128253. private _animationLoopFlags;
  128254. private _processLoop;
  128255. /**
  128256. * Start all animations on given targets
  128257. * @param loop defines if animations must loop
  128258. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  128259. * @param from defines the from key (optional)
  128260. * @param to defines the to key (optional)
  128261. * @param isAdditive defines the additive state for the resulting animatables (optional)
  128262. * @returns the current animation group
  128263. */
  128264. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  128265. /**
  128266. * Pause all animations
  128267. * @returns the animation group
  128268. */
  128269. pause(): AnimationGroup;
  128270. /**
  128271. * Play all animations to initial state
  128272. * This function will start() the animations if they were not started or will restart() them if they were paused
  128273. * @param loop defines if animations must loop
  128274. * @returns the animation group
  128275. */
  128276. play(loop?: boolean): AnimationGroup;
  128277. /**
  128278. * Reset all animations to initial state
  128279. * @returns the animation group
  128280. */
  128281. reset(): AnimationGroup;
  128282. /**
  128283. * Restart animations from key 0
  128284. * @returns the animation group
  128285. */
  128286. restart(): AnimationGroup;
  128287. /**
  128288. * Stop all animations
  128289. * @returns the animation group
  128290. */
  128291. stop(): AnimationGroup;
  128292. /**
  128293. * Set animation weight for all animatables
  128294. * @param weight defines the weight to use
  128295. * @return the animationGroup
  128296. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  128297. */
  128298. setWeightForAllAnimatables(weight: number): AnimationGroup;
  128299. /**
  128300. * Synchronize and normalize all animatables with a source animatable
  128301. * @param root defines the root animatable to synchronize with
  128302. * @return the animationGroup
  128303. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  128304. */
  128305. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  128306. /**
  128307. * Goes to a specific frame in this animation group
  128308. * @param frame the frame number to go to
  128309. * @return the animationGroup
  128310. */
  128311. goToFrame(frame: number): AnimationGroup;
  128312. /**
  128313. * Dispose all associated resources
  128314. */
  128315. dispose(): void;
  128316. private _checkAnimationGroupEnded;
  128317. /**
  128318. * Clone the current animation group and returns a copy
  128319. * @param newName defines the name of the new group
  128320. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  128321. * @returns the new aniamtion group
  128322. */
  128323. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  128324. /**
  128325. * Serializes the animationGroup to an object
  128326. * @returns Serialized object
  128327. */
  128328. serialize(): any;
  128329. /**
  128330. * Returns a new AnimationGroup object parsed from the source provided.
  128331. * @param parsedAnimationGroup defines the source
  128332. * @param scene defines the scene that will receive the animationGroup
  128333. * @returns a new AnimationGroup
  128334. */
  128335. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  128336. /**
  128337. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  128338. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  128339. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  128340. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  128341. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  128342. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  128343. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  128344. */
  128345. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  128346. /**
  128347. * Returns the string "AnimationGroup"
  128348. * @returns "AnimationGroup"
  128349. */
  128350. getClassName(): string;
  128351. /**
  128352. * Creates a detailled string about the object
  128353. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  128354. * @returns a string representing the object
  128355. */
  128356. toString(fullDetails?: boolean): string;
  128357. }
  128358. }
  128359. declare module BABYLON {
  128360. /**
  128361. * @hidden
  128362. **/
  128363. export class _TimeToken {
  128364. _startTimeQuery: Nullable<WebGLQuery>;
  128365. _endTimeQuery: Nullable<WebGLQuery>;
  128366. _timeElapsedQuery: Nullable<WebGLQuery>;
  128367. _timeElapsedQueryEnded: boolean;
  128368. }
  128369. }
  128370. declare module BABYLON {
  128371. /** @hidden */
  128372. export enum ExtensionName {
  128373. DepthClamping = "depth-clamping",
  128374. Depth24UnormStencil8 = "depth24unorm-stencil8",
  128375. Depth32FloatStencil8 = "depth32float-stencil8",
  128376. PipelineStatisticsQuery = "pipeline-statistics-query",
  128377. TextureCompressionBC = "texture-compression-bc",
  128378. TimestampQuery = "timestamp-query"
  128379. }
  128380. /** @hidden */
  128381. export enum AddressMode {
  128382. ClampToEdge = "clamp-to-edge",
  128383. Repeat = "repeat",
  128384. MirrorRepeat = "mirror-repeat"
  128385. }
  128386. /** @hidden */
  128387. export enum BindingType {
  128388. UniformBuffer = "uniform-buffer",
  128389. StorageBuffer = "storage-buffer",
  128390. ReadonlyStorageBuffer = "readonly-storage-buffer",
  128391. Sampler = "sampler",
  128392. ComparisonSampler = "comparison-sampler",
  128393. SampledTexture = "sampled-texture",
  128394. ReadonlyStorageTexture = "readonly-storage-texture",
  128395. WriteonlyStorageTexture = "writeonly-storage-texture"
  128396. }
  128397. /** @hidden */
  128398. export enum BlendFactor {
  128399. Zero = "zero",
  128400. One = "one",
  128401. SrcColor = "src-color",
  128402. OneMinusSrcColor = "one-minus-src-color",
  128403. SrcAlpha = "src-alpha",
  128404. OneMinusSrcAlpha = "one-minus-src-alpha",
  128405. DstColor = "dst-color",
  128406. OneMinusDstColor = "one-minus-dst-color",
  128407. DstAlpha = "dst-alpha",
  128408. OneMinusDstAlpha = "one-minus-dst-alpha",
  128409. SrcAlphaSaturated = "src-alpha-saturated",
  128410. BlendColor = "blend-color",
  128411. OneMinusBlendColor = "one-minus-blend-color"
  128412. }
  128413. /** @hidden */
  128414. export enum BlendOperation {
  128415. Add = "add",
  128416. Subtract = "subtract",
  128417. ReverseSubtract = "reverse-subtract",
  128418. Min = "min",
  128419. Max = "max"
  128420. }
  128421. /** @hidden */
  128422. export enum CompareFunction {
  128423. Never = "never",
  128424. Less = "less",
  128425. Equal = "equal",
  128426. LessEqual = "less-equal",
  128427. Greater = "greater",
  128428. NotEqual = "not-equal",
  128429. GreaterEqual = "greater-equal",
  128430. Always = "always"
  128431. }
  128432. /** @hidden */
  128433. export enum CullMode {
  128434. None = "none",
  128435. Front = "front",
  128436. Back = "back"
  128437. }
  128438. /** @hidden */
  128439. export enum FilterMode {
  128440. Nearest = "nearest",
  128441. Linear = "linear"
  128442. }
  128443. /** @hidden */
  128444. export enum FrontFace {
  128445. CCW = "ccw",
  128446. CW = "cw"
  128447. }
  128448. /** @hidden */
  128449. export enum IndexFormat {
  128450. Uint16 = "uint16",
  128451. Uint32 = "uint32"
  128452. }
  128453. /** @hidden */
  128454. export enum InputStepMode {
  128455. Vertex = "vertex",
  128456. Instance = "instance"
  128457. }
  128458. /** @hidden */
  128459. export enum LoadOp {
  128460. Load = "load"
  128461. }
  128462. /** @hidden */
  128463. export enum PrimitiveTopology {
  128464. PointList = "point-list",
  128465. LineList = "line-list",
  128466. LineStrip = "line-strip",
  128467. TriangleList = "triangle-list",
  128468. TriangleStrip = "triangle-strip"
  128469. }
  128470. /** @hidden */
  128471. export enum StencilOperation {
  128472. Keep = "keep",
  128473. Zero = "zero",
  128474. Replace = "replace",
  128475. Invert = "invert",
  128476. IncrementClamp = "increment-clamp",
  128477. DecrementClamp = "decrement-clamp",
  128478. IncrementWrap = "increment-wrap",
  128479. DecrementWrap = "decrement-wrap"
  128480. }
  128481. /** @hidden */
  128482. export enum StoreOp {
  128483. Store = "store",
  128484. Clear = "clear"
  128485. }
  128486. /** @hidden */
  128487. export enum TextureDimension {
  128488. E1d = "1d",
  128489. E2d = "2d",
  128490. E3d = "3d"
  128491. }
  128492. /** @hidden */
  128493. export enum TextureFormat {
  128494. R8Unorm = "r8unorm",
  128495. R8Snorm = "r8snorm",
  128496. R8Uint = "r8uint",
  128497. R8Sint = "r8sint",
  128498. R16Uint = "r16uint",
  128499. R16Sint = "r16sint",
  128500. R16Float = "r16float",
  128501. RG8Unorm = "rg8unorm",
  128502. RG8Snorm = "rg8snorm",
  128503. RG8Uint = "rg8uint",
  128504. RG8Sint = "rg8sint",
  128505. R32Uint = "r32uint",
  128506. R32Sint = "r32sint",
  128507. R32Float = "r32float",
  128508. RG16Uint = "rg16uint",
  128509. RG16Sint = "rg16sint",
  128510. RG16Float = "rg16float",
  128511. RGBA8Unorm = "rgba8unorm",
  128512. RGBA8UnormSRGB = "rgba8unorm-srgb",
  128513. RGBA8Snorm = "rgba8snorm",
  128514. RGBA8Uint = "rgba8uint",
  128515. RGBA8Sint = "rgba8sint",
  128516. BGRA8Unorm = "bgra8unorm",
  128517. BGRA8UnormSRGB = "bgra8unorm-srgb",
  128518. RGB9E5UFloat = "rgb9e5ufloat",
  128519. RGB10A2Unorm = "rgb10a2unorm",
  128520. RG11B10UFloat = "rg11b10ufloat",
  128521. RG32Uint = "rg32uint",
  128522. RG32Sint = "rg32sint",
  128523. RG32Float = "rg32float",
  128524. RGBA16Uint = "rgba16uint",
  128525. RGBA16Sint = "rgba16sint",
  128526. RGBA16Float = "rgba16float",
  128527. RGBA32Uint = "rgba32uint",
  128528. RGBA32Sint = "rgba32sint",
  128529. RGBA32Float = "rgba32float",
  128530. Stencil8 = "stencil8",
  128531. Depth16Unorm = "depth16unorm",
  128532. Depth24Plus = "depth24plus",
  128533. Depth24PlusStencil8 = "depth24plus-stencil8",
  128534. Depth32Float = "depth32float",
  128535. BC1RGBAUNorm = "bc1-rgba-unorm",
  128536. BC1RGBAUnormSRGB = "bc1-rgba-unorm-srgb",
  128537. BC2RGBAUnorm = "bc2-rgba-unorm",
  128538. BC2RGBAUnormSRGB = "bc2-rgba-unorm-srgb",
  128539. BC3RGBAUnorm = "bc3-rgba-unorm",
  128540. BC3RGBAUnormSRGB = "bc3-rgba-unorm-srgb",
  128541. BC4RUnorm = "bc4-r-unorm",
  128542. BC4RSnorm = "bc4-r-snorm",
  128543. BC5RGUnorm = "bc5-rg-unorm",
  128544. BC5RGSnorm = "bc5-rg-snorm",
  128545. BC6HRGBUFloat = "bc6h-rgb-ufloat",
  128546. BC6HRGBFloat = "bc6h-rgb-float",
  128547. BC7RGBAUnorm = "bc7-rgba-unorm",
  128548. BC7RGBAUnormSRGB = "bc7-rgba-unorm-srgb",
  128549. Depth24UnormStencil8 = "depth24unorm-stencil8",
  128550. Depth32FloatStencil8 = "depth32float-stencil8"
  128551. }
  128552. /** @hidden */
  128553. export enum TextureComponentType {
  128554. Float = "float",
  128555. Sint = "sint",
  128556. Uint = "uint",
  128557. DepthComparison = "depth-comparison"
  128558. }
  128559. /** @hidden */
  128560. export enum TextureViewDimension {
  128561. E1d = "1d",
  128562. E2d = "2d",
  128563. E2dArray = "2d-array",
  128564. Cube = "cube",
  128565. CubeArray = "cube-array",
  128566. E3d = "3d"
  128567. }
  128568. /** @hidden */
  128569. export enum VertexFormat {
  128570. Uchar2 = "uchar2",
  128571. Uchar4 = "uchar4",
  128572. Char2 = "char2",
  128573. Char4 = "char4",
  128574. Uchar2Norm = "uchar2norm",
  128575. Uchar4Norm = "uchar4norm",
  128576. Char2Norm = "char2norm",
  128577. Char4Norm = "char4norm",
  128578. Ushort2 = "ushort2",
  128579. Ushort4 = "ushort4",
  128580. Short2 = "short2",
  128581. Short4 = "short4",
  128582. Ushort2Norm = "ushort2norm",
  128583. Ushort4Norm = "ushort4norm",
  128584. Short2Norm = "short2norm",
  128585. Short4Norm = "short4norm",
  128586. Half2 = "half2",
  128587. Half4 = "half4",
  128588. Float = "float",
  128589. Float2 = "float2",
  128590. Float3 = "float3",
  128591. Float4 = "float4",
  128592. Uint = "uint",
  128593. Uint2 = "uint2",
  128594. Uint3 = "uint3",
  128595. Uint4 = "uint4",
  128596. Int = "int",
  128597. Int2 = "int2",
  128598. Int3 = "int3",
  128599. Int4 = "int4"
  128600. }
  128601. /** @hidden */
  128602. export enum TextureAspect {
  128603. All = "all",
  128604. StencilOnly = "stencil-only",
  128605. DepthOnly = "depth-only"
  128606. }
  128607. /** @hidden */
  128608. export enum CompilationMessageType {
  128609. Error = "error",
  128610. Warning = "warning",
  128611. Info = "info"
  128612. }
  128613. /** @hidden */
  128614. export enum QueryType {
  128615. Occlusion = "occlusion"
  128616. }
  128617. /** @hidden */
  128618. export enum BufferUsage {
  128619. MapRead = 1,
  128620. MapWrite = 2,
  128621. CopySrc = 4,
  128622. CopyDst = 8,
  128623. Index = 16,
  128624. Vertex = 32,
  128625. Uniform = 64,
  128626. Storage = 128,
  128627. Indirect = 256,
  128628. QueryResolve = 512
  128629. }
  128630. /** @hidden */
  128631. export enum ColorWrite {
  128632. Red = 1,
  128633. Green = 2,
  128634. Blue = 4,
  128635. Alpha = 8,
  128636. All = 15
  128637. }
  128638. /** @hidden */
  128639. export enum ShaderStage {
  128640. Vertex = 1,
  128641. Fragment = 2,
  128642. Compute = 4
  128643. }
  128644. /** @hidden */
  128645. export enum TextureUsage {
  128646. CopySrc = 1,
  128647. CopyDst = 2,
  128648. Sampled = 4,
  128649. Storage = 8,
  128650. OutputAttachment = 16
  128651. }
  128652. /** @hidden */
  128653. export enum MapMode {
  128654. Read = 1,
  128655. Write = 2
  128656. }
  128657. }
  128658. declare module BABYLON {
  128659. /** @hidden */
  128660. export interface WebGPUBindingInfo {
  128661. setIndex: number;
  128662. bindingIndex: number;
  128663. }
  128664. /** @hidden */
  128665. export interface WebGPUTextureSamplerBindingDescription {
  128666. sampler: WebGPUBindingInfo;
  128667. isTextureArray: boolean;
  128668. textures: Array<WebGPUBindingInfo>;
  128669. }
  128670. /** @hidden
  128671. * If the binding is a UBO, isSampler=isTexture=false
  128672. */
  128673. export interface WebGPUBindingDescription {
  128674. name: string;
  128675. usedInVertex: boolean;
  128676. usedInFragment: boolean;
  128677. isSampler: boolean;
  128678. isComparisonSampler?: boolean;
  128679. isTexture: boolean;
  128680. componentType?: GPUTextureComponentType;
  128681. textureDimension?: GPUTextureViewDimension;
  128682. }
  128683. /**
  128684. * @hidden
  128685. */
  128686. export class WebGPUShaderProcessingContext implements ShaderProcessingContext {
  128687. uboNextBindingIndex: number;
  128688. freeSetIndex: number;
  128689. freeBindingIndex: number;
  128690. availableVaryings: {
  128691. [key: string]: number;
  128692. };
  128693. availableAttributes: {
  128694. [key: string]: number;
  128695. };
  128696. availableUBOs: {
  128697. [key: string]: {
  128698. setIndex: number;
  128699. bindingIndex: number;
  128700. };
  128701. };
  128702. availableSamplers: {
  128703. [key: string]: WebGPUTextureSamplerBindingDescription;
  128704. };
  128705. leftOverUniforms: {
  128706. name: string;
  128707. type: string;
  128708. length: number;
  128709. }[];
  128710. orderedAttributes: string[];
  128711. orderedUBOsAndSamplers: WebGPUBindingDescription[][];
  128712. private _attributeNextLocation;
  128713. private _varyingNextLocation;
  128714. constructor();
  128715. getAttributeNextLocation(dataType: string, arrayLength?: number): number;
  128716. getVaryingNextLocation(dataType: string, arrayLength?: number): number;
  128717. getNextFreeUBOBinding(): {
  128718. setIndex: number;
  128719. bindingIndex: number;
  128720. };
  128721. private _getNextFreeBinding;
  128722. }
  128723. }
  128724. declare module BABYLON {
  128725. /** @hidden */
  128726. export interface IWebGPUPipelineContextSamplerCache {
  128727. samplerBinding: number;
  128728. firstTextureName: string;
  128729. }
  128730. /** @hidden */
  128731. export interface IWebGPUPipelineContextTextureCache {
  128732. textureBinding: number;
  128733. texture: InternalTexture;
  128734. }
  128735. /** @hidden */
  128736. export interface IWebGPUPipelineContextVertexInputsCache {
  128737. indexBuffer: Nullable<GPUBuffer>;
  128738. indexOffset: number;
  128739. vertexStartSlot: number;
  128740. vertexBuffers: GPUBuffer[];
  128741. vertexOffsets: number[];
  128742. }
  128743. /** @hidden */
  128744. export interface IWebGPURenderPipelineStageDescriptor {
  128745. vertexStage: GPUProgrammableStageDescriptor;
  128746. fragmentStage?: GPUProgrammableStageDescriptor;
  128747. }
  128748. /** @hidden */
  128749. export class WebGPUPipelineContext implements IPipelineContext {
  128750. engine: WebGPUEngine;
  128751. shaderProcessingContext: WebGPUShaderProcessingContext;
  128752. leftOverUniformsByName: {
  128753. [name: string]: string;
  128754. };
  128755. sources: {
  128756. vertex: string;
  128757. fragment: string;
  128758. rawVertex: string;
  128759. rawFragment: string;
  128760. };
  128761. stages: Nullable<IWebGPURenderPipelineStageDescriptor>;
  128762. samplers: {
  128763. [name: string]: Nullable<IWebGPUPipelineContextSamplerCache>;
  128764. };
  128765. textures: {
  128766. [name: string]: Nullable<IWebGPUPipelineContextTextureCache>;
  128767. };
  128768. bindGroupLayouts: GPUBindGroupLayout[];
  128769. /**
  128770. * Stores the uniform buffer
  128771. */
  128772. uniformBuffer: Nullable<UniformBuffer>;
  128773. onCompiled?: () => void;
  128774. get isAsync(): boolean;
  128775. get isReady(): boolean;
  128776. /** @hidden */
  128777. _name: string;
  128778. constructor(shaderProcessingContext: WebGPUShaderProcessingContext, engine: WebGPUEngine);
  128779. _handlesSpectorRebuildCallback(onCompiled: (program: any) => void): void;
  128780. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  128781. [key: string]: number;
  128782. }, uniformsNames: string[], uniforms: {
  128783. [key: string]: Nullable<WebGLUniformLocation>;
  128784. }, samplerList: string[], samplers: {
  128785. [key: string]: number;
  128786. }, attributesNames: string[], attributes: number[]): void;
  128787. /** @hidden */
  128788. /**
  128789. * Build the uniform buffer used in the material.
  128790. */
  128791. buildUniformLayout(): void;
  128792. /**
  128793. * Release all associated resources.
  128794. **/
  128795. dispose(): void;
  128796. /**
  128797. * Sets an integer value on a uniform variable.
  128798. * @param uniformName Name of the variable.
  128799. * @param value Value to be set.
  128800. */
  128801. setInt(uniformName: string, value: number): void;
  128802. /**
  128803. * Sets an int2 value on a uniform variable.
  128804. * @param uniformName Name of the variable.
  128805. * @param x First int in int2.
  128806. * @param y Second int in int2.
  128807. */
  128808. setInt2(uniformName: string, x: number, y: number): void;
  128809. /**
  128810. * Sets an int3 value on a uniform variable.
  128811. * @param uniformName Name of the variable.
  128812. * @param x First int in int3.
  128813. * @param y Second int in int3.
  128814. * @param z Third int in int3.
  128815. */
  128816. setInt3(uniformName: string, x: number, y: number, z: number): void;
  128817. /**
  128818. * Sets an int4 value on a uniform variable.
  128819. * @param uniformName Name of the variable.
  128820. * @param x First int in int4.
  128821. * @param y Second int in int4.
  128822. * @param z Third int in int4.
  128823. * @param w Fourth int in int4.
  128824. */
  128825. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  128826. /**
  128827. * Sets an int array on a uniform variable.
  128828. * @param uniformName Name of the variable.
  128829. * @param array array to be set.
  128830. */
  128831. setIntArray(uniformName: string, array: Int32Array): void;
  128832. /**
  128833. * 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)
  128834. * @param uniformName Name of the variable.
  128835. * @param array array to be set.
  128836. */
  128837. setIntArray2(uniformName: string, array: Int32Array): void;
  128838. /**
  128839. * 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)
  128840. * @param uniformName Name of the variable.
  128841. * @param array array to be set.
  128842. */
  128843. setIntArray3(uniformName: string, array: Int32Array): void;
  128844. /**
  128845. * 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)
  128846. * @param uniformName Name of the variable.
  128847. * @param array array to be set.
  128848. */
  128849. setIntArray4(uniformName: string, array: Int32Array): void;
  128850. /**
  128851. * Sets an array on a uniform variable.
  128852. * @param uniformName Name of the variable.
  128853. * @param array array to be set.
  128854. */
  128855. setArray(uniformName: string, array: number[]): void;
  128856. /**
  128857. * 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)
  128858. * @param uniformName Name of the variable.
  128859. * @param array array to be set.
  128860. */
  128861. setArray2(uniformName: string, array: number[]): void;
  128862. /**
  128863. * 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)
  128864. * @param uniformName Name of the variable.
  128865. * @param array array to be set.
  128866. * @returns this effect.
  128867. */
  128868. setArray3(uniformName: string, array: number[]): void;
  128869. /**
  128870. * 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)
  128871. * @param uniformName Name of the variable.
  128872. * @param array array to be set.
  128873. */
  128874. setArray4(uniformName: string, array: number[]): void;
  128875. /**
  128876. * Sets matrices on a uniform variable.
  128877. * @param uniformName Name of the variable.
  128878. * @param matrices matrices to be set.
  128879. */
  128880. setMatrices(uniformName: string, matrices: Float32Array): void;
  128881. /**
  128882. * Sets matrix on a uniform variable.
  128883. * @param uniformName Name of the variable.
  128884. * @param matrix matrix to be set.
  128885. */
  128886. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  128887. /**
  128888. * 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)
  128889. * @param uniformName Name of the variable.
  128890. * @param matrix matrix to be set.
  128891. */
  128892. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  128893. /**
  128894. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  128895. * @param uniformName Name of the variable.
  128896. * @param matrix matrix to be set.
  128897. */
  128898. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  128899. /**
  128900. * Sets a float on a uniform variable.
  128901. * @param uniformName Name of the variable.
  128902. * @param value value to be set.
  128903. * @returns this effect.
  128904. */
  128905. setFloat(uniformName: string, value: number): void;
  128906. /**
  128907. * Sets a Vector2 on a uniform variable.
  128908. * @param uniformName Name of the variable.
  128909. * @param vector2 vector2 to be set.
  128910. */
  128911. setVector2(uniformName: string, vector2: IVector2Like): void;
  128912. /**
  128913. * Sets a float2 on a uniform variable.
  128914. * @param uniformName Name of the variable.
  128915. * @param x First float in float2.
  128916. * @param y Second float in float2.
  128917. */
  128918. setFloat2(uniformName: string, x: number, y: number): void;
  128919. /**
  128920. * Sets a Vector3 on a uniform variable.
  128921. * @param uniformName Name of the variable.
  128922. * @param vector3 Value to be set.
  128923. */
  128924. setVector3(uniformName: string, vector3: IVector3Like): void;
  128925. /**
  128926. * Sets a float3 on a uniform variable.
  128927. * @param uniformName Name of the variable.
  128928. * @param x First float in float3.
  128929. * @param y Second float in float3.
  128930. * @param z Third float in float3.
  128931. */
  128932. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  128933. /**
  128934. * Sets a Vector4 on a uniform variable.
  128935. * @param uniformName Name of the variable.
  128936. * @param vector4 Value to be set.
  128937. */
  128938. setVector4(uniformName: string, vector4: IVector4Like): void;
  128939. /**
  128940. * Sets a float4 on a uniform variable.
  128941. * @param uniformName Name of the variable.
  128942. * @param x First float in float4.
  128943. * @param y Second float in float4.
  128944. * @param z Third float in float4.
  128945. * @param w Fourth float in float4.
  128946. * @returns this effect.
  128947. */
  128948. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  128949. /**
  128950. * Sets a Color3 on a uniform variable.
  128951. * @param uniformName Name of the variable.
  128952. * @param color3 Value to be set.
  128953. */
  128954. setColor3(uniformName: string, color3: IColor3Like): void;
  128955. /**
  128956. * Sets a Color4 on a uniform variable.
  128957. * @param uniformName Name of the variable.
  128958. * @param color3 Value to be set.
  128959. * @param alpha Alpha value to be set.
  128960. */
  128961. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  128962. /**
  128963. * Sets a Color4 on a uniform variable
  128964. * @param uniformName defines the name of the variable
  128965. * @param color4 defines the value to be set
  128966. */
  128967. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  128968. _getVertexShaderCode(): string | null;
  128969. _getFragmentShaderCode(): string | null;
  128970. }
  128971. }
  128972. declare module BABYLON {
  128973. /** @hidden */
  128974. export class WebGPUDataBuffer extends DataBuffer {
  128975. private _buffer;
  128976. constructor(resource: GPUBuffer);
  128977. get underlyingResource(): any;
  128978. }
  128979. }
  128980. declare module BABYLON {
  128981. /**
  128982. * Class used to inline functions in shader code
  128983. */
  128984. export class ShaderCodeInliner {
  128985. private static readonly _RegexpFindFunctionNameAndType;
  128986. private _sourceCode;
  128987. private _functionDescr;
  128988. private _numMaxIterations;
  128989. /** Gets or sets the token used to mark the functions to inline */
  128990. inlineToken: string;
  128991. /** Gets or sets the debug mode */
  128992. debug: boolean;
  128993. /** Gets the code after the inlining process */
  128994. get code(): string;
  128995. /**
  128996. * Initializes the inliner
  128997. * @param sourceCode shader code source to inline
  128998. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  128999. */
  129000. constructor(sourceCode: string, numMaxIterations?: number);
  129001. /**
  129002. * Start the processing of the shader code
  129003. */
  129004. processCode(): void;
  129005. private _collectFunctions;
  129006. private _processInlining;
  129007. private _extractBetweenMarkers;
  129008. private _skipWhitespaces;
  129009. private _isIdentifierChar;
  129010. private _removeComments;
  129011. private _replaceFunctionCallsByCode;
  129012. private _findBackward;
  129013. private _escapeRegExp;
  129014. private _replaceNames;
  129015. }
  129016. }
  129017. declare module BABYLON {
  129018. /** @hidden */
  129019. export class WebGPUShaderProcessor implements IShaderProcessor {
  129020. protected _missingVaryings: Array<string>;
  129021. protected _textureArrayProcessing: Array<string>;
  129022. protected _preProcessors: {
  129023. [key: string]: string;
  129024. };
  129025. private _getArraySize;
  129026. initializeShaders(processingContext: Nullable<ShaderProcessingContext>): void;
  129027. varyingProcessor(varying: string, isFragment: boolean, preProcessors: {
  129028. [key: string]: string;
  129029. }, processingContext: Nullable<ShaderProcessingContext>): string;
  129030. attributeProcessor(attribute: string, preProcessors: {
  129031. [key: string]: string;
  129032. }, processingContext: Nullable<ShaderProcessingContext>): string;
  129033. uniformProcessor(uniform: string, isFragment: boolean, preProcessors: {
  129034. [key: string]: string;
  129035. }, processingContext: Nullable<ShaderProcessingContext>): string;
  129036. uniformBufferProcessor(uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  129037. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  129038. private _applyTextureArrayProcessing;
  129039. finalizeShaders(vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>): {
  129040. vertexCode: string;
  129041. fragmentCode: string;
  129042. };
  129043. }
  129044. }
  129045. declare module BABYLON {
  129046. /** @hidden */
  129047. export class WebGPUBufferManager {
  129048. private _device;
  129049. private _deferredReleaseBuffers;
  129050. private static _IsGPUBuffer;
  129051. constructor(device: GPUDevice);
  129052. createRawBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags, mappedAtCreation?: boolean): GPUBuffer;
  129053. createBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags): DataBuffer;
  129054. setSubData(dataBuffer: WebGPUDataBuffer, dstByteOffset: number, src: ArrayBufferView, srcByteOffset?: number, byteLength?: number): void;
  129055. private _FromHalfFloat;
  129056. private _GetHalfFloatAsFloatRGBAArrayBuffer;
  129057. readDataFromBuffer(gpuBuffer: GPUBuffer, size: number, width: number, height: number, bytesPerRow: number, bytesPerRowAligned: number, floatFormat?: number, offset?: number, buffer?: Nullable<ArrayBufferView>, destroyBuffer?: boolean): Promise<ArrayBufferView>;
  129058. releaseBuffer(buffer: DataBuffer | GPUBuffer): boolean;
  129059. destroyDeferredBuffers(): void;
  129060. }
  129061. }
  129062. declare module BABYLON {
  129063. /** @hidden */
  129064. export class WebGPUHardwareTexture implements HardwareTextureWrapper {
  129065. private _webgpuTexture;
  129066. private _webgpuMSAATexture;
  129067. get underlyingResource(): Nullable<GPUTexture>;
  129068. get msaaTexture(): Nullable<GPUTexture>;
  129069. set msaaTexture(texture: Nullable<GPUTexture>);
  129070. view: Nullable<GPUTextureView>;
  129071. format: GPUTextureFormat;
  129072. textureUsages: number;
  129073. constructor(existingTexture?: Nullable<GPUTexture>);
  129074. set(hardwareTexture: GPUTexture): void;
  129075. setMSAATexture(hardwareTexture: GPUTexture): void;
  129076. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  129077. createView(descriptor?: GPUTextureViewDescriptor): void;
  129078. reset(): void;
  129079. release(): void;
  129080. }
  129081. }
  129082. declare module BABYLON {
  129083. /** @hidden */
  129084. export class WebGPUTextureHelper {
  129085. private _device;
  129086. private _glslang;
  129087. private _bufferManager;
  129088. private _mipmapSampler;
  129089. private _invertYPreMultiplyAlphaSampler;
  129090. private _pipelines;
  129091. private _compiledShaders;
  129092. private _deferredReleaseTextures;
  129093. private _commandEncoderForCreation;
  129094. static ComputeNumMipmapLevels(width: number, height: number): number;
  129095. constructor(device: GPUDevice, glslang: any, bufferManager: WebGPUBufferManager);
  129096. private _getPipeline;
  129097. private static _GetTextureTypeFromFormat;
  129098. private static _GetBlockInformationFromFormat;
  129099. private static _IsHardwareTexture;
  129100. private static _IsInternalTexture;
  129101. static GetCompareFunction(compareFunction: Nullable<number>): GPUCompareFunction;
  129102. static IsImageBitmap(imageBitmap: ImageBitmap | {
  129103. width: number;
  129104. height: number;
  129105. }): imageBitmap is ImageBitmap;
  129106. static IsImageBitmapArray(imageBitmap: ImageBitmap[] | {
  129107. width: number;
  129108. height: number;
  129109. }): imageBitmap is ImageBitmap[];
  129110. setCommandEncoder(encoder: GPUCommandEncoder): void;
  129111. static IsCompressedFormat(format: GPUTextureFormat): boolean;
  129112. static GetWebGPUTextureFormat(type: number, format: number): GPUTextureFormat;
  129113. invertYPreMultiplyAlpha(gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  129114. clear(format: GPUTextureFormat, color: IColor4Like, passEncoder: GPURenderPassEncoder): void;
  129115. createTexture(imageBitmap: ImageBitmap | {
  129116. width: number;
  129117. height: number;
  129118. layers: number;
  129119. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, is3D?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  129120. createCubeTexture(imageBitmaps: ImageBitmap[] | {
  129121. width: number;
  129122. height: number;
  129123. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  129124. generateCubeMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, commandEncoder?: GPUCommandEncoder): void;
  129125. generateMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  129126. createGPUTextureForInternalTexture(texture: InternalTexture, width?: number, height?: number, depth?: number): WebGPUHardwareTexture;
  129127. createMSAATexture(texture: InternalTexture, samples: number): void;
  129128. updateCubeTextures(imageBitmaps: ImageBitmap[] | Uint8Array[], gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, offsetX?: number, offsetY?: number, commandEncoder?: GPUCommandEncoder): void;
  129129. 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;
  129130. readPixels(texture: GPUTexture, x: number, y: number, width: number, height: number, format: GPUTextureFormat, faceIndex?: number, mipLevel?: number, buffer?: Nullable<ArrayBufferView>): Promise<ArrayBufferView>;
  129131. releaseTexture(texture: InternalTexture | GPUTexture): void;
  129132. destroyDeferredTextures(): void;
  129133. }
  129134. }
  129135. declare module BABYLON {
  129136. /** @hidden */
  129137. export class WebGPURenderPassWrapper {
  129138. renderPassDescriptor: Nullable<GPURenderPassDescriptor>;
  129139. renderPass: Nullable<GPURenderPassEncoder>;
  129140. colorAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  129141. depthAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  129142. colorAttachmentGPUTextures: WebGPUHardwareTexture[];
  129143. depthTextureFormat: GPUTextureFormat | undefined;
  129144. constructor();
  129145. reset(fullReset?: boolean): void;
  129146. }
  129147. }
  129148. declare module BABYLON {
  129149. /** @hidden */
  129150. export class WebGPUCacheSampler {
  129151. private _samplers;
  129152. private _device;
  129153. constructor(device: GPUDevice);
  129154. private static _GetSamplerHashCode;
  129155. private static _GetSamplerFilterDescriptor;
  129156. private static _GetWrappingMode;
  129157. private static _GetSamplerWrappingDescriptor;
  129158. private static _GetSamplerDescriptor;
  129159. getSampler(internalTexture: InternalTexture, bypassCache?: boolean): GPUSampler;
  129160. }
  129161. }
  129162. declare module BABYLON {
  129163. /** @hidden */
  129164. export class WebGPUShaderManager {
  129165. private _shaders;
  129166. private _device;
  129167. constructor(device: GPUDevice);
  129168. getCompiledShaders(name: string): IWebGPURenderPipelineStageDescriptor;
  129169. }
  129170. }
  129171. declare module BABYLON {
  129172. /** @hidden */
  129173. export var clearQuadVertexShader: {
  129174. name: string;
  129175. shader: string;
  129176. };
  129177. }
  129178. declare module BABYLON {
  129179. /** @hidden */
  129180. export var clearQuadPixelShader: {
  129181. name: string;
  129182. shader: string;
  129183. };
  129184. }
  129185. declare module BABYLON {
  129186. /**
  129187. * Options to load the associated Glslang library
  129188. */
  129189. export interface GlslangOptions {
  129190. /**
  129191. * Defines an existing instance of Glslang (usefull in modules who do not access the global instance).
  129192. */
  129193. glslang?: any;
  129194. /**
  129195. * Defines the URL of the glslang JS File.
  129196. */
  129197. jsPath?: string;
  129198. /**
  129199. * Defines the URL of the glslang WASM File.
  129200. */
  129201. wasmPath?: string;
  129202. }
  129203. /**
  129204. * Options to create the WebGPU engine
  129205. */
  129206. export interface WebGPUEngineOptions extends GPURequestAdapterOptions {
  129207. /**
  129208. * If delta time between frames should be constant
  129209. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  129210. */
  129211. deterministicLockstep?: boolean;
  129212. /**
  129213. * Maximum about of steps between frames (Default: 4)
  129214. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  129215. */
  129216. lockstepMaxSteps?: number;
  129217. /**
  129218. * Defines the seconds between each deterministic lock step
  129219. */
  129220. timeStep?: number;
  129221. /**
  129222. * Defines that engine should ignore modifying touch action attribute and style
  129223. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  129224. */
  129225. doNotHandleTouchAction?: boolean;
  129226. /**
  129227. * Defines if webaudio should be initialized as well
  129228. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  129229. */
  129230. audioEngine?: boolean;
  129231. /**
  129232. * Defines the category of adapter to use.
  129233. * Is it the discrete or integrated device.
  129234. */
  129235. powerPreference?: GPUPowerPreference;
  129236. /**
  129237. * Defines the device descriptor used to create a device.
  129238. */
  129239. deviceDescriptor?: GPUDeviceDescriptor;
  129240. /**
  129241. * Defines the requested Swap Chain Format.
  129242. */
  129243. swapChainFormat?: GPUTextureFormat;
  129244. /**
  129245. * Defines wether MSAA is enabled on the canvas.
  129246. */
  129247. antialiasing?: boolean;
  129248. /**
  129249. * Defines wether the stencil buffer should be enabled.
  129250. */
  129251. stencil?: boolean;
  129252. /**
  129253. * Defines wether we should generate debug markers in the gpu command lists (can be seen with PIX for eg)
  129254. */
  129255. enableGPUDebugMarkers?: boolean;
  129256. }
  129257. /**
  129258. * The web GPU engine class provides support for WebGPU version of babylon.js.
  129259. */
  129260. export class WebGPUEngine extends Engine {
  129261. private static readonly _glslangDefaultOptions;
  129262. private readonly _uploadEncoderDescriptor;
  129263. private readonly _renderEncoderDescriptor;
  129264. private readonly _renderTargetEncoderDescriptor;
  129265. private readonly _clearDepthValue;
  129266. private readonly _clearReverseDepthValue;
  129267. private readonly _clearStencilValue;
  129268. private readonly _defaultSampleCount;
  129269. private _canvas;
  129270. private _options;
  129271. private _glslang;
  129272. private _adapter;
  129273. private _adapterSupportedExtensions;
  129274. private _device;
  129275. private _deviceEnabledExtensions;
  129276. private _context;
  129277. private _swapChain;
  129278. private _swapChainTexture;
  129279. private _mainPassSampleCount;
  129280. private _textureHelper;
  129281. private _bufferManager;
  129282. private _shaderManager;
  129283. private _cacheSampler;
  129284. private _emptyVertexBuffer;
  129285. private _lastCachedWrapU;
  129286. private _lastCachedWrapV;
  129287. private _lastCachedWrapR;
  129288. private _mrtAttachments;
  129289. private _counters;
  129290. private _mainTexture;
  129291. private _depthTexture;
  129292. private _mainTextureExtends;
  129293. private _depthTextureFormat;
  129294. private _colorFormat;
  129295. private _uploadEncoder;
  129296. private _renderEncoder;
  129297. private _renderTargetEncoder;
  129298. private _commandBuffers;
  129299. private _currentRenderPass;
  129300. private _mainRenderPassWrapper;
  129301. private _rttRenderPassWrapper;
  129302. private _pendingDebugCommands;
  129303. private _currentVertexBuffers;
  129304. private _currentIndexBuffer;
  129305. private __colorWrite;
  129306. private _uniformsBuffers;
  129307. private _forceEnableEffect;
  129308. /** @hidden */
  129309. dbgShowShaderCode: boolean;
  129310. /** @hidden */
  129311. dbgSanityChecks: boolean;
  129312. /** @hidden */
  129313. dbgGenerateLogs: boolean;
  129314. /** @hidden */
  129315. dbgVerboseLogsForFirstFrames: boolean;
  129316. /** @hidden */
  129317. dbgVerboseLogsNumFrames: number;
  129318. /** @hidden */
  129319. dbgShowWarningsNotImplemented: boolean;
  129320. /**
  129321. * Gets a boolean indicating that the engine supports uniform buffers
  129322. */
  129323. get supportsUniformBuffers(): boolean;
  129324. /** Gets the supported extensions by the WebGPU adapter */
  129325. get supportedExtensions(): Immutable<GPUExtensionName[]>;
  129326. /** Gets the currently enabled extensions on the WebGPU device */
  129327. get enabledExtensions(): Immutable<GPUExtensionName[]>;
  129328. /**
  129329. * Returns the name of the engine
  129330. */
  129331. get name(): string;
  129332. /**
  129333. * Returns a string describing the current engine
  129334. */
  129335. get description(): string;
  129336. /**
  129337. * Returns the version of the engine
  129338. */
  129339. get version(): number;
  129340. /**
  129341. * Create a new instance of the gpu engine.
  129342. * @param canvas Defines the canvas to use to display the result
  129343. * @param options Defines the options passed to the engine to create the GPU context dependencies
  129344. */
  129345. constructor(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions);
  129346. /**
  129347. * Initializes the WebGPU context and dependencies.
  129348. * @param glslangOptions Defines the GLSLang compiler options if necessary
  129349. * @returns a promise notifying the readiness of the engine.
  129350. */
  129351. initAsync(glslangOptions?: GlslangOptions): Promise<void>;
  129352. private _initGlslang;
  129353. private _initializeLimits;
  129354. private _initializeContextAndSwapChain;
  129355. private _initializeMainAttachments;
  129356. /**
  129357. * Force a specific size of the canvas
  129358. * @param width defines the new canvas' width
  129359. * @param height defines the new canvas' height
  129360. * @param forceSetSize true to force setting the sizes of the underlying canvas
  129361. * @returns true if the size was changed
  129362. */
  129363. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  129364. /**
  129365. * Gets a shader processor implementation fitting with the current engine type.
  129366. * @returns The shader processor implementation.
  129367. */
  129368. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  129369. /** @hidden */
  129370. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  129371. /**
  129372. * Force the entire cache to be cleared
  129373. * You should not have to use this function unless your engine needs to share the WebGPU context with another engine
  129374. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  129375. */
  129376. wipeCaches(bruteForce?: boolean): void;
  129377. /**
  129378. * Enable or disable color writing
  129379. * @param enable defines the state to set
  129380. */
  129381. setColorWrite(enable: boolean): void;
  129382. /**
  129383. * Gets a boolean indicating if color writing is enabled
  129384. * @returns the current color writing state
  129385. */
  129386. getColorWrite(): boolean;
  129387. private _viewportsCurrent;
  129388. private _resetCurrentViewport;
  129389. private _applyViewport;
  129390. /** @hidden */
  129391. _viewport(x: number, y: number, width: number, height: number): void;
  129392. private _scissorsCurrent;
  129393. protected _scissorCached: {
  129394. x: number;
  129395. y: number;
  129396. z: number;
  129397. w: number;
  129398. };
  129399. private _resetCurrentScissor;
  129400. private _applyScissor;
  129401. private _scissorIsActive;
  129402. enableScissor(x: number, y: number, width: number, height: number): void;
  129403. disableScissor(): void;
  129404. /**
  129405. * Clear the current render buffer or the current render target (if any is set up)
  129406. * @param color defines the color to use
  129407. * @param backBuffer defines if the back buffer must be cleared
  129408. * @param depth defines if the depth buffer must be cleared
  129409. * @param stencil defines if the stencil buffer must be cleared
  129410. */
  129411. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  129412. /**
  129413. * Clears a list of attachments
  129414. * @param attachments list of the attachments
  129415. * @param colorMain clear color for the main attachment (the first one)
  129416. * @param colorOthers clear color for the other attachments
  129417. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  129418. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  129419. */
  129420. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  129421. /**
  129422. * Creates a vertex buffer
  129423. * @param data the data for the vertex buffer
  129424. * @returns the new buffer
  129425. */
  129426. createVertexBuffer(data: DataArray): DataBuffer;
  129427. /**
  129428. * Creates a vertex buffer
  129429. * @param data the data for the dynamic vertex buffer
  129430. * @returns the new buffer
  129431. */
  129432. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  129433. /**
  129434. * Updates a vertex buffer.
  129435. * @param vertexBuffer the vertex buffer to update
  129436. * @param data the data used to update the vertex buffer
  129437. * @param byteOffset the byte offset of the data
  129438. * @param byteLength the byte length of the data
  129439. */
  129440. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  129441. /**
  129442. * Creates a new index buffer
  129443. * @param indices defines the content of the index buffer
  129444. * @param updatable defines if the index buffer must be updatable - not used in WebGPU
  129445. * @returns a new buffer
  129446. */
  129447. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  129448. /**
  129449. * Update an index buffer
  129450. * @param indexBuffer defines the target index buffer
  129451. * @param indices defines the data to update
  129452. * @param offset defines the offset in the target index buffer where update should start
  129453. */
  129454. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  129455. /** @hidden */
  129456. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  129457. /** @hidden */
  129458. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  129459. /**
  129460. * Bind a list of vertex buffers with the engine
  129461. * @param vertexBuffers defines the list of vertex buffers to bind
  129462. * @param indexBuffer defines the index buffer to bind
  129463. * @param effect defines the effect associated with the vertex buffers
  129464. */
  129465. bindBuffers(vertexBuffers: {
  129466. [key: string]: Nullable<VertexBuffer>;
  129467. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  129468. /** @hidden */
  129469. _releaseBuffer(buffer: DataBuffer): boolean;
  129470. createUniformBuffer(elements: FloatArray): DataBuffer;
  129471. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  129472. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  129473. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  129474. /**
  129475. * Create a new effect (used to store vertex/fragment shaders)
  129476. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  129477. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  129478. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  129479. * @param samplers defines an array of string used to represent textures
  129480. * @param defines defines the string containing the defines to use to compile the shaders
  129481. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  129482. * @param onCompiled defines a function to call when the effect creation is successful
  129483. * @param onError defines a function to call when the effect creation has failed
  129484. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  129485. * @returns the new Effect
  129486. */
  129487. 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;
  129488. private _compileRawShaderToSpirV;
  129489. private _compileShaderToSpirV;
  129490. private _createPipelineStageDescriptor;
  129491. private _compileRawPipelineStageDescriptor;
  129492. private _compilePipelineStageDescriptor;
  129493. /** @hidden */
  129494. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  129495. /** @hidden */
  129496. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  129497. /**
  129498. * Creates a new pipeline context
  129499. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  129500. * @returns the new pipeline
  129501. */
  129502. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  129503. /** @hidden */
  129504. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  129505. /**
  129506. * Gets the list of active attributes for a given WebGPU program
  129507. * @param pipelineContext defines the pipeline context to use
  129508. * @param attributesNames defines the list of attribute names to get
  129509. * @returns an array of indices indicating the offset of each attribute
  129510. */
  129511. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  129512. /**
  129513. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  129514. * @param effect defines the effect to activate
  129515. */
  129516. enableEffect(effect: Nullable<Effect>): void;
  129517. /** @hidden */
  129518. _releaseEffect(effect: Effect): void;
  129519. /**
  129520. * 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
  129521. */
  129522. releaseEffects(): void;
  129523. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  129524. /**
  129525. * Gets a boolean indicating that only power of 2 textures are supported
  129526. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  129527. */
  129528. get needPOTTextures(): boolean;
  129529. /** @hidden */
  129530. _createHardwareTexture(): HardwareTextureWrapper;
  129531. /** @hidden */
  129532. _releaseTexture(texture: InternalTexture): void;
  129533. /** @hidden */
  129534. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  129535. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  129536. /**
  129537. * Usually called from Texture.ts.
  129538. * Passed information to create a hardware texture
  129539. * @param url defines a value which contains one of the following:
  129540. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  129541. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  129542. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  129543. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  129544. * @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)
  129545. * @param scene needed for loading to the correct scene
  129546. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  129547. * @param onLoad optional callback to be called upon successful completion
  129548. * @param onError optional callback to be called upon failure
  129549. * @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
  129550. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  129551. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  129552. * @param forcedExtension defines the extension to use to pick the right loader
  129553. * @param mimeType defines an optional mime type
  129554. * @param loaderOptions options to be passed to the loader
  129555. * @returns a InternalTexture for assignment back into BABYLON.Texture
  129556. */
  129557. 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;
  129558. /** @hidden */
  129559. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  129560. /**
  129561. * Creates a cube texture
  129562. * @param rootUrl defines the url where the files to load is located
  129563. * @param scene defines the current scene
  129564. * @param files defines the list of files to load (1 per face)
  129565. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  129566. * @param onLoad defines an optional callback raised when the texture is loaded
  129567. * @param onError defines an optional callback raised if there is an issue to load the texture
  129568. * @param format defines the format of the data
  129569. * @param forcedExtension defines the extension to use to pick the right loader
  129570. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  129571. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  129572. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  129573. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  129574. * @param loaderOptions options to be passed to the loader
  129575. * @returns the cube texture as an InternalTexture
  129576. */
  129577. 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;
  129578. /**
  129579. * Creates a raw texture
  129580. * @param data defines the data to store in the texture
  129581. * @param width defines the width of the texture
  129582. * @param height defines the height of the texture
  129583. * @param format defines the format of the data
  129584. * @param generateMipMaps defines if the engine should generate the mip levels
  129585. * @param invertY defines if data must be stored with Y axis inverted
  129586. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  129587. * @param compression defines the compression used (null by default)
  129588. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  129589. * @returns the raw texture inside an InternalTexture
  129590. */
  129591. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  129592. /**
  129593. * Creates a new raw cube texture
  129594. * @param data defines the array of data to use to create each face
  129595. * @param size defines the size of the textures
  129596. * @param format defines the format of the data
  129597. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  129598. * @param generateMipMaps defines if the engine should generate the 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 compression used (null by default)
  129602. * @returns the cube texture as an InternalTexture
  129603. */
  129604. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  129605. /**
  129606. * Creates a new raw cube texture from a specified url
  129607. * @param url defines the url where the data is located
  129608. * @param scene defines the current scene
  129609. * @param size defines the size of the textures
  129610. * @param format defines the format of the data
  129611. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  129612. * @param noMipmap defines if the engine should avoid generating the mip levels
  129613. * @param callback defines a callback used to extract texture data from loaded data
  129614. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  129615. * @param onLoad defines a callback called when texture is loaded
  129616. * @param onError defines a callback called if there is an error
  129617. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  129618. * @param invertY defines if data must be stored with Y axis inverted
  129619. * @returns the cube texture as an InternalTexture
  129620. */
  129621. 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;
  129622. /**
  129623. * Creates a new raw 2D array texture
  129624. * @param data defines the data used to create the texture
  129625. * @param width defines the width of the texture
  129626. * @param height defines the height of the texture
  129627. * @param depth defines the number of layers of the texture
  129628. * @param format defines the format of the texture
  129629. * @param generateMipMaps defines if the engine must generate mip levels
  129630. * @param invertY defines if data must be stored with Y axis inverted
  129631. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  129632. * @param compression defines the compressed used (can be null)
  129633. * @param textureType defines the compressed used (can be null)
  129634. * @returns a new raw 2D array texture (stored in an InternalTexture)
  129635. */
  129636. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  129637. /**
  129638. * Creates a new raw 3D texture
  129639. * @param data defines the data used to create the texture
  129640. * @param width defines the width of the texture
  129641. * @param height defines the height of the texture
  129642. * @param depth defines the depth of the texture
  129643. * @param format defines the format of the texture
  129644. * @param generateMipMaps defines if the engine must generate mip levels
  129645. * @param invertY defines if data must be stored with Y axis inverted
  129646. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  129647. * @param compression defines the compressed used (can be null)
  129648. * @param textureType defines the compressed used (can be null)
  129649. * @returns a new raw 3D texture (stored in an InternalTexture)
  129650. */
  129651. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  129652. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  129653. /**
  129654. * Update the sampling mode of a given texture
  129655. * @param samplingMode defines the required sampling mode
  129656. * @param texture defines the texture to update
  129657. * @param generateMipMaps defines whether to generate mipmaps for the texture
  129658. */
  129659. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  129660. /**
  129661. * Update the sampling mode of a given texture
  129662. * @param texture defines the texture to update
  129663. * @param wrapU defines the texture wrap mode of the u coordinates
  129664. * @param wrapV defines the texture wrap mode of the v coordinates
  129665. * @param wrapR defines the texture wrap mode of the r coordinates
  129666. */
  129667. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  129668. /**
  129669. * Update the dimensions of a texture
  129670. * @param texture texture to update
  129671. * @param width new width of the texture
  129672. * @param height new height of the texture
  129673. * @param depth new depth of the texture
  129674. */
  129675. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  129676. private _setInternalTexture;
  129677. /**
  129678. * Sets a texture to the according uniform.
  129679. * @param channel The texture channel
  129680. * @param unused unused parameter
  129681. * @param texture The texture to apply
  129682. * @param name The name of the uniform in the effect
  129683. */
  129684. setTexture(channel: number, unused: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>, name: string): void;
  129685. /**
  129686. * Sets an array of texture to the WebGPU context
  129687. * @param channel defines the channel where the texture array must be set
  129688. * @param unused unused parameter
  129689. * @param textures defines the array of textures to bind
  129690. * @param name name of the channel
  129691. */
  129692. setTextureArray(channel: number, unused: Nullable<WebGLUniformLocation>, textures: BaseTexture[], name: string): void;
  129693. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string, baseName?: string, textureIndex?: number): boolean;
  129694. /** @hidden */
  129695. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  129696. /** @hidden */
  129697. _bindTexture(channel: number, texture: InternalTexture, name: string): void;
  129698. private _generateMipmaps;
  129699. /**
  129700. * Update the content of a texture
  129701. * @param texture defines the texture to update
  129702. * @param canvas defines the source containing the data
  129703. * @param invertY defines if data must be stored with Y axis inverted
  129704. * @param premulAlpha defines if alpha is stored as premultiplied
  129705. * @param format defines the format of the data
  129706. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  129707. */
  129708. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  129709. /**
  129710. * Update a portion of an internal texture
  129711. * @param texture defines the texture to update
  129712. * @param imageData defines the data to store into the texture
  129713. * @param xOffset defines the x coordinates of the update rectangle
  129714. * @param yOffset defines the y coordinates of the update rectangle
  129715. * @param width defines the width of the update rectangle
  129716. * @param height defines the height of the update rectangle
  129717. * @param faceIndex defines the face index if texture is a cube (0 by default)
  129718. * @param lod defines the lod level to update (0 by default)
  129719. */
  129720. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  129721. /**
  129722. * Update a video texture
  129723. * @param texture defines the texture to update
  129724. * @param video defines the video element to use
  129725. * @param invertY defines if data must be stored with Y axis inverted
  129726. */
  129727. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  129728. /** @hidden */
  129729. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129730. /** @hidden */
  129731. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  129732. /** @hidden */
  129733. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129734. /** @hidden */
  129735. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  129736. /**
  129737. * Update a raw texture
  129738. * @param texture defines the texture to update
  129739. * @param bufferView defines the data to store in the texture
  129740. * @param format defines the format of the data
  129741. * @param invertY defines if data must be stored with Y axis inverted
  129742. * @param compression defines the compression used (null by default)
  129743. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  129744. */
  129745. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  129746. /**
  129747. * Update a raw cube texture
  129748. * @param texture defines the texture to udpdate
  129749. * @param bufferView defines the data to store
  129750. * @param format defines the data format
  129751. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  129752. * @param invertY defines if data must be stored with Y axis inverted
  129753. * @param compression defines the compression used (null by default)
  129754. * @param level defines which level of the texture to update
  129755. */
  129756. updateRawCubeTexture(texture: InternalTexture, bufferView: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  129757. /**
  129758. * Update a raw 2D array texture
  129759. * @param texture defines the texture to update
  129760. * @param bufferView defines the data to store
  129761. * @param format defines the data format
  129762. * @param invertY defines if data must be stored with Y axis inverted
  129763. * @param compression defines the used compression (can be null)
  129764. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129765. */
  129766. updateRawTexture2DArray(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  129767. /**
  129768. * Update a raw 3D texture
  129769. * @param texture defines the texture to update
  129770. * @param bufferView defines the data to store
  129771. * @param format defines the data format
  129772. * @param invertY defines if data must be stored with Y axis inverted
  129773. * @param compression defines the used compression (can be null)
  129774. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129775. */
  129776. updateRawTexture3D(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  129777. /**
  129778. * Reads pixels from the current frame buffer. Please note that this function can be slow
  129779. * @param x defines the x coordinate of the rectangle where pixels must be read
  129780. * @param y defines the y coordinate of the rectangle where pixels must be read
  129781. * @param width defines the width of the rectangle where pixels must be read
  129782. * @param height defines the height of the rectangle where pixels must be read
  129783. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  129784. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  129785. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  129786. */
  129787. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  129788. /** @hidden */
  129789. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  129790. /**
  129791. * Creates a new render target texture
  129792. * @param size defines the size of the texture
  129793. * @param options defines the options used to create the texture
  129794. * @returns a new render target texture stored in an InternalTexture
  129795. */
  129796. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  129797. /**
  129798. * Create a multi render target texture
  129799. * @param size defines the size of the texture
  129800. * @param options defines the creation options
  129801. * @returns the cube texture as an InternalTexture
  129802. */
  129803. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  129804. /**
  129805. * Creates a new render target cube texture
  129806. * @param size defines the size of the texture
  129807. * @param options defines the options used to create the texture
  129808. * @returns a new render target cube texture stored in an InternalTexture
  129809. */
  129810. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  129811. /** @hidden */
  129812. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  129813. width: number;
  129814. height: number;
  129815. layers?: number;
  129816. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  129817. /** @hidden */
  129818. _createDepthStencilTexture(size: number | {
  129819. width: number;
  129820. height: number;
  129821. layers?: number;
  129822. }, options: DepthTextureCreationOptions): InternalTexture;
  129823. /** @hidden */
  129824. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  129825. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  129826. /**
  129827. * Update the sample count for a given multiple render target texture
  129828. * @param textures defines the textures to update
  129829. * @param samples defines the sample count to set
  129830. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  129831. */
  129832. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  129833. /**
  129834. * Begin a new frame
  129835. */
  129836. beginFrame(): void;
  129837. /**
  129838. * End the current frame
  129839. */
  129840. endFrame(): void;
  129841. /**
  129842. * Force a WebGPU flush (ie. a flush of all waiting commands)
  129843. */
  129844. flushFramebuffer(): void;
  129845. private _startRenderTargetRenderPass;
  129846. private _endRenderTargetRenderPass;
  129847. private _getCurrentRenderPass;
  129848. private _currentRenderPassIsMRT;
  129849. private _startMainRenderPass;
  129850. private _endMainRenderPass;
  129851. /**
  129852. * Restores the WebGPU state to only draw on the main color attachment
  129853. */
  129854. restoreSingleAttachment(): void;
  129855. /**
  129856. * Creates a layout object to draw/clear on specific textures in a MRT
  129857. * @param textureStatus textureStatus[i] indicates if the i-th is active
  129858. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  129859. */
  129860. buildTextureLayout(textureStatus: boolean[]): number[];
  129861. /**
  129862. * Select a subsets of attachments to draw to.
  129863. * @param attachments index of attachments
  129864. */
  129865. bindAttachments(attachments: number[]): void;
  129866. /**
  129867. * Binds the frame buffer to the specified texture.
  129868. * @param texture The texture to render to or null for the default canvas
  129869. * @param faceIndex The face of the texture to render to in case of cube texture
  129870. * @param requiredWidth The width of the target to render to
  129871. * @param requiredHeight The height of the target to render to
  129872. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  129873. * @param lodLevel defines the lod level to bind to the frame buffer
  129874. * @param layer defines the 2d array index to bind to frame buffer to
  129875. */
  129876. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  129877. /**
  129878. * Unbind the current render target texture from the WebGPU context
  129879. * @param texture defines the render target texture to unbind
  129880. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  129881. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  129882. */
  129883. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  129884. /**
  129885. * Unbind a list of render target textures from the WebGPU context
  129886. * @param textures defines the render target textures to unbind
  129887. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  129888. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  129889. */
  129890. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  129891. /**
  129892. * Unbind the current render target and bind the default framebuffer
  129893. */
  129894. restoreDefaultFramebuffer(): void;
  129895. setZOffset(value: number): void;
  129896. private _setColorFormat;
  129897. private _setDepthTextureFormat;
  129898. setDepthBuffer(enable: boolean): void;
  129899. setDepthWrite(enable: boolean): void;
  129900. setStencilBuffer(enable: boolean): void;
  129901. setStencilMask(mask: number): void;
  129902. setStencilFunction(stencilFunc: number): void;
  129903. setStencilFunctionReference(reference: number): void;
  129904. setStencilFunctionMask(mask: number): void;
  129905. setStencilOperationFail(operation: number): void;
  129906. setStencilOperationDepthFail(operation: number): void;
  129907. setStencilOperationPass(operation: number): void;
  129908. setDitheringState(value: boolean): void;
  129909. setRasterizerState(value: boolean): void;
  129910. setDepthFunction(depthFunc: number): void;
  129911. setDepthFunctionToGreater(): void;
  129912. setDepthFunctionToGreaterOrEqual(): void;
  129913. setDepthFunctionToLess(): void;
  129914. setDepthFunctionToLessOrEqual(): void;
  129915. private _indexFormatInRenderPass;
  129916. private _getTopology;
  129917. private _getOpFunction;
  129918. private _getDepthStencilStateDescriptor;
  129919. /**
  129920. * Set various states to the context
  129921. * @param culling defines backface culling state
  129922. * @param zOffset defines the value to apply to zOffset (0 by default)
  129923. * @param force defines if states must be applied even if cache is up to date
  129924. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  129925. */
  129926. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  129927. private _getFrontFace;
  129928. private _getCullMode;
  129929. private _getRasterizationStateDescriptor;
  129930. private _getWriteMask;
  129931. /**
  129932. * Sets the current alpha mode
  129933. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  129934. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  129935. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  129936. */
  129937. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  129938. private _getAphaBlendOperation;
  129939. private _getAphaBlendFactor;
  129940. private _getAphaBlendState;
  129941. private _getColorBlendState;
  129942. private _getColorStateDescriptors;
  129943. private _getStages;
  129944. private _getVertexInputDescriptorFormat;
  129945. private _getVertexInputDescriptor;
  129946. private _getPipelineLayout;
  129947. private _getRenderPipeline;
  129948. private _getVertexInputsToRender;
  129949. private _getBindGroupsToRender;
  129950. private _bindVertexInputs;
  129951. private _setRenderBindGroups;
  129952. private _setRenderPipeline;
  129953. /**
  129954. * Draw a list of indexed primitives
  129955. * @param fillMode defines the primitive to use
  129956. * @param indexStart defines the starting index
  129957. * @param indexCount defines the number of index to draw
  129958. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129959. */
  129960. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  129961. /**
  129962. * Draw a list of unindexed primitives
  129963. * @param fillMode defines the primitive to use
  129964. * @param verticesStart defines the index of first vertex to draw
  129965. * @param verticesCount defines the count of vertices to draw
  129966. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129967. */
  129968. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  129969. private _bundleEncoder;
  129970. /**
  129971. * Start recording all the gpu calls into a bundle.
  129972. */
  129973. startRecordBundle(): void;
  129974. /**
  129975. * Stops recording the bundle.
  129976. * @returns the recorded bundle
  129977. */
  129978. stopRecordBundle(): GPURenderBundle;
  129979. /**
  129980. * Execute the previously recorded bundle.
  129981. * @param bundles defines the bundle to replay
  129982. */
  129983. executeBundles(bundles: GPURenderBundle[]): void;
  129984. /**
  129985. * Dispose and release all associated resources
  129986. */
  129987. dispose(): void;
  129988. /**
  129989. * Gets the current render width
  129990. * @param useScreen defines if screen size must be used (or the current render target if any)
  129991. * @returns a number defining the current render width
  129992. */
  129993. getRenderWidth(useScreen?: boolean): number;
  129994. /**
  129995. * Gets the current render height
  129996. * @param useScreen defines if screen size must be used (or the current render target if any)
  129997. * @returns a number defining the current render height
  129998. */
  129999. getRenderHeight(useScreen?: boolean): number;
  130000. /**
  130001. * Gets the HTML canvas attached with the current WebGPU context
  130002. * @returns a HTML canvas
  130003. */
  130004. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  130005. /** @hidden */
  130006. _debugPushGroup(groupName: string, targetObject?: number): void;
  130007. /** @hidden */
  130008. _debugPopGroup(targetObject?: number): void;
  130009. /** @hidden */
  130010. _debugInsertMarker(text: string, targetObject?: number): void;
  130011. private _debugFlushPendingCommands;
  130012. /**
  130013. * Get the current error code of the WebGPU context
  130014. * @returns the error code
  130015. */
  130016. getError(): number;
  130017. /** @hidden */
  130018. bindSamplers(effect: Effect): void;
  130019. /** @hidden */
  130020. _bindTextureDirectly(target: number, texture: InternalTexture, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  130021. /** @hidden */
  130022. _releaseFramebufferObjects(texture: InternalTexture): void;
  130023. /** @hidden */
  130024. applyStates(): void;
  130025. /**
  130026. * Gets a boolean indicating if all created effects are ready
  130027. * @returns always true - No parallel shader compilation
  130028. */
  130029. areAllEffectsReady(): boolean;
  130030. /** @hidden */
  130031. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  130032. /** @hidden */
  130033. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  130034. /** @hidden */
  130035. _getUnpackAlignement(): number;
  130036. /** @hidden */
  130037. _unpackFlipY(value: boolean): void;
  130038. /** @hidden */
  130039. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  130040. min: number;
  130041. mag: number;
  130042. };
  130043. /** @hidden */
  130044. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  130045. /** @hidden */
  130046. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  130047. /** @hidden */
  130048. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  130049. /** @hidden */
  130050. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  130051. /** @hidden */
  130052. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  130053. /** @hidden */
  130054. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  130055. /** @hidden */
  130056. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  130057. /** @hidden */
  130058. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  130059. /** @hidden */
  130060. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  130061. /** @hidden */
  130062. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  130063. /** @hidden */
  130064. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  130065. /** @hidden */
  130066. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  130067. /** @hidden */
  130068. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  130069. /** @hidden */
  130070. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  130071. /** @hidden */
  130072. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  130073. /** @hidden */
  130074. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  130075. /** @hidden */
  130076. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  130077. }
  130078. }
  130079. declare module BABYLON {
  130080. /**
  130081. * Define an interface for all classes that will hold resources
  130082. */
  130083. export interface IDisposable {
  130084. /**
  130085. * Releases all held resources
  130086. */
  130087. dispose(): void;
  130088. }
  130089. /** Interface defining initialization parameters for Scene class */
  130090. export interface SceneOptions {
  130091. /**
  130092. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  130093. * It will improve performance when the number of geometries becomes important.
  130094. */
  130095. useGeometryUniqueIdsMap?: boolean;
  130096. /**
  130097. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  130098. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  130099. */
  130100. useMaterialMeshMap?: boolean;
  130101. /**
  130102. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  130103. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  130104. */
  130105. useClonedMeshMap?: boolean;
  130106. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  130107. virtual?: boolean;
  130108. }
  130109. /**
  130110. * Represents a scene to be rendered by the engine.
  130111. * @see https://doc.babylonjs.com/features/scene
  130112. */
  130113. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  130114. /** The fog is deactivated */
  130115. static readonly FOGMODE_NONE: number;
  130116. /** The fog density is following an exponential function */
  130117. static readonly FOGMODE_EXP: number;
  130118. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  130119. static readonly FOGMODE_EXP2: number;
  130120. /** The fog density is following a linear function. */
  130121. static readonly FOGMODE_LINEAR: number;
  130122. /**
  130123. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  130124. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130125. */
  130126. static MinDeltaTime: number;
  130127. /**
  130128. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  130129. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130130. */
  130131. static MaxDeltaTime: number;
  130132. /**
  130133. * Factory used to create the default material.
  130134. * @param name The name of the material to create
  130135. * @param scene The scene to create the material for
  130136. * @returns The default material
  130137. */
  130138. static DefaultMaterialFactory(scene: Scene): Material;
  130139. /**
  130140. * Factory used to create the a collision coordinator.
  130141. * @returns The collision coordinator
  130142. */
  130143. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  130144. /** @hidden */
  130145. _inputManager: InputManager;
  130146. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  130147. cameraToUseForPointers: Nullable<Camera>;
  130148. /** @hidden */
  130149. readonly _isScene: boolean;
  130150. /** @hidden */
  130151. _blockEntityCollection: boolean;
  130152. /**
  130153. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  130154. */
  130155. autoClear: boolean;
  130156. /**
  130157. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  130158. */
  130159. autoClearDepthAndStencil: boolean;
  130160. /**
  130161. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  130162. */
  130163. clearColor: Color4;
  130164. /**
  130165. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  130166. */
  130167. ambientColor: Color3;
  130168. /**
  130169. * This is use to store the default BRDF lookup for PBR materials in your scene.
  130170. * It should only be one of the following (if not the default embedded one):
  130171. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  130172. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  130173. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  130174. * The material properties need to be setup according to the type of texture in use.
  130175. */
  130176. environmentBRDFTexture: BaseTexture;
  130177. /**
  130178. * Texture used in all pbr material as the reflection texture.
  130179. * As in the majority of the scene they are the same (exception for multi room and so on),
  130180. * this is easier to reference from here than from all the materials.
  130181. */
  130182. get environmentTexture(): Nullable<BaseTexture>;
  130183. /**
  130184. * Texture used in all pbr material as the reflection texture.
  130185. * As in the majority of the scene they are the same (exception for multi room and so on),
  130186. * this is easier to set here than in all the materials.
  130187. */
  130188. set environmentTexture(value: Nullable<BaseTexture>);
  130189. /** @hidden */
  130190. protected _environmentIntensity: number;
  130191. /**
  130192. * Intensity of the environment in all pbr material.
  130193. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  130194. * As in the majority of the scene they are the same (exception for multi room and so on),
  130195. * this is easier to reference from here than from all the materials.
  130196. */
  130197. get environmentIntensity(): number;
  130198. /**
  130199. * Intensity of the environment in all pbr material.
  130200. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  130201. * As in the majority of the scene they are the same (exception for multi room and so on),
  130202. * this is easier to set here than in all the materials.
  130203. */
  130204. set environmentIntensity(value: number);
  130205. /** @hidden */
  130206. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  130207. /**
  130208. * Default image processing configuration used either in the rendering
  130209. * Forward main pass or through the imageProcessingPostProcess if present.
  130210. * As in the majority of the scene they are the same (exception for multi camera),
  130211. * this is easier to reference from here than from all the materials and post process.
  130212. *
  130213. * No setter as we it is a shared configuration, you can set the values instead.
  130214. */
  130215. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  130216. private _forceWireframe;
  130217. /**
  130218. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  130219. */
  130220. set forceWireframe(value: boolean);
  130221. get forceWireframe(): boolean;
  130222. private _skipFrustumClipping;
  130223. /**
  130224. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  130225. */
  130226. set skipFrustumClipping(value: boolean);
  130227. get skipFrustumClipping(): boolean;
  130228. private _forcePointsCloud;
  130229. /**
  130230. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  130231. */
  130232. set forcePointsCloud(value: boolean);
  130233. get forcePointsCloud(): boolean;
  130234. /**
  130235. * Gets or sets the active clipplane 1
  130236. */
  130237. clipPlane: Nullable<Plane>;
  130238. /**
  130239. * Gets or sets the active clipplane 2
  130240. */
  130241. clipPlane2: Nullable<Plane>;
  130242. /**
  130243. * Gets or sets the active clipplane 3
  130244. */
  130245. clipPlane3: Nullable<Plane>;
  130246. /**
  130247. * Gets or sets the active clipplane 4
  130248. */
  130249. clipPlane4: Nullable<Plane>;
  130250. /**
  130251. * Gets or sets the active clipplane 5
  130252. */
  130253. clipPlane5: Nullable<Plane>;
  130254. /**
  130255. * Gets or sets the active clipplane 6
  130256. */
  130257. clipPlane6: Nullable<Plane>;
  130258. /**
  130259. * Gets or sets a boolean indicating if animations are enabled
  130260. */
  130261. animationsEnabled: boolean;
  130262. private _animationPropertiesOverride;
  130263. /**
  130264. * Gets or sets the animation properties override
  130265. */
  130266. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  130267. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  130268. /**
  130269. * Gets or sets a boolean indicating if a constant deltatime has to be used
  130270. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  130271. */
  130272. useConstantAnimationDeltaTime: boolean;
  130273. /**
  130274. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  130275. * Please note that it requires to run a ray cast through the scene on every frame
  130276. */
  130277. constantlyUpdateMeshUnderPointer: boolean;
  130278. /**
  130279. * Defines the HTML cursor to use when hovering over interactive elements
  130280. */
  130281. hoverCursor: string;
  130282. /**
  130283. * Defines the HTML default cursor to use (empty by default)
  130284. */
  130285. defaultCursor: string;
  130286. /**
  130287. * Defines whether cursors are handled by the scene.
  130288. */
  130289. doNotHandleCursors: boolean;
  130290. /**
  130291. * This is used to call preventDefault() on pointer down
  130292. * in order to block unwanted artifacts like system double clicks
  130293. */
  130294. preventDefaultOnPointerDown: boolean;
  130295. /**
  130296. * This is used to call preventDefault() on pointer up
  130297. * in order to block unwanted artifacts like system double clicks
  130298. */
  130299. preventDefaultOnPointerUp: boolean;
  130300. /**
  130301. * Gets or sets user defined metadata
  130302. */
  130303. metadata: any;
  130304. /**
  130305. * For internal use only. Please do not use.
  130306. */
  130307. reservedDataStore: any;
  130308. /**
  130309. * Gets the name of the plugin used to load this scene (null by default)
  130310. */
  130311. loadingPluginName: string;
  130312. /**
  130313. * Use this array to add regular expressions used to disable offline support for specific urls
  130314. */
  130315. disableOfflineSupportExceptionRules: RegExp[];
  130316. /**
  130317. * An event triggered when the scene is disposed.
  130318. */
  130319. onDisposeObservable: Observable<Scene>;
  130320. private _onDisposeObserver;
  130321. /** Sets a function to be executed when this scene is disposed. */
  130322. set onDispose(callback: () => void);
  130323. /**
  130324. * An event triggered before rendering the scene (right after animations and physics)
  130325. */
  130326. onBeforeRenderObservable: Observable<Scene>;
  130327. private _onBeforeRenderObserver;
  130328. /** Sets a function to be executed before rendering this scene */
  130329. set beforeRender(callback: Nullable<() => void>);
  130330. /**
  130331. * An event triggered after rendering the scene
  130332. */
  130333. onAfterRenderObservable: Observable<Scene>;
  130334. /**
  130335. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  130336. */
  130337. onAfterRenderCameraObservable: Observable<Camera>;
  130338. private _onAfterRenderObserver;
  130339. /** Sets a function to be executed after rendering this scene */
  130340. set afterRender(callback: Nullable<() => void>);
  130341. /**
  130342. * An event triggered before animating the scene
  130343. */
  130344. onBeforeAnimationsObservable: Observable<Scene>;
  130345. /**
  130346. * An event triggered after animations processing
  130347. */
  130348. onAfterAnimationsObservable: Observable<Scene>;
  130349. /**
  130350. * An event triggered before draw calls are ready to be sent
  130351. */
  130352. onBeforeDrawPhaseObservable: Observable<Scene>;
  130353. /**
  130354. * An event triggered after draw calls have been sent
  130355. */
  130356. onAfterDrawPhaseObservable: Observable<Scene>;
  130357. /**
  130358. * An event triggered when the scene is ready
  130359. */
  130360. onReadyObservable: Observable<Scene>;
  130361. /**
  130362. * An event triggered before rendering a camera
  130363. */
  130364. onBeforeCameraRenderObservable: Observable<Camera>;
  130365. private _onBeforeCameraRenderObserver;
  130366. /** Sets a function to be executed before rendering a camera*/
  130367. set beforeCameraRender(callback: () => void);
  130368. /**
  130369. * An event triggered after rendering a camera
  130370. */
  130371. onAfterCameraRenderObservable: Observable<Camera>;
  130372. private _onAfterCameraRenderObserver;
  130373. /** Sets a function to be executed after rendering a camera*/
  130374. set afterCameraRender(callback: () => void);
  130375. /**
  130376. * An event triggered when active meshes evaluation is about to start
  130377. */
  130378. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  130379. /**
  130380. * An event triggered when active meshes evaluation is done
  130381. */
  130382. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  130383. /**
  130384. * An event triggered when particles rendering is about to start
  130385. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  130386. */
  130387. onBeforeParticlesRenderingObservable: Observable<Scene>;
  130388. /**
  130389. * An event triggered when particles rendering is done
  130390. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  130391. */
  130392. onAfterParticlesRenderingObservable: Observable<Scene>;
  130393. /**
  130394. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  130395. */
  130396. onDataLoadedObservable: Observable<Scene>;
  130397. /**
  130398. * An event triggered when a camera is created
  130399. */
  130400. onNewCameraAddedObservable: Observable<Camera>;
  130401. /**
  130402. * An event triggered when a camera is removed
  130403. */
  130404. onCameraRemovedObservable: Observable<Camera>;
  130405. /**
  130406. * An event triggered when a light is created
  130407. */
  130408. onNewLightAddedObservable: Observable<Light>;
  130409. /**
  130410. * An event triggered when a light is removed
  130411. */
  130412. onLightRemovedObservable: Observable<Light>;
  130413. /**
  130414. * An event triggered when a geometry is created
  130415. */
  130416. onNewGeometryAddedObservable: Observable<Geometry>;
  130417. /**
  130418. * An event triggered when a geometry is removed
  130419. */
  130420. onGeometryRemovedObservable: Observable<Geometry>;
  130421. /**
  130422. * An event triggered when a transform node is created
  130423. */
  130424. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  130425. /**
  130426. * An event triggered when a transform node is removed
  130427. */
  130428. onTransformNodeRemovedObservable: Observable<TransformNode>;
  130429. /**
  130430. * An event triggered when a mesh is created
  130431. */
  130432. onNewMeshAddedObservable: Observable<AbstractMesh>;
  130433. /**
  130434. * An event triggered when a mesh is removed
  130435. */
  130436. onMeshRemovedObservable: Observable<AbstractMesh>;
  130437. /**
  130438. * An event triggered when a skeleton is created
  130439. */
  130440. onNewSkeletonAddedObservable: Observable<Skeleton>;
  130441. /**
  130442. * An event triggered when a skeleton is removed
  130443. */
  130444. onSkeletonRemovedObservable: Observable<Skeleton>;
  130445. /**
  130446. * An event triggered when a material is created
  130447. */
  130448. onNewMaterialAddedObservable: Observable<Material>;
  130449. /**
  130450. * An event triggered when a multi material is created
  130451. */
  130452. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  130453. /**
  130454. * An event triggered when a material is removed
  130455. */
  130456. onMaterialRemovedObservable: Observable<Material>;
  130457. /**
  130458. * An event triggered when a multi material is removed
  130459. */
  130460. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  130461. /**
  130462. * An event triggered when a texture is created
  130463. */
  130464. onNewTextureAddedObservable: Observable<BaseTexture>;
  130465. /**
  130466. * An event triggered when a texture is removed
  130467. */
  130468. onTextureRemovedObservable: Observable<BaseTexture>;
  130469. /**
  130470. * An event triggered when render targets are about to be rendered
  130471. * Can happen multiple times per frame.
  130472. */
  130473. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  130474. /**
  130475. * An event triggered when render targets were rendered.
  130476. * Can happen multiple times per frame.
  130477. */
  130478. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  130479. /**
  130480. * An event triggered before calculating deterministic simulation step
  130481. */
  130482. onBeforeStepObservable: Observable<Scene>;
  130483. /**
  130484. * An event triggered after calculating deterministic simulation step
  130485. */
  130486. onAfterStepObservable: Observable<Scene>;
  130487. /**
  130488. * An event triggered when the activeCamera property is updated
  130489. */
  130490. onActiveCameraChanged: Observable<Scene>;
  130491. /**
  130492. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  130493. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  130494. * 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)
  130495. */
  130496. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  130497. /**
  130498. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  130499. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  130500. * 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)
  130501. */
  130502. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  130503. /**
  130504. * This Observable will when a mesh has been imported into the scene.
  130505. */
  130506. onMeshImportedObservable: Observable<AbstractMesh>;
  130507. /**
  130508. * This Observable will when an animation file has been imported into the scene.
  130509. */
  130510. onAnimationFileImportedObservable: Observable<Scene>;
  130511. /**
  130512. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  130513. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  130514. */
  130515. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  130516. /** @hidden */
  130517. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  130518. /**
  130519. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  130520. */
  130521. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  130522. /**
  130523. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  130524. */
  130525. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  130526. /**
  130527. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  130528. */
  130529. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  130530. /** Callback called when a pointer move is detected */
  130531. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  130532. /** Callback called when a pointer down is detected */
  130533. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  130534. /** Callback called when a pointer up is detected */
  130535. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  130536. /** Callback called when a pointer pick is detected */
  130537. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  130538. /**
  130539. * 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).
  130540. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  130541. */
  130542. onPrePointerObservable: Observable<PointerInfoPre>;
  130543. /**
  130544. * Observable event triggered each time an input event is received from the rendering canvas
  130545. */
  130546. onPointerObservable: Observable<PointerInfo>;
  130547. /**
  130548. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  130549. */
  130550. get unTranslatedPointer(): Vector2;
  130551. /**
  130552. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  130553. */
  130554. static get DragMovementThreshold(): number;
  130555. static set DragMovementThreshold(value: number);
  130556. /**
  130557. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  130558. */
  130559. static get LongPressDelay(): number;
  130560. static set LongPressDelay(value: number);
  130561. /**
  130562. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  130563. */
  130564. static get DoubleClickDelay(): number;
  130565. static set DoubleClickDelay(value: number);
  130566. /** If you need to check double click without raising a single click at first click, enable this flag */
  130567. static get ExclusiveDoubleClickMode(): boolean;
  130568. static set ExclusiveDoubleClickMode(value: boolean);
  130569. /** @hidden */
  130570. _mirroredCameraPosition: Nullable<Vector3>;
  130571. /**
  130572. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  130573. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  130574. */
  130575. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  130576. /**
  130577. * Observable event triggered each time an keyboard event is received from the hosting window
  130578. */
  130579. onKeyboardObservable: Observable<KeyboardInfo>;
  130580. private _useRightHandedSystem;
  130581. /**
  130582. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  130583. */
  130584. set useRightHandedSystem(value: boolean);
  130585. get useRightHandedSystem(): boolean;
  130586. private _timeAccumulator;
  130587. private _currentStepId;
  130588. private _currentInternalStep;
  130589. /**
  130590. * Sets the step Id used by deterministic lock step
  130591. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130592. * @param newStepId defines the step Id
  130593. */
  130594. setStepId(newStepId: number): void;
  130595. /**
  130596. * Gets the step Id used by deterministic lock step
  130597. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130598. * @returns the step Id
  130599. */
  130600. getStepId(): number;
  130601. /**
  130602. * Gets the internal step used by deterministic lock step
  130603. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130604. * @returns the internal step
  130605. */
  130606. getInternalStep(): number;
  130607. private _fogEnabled;
  130608. /**
  130609. * Gets or sets a boolean indicating if fog is enabled on this scene
  130610. * @see https://doc.babylonjs.com/babylon101/environment#fog
  130611. * (Default is true)
  130612. */
  130613. set fogEnabled(value: boolean);
  130614. get fogEnabled(): boolean;
  130615. private _fogMode;
  130616. /**
  130617. * Gets or sets the fog mode to use
  130618. * @see https://doc.babylonjs.com/babylon101/environment#fog
  130619. * | mode | value |
  130620. * | --- | --- |
  130621. * | FOGMODE_NONE | 0 |
  130622. * | FOGMODE_EXP | 1 |
  130623. * | FOGMODE_EXP2 | 2 |
  130624. * | FOGMODE_LINEAR | 3 |
  130625. */
  130626. set fogMode(value: number);
  130627. get fogMode(): number;
  130628. /**
  130629. * Gets or sets the fog color to use
  130630. * @see https://doc.babylonjs.com/babylon101/environment#fog
  130631. * (Default is Color3(0.2, 0.2, 0.3))
  130632. */
  130633. fogColor: Color3;
  130634. /**
  130635. * Gets or sets the fog density to use
  130636. * @see https://doc.babylonjs.com/babylon101/environment#fog
  130637. * (Default is 0.1)
  130638. */
  130639. fogDensity: number;
  130640. /**
  130641. * Gets or sets the fog start distance to use
  130642. * @see https://doc.babylonjs.com/babylon101/environment#fog
  130643. * (Default is 0)
  130644. */
  130645. fogStart: number;
  130646. /**
  130647. * Gets or sets the fog end distance to use
  130648. * @see https://doc.babylonjs.com/babylon101/environment#fog
  130649. * (Default is 1000)
  130650. */
  130651. fogEnd: number;
  130652. /**
  130653. * Flag indicating that the frame buffer binding is handled by another component
  130654. */
  130655. prePass: boolean;
  130656. private _shadowsEnabled;
  130657. /**
  130658. * Gets or sets a boolean indicating if shadows are enabled on this scene
  130659. */
  130660. set shadowsEnabled(value: boolean);
  130661. get shadowsEnabled(): boolean;
  130662. private _lightsEnabled;
  130663. /**
  130664. * Gets or sets a boolean indicating if lights are enabled on this scene
  130665. */
  130666. set lightsEnabled(value: boolean);
  130667. get lightsEnabled(): boolean;
  130668. /** All of the active cameras added to this scene. */
  130669. activeCameras: Nullable<Camera[]>;
  130670. /** @hidden */
  130671. _activeCamera: Nullable<Camera>;
  130672. /** Gets or sets the current active camera */
  130673. get activeCamera(): Nullable<Camera>;
  130674. set activeCamera(value: Nullable<Camera>);
  130675. private _defaultMaterial;
  130676. /** The default material used on meshes when no material is affected */
  130677. get defaultMaterial(): Material;
  130678. /** The default material used on meshes when no material is affected */
  130679. set defaultMaterial(value: Material);
  130680. private _texturesEnabled;
  130681. /**
  130682. * Gets or sets a boolean indicating if textures are enabled on this scene
  130683. */
  130684. set texturesEnabled(value: boolean);
  130685. get texturesEnabled(): boolean;
  130686. /**
  130687. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  130688. */
  130689. physicsEnabled: boolean;
  130690. /**
  130691. * Gets or sets a boolean indicating if particles are enabled on this scene
  130692. */
  130693. particlesEnabled: boolean;
  130694. /**
  130695. * Gets or sets a boolean indicating if sprites are enabled on this scene
  130696. */
  130697. spritesEnabled: boolean;
  130698. private _skeletonsEnabled;
  130699. /**
  130700. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  130701. */
  130702. set skeletonsEnabled(value: boolean);
  130703. get skeletonsEnabled(): boolean;
  130704. /**
  130705. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  130706. */
  130707. lensFlaresEnabled: boolean;
  130708. /**
  130709. * Gets or sets a boolean indicating if collisions are enabled on this scene
  130710. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  130711. */
  130712. collisionsEnabled: boolean;
  130713. private _collisionCoordinator;
  130714. /** @hidden */
  130715. get collisionCoordinator(): ICollisionCoordinator;
  130716. /**
  130717. * Defines the gravity applied to this scene (used only for collisions)
  130718. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  130719. */
  130720. gravity: Vector3;
  130721. /**
  130722. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  130723. */
  130724. postProcessesEnabled: boolean;
  130725. /**
  130726. * Gets the current postprocess manager
  130727. */
  130728. postProcessManager: PostProcessManager;
  130729. /**
  130730. * Gets or sets a boolean indicating if render targets are enabled on this scene
  130731. */
  130732. renderTargetsEnabled: boolean;
  130733. /**
  130734. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  130735. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  130736. */
  130737. dumpNextRenderTargets: boolean;
  130738. /**
  130739. * The list of user defined render targets added to the scene
  130740. */
  130741. customRenderTargets: RenderTargetTexture[];
  130742. /**
  130743. * Defines if texture loading must be delayed
  130744. * If true, textures will only be loaded when they need to be rendered
  130745. */
  130746. useDelayedTextureLoading: boolean;
  130747. /**
  130748. * Gets the list of meshes imported to the scene through SceneLoader
  130749. */
  130750. importedMeshesFiles: String[];
  130751. /**
  130752. * Gets or sets a boolean indicating if probes are enabled on this scene
  130753. */
  130754. probesEnabled: boolean;
  130755. /**
  130756. * Gets or sets the current offline provider to use to store scene data
  130757. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  130758. */
  130759. offlineProvider: IOfflineProvider;
  130760. /**
  130761. * Gets or sets the action manager associated with the scene
  130762. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  130763. */
  130764. actionManager: AbstractActionManager;
  130765. private _meshesForIntersections;
  130766. /**
  130767. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  130768. */
  130769. proceduralTexturesEnabled: boolean;
  130770. private _engine;
  130771. private _totalVertices;
  130772. /** @hidden */
  130773. _activeIndices: PerfCounter;
  130774. /** @hidden */
  130775. _activeParticles: PerfCounter;
  130776. /** @hidden */
  130777. _activeBones: PerfCounter;
  130778. private _animationRatio;
  130779. /** @hidden */
  130780. _animationTimeLast: number;
  130781. /** @hidden */
  130782. _animationTime: number;
  130783. /**
  130784. * Gets or sets a general scale for animation speed
  130785. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  130786. */
  130787. animationTimeScale: number;
  130788. /** @hidden */
  130789. _cachedMaterial: Nullable<Material>;
  130790. /** @hidden */
  130791. _cachedEffect: Nullable<Effect>;
  130792. /** @hidden */
  130793. _cachedVisibility: Nullable<number>;
  130794. private _renderId;
  130795. private _frameId;
  130796. private _executeWhenReadyTimeoutId;
  130797. private _intermediateRendering;
  130798. private _viewUpdateFlag;
  130799. private _projectionUpdateFlag;
  130800. /** @hidden */
  130801. _toBeDisposed: Nullable<IDisposable>[];
  130802. private _activeRequests;
  130803. /** @hidden */
  130804. _pendingData: any[];
  130805. private _isDisposed;
  130806. /**
  130807. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  130808. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  130809. */
  130810. dispatchAllSubMeshesOfActiveMeshes: boolean;
  130811. private _activeMeshes;
  130812. private _processedMaterials;
  130813. private _renderTargets;
  130814. /** @hidden */
  130815. _activeParticleSystems: SmartArray<IParticleSystem>;
  130816. private _activeSkeletons;
  130817. private _softwareSkinnedMeshes;
  130818. private _renderingManager;
  130819. /** @hidden */
  130820. _activeAnimatables: Animatable[];
  130821. private _transformMatrix;
  130822. private _sceneUbo;
  130823. /** @hidden */
  130824. _viewMatrix: Matrix;
  130825. /** @hidden */
  130826. _projectionMatrix: Matrix;
  130827. /** @hidden */
  130828. _forcedViewPosition: Nullable<Vector3>;
  130829. /** @hidden */
  130830. _frustumPlanes: Plane[];
  130831. /**
  130832. * Gets the list of frustum planes (built from the active camera)
  130833. */
  130834. get frustumPlanes(): Plane[];
  130835. /**
  130836. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  130837. * This is useful if there are more lights that the maximum simulteanous authorized
  130838. */
  130839. requireLightSorting: boolean;
  130840. /** @hidden */
  130841. readonly useMaterialMeshMap: boolean;
  130842. /** @hidden */
  130843. readonly useClonedMeshMap: boolean;
  130844. private _externalData;
  130845. private _uid;
  130846. /**
  130847. * @hidden
  130848. * Backing store of defined scene components.
  130849. */
  130850. _components: ISceneComponent[];
  130851. /**
  130852. * @hidden
  130853. * Backing store of defined scene components.
  130854. */
  130855. _serializableComponents: ISceneSerializableComponent[];
  130856. /**
  130857. * List of components to register on the next registration step.
  130858. */
  130859. private _transientComponents;
  130860. /**
  130861. * Registers the transient components if needed.
  130862. */
  130863. private _registerTransientComponents;
  130864. /**
  130865. * @hidden
  130866. * Add a component to the scene.
  130867. * Note that the ccomponent could be registered on th next frame if this is called after
  130868. * the register component stage.
  130869. * @param component Defines the component to add to the scene
  130870. */
  130871. _addComponent(component: ISceneComponent): void;
  130872. /**
  130873. * @hidden
  130874. * Gets a component from the scene.
  130875. * @param name defines the name of the component to retrieve
  130876. * @returns the component or null if not present
  130877. */
  130878. _getComponent(name: string): Nullable<ISceneComponent>;
  130879. /**
  130880. * @hidden
  130881. * Defines the actions happening before camera updates.
  130882. */
  130883. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  130884. /**
  130885. * @hidden
  130886. * Defines the actions happening before clear the canvas.
  130887. */
  130888. _beforeClearStage: Stage<SimpleStageAction>;
  130889. /**
  130890. * @hidden
  130891. * Defines the actions when collecting render targets for the frame.
  130892. */
  130893. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  130894. /**
  130895. * @hidden
  130896. * Defines the actions happening for one camera in the frame.
  130897. */
  130898. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  130899. /**
  130900. * @hidden
  130901. * Defines the actions happening during the per mesh ready checks.
  130902. */
  130903. _isReadyForMeshStage: Stage<MeshStageAction>;
  130904. /**
  130905. * @hidden
  130906. * Defines the actions happening before evaluate active mesh checks.
  130907. */
  130908. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  130909. /**
  130910. * @hidden
  130911. * Defines the actions happening during the evaluate sub mesh checks.
  130912. */
  130913. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  130914. /**
  130915. * @hidden
  130916. * Defines the actions happening during the active mesh stage.
  130917. */
  130918. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  130919. /**
  130920. * @hidden
  130921. * Defines the actions happening during the per camera render target step.
  130922. */
  130923. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  130924. /**
  130925. * @hidden
  130926. * Defines the actions happening just before the active camera is drawing.
  130927. */
  130928. _beforeCameraDrawStage: Stage<CameraStageAction>;
  130929. /**
  130930. * @hidden
  130931. * Defines the actions happening just before a render target is drawing.
  130932. */
  130933. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  130934. /**
  130935. * @hidden
  130936. * Defines the actions happening just before a rendering group is drawing.
  130937. */
  130938. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  130939. /**
  130940. * @hidden
  130941. * Defines the actions happening just before a mesh is drawing.
  130942. */
  130943. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  130944. /**
  130945. * @hidden
  130946. * Defines the actions happening just after a mesh has been drawn.
  130947. */
  130948. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  130949. /**
  130950. * @hidden
  130951. * Defines the actions happening just after a rendering group has been drawn.
  130952. */
  130953. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  130954. /**
  130955. * @hidden
  130956. * Defines the actions happening just after the active camera has been drawn.
  130957. */
  130958. _afterCameraDrawStage: Stage<CameraStageAction>;
  130959. /**
  130960. * @hidden
  130961. * Defines the actions happening just after a render target has been drawn.
  130962. */
  130963. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  130964. /**
  130965. * @hidden
  130966. * Defines the actions happening just after rendering all cameras and computing intersections.
  130967. */
  130968. _afterRenderStage: Stage<SimpleStageAction>;
  130969. /**
  130970. * @hidden
  130971. * Defines the actions happening when a pointer move event happens.
  130972. */
  130973. _pointerMoveStage: Stage<PointerMoveStageAction>;
  130974. /**
  130975. * @hidden
  130976. * Defines the actions happening when a pointer down event happens.
  130977. */
  130978. _pointerDownStage: Stage<PointerUpDownStageAction>;
  130979. /**
  130980. * @hidden
  130981. * Defines the actions happening when a pointer up event happens.
  130982. */
  130983. _pointerUpStage: Stage<PointerUpDownStageAction>;
  130984. /**
  130985. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  130986. */
  130987. private geometriesByUniqueId;
  130988. private _renderBundles;
  130989. /**
  130990. * Creates a new Scene
  130991. * @param engine defines the engine to use to render this scene
  130992. * @param options defines the scene options
  130993. */
  130994. constructor(engine: Engine, options?: SceneOptions);
  130995. /**
  130996. * Gets a string identifying the name of the class
  130997. * @returns "Scene" string
  130998. */
  130999. getClassName(): string;
  131000. private _defaultMeshCandidates;
  131001. /**
  131002. * @hidden
  131003. */
  131004. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  131005. private _defaultSubMeshCandidates;
  131006. /**
  131007. * @hidden
  131008. */
  131009. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  131010. /**
  131011. * Sets the default candidate providers for the scene.
  131012. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  131013. * and getCollidingSubMeshCandidates to their default function
  131014. */
  131015. setDefaultCandidateProviders(): void;
  131016. /**
  131017. * Gets the mesh that is currently under the pointer
  131018. */
  131019. get meshUnderPointer(): Nullable<AbstractMesh>;
  131020. /**
  131021. * Gets or sets the current on-screen X position of the pointer
  131022. */
  131023. get pointerX(): number;
  131024. set pointerX(value: number);
  131025. /**
  131026. * Gets or sets the current on-screen Y position of the pointer
  131027. */
  131028. get pointerY(): number;
  131029. set pointerY(value: number);
  131030. /**
  131031. * Gets the cached material (ie. the latest rendered one)
  131032. * @returns the cached material
  131033. */
  131034. getCachedMaterial(): Nullable<Material>;
  131035. /**
  131036. * Gets the cached effect (ie. the latest rendered one)
  131037. * @returns the cached effect
  131038. */
  131039. getCachedEffect(): Nullable<Effect>;
  131040. /**
  131041. * Gets the cached visibility state (ie. the latest rendered one)
  131042. * @returns the cached visibility state
  131043. */
  131044. getCachedVisibility(): Nullable<number>;
  131045. /**
  131046. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  131047. * @param material defines the current material
  131048. * @param effect defines the current effect
  131049. * @param visibility defines the current visibility state
  131050. * @returns true if one parameter is not cached
  131051. */
  131052. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  131053. /**
  131054. * Gets the engine associated with the scene
  131055. * @returns an Engine
  131056. */
  131057. getEngine(): Engine;
  131058. /**
  131059. * Gets the total number of vertices rendered per frame
  131060. * @returns the total number of vertices rendered per frame
  131061. */
  131062. getTotalVertices(): number;
  131063. /**
  131064. * Gets the performance counter for total vertices
  131065. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  131066. */
  131067. get totalVerticesPerfCounter(): PerfCounter;
  131068. /**
  131069. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  131070. * @returns the total number of active indices rendered per frame
  131071. */
  131072. getActiveIndices(): number;
  131073. /**
  131074. * Gets the performance counter for active indices
  131075. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  131076. */
  131077. get totalActiveIndicesPerfCounter(): PerfCounter;
  131078. /**
  131079. * Gets the total number of active particles rendered per frame
  131080. * @returns the total number of active particles rendered per frame
  131081. */
  131082. getActiveParticles(): number;
  131083. /**
  131084. * Gets the performance counter for active particles
  131085. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  131086. */
  131087. get activeParticlesPerfCounter(): PerfCounter;
  131088. /**
  131089. * Gets the total number of active bones rendered per frame
  131090. * @returns the total number of active bones rendered per frame
  131091. */
  131092. getActiveBones(): number;
  131093. /**
  131094. * Gets the performance counter for active bones
  131095. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  131096. */
  131097. get activeBonesPerfCounter(): PerfCounter;
  131098. /**
  131099. * Gets the array of active meshes
  131100. * @returns an array of AbstractMesh
  131101. */
  131102. getActiveMeshes(): SmartArray<AbstractMesh>;
  131103. /**
  131104. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  131105. * @returns a number
  131106. */
  131107. getAnimationRatio(): number;
  131108. /**
  131109. * Gets an unique Id for the current render phase
  131110. * @returns a number
  131111. */
  131112. getRenderId(): number;
  131113. /**
  131114. * Gets an unique Id for the current frame
  131115. * @returns a number
  131116. */
  131117. getFrameId(): number;
  131118. /** Call this function if you want to manually increment the render Id*/
  131119. incrementRenderId(): void;
  131120. private _createUbo;
  131121. /**
  131122. * Use this method to simulate a pointer move on a mesh
  131123. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  131124. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  131125. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  131126. * @returns the current scene
  131127. */
  131128. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  131129. /**
  131130. * Use this method to simulate a pointer down on a mesh
  131131. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  131132. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  131133. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  131134. * @returns the current scene
  131135. */
  131136. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  131137. /**
  131138. * Use this method to simulate a pointer up on a mesh
  131139. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  131140. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  131141. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  131142. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  131143. * @returns the current scene
  131144. */
  131145. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  131146. /**
  131147. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  131148. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  131149. * @returns true if the pointer was captured
  131150. */
  131151. isPointerCaptured(pointerId?: number): boolean;
  131152. /**
  131153. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  131154. * @param attachUp defines if you want to attach events to pointerup
  131155. * @param attachDown defines if you want to attach events to pointerdown
  131156. * @param attachMove defines if you want to attach events to pointermove
  131157. */
  131158. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  131159. /** Detaches all event handlers*/
  131160. detachControl(): void;
  131161. /**
  131162. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  131163. * Delay loaded resources are not taking in account
  131164. * @return true if all required resources are ready
  131165. */
  131166. isReady(): boolean;
  131167. /** Resets all cached information relative to material (including effect and visibility) */
  131168. resetCachedMaterial(): void;
  131169. /**
  131170. * Registers a function to be called before every frame render
  131171. * @param func defines the function to register
  131172. */
  131173. registerBeforeRender(func: () => void): void;
  131174. /**
  131175. * Unregisters a function called before every frame render
  131176. * @param func defines the function to unregister
  131177. */
  131178. unregisterBeforeRender(func: () => void): void;
  131179. /**
  131180. * Registers a function to be called after every frame render
  131181. * @param func defines the function to register
  131182. */
  131183. registerAfterRender(func: () => void): void;
  131184. /**
  131185. * Unregisters a function called after every frame render
  131186. * @param func defines the function to unregister
  131187. */
  131188. unregisterAfterRender(func: () => void): void;
  131189. private _executeOnceBeforeRender;
  131190. /**
  131191. * The provided function will run before render once and will be disposed afterwards.
  131192. * A timeout delay can be provided so that the function will be executed in N ms.
  131193. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  131194. * @param func The function to be executed.
  131195. * @param timeout optional delay in ms
  131196. */
  131197. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  131198. /** @hidden */
  131199. _addPendingData(data: any): void;
  131200. /** @hidden */
  131201. _removePendingData(data: any): void;
  131202. /**
  131203. * Returns the number of items waiting to be loaded
  131204. * @returns the number of items waiting to be loaded
  131205. */
  131206. getWaitingItemsCount(): number;
  131207. /**
  131208. * Returns a boolean indicating if the scene is still loading data
  131209. */
  131210. get isLoading(): boolean;
  131211. /**
  131212. * Registers a function to be executed when the scene is ready
  131213. * @param {Function} func - the function to be executed
  131214. */
  131215. executeWhenReady(func: () => void): void;
  131216. /**
  131217. * Returns a promise that resolves when the scene is ready
  131218. * @returns A promise that resolves when the scene is ready
  131219. */
  131220. whenReadyAsync(): Promise<void>;
  131221. /** @hidden */
  131222. _checkIsReady(): void;
  131223. /**
  131224. * Gets all animatable attached to the scene
  131225. */
  131226. get animatables(): Animatable[];
  131227. /**
  131228. * Resets the last animation time frame.
  131229. * Useful to override when animations start running when loading a scene for the first time.
  131230. */
  131231. resetLastAnimationTimeFrame(): void;
  131232. /**
  131233. * Gets the current view matrix
  131234. * @returns a Matrix
  131235. */
  131236. getViewMatrix(): Matrix;
  131237. /**
  131238. * Gets the current projection matrix
  131239. * @returns a Matrix
  131240. */
  131241. getProjectionMatrix(): Matrix;
  131242. /**
  131243. * Gets the current transform matrix
  131244. * @returns a Matrix made of View * Projection
  131245. */
  131246. getTransformMatrix(): Matrix;
  131247. /**
  131248. * Sets the current transform matrix
  131249. * @param viewL defines the View matrix to use
  131250. * @param projectionL defines the Projection matrix to use
  131251. * @param viewR defines the right View matrix to use (if provided)
  131252. * @param projectionR defines the right Projection matrix to use (if provided)
  131253. */
  131254. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  131255. /**
  131256. * Gets the uniform buffer used to store scene data
  131257. * @returns a UniformBuffer
  131258. */
  131259. getSceneUniformBuffer(): UniformBuffer;
  131260. /**
  131261. * Gets an unique (relatively to the current scene) Id
  131262. * @returns an unique number for the scene
  131263. */
  131264. getUniqueId(): number;
  131265. /**
  131266. * Add a mesh to the list of scene's meshes
  131267. * @param newMesh defines the mesh to add
  131268. * @param recursive if all child meshes should also be added to the scene
  131269. */
  131270. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  131271. /**
  131272. * Remove a mesh for the list of scene's meshes
  131273. * @param toRemove defines the mesh to remove
  131274. * @param recursive if all child meshes should also be removed from the scene
  131275. * @returns the index where the mesh was in the mesh list
  131276. */
  131277. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  131278. /**
  131279. * Add a transform node to the list of scene's transform nodes
  131280. * @param newTransformNode defines the transform node to add
  131281. */
  131282. addTransformNode(newTransformNode: TransformNode): void;
  131283. /**
  131284. * Remove a transform node for the list of scene's transform nodes
  131285. * @param toRemove defines the transform node to remove
  131286. * @returns the index where the transform node was in the transform node list
  131287. */
  131288. removeTransformNode(toRemove: TransformNode): number;
  131289. /**
  131290. * Remove a skeleton for the list of scene's skeletons
  131291. * @param toRemove defines the skeleton to remove
  131292. * @returns the index where the skeleton was in the skeleton list
  131293. */
  131294. removeSkeleton(toRemove: Skeleton): number;
  131295. /**
  131296. * Remove a morph target for the list of scene's morph targets
  131297. * @param toRemove defines the morph target to remove
  131298. * @returns the index where the morph target was in the morph target list
  131299. */
  131300. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  131301. /**
  131302. * Remove a light for the list of scene's lights
  131303. * @param toRemove defines the light to remove
  131304. * @returns the index where the light was in the light list
  131305. */
  131306. removeLight(toRemove: Light): number;
  131307. /**
  131308. * Remove a camera for the list of scene's cameras
  131309. * @param toRemove defines the camera to remove
  131310. * @returns the index where the camera was in the camera list
  131311. */
  131312. removeCamera(toRemove: Camera): number;
  131313. /**
  131314. * Remove a particle system for the list of scene's particle systems
  131315. * @param toRemove defines the particle system to remove
  131316. * @returns the index where the particle system was in the particle system list
  131317. */
  131318. removeParticleSystem(toRemove: IParticleSystem): number;
  131319. /**
  131320. * Remove a animation for the list of scene's animations
  131321. * @param toRemove defines the animation to remove
  131322. * @returns the index where the animation was in the animation list
  131323. */
  131324. removeAnimation(toRemove: Animation): number;
  131325. /**
  131326. * Will stop the animation of the given target
  131327. * @param target - the target
  131328. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  131329. * @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)
  131330. */
  131331. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  131332. /**
  131333. * Removes the given animation group from this scene.
  131334. * @param toRemove The animation group to remove
  131335. * @returns The index of the removed animation group
  131336. */
  131337. removeAnimationGroup(toRemove: AnimationGroup): number;
  131338. /**
  131339. * Removes the given multi-material from this scene.
  131340. * @param toRemove The multi-material to remove
  131341. * @returns The index of the removed multi-material
  131342. */
  131343. removeMultiMaterial(toRemove: MultiMaterial): number;
  131344. /**
  131345. * Removes the given material from this scene.
  131346. * @param toRemove The material to remove
  131347. * @returns The index of the removed material
  131348. */
  131349. removeMaterial(toRemove: Material): number;
  131350. /**
  131351. * Removes the given action manager from this scene.
  131352. * @param toRemove The action manager to remove
  131353. * @returns The index of the removed action manager
  131354. */
  131355. removeActionManager(toRemove: AbstractActionManager): number;
  131356. /**
  131357. * Removes the given texture from this scene.
  131358. * @param toRemove The texture to remove
  131359. * @returns The index of the removed texture
  131360. */
  131361. removeTexture(toRemove: BaseTexture): number;
  131362. /**
  131363. * Adds the given light to this scene
  131364. * @param newLight The light to add
  131365. */
  131366. addLight(newLight: Light): void;
  131367. /**
  131368. * Sorts the list list based on light priorities
  131369. */
  131370. sortLightsByPriority(): void;
  131371. /**
  131372. * Adds the given camera to this scene
  131373. * @param newCamera The camera to add
  131374. */
  131375. addCamera(newCamera: Camera): void;
  131376. /**
  131377. * Adds the given skeleton to this scene
  131378. * @param newSkeleton The skeleton to add
  131379. */
  131380. addSkeleton(newSkeleton: Skeleton): void;
  131381. /**
  131382. * Adds the given particle system to this scene
  131383. * @param newParticleSystem The particle system to add
  131384. */
  131385. addParticleSystem(newParticleSystem: IParticleSystem): void;
  131386. /**
  131387. * Adds the given animation to this scene
  131388. * @param newAnimation The animation to add
  131389. */
  131390. addAnimation(newAnimation: Animation): void;
  131391. /**
  131392. * Adds the given animation group to this scene.
  131393. * @param newAnimationGroup The animation group to add
  131394. */
  131395. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  131396. /**
  131397. * Adds the given multi-material to this scene
  131398. * @param newMultiMaterial The multi-material to add
  131399. */
  131400. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  131401. /**
  131402. * Adds the given material to this scene
  131403. * @param newMaterial The material to add
  131404. */
  131405. addMaterial(newMaterial: Material): void;
  131406. /**
  131407. * Adds the given morph target to this scene
  131408. * @param newMorphTargetManager The morph target to add
  131409. */
  131410. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  131411. /**
  131412. * Adds the given geometry to this scene
  131413. * @param newGeometry The geometry to add
  131414. */
  131415. addGeometry(newGeometry: Geometry): void;
  131416. /**
  131417. * Adds the given action manager to this scene
  131418. * @param newActionManager The action manager to add
  131419. */
  131420. addActionManager(newActionManager: AbstractActionManager): void;
  131421. /**
  131422. * Adds the given texture to this scene.
  131423. * @param newTexture The texture to add
  131424. */
  131425. addTexture(newTexture: BaseTexture): void;
  131426. /**
  131427. * Switch active camera
  131428. * @param newCamera defines the new active camera
  131429. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  131430. */
  131431. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  131432. /**
  131433. * sets the active camera of the scene using its ID
  131434. * @param id defines the camera's ID
  131435. * @return the new active camera or null if none found.
  131436. */
  131437. setActiveCameraByID(id: string): Nullable<Camera>;
  131438. /**
  131439. * sets the active camera of the scene using its name
  131440. * @param name defines the camera's name
  131441. * @returns the new active camera or null if none found.
  131442. */
  131443. setActiveCameraByName(name: string): Nullable<Camera>;
  131444. /**
  131445. * get an animation group using its name
  131446. * @param name defines the material's name
  131447. * @return the animation group or null if none found.
  131448. */
  131449. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  131450. /**
  131451. * Get a material using its unique id
  131452. * @param uniqueId defines the material's unique id
  131453. * @return the material or null if none found.
  131454. */
  131455. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  131456. /**
  131457. * get a material using its id
  131458. * @param id defines the material's ID
  131459. * @return the material or null if none found.
  131460. */
  131461. getMaterialByID(id: string): Nullable<Material>;
  131462. /**
  131463. * Gets a the last added material using a given id
  131464. * @param id defines the material's ID
  131465. * @return the last material with the given id or null if none found.
  131466. */
  131467. getLastMaterialByID(id: string): Nullable<Material>;
  131468. /**
  131469. * Gets a material using its name
  131470. * @param name defines the material's name
  131471. * @return the material or null if none found.
  131472. */
  131473. getMaterialByName(name: string): Nullable<Material>;
  131474. /**
  131475. * Get a texture using its unique id
  131476. * @param uniqueId defines the texture's unique id
  131477. * @return the texture or null if none found.
  131478. */
  131479. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  131480. /**
  131481. * Gets a camera using its id
  131482. * @param id defines the id to look for
  131483. * @returns the camera or null if not found
  131484. */
  131485. getCameraByID(id: string): Nullable<Camera>;
  131486. /**
  131487. * Gets a camera using its unique id
  131488. * @param uniqueId defines the unique id to look for
  131489. * @returns the camera or null if not found
  131490. */
  131491. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  131492. /**
  131493. * Gets a camera using its name
  131494. * @param name defines the camera's name
  131495. * @return the camera or null if none found.
  131496. */
  131497. getCameraByName(name: string): Nullable<Camera>;
  131498. /**
  131499. * Gets a bone using its id
  131500. * @param id defines the bone's id
  131501. * @return the bone or null if not found
  131502. */
  131503. getBoneByID(id: string): Nullable<Bone>;
  131504. /**
  131505. * Gets a bone using its id
  131506. * @param name defines the bone's name
  131507. * @return the bone or null if not found
  131508. */
  131509. getBoneByName(name: string): Nullable<Bone>;
  131510. /**
  131511. * Gets a light node using its name
  131512. * @param name defines the the light's name
  131513. * @return the light or null if none found.
  131514. */
  131515. getLightByName(name: string): Nullable<Light>;
  131516. /**
  131517. * Gets a light node using its id
  131518. * @param id defines the light's id
  131519. * @return the light or null if none found.
  131520. */
  131521. getLightByID(id: string): Nullable<Light>;
  131522. /**
  131523. * Gets a light node using its scene-generated unique ID
  131524. * @param uniqueId defines the light's unique id
  131525. * @return the light or null if none found.
  131526. */
  131527. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  131528. /**
  131529. * Gets a particle system by id
  131530. * @param id defines the particle system id
  131531. * @return the corresponding system or null if none found
  131532. */
  131533. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  131534. /**
  131535. * Gets a geometry using its ID
  131536. * @param id defines the geometry's id
  131537. * @return the geometry or null if none found.
  131538. */
  131539. getGeometryByID(id: string): Nullable<Geometry>;
  131540. private _getGeometryByUniqueID;
  131541. /**
  131542. * Add a new geometry to this scene
  131543. * @param geometry defines the geometry to be added to the scene.
  131544. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  131545. * @return a boolean defining if the geometry was added or not
  131546. */
  131547. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  131548. /**
  131549. * Removes an existing geometry
  131550. * @param geometry defines the geometry to be removed from the scene
  131551. * @return a boolean defining if the geometry was removed or not
  131552. */
  131553. removeGeometry(geometry: Geometry): boolean;
  131554. /**
  131555. * Gets the list of geometries attached to the scene
  131556. * @returns an array of Geometry
  131557. */
  131558. getGeometries(): Geometry[];
  131559. /**
  131560. * Gets the first added mesh found of a given ID
  131561. * @param id defines the id to search for
  131562. * @return the mesh found or null if not found at all
  131563. */
  131564. getMeshByID(id: string): Nullable<AbstractMesh>;
  131565. /**
  131566. * Gets a list of meshes using their id
  131567. * @param id defines the id to search for
  131568. * @returns a list of meshes
  131569. */
  131570. getMeshesByID(id: string): Array<AbstractMesh>;
  131571. /**
  131572. * Gets the first added transform node found of a given ID
  131573. * @param id defines the id to search for
  131574. * @return the found transform node or null if not found at all.
  131575. */
  131576. getTransformNodeByID(id: string): Nullable<TransformNode>;
  131577. /**
  131578. * Gets a transform node with its auto-generated unique id
  131579. * @param uniqueId efines the unique id to search for
  131580. * @return the found transform node or null if not found at all.
  131581. */
  131582. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  131583. /**
  131584. * Gets a list of transform nodes using their id
  131585. * @param id defines the id to search for
  131586. * @returns a list of transform nodes
  131587. */
  131588. getTransformNodesByID(id: string): Array<TransformNode>;
  131589. /**
  131590. * Gets a mesh with its auto-generated unique id
  131591. * @param uniqueId defines the unique id to search for
  131592. * @return the found mesh or null if not found at all.
  131593. */
  131594. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  131595. /**
  131596. * Gets a the last added mesh using a given id
  131597. * @param id defines the id to search for
  131598. * @return the found mesh or null if not found at all.
  131599. */
  131600. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  131601. /**
  131602. * Gets a the last added node (Mesh, Camera, Light) using a given id
  131603. * @param id defines the id to search for
  131604. * @return the found node or null if not found at all
  131605. */
  131606. getLastEntryByID(id: string): Nullable<Node>;
  131607. /**
  131608. * Gets a node (Mesh, Camera, Light) using a given id
  131609. * @param id defines the id to search for
  131610. * @return the found node or null if not found at all
  131611. */
  131612. getNodeByID(id: string): Nullable<Node>;
  131613. /**
  131614. * Gets a node (Mesh, Camera, Light) using a given name
  131615. * @param name defines the name to search for
  131616. * @return the found node or null if not found at all.
  131617. */
  131618. getNodeByName(name: string): Nullable<Node>;
  131619. /**
  131620. * Gets a mesh using a given name
  131621. * @param name defines the name to search for
  131622. * @return the found mesh or null if not found at all.
  131623. */
  131624. getMeshByName(name: string): Nullable<AbstractMesh>;
  131625. /**
  131626. * Gets a transform node using a given name
  131627. * @param name defines the name to search for
  131628. * @return the found transform node or null if not found at all.
  131629. */
  131630. getTransformNodeByName(name: string): Nullable<TransformNode>;
  131631. /**
  131632. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  131633. * @param id defines the id to search for
  131634. * @return the found skeleton or null if not found at all.
  131635. */
  131636. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  131637. /**
  131638. * Gets a skeleton using a given auto generated unique id
  131639. * @param uniqueId defines the unique id to search for
  131640. * @return the found skeleton or null if not found at all.
  131641. */
  131642. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  131643. /**
  131644. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  131645. * @param id defines the id to search for
  131646. * @return the found skeleton or null if not found at all.
  131647. */
  131648. getSkeletonById(id: string): Nullable<Skeleton>;
  131649. /**
  131650. * Gets a skeleton using a given name
  131651. * @param name defines the name to search for
  131652. * @return the found skeleton or null if not found at all.
  131653. */
  131654. getSkeletonByName(name: string): Nullable<Skeleton>;
  131655. /**
  131656. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  131657. * @param id defines the id to search for
  131658. * @return the found morph target manager or null if not found at all.
  131659. */
  131660. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  131661. /**
  131662. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  131663. * @param id defines the id to search for
  131664. * @return the found morph target or null if not found at all.
  131665. */
  131666. getMorphTargetById(id: string): Nullable<MorphTarget>;
  131667. /**
  131668. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  131669. * @param name defines the name to search for
  131670. * @return the found morph target or null if not found at all.
  131671. */
  131672. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  131673. /**
  131674. * Gets a post process using a given name (if many are found, this function will pick the first one)
  131675. * @param name defines the name to search for
  131676. * @return the found post process or null if not found at all.
  131677. */
  131678. getPostProcessByName(name: string): Nullable<PostProcess>;
  131679. /**
  131680. * Gets a boolean indicating if the given mesh is active
  131681. * @param mesh defines the mesh to look for
  131682. * @returns true if the mesh is in the active list
  131683. */
  131684. isActiveMesh(mesh: AbstractMesh): boolean;
  131685. /**
  131686. * Return a unique id as a string which can serve as an identifier for the scene
  131687. */
  131688. get uid(): string;
  131689. /**
  131690. * Add an externaly attached data from its key.
  131691. * This method call will fail and return false, if such key already exists.
  131692. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  131693. * @param key the unique key that identifies the data
  131694. * @param data the data object to associate to the key for this Engine instance
  131695. * @return true if no such key were already present and the data was added successfully, false otherwise
  131696. */
  131697. addExternalData<T>(key: string, data: T): boolean;
  131698. /**
  131699. * Get an externaly attached data from its key
  131700. * @param key the unique key that identifies the data
  131701. * @return the associated data, if present (can be null), or undefined if not present
  131702. */
  131703. getExternalData<T>(key: string): Nullable<T>;
  131704. /**
  131705. * Get an externaly attached data from its key, create it using a factory if it's not already present
  131706. * @param key the unique key that identifies the data
  131707. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  131708. * @return the associated data, can be null if the factory returned null.
  131709. */
  131710. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  131711. /**
  131712. * Remove an externaly attached data from the Engine instance
  131713. * @param key the unique key that identifies the data
  131714. * @return true if the data was successfully removed, false if it doesn't exist
  131715. */
  131716. removeExternalData(key: string): boolean;
  131717. private _evaluateSubMesh;
  131718. /**
  131719. * Clear the processed materials smart array preventing retention point in material dispose.
  131720. */
  131721. freeProcessedMaterials(): void;
  131722. private _preventFreeActiveMeshesAndRenderingGroups;
  131723. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  131724. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  131725. * when disposing several meshes in a row or a hierarchy of meshes.
  131726. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  131727. */
  131728. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  131729. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  131730. /**
  131731. * Clear the active meshes smart array preventing retention point in mesh dispose.
  131732. */
  131733. freeActiveMeshes(): void;
  131734. /**
  131735. * Clear the info related to rendering groups preventing retention points during dispose.
  131736. */
  131737. freeRenderingGroups(): void;
  131738. /** @hidden */
  131739. _isInIntermediateRendering(): boolean;
  131740. /**
  131741. * Lambda returning the list of potentially active meshes.
  131742. */
  131743. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  131744. /**
  131745. * Lambda returning the list of potentially active sub meshes.
  131746. */
  131747. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  131748. /**
  131749. * Lambda returning the list of potentially intersecting sub meshes.
  131750. */
  131751. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  131752. /**
  131753. * Lambda returning the list of potentially colliding sub meshes.
  131754. */
  131755. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  131756. /** @hidden */
  131757. _activeMeshesFrozen: boolean;
  131758. private _skipEvaluateActiveMeshesCompletely;
  131759. /**
  131760. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  131761. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  131762. * @param onSuccess optional success callback
  131763. * @param onError optional error callback
  131764. * @returns the current scene
  131765. */
  131766. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  131767. /**
  131768. * Use this function to restart evaluating active meshes on every frame
  131769. * @returns the current scene
  131770. */
  131771. unfreezeActiveMeshes(): Scene;
  131772. private _evaluateActiveMeshes;
  131773. private _activeMesh;
  131774. /**
  131775. * Update the transform matrix to update from the current active camera
  131776. * @param force defines a boolean used to force the update even if cache is up to date
  131777. */
  131778. updateTransformMatrix(force?: boolean): void;
  131779. private _bindFrameBuffer;
  131780. /** @hidden */
  131781. _allowPostProcessClearColor: boolean;
  131782. /** @hidden */
  131783. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  131784. private _processSubCameras;
  131785. private _checkIntersections;
  131786. /** @hidden */
  131787. _advancePhysicsEngineStep(step: number): void;
  131788. /**
  131789. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  131790. */
  131791. getDeterministicFrameTime: () => number;
  131792. /** @hidden */
  131793. _animate(): void;
  131794. /** Execute all animations (for a frame) */
  131795. animate(): void;
  131796. /**
  131797. * Render the scene
  131798. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  131799. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  131800. */
  131801. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  131802. /**
  131803. * Freeze all materials
  131804. * A frozen material will not be updatable but should be faster to render
  131805. */
  131806. freezeMaterials(): void;
  131807. /**
  131808. * Unfreeze all materials
  131809. * A frozen material will not be updatable but should be faster to render
  131810. */
  131811. unfreezeMaterials(): void;
  131812. /**
  131813. * Releases all held ressources
  131814. */
  131815. dispose(): void;
  131816. /**
  131817. * Gets if the scene is already disposed
  131818. */
  131819. get isDisposed(): boolean;
  131820. /**
  131821. * Call this function to reduce memory footprint of the scene.
  131822. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  131823. */
  131824. clearCachedVertexData(): void;
  131825. /**
  131826. * This function will remove the local cached buffer data from texture.
  131827. * It will save memory but will prevent the texture from being rebuilt
  131828. */
  131829. cleanCachedTextureBuffer(): void;
  131830. /**
  131831. * Get the world extend vectors with an optional filter
  131832. *
  131833. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  131834. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  131835. */
  131836. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  131837. min: Vector3;
  131838. max: Vector3;
  131839. };
  131840. /**
  131841. * Creates a ray that can be used to pick in the scene
  131842. * @param x defines the x coordinate of the origin (on-screen)
  131843. * @param y defines the y coordinate of the origin (on-screen)
  131844. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  131845. * @param camera defines the camera to use for the picking
  131846. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  131847. * @returns a Ray
  131848. */
  131849. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  131850. /**
  131851. * Creates a ray that can be used to pick in the scene
  131852. * @param x defines the x coordinate of the origin (on-screen)
  131853. * @param y defines the y coordinate of the origin (on-screen)
  131854. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  131855. * @param result defines the ray where to store the picking ray
  131856. * @param camera defines the camera to use for the picking
  131857. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  131858. * @returns the current scene
  131859. */
  131860. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  131861. /**
  131862. * Creates a ray that can be used to pick in the scene
  131863. * @param x defines the x coordinate of the origin (on-screen)
  131864. * @param y defines the y coordinate of the origin (on-screen)
  131865. * @param camera defines the camera to use for the picking
  131866. * @returns a Ray
  131867. */
  131868. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  131869. /**
  131870. * Creates a ray that can be used to pick in the scene
  131871. * @param x defines the x coordinate of the origin (on-screen)
  131872. * @param y defines the y coordinate of the origin (on-screen)
  131873. * @param result defines the ray where to store the picking ray
  131874. * @param camera defines the camera to use for the picking
  131875. * @returns the current scene
  131876. */
  131877. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  131878. /** Launch a ray to try to pick a mesh in the scene
  131879. * @param x position on screen
  131880. * @param y position on screen
  131881. * @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
  131882. * @param fastCheck defines if the first intersection will be used (and not the closest)
  131883. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  131884. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  131885. * @returns a PickingInfo
  131886. */
  131887. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  131888. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  131889. * @param x position on screen
  131890. * @param y position on screen
  131891. * @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
  131892. * @param fastCheck defines if the first intersection will be used (and not the closest)
  131893. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  131894. * @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)
  131895. */
  131896. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  131897. /** Use the given ray to pick a mesh in the scene
  131898. * @param ray The ray to use to pick meshes
  131899. * @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
  131900. * @param fastCheck defines if the first intersection will be used (and not the closest)
  131901. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  131902. * @returns a PickingInfo
  131903. */
  131904. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  131905. /**
  131906. * Launch a ray to try to pick a mesh in the scene
  131907. * @param x X position on screen
  131908. * @param y Y position on screen
  131909. * @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
  131910. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  131911. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  131912. * @returns an array of PickingInfo
  131913. */
  131914. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  131915. /**
  131916. * Launch a ray to try to pick a mesh in the scene
  131917. * @param ray Ray to use
  131918. * @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
  131919. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  131920. * @returns an array of PickingInfo
  131921. */
  131922. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  131923. /**
  131924. * Force the value of meshUnderPointer
  131925. * @param mesh defines the mesh to use
  131926. * @param pointerId optional pointer id when using more than one pointer
  131927. */
  131928. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  131929. /**
  131930. * Gets the mesh under the pointer
  131931. * @returns a Mesh or null if no mesh is under the pointer
  131932. */
  131933. getPointerOverMesh(): Nullable<AbstractMesh>;
  131934. /** @hidden */
  131935. _rebuildGeometries(): void;
  131936. /** @hidden */
  131937. _rebuildTextures(): void;
  131938. private _getByTags;
  131939. /**
  131940. * Get a list of meshes by tags
  131941. * @param tagsQuery defines the tags query to use
  131942. * @param forEach defines a predicate used to filter results
  131943. * @returns an array of Mesh
  131944. */
  131945. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  131946. /**
  131947. * Get a list of cameras by tags
  131948. * @param tagsQuery defines the tags query to use
  131949. * @param forEach defines a predicate used to filter results
  131950. * @returns an array of Camera
  131951. */
  131952. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  131953. /**
  131954. * Get a list of lights by tags
  131955. * @param tagsQuery defines the tags query to use
  131956. * @param forEach defines a predicate used to filter results
  131957. * @returns an array of Light
  131958. */
  131959. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  131960. /**
  131961. * Get a list of materials by tags
  131962. * @param tagsQuery defines the tags query to use
  131963. * @param forEach defines a predicate used to filter results
  131964. * @returns an array of Material
  131965. */
  131966. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  131967. /**
  131968. * Get a list of transform nodes by tags
  131969. * @param tagsQuery defines the tags query to use
  131970. * @param forEach defines a predicate used to filter results
  131971. * @returns an array of TransformNode
  131972. */
  131973. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  131974. /**
  131975. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  131976. * This allowed control for front to back rendering or reversly depending of the special needs.
  131977. *
  131978. * @param renderingGroupId The rendering group id corresponding to its index
  131979. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  131980. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  131981. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  131982. */
  131983. 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;
  131984. /**
  131985. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  131986. *
  131987. * @param renderingGroupId The rendering group id corresponding to its index
  131988. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  131989. * @param depth Automatically clears depth between groups if true and autoClear is true.
  131990. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  131991. */
  131992. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  131993. /**
  131994. * Gets the current auto clear configuration for one rendering group of the rendering
  131995. * manager.
  131996. * @param index the rendering group index to get the information for
  131997. * @returns The auto clear setup for the requested rendering group
  131998. */
  131999. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  132000. private _blockMaterialDirtyMechanism;
  132001. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  132002. get blockMaterialDirtyMechanism(): boolean;
  132003. set blockMaterialDirtyMechanism(value: boolean);
  132004. /**
  132005. * Will flag all materials as dirty to trigger new shader compilation
  132006. * @param flag defines the flag used to specify which material part must be marked as dirty
  132007. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  132008. */
  132009. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  132010. /** @hidden */
  132011. _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;
  132012. /** @hidden */
  132013. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  132014. /** @hidden */
  132015. _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;
  132016. /** @hidden */
  132017. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  132018. /** @hidden */
  132019. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  132020. /** @hidden */
  132021. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  132022. }
  132023. }
  132024. declare module BABYLON {
  132025. /**
  132026. * Set of assets to keep when moving a scene into an asset container.
  132027. */
  132028. export class KeepAssets extends AbstractScene {
  132029. }
  132030. /**
  132031. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  132032. */
  132033. export class InstantiatedEntries {
  132034. /**
  132035. * List of new root nodes (eg. nodes with no parent)
  132036. */
  132037. rootNodes: TransformNode[];
  132038. /**
  132039. * List of new skeletons
  132040. */
  132041. skeletons: Skeleton[];
  132042. /**
  132043. * List of new animation groups
  132044. */
  132045. animationGroups: AnimationGroup[];
  132046. }
  132047. /**
  132048. * Container with a set of assets that can be added or removed from a scene.
  132049. */
  132050. export class AssetContainer extends AbstractScene {
  132051. private _wasAddedToScene;
  132052. /**
  132053. * The scene the AssetContainer belongs to.
  132054. */
  132055. scene: Scene;
  132056. /**
  132057. * Instantiates an AssetContainer.
  132058. * @param scene The scene the AssetContainer belongs to.
  132059. */
  132060. constructor(scene: Scene);
  132061. /**
  132062. * Instantiate or clone all meshes and add the new ones to the scene.
  132063. * Skeletons and animation groups will all be cloned
  132064. * @param nameFunction defines an optional function used to get new names for clones
  132065. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  132066. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  132067. */
  132068. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  132069. /**
  132070. * Adds all the assets from the container to the scene.
  132071. */
  132072. addAllToScene(): void;
  132073. /**
  132074. * Removes all the assets in the container from the scene
  132075. */
  132076. removeAllFromScene(): void;
  132077. /**
  132078. * Disposes all the assets in the container
  132079. */
  132080. dispose(): void;
  132081. private _moveAssets;
  132082. /**
  132083. * Removes all the assets contained in the scene and adds them to the container.
  132084. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  132085. */
  132086. moveAllFromScene(keepAssets?: KeepAssets): void;
  132087. /**
  132088. * 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.
  132089. * @returns the root mesh
  132090. */
  132091. createRootMesh(): Mesh;
  132092. /**
  132093. * Merge animations (direct and animation groups) from this asset container into a scene
  132094. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  132095. * @param animatables set of animatables to retarget to a node from the scene
  132096. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  132097. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  132098. */
  132099. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  132100. }
  132101. }
  132102. declare module BABYLON {
  132103. /**
  132104. * Defines how the parser contract is defined.
  132105. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  132106. */
  132107. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  132108. /**
  132109. * Defines how the individual parser contract is defined.
  132110. * These parser can parse an individual asset
  132111. */
  132112. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  132113. /**
  132114. * Base class of the scene acting as a container for the different elements composing a scene.
  132115. * This class is dynamically extended by the different components of the scene increasing
  132116. * flexibility and reducing coupling
  132117. */
  132118. export abstract class AbstractScene {
  132119. /**
  132120. * Stores the list of available parsers in the application.
  132121. */
  132122. private static _BabylonFileParsers;
  132123. /**
  132124. * Stores the list of available individual parsers in the application.
  132125. */
  132126. private static _IndividualBabylonFileParsers;
  132127. /**
  132128. * Adds a parser in the list of available ones
  132129. * @param name Defines the name of the parser
  132130. * @param parser Defines the parser to add
  132131. */
  132132. static AddParser(name: string, parser: BabylonFileParser): void;
  132133. /**
  132134. * Gets a general parser from the list of avaialble ones
  132135. * @param name Defines the name of the parser
  132136. * @returns the requested parser or null
  132137. */
  132138. static GetParser(name: string): Nullable<BabylonFileParser>;
  132139. /**
  132140. * Adds n individual parser in the list of available ones
  132141. * @param name Defines the name of the parser
  132142. * @param parser Defines the parser to add
  132143. */
  132144. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  132145. /**
  132146. * Gets an individual parser from the list of avaialble ones
  132147. * @param name Defines the name of the parser
  132148. * @returns the requested parser or null
  132149. */
  132150. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  132151. /**
  132152. * Parser json data and populate both a scene and its associated container object
  132153. * @param jsonData Defines the data to parse
  132154. * @param scene Defines the scene to parse the data for
  132155. * @param container Defines the container attached to the parsing sequence
  132156. * @param rootUrl Defines the root url of the data
  132157. */
  132158. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  132159. /**
  132160. * Gets the list of root nodes (ie. nodes with no parent)
  132161. */
  132162. rootNodes: Node[];
  132163. /** All of the cameras added to this scene
  132164. * @see https://doc.babylonjs.com/babylon101/cameras
  132165. */
  132166. cameras: Camera[];
  132167. /**
  132168. * All of the lights added to this scene
  132169. * @see https://doc.babylonjs.com/babylon101/lights
  132170. */
  132171. lights: Light[];
  132172. /**
  132173. * All of the (abstract) meshes added to this scene
  132174. */
  132175. meshes: AbstractMesh[];
  132176. /**
  132177. * The list of skeletons added to the scene
  132178. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  132179. */
  132180. skeletons: Skeleton[];
  132181. /**
  132182. * All of the particle systems added to this scene
  132183. * @see https://doc.babylonjs.com/babylon101/particles
  132184. */
  132185. particleSystems: IParticleSystem[];
  132186. /**
  132187. * Gets a list of Animations associated with the scene
  132188. */
  132189. animations: Animation[];
  132190. /**
  132191. * All of the animation groups added to this scene
  132192. * @see https://doc.babylonjs.com/how_to/group
  132193. */
  132194. animationGroups: AnimationGroup[];
  132195. /**
  132196. * All of the multi-materials added to this scene
  132197. * @see https://doc.babylonjs.com/how_to/multi_materials
  132198. */
  132199. multiMaterials: MultiMaterial[];
  132200. /**
  132201. * All of the materials added to this scene
  132202. * In the context of a Scene, it is not supposed to be modified manually.
  132203. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  132204. * Note also that the order of the Material within the array is not significant and might change.
  132205. * @see https://doc.babylonjs.com/babylon101/materials
  132206. */
  132207. materials: Material[];
  132208. /**
  132209. * The list of morph target managers added to the scene
  132210. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  132211. */
  132212. morphTargetManagers: MorphTargetManager[];
  132213. /**
  132214. * The list of geometries used in the scene.
  132215. */
  132216. geometries: Geometry[];
  132217. /**
  132218. * All of the tranform nodes added to this scene
  132219. * In the context of a Scene, it is not supposed to be modified manually.
  132220. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  132221. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  132222. * @see https://doc.babylonjs.com/how_to/transformnode
  132223. */
  132224. transformNodes: TransformNode[];
  132225. /**
  132226. * ActionManagers available on the scene.
  132227. */
  132228. actionManagers: AbstractActionManager[];
  132229. /**
  132230. * Textures to keep.
  132231. */
  132232. textures: BaseTexture[];
  132233. /** @hidden */
  132234. protected _environmentTexture: Nullable<BaseTexture>;
  132235. /**
  132236. * Texture used in all pbr material as the reflection texture.
  132237. * As in the majority of the scene they are the same (exception for multi room and so on),
  132238. * this is easier to reference from here than from all the materials.
  132239. */
  132240. get environmentTexture(): Nullable<BaseTexture>;
  132241. set environmentTexture(value: Nullable<BaseTexture>);
  132242. /**
  132243. * The list of postprocesses added to the scene
  132244. */
  132245. postProcesses: PostProcess[];
  132246. /**
  132247. * @returns all meshes, lights, cameras, transformNodes and bones
  132248. */
  132249. getNodes(): Array<Node>;
  132250. }
  132251. }
  132252. declare module BABYLON {
  132253. /**
  132254. * Interface used to define options for Sound class
  132255. */
  132256. export interface ISoundOptions {
  132257. /**
  132258. * Does the sound autoplay once loaded.
  132259. */
  132260. autoplay?: boolean;
  132261. /**
  132262. * Does the sound loop after it finishes playing once.
  132263. */
  132264. loop?: boolean;
  132265. /**
  132266. * Sound's volume
  132267. */
  132268. volume?: number;
  132269. /**
  132270. * Is it a spatial sound?
  132271. */
  132272. spatialSound?: boolean;
  132273. /**
  132274. * Maximum distance to hear that sound
  132275. */
  132276. maxDistance?: number;
  132277. /**
  132278. * Uses user defined attenuation function
  132279. */
  132280. useCustomAttenuation?: boolean;
  132281. /**
  132282. * Define the roll off factor of spatial sounds.
  132283. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  132284. */
  132285. rolloffFactor?: number;
  132286. /**
  132287. * Define the reference distance the sound should be heard perfectly.
  132288. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  132289. */
  132290. refDistance?: number;
  132291. /**
  132292. * Define the distance attenuation model the sound will follow.
  132293. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  132294. */
  132295. distanceModel?: string;
  132296. /**
  132297. * Defines the playback speed (1 by default)
  132298. */
  132299. playbackRate?: number;
  132300. /**
  132301. * Defines if the sound is from a streaming source
  132302. */
  132303. streaming?: boolean;
  132304. /**
  132305. * Defines an optional length (in seconds) inside the sound file
  132306. */
  132307. length?: number;
  132308. /**
  132309. * Defines an optional offset (in seconds) inside the sound file
  132310. */
  132311. offset?: number;
  132312. /**
  132313. * If true, URLs will not be required to state the audio file codec to use.
  132314. */
  132315. skipCodecCheck?: boolean;
  132316. }
  132317. }
  132318. declare module BABYLON {
  132319. /**
  132320. * Defines a sound that can be played in the application.
  132321. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  132322. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  132323. */
  132324. export class Sound {
  132325. /**
  132326. * The name of the sound in the scene.
  132327. */
  132328. name: string;
  132329. /**
  132330. * Does the sound autoplay once loaded.
  132331. */
  132332. autoplay: boolean;
  132333. private _loop;
  132334. /**
  132335. * Does the sound loop after it finishes playing once.
  132336. */
  132337. get loop(): boolean;
  132338. set loop(value: boolean);
  132339. /**
  132340. * Does the sound use a custom attenuation curve to simulate the falloff
  132341. * happening when the source gets further away from the camera.
  132342. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  132343. */
  132344. useCustomAttenuation: boolean;
  132345. /**
  132346. * The sound track id this sound belongs to.
  132347. */
  132348. soundTrackId: number;
  132349. /**
  132350. * Is this sound currently played.
  132351. */
  132352. isPlaying: boolean;
  132353. /**
  132354. * Is this sound currently paused.
  132355. */
  132356. isPaused: boolean;
  132357. /**
  132358. * Does this sound enables spatial sound.
  132359. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  132360. */
  132361. spatialSound: boolean;
  132362. /**
  132363. * Define the reference distance the sound should be heard perfectly.
  132364. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  132365. */
  132366. refDistance: number;
  132367. /**
  132368. * Define the roll off factor of spatial sounds.
  132369. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  132370. */
  132371. rolloffFactor: number;
  132372. /**
  132373. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  132374. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  132375. */
  132376. maxDistance: number;
  132377. /**
  132378. * Define the distance attenuation model the sound will follow.
  132379. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  132380. */
  132381. distanceModel: string;
  132382. /**
  132383. * @hidden
  132384. * Back Compat
  132385. **/
  132386. onended: () => any;
  132387. /**
  132388. * Gets or sets an object used to store user defined information for the sound.
  132389. */
  132390. metadata: any;
  132391. /**
  132392. * Observable event when the current playing sound finishes.
  132393. */
  132394. onEndedObservable: Observable<Sound>;
  132395. /**
  132396. * Gets the current time for the sound.
  132397. */
  132398. get currentTime(): number;
  132399. private _panningModel;
  132400. private _playbackRate;
  132401. private _streaming;
  132402. private _startTime;
  132403. private _startOffset;
  132404. private _position;
  132405. /** @hidden */
  132406. _positionInEmitterSpace: boolean;
  132407. private _localDirection;
  132408. private _volume;
  132409. private _isReadyToPlay;
  132410. private _isDirectional;
  132411. private _readyToPlayCallback;
  132412. private _audioBuffer;
  132413. private _soundSource;
  132414. private _streamingSource;
  132415. private _soundPanner;
  132416. private _soundGain;
  132417. private _inputAudioNode;
  132418. private _outputAudioNode;
  132419. private _coneInnerAngle;
  132420. private _coneOuterAngle;
  132421. private _coneOuterGain;
  132422. private _scene;
  132423. private _connectedTransformNode;
  132424. private _customAttenuationFunction;
  132425. private _registerFunc;
  132426. private _isOutputConnected;
  132427. private _htmlAudioElement;
  132428. private _urlType;
  132429. private _length?;
  132430. private _offset?;
  132431. /** @hidden */
  132432. static _SceneComponentInitialization: (scene: Scene) => void;
  132433. /**
  132434. * Create a sound and attach it to a scene
  132435. * @param name Name of your sound
  132436. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  132437. * @param scene defines the scene the sound belongs to
  132438. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  132439. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  132440. */
  132441. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  132442. /**
  132443. * Release the sound and its associated resources
  132444. */
  132445. dispose(): void;
  132446. /**
  132447. * Gets if the sounds is ready to be played or not.
  132448. * @returns true if ready, otherwise false
  132449. */
  132450. isReady(): boolean;
  132451. /**
  132452. * Get the current class name.
  132453. * @returns current class name
  132454. */
  132455. getClassName(): string;
  132456. private _soundLoaded;
  132457. /**
  132458. * Sets the data of the sound from an audiobuffer
  132459. * @param audioBuffer The audioBuffer containing the data
  132460. */
  132461. setAudioBuffer(audioBuffer: AudioBuffer): void;
  132462. /**
  132463. * Updates the current sounds options such as maxdistance, loop...
  132464. * @param options A JSON object containing values named as the object properties
  132465. */
  132466. updateOptions(options: ISoundOptions): void;
  132467. private _createSpatialParameters;
  132468. private _updateSpatialParameters;
  132469. /**
  132470. * Switch the panning model to HRTF:
  132471. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  132472. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  132473. */
  132474. switchPanningModelToHRTF(): void;
  132475. /**
  132476. * Switch the panning model to Equal Power:
  132477. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  132478. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  132479. */
  132480. switchPanningModelToEqualPower(): void;
  132481. private _switchPanningModel;
  132482. /**
  132483. * Connect this sound to a sound track audio node like gain...
  132484. * @param soundTrackAudioNode the sound track audio node to connect to
  132485. */
  132486. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  132487. /**
  132488. * Transform this sound into a directional source
  132489. * @param coneInnerAngle Size of the inner cone in degree
  132490. * @param coneOuterAngle Size of the outer cone in degree
  132491. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  132492. */
  132493. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  132494. /**
  132495. * Gets or sets the inner angle for the directional cone.
  132496. */
  132497. get directionalConeInnerAngle(): number;
  132498. /**
  132499. * Gets or sets the inner angle for the directional cone.
  132500. */
  132501. set directionalConeInnerAngle(value: number);
  132502. /**
  132503. * Gets or sets the outer angle for the directional cone.
  132504. */
  132505. get directionalConeOuterAngle(): number;
  132506. /**
  132507. * Gets or sets the outer angle for the directional cone.
  132508. */
  132509. set directionalConeOuterAngle(value: number);
  132510. /**
  132511. * Sets the position of the emitter if spatial sound is enabled
  132512. * @param newPosition Defines the new posisiton
  132513. */
  132514. setPosition(newPosition: Vector3): void;
  132515. /**
  132516. * Sets the local direction of the emitter if spatial sound is enabled
  132517. * @param newLocalDirection Defines the new local direction
  132518. */
  132519. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  132520. private _updateDirection;
  132521. /** @hidden */
  132522. updateDistanceFromListener(): void;
  132523. /**
  132524. * Sets a new custom attenuation function for the sound.
  132525. * @param callback Defines the function used for the attenuation
  132526. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  132527. */
  132528. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  132529. /**
  132530. * Play the sound
  132531. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  132532. * @param offset (optional) Start the sound at a specific time in seconds
  132533. * @param length (optional) Sound duration (in seconds)
  132534. */
  132535. play(time?: number, offset?: number, length?: number): void;
  132536. private _onended;
  132537. /**
  132538. * Stop the sound
  132539. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  132540. */
  132541. stop(time?: number): void;
  132542. /**
  132543. * Put the sound in pause
  132544. */
  132545. pause(): void;
  132546. /**
  132547. * Sets a dedicated volume for this sounds
  132548. * @param newVolume Define the new volume of the sound
  132549. * @param time Define time for gradual change to new volume
  132550. */
  132551. setVolume(newVolume: number, time?: number): void;
  132552. /**
  132553. * Set the sound play back rate
  132554. * @param newPlaybackRate Define the playback rate the sound should be played at
  132555. */
  132556. setPlaybackRate(newPlaybackRate: number): void;
  132557. /**
  132558. * Gets the volume of the sound.
  132559. * @returns the volume of the sound
  132560. */
  132561. getVolume(): number;
  132562. /**
  132563. * Attach the sound to a dedicated mesh
  132564. * @param transformNode The transform node to connect the sound with
  132565. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  132566. */
  132567. attachToMesh(transformNode: TransformNode): void;
  132568. /**
  132569. * Detach the sound from the previously attached mesh
  132570. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  132571. */
  132572. detachFromMesh(): void;
  132573. private _onRegisterAfterWorldMatrixUpdate;
  132574. /**
  132575. * Clone the current sound in the scene.
  132576. * @returns the new sound clone
  132577. */
  132578. clone(): Nullable<Sound>;
  132579. /**
  132580. * Gets the current underlying audio buffer containing the data
  132581. * @returns the audio buffer
  132582. */
  132583. getAudioBuffer(): Nullable<AudioBuffer>;
  132584. /**
  132585. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  132586. * @returns the source node
  132587. */
  132588. getSoundSource(): Nullable<AudioBufferSourceNode>;
  132589. /**
  132590. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  132591. * @returns the gain node
  132592. */
  132593. getSoundGain(): Nullable<GainNode>;
  132594. /**
  132595. * Serializes the Sound in a JSON representation
  132596. * @returns the JSON representation of the sound
  132597. */
  132598. serialize(): any;
  132599. /**
  132600. * Parse a JSON representation of a sound to innstantiate in a given scene
  132601. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  132602. * @param scene Define the scene the new parsed sound should be created in
  132603. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  132604. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  132605. * @returns the newly parsed sound
  132606. */
  132607. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  132608. }
  132609. }
  132610. declare module BABYLON {
  132611. /**
  132612. * This defines an action helpful to play a defined sound on a triggered action.
  132613. */
  132614. export class PlaySoundAction extends Action {
  132615. private _sound;
  132616. /**
  132617. * Instantiate the action
  132618. * @param triggerOptions defines the trigger options
  132619. * @param sound defines the sound to play
  132620. * @param condition defines the trigger related conditions
  132621. */
  132622. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  132623. /** @hidden */
  132624. _prepare(): void;
  132625. /**
  132626. * Execute the action and play the sound.
  132627. */
  132628. execute(): void;
  132629. /**
  132630. * Serializes the actions and its related information.
  132631. * @param parent defines the object to serialize in
  132632. * @returns the serialized object
  132633. */
  132634. serialize(parent: any): any;
  132635. }
  132636. /**
  132637. * This defines an action helpful to stop a defined sound on a triggered action.
  132638. */
  132639. export class StopSoundAction extends Action {
  132640. private _sound;
  132641. /**
  132642. * Instantiate the action
  132643. * @param triggerOptions defines the trigger options
  132644. * @param sound defines the sound to stop
  132645. * @param condition defines the trigger related conditions
  132646. */
  132647. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  132648. /** @hidden */
  132649. _prepare(): void;
  132650. /**
  132651. * Execute the action and stop the sound.
  132652. */
  132653. execute(): void;
  132654. /**
  132655. * Serializes the actions and its related information.
  132656. * @param parent defines the object to serialize in
  132657. * @returns the serialized object
  132658. */
  132659. serialize(parent: any): any;
  132660. }
  132661. }
  132662. declare module BABYLON {
  132663. /**
  132664. * This defines an action responsible to change the value of a property
  132665. * by interpolating between its current value and the newly set one once triggered.
  132666. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  132667. */
  132668. export class InterpolateValueAction extends Action {
  132669. /**
  132670. * Defines the path of the property where the value should be interpolated
  132671. */
  132672. propertyPath: string;
  132673. /**
  132674. * Defines the target value at the end of the interpolation.
  132675. */
  132676. value: any;
  132677. /**
  132678. * Defines the time it will take for the property to interpolate to the value.
  132679. */
  132680. duration: number;
  132681. /**
  132682. * Defines if the other scene animations should be stopped when the action has been triggered
  132683. */
  132684. stopOtherAnimations?: boolean;
  132685. /**
  132686. * Defines a callback raised once the interpolation animation has been done.
  132687. */
  132688. onInterpolationDone?: () => void;
  132689. /**
  132690. * Observable triggered once the interpolation animation has been done.
  132691. */
  132692. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  132693. private _target;
  132694. private _effectiveTarget;
  132695. private _property;
  132696. /**
  132697. * Instantiate the action
  132698. * @param triggerOptions defines the trigger options
  132699. * @param target defines the object containing the value to interpolate
  132700. * @param propertyPath defines the path to the property in the target object
  132701. * @param value defines the target value at the end of the interpolation
  132702. * @param duration deines the time it will take for the property to interpolate to the value.
  132703. * @param condition defines the trigger related conditions
  132704. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  132705. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  132706. */
  132707. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  132708. /** @hidden */
  132709. _prepare(): void;
  132710. /**
  132711. * Execute the action starts the value interpolation.
  132712. */
  132713. execute(): void;
  132714. /**
  132715. * Serializes the actions and its related information.
  132716. * @param parent defines the object to serialize in
  132717. * @returns the serialized object
  132718. */
  132719. serialize(parent: any): any;
  132720. }
  132721. }
  132722. declare module BABYLON {
  132723. /**
  132724. * This represents the default audio engine used in babylon.
  132725. * It is responsible to play, synchronize and analyse sounds throughout the application.
  132726. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  132727. */
  132728. export class AudioEngine implements IAudioEngine {
  132729. private _audioContext;
  132730. private _audioContextInitialized;
  132731. private _muteButton;
  132732. private _hostElement;
  132733. /**
  132734. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  132735. */
  132736. canUseWebAudio: boolean;
  132737. /**
  132738. * The master gain node defines the global audio volume of your audio engine.
  132739. */
  132740. masterGain: GainNode;
  132741. /**
  132742. * Defines if Babylon should emit a warning if WebAudio is not supported.
  132743. * @ignoreNaming
  132744. */
  132745. WarnedWebAudioUnsupported: boolean;
  132746. /**
  132747. * Gets whether or not mp3 are supported by your browser.
  132748. */
  132749. isMP3supported: boolean;
  132750. /**
  132751. * Gets whether or not ogg are supported by your browser.
  132752. */
  132753. isOGGsupported: boolean;
  132754. /**
  132755. * Gets whether audio has been unlocked on the device.
  132756. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  132757. * a user interaction has happened.
  132758. */
  132759. unlocked: boolean;
  132760. /**
  132761. * Defines if the audio engine relies on a custom unlocked button.
  132762. * In this case, the embedded button will not be displayed.
  132763. */
  132764. useCustomUnlockedButton: boolean;
  132765. /**
  132766. * Event raised when audio has been unlocked on the browser.
  132767. */
  132768. onAudioUnlockedObservable: Observable<IAudioEngine>;
  132769. /**
  132770. * Event raised when audio has been locked on the browser.
  132771. */
  132772. onAudioLockedObservable: Observable<IAudioEngine>;
  132773. /**
  132774. * Gets the current AudioContext if available.
  132775. */
  132776. get audioContext(): Nullable<AudioContext>;
  132777. private _connectedAnalyser;
  132778. /**
  132779. * Instantiates a new audio engine.
  132780. *
  132781. * There should be only one per page as some browsers restrict the number
  132782. * of audio contexts you can create.
  132783. * @param hostElement defines the host element where to display the mute icon if necessary
  132784. */
  132785. constructor(hostElement?: Nullable<HTMLElement>);
  132786. /**
  132787. * Flags the audio engine in Locked state.
  132788. * This happens due to new browser policies preventing audio to autoplay.
  132789. */
  132790. lock(): void;
  132791. /**
  132792. * Unlocks the audio engine once a user action has been done on the dom.
  132793. * This is helpful to resume play once browser policies have been satisfied.
  132794. */
  132795. unlock(): void;
  132796. private _resumeAudioContext;
  132797. private _initializeAudioContext;
  132798. private _tryToRun;
  132799. private _triggerRunningState;
  132800. private _triggerSuspendedState;
  132801. private _displayMuteButton;
  132802. private _moveButtonToTopLeft;
  132803. private _onResize;
  132804. private _hideMuteButton;
  132805. /**
  132806. * Destroy and release the resources associated with the audio ccontext.
  132807. */
  132808. dispose(): void;
  132809. /**
  132810. * Gets the global volume sets on the master gain.
  132811. * @returns the global volume if set or -1 otherwise
  132812. */
  132813. getGlobalVolume(): number;
  132814. /**
  132815. * Sets the global volume of your experience (sets on the master gain).
  132816. * @param newVolume Defines the new global volume of the application
  132817. */
  132818. setGlobalVolume(newVolume: number): void;
  132819. /**
  132820. * Connect the audio engine to an audio analyser allowing some amazing
  132821. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  132822. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  132823. * @param analyser The analyser to connect to the engine
  132824. */
  132825. connectToAnalyser(analyser: Analyser): void;
  132826. }
  132827. }
  132828. declare module BABYLON {
  132829. /**
  132830. * Options allowed during the creation of a sound track.
  132831. */
  132832. export interface ISoundTrackOptions {
  132833. /**
  132834. * The volume the sound track should take during creation
  132835. */
  132836. volume?: number;
  132837. /**
  132838. * Define if the sound track is the main sound track of the scene
  132839. */
  132840. mainTrack?: boolean;
  132841. }
  132842. /**
  132843. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  132844. * It will be also used in a future release to apply effects on a specific track.
  132845. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  132846. */
  132847. export class SoundTrack {
  132848. /**
  132849. * The unique identifier of the sound track in the scene.
  132850. */
  132851. id: number;
  132852. /**
  132853. * The list of sounds included in the sound track.
  132854. */
  132855. soundCollection: Array<Sound>;
  132856. private _outputAudioNode;
  132857. private _scene;
  132858. private _connectedAnalyser;
  132859. private _options;
  132860. private _isInitialized;
  132861. /**
  132862. * Creates a new sound track.
  132863. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  132864. * @param scene Define the scene the sound track belongs to
  132865. * @param options
  132866. */
  132867. constructor(scene: Scene, options?: ISoundTrackOptions);
  132868. private _initializeSoundTrackAudioGraph;
  132869. /**
  132870. * Release the sound track and its associated resources
  132871. */
  132872. dispose(): void;
  132873. /**
  132874. * Adds a sound to this sound track
  132875. * @param sound define the cound to add
  132876. * @ignoreNaming
  132877. */
  132878. addSound(sound: Sound): void;
  132879. /**
  132880. * Removes a sound to this sound track
  132881. * @param sound define the cound to remove
  132882. * @ignoreNaming
  132883. */
  132884. removeSound(sound: Sound): void;
  132885. /**
  132886. * Set a global volume for the full sound track.
  132887. * @param newVolume Define the new volume of the sound track
  132888. */
  132889. setVolume(newVolume: number): void;
  132890. /**
  132891. * Switch the panning model to HRTF:
  132892. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  132893. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  132894. */
  132895. switchPanningModelToHRTF(): void;
  132896. /**
  132897. * Switch the panning model to Equal Power:
  132898. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  132899. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  132900. */
  132901. switchPanningModelToEqualPower(): void;
  132902. /**
  132903. * Connect the sound track to an audio analyser allowing some amazing
  132904. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  132905. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  132906. * @param analyser The analyser to connect to the engine
  132907. */
  132908. connectToAnalyser(analyser: Analyser): void;
  132909. }
  132910. }
  132911. declare module BABYLON {
  132912. interface AbstractScene {
  132913. /**
  132914. * The list of sounds used in the scene.
  132915. */
  132916. sounds: Nullable<Array<Sound>>;
  132917. }
  132918. interface Scene {
  132919. /**
  132920. * @hidden
  132921. * Backing field
  132922. */
  132923. _mainSoundTrack: SoundTrack;
  132924. /**
  132925. * The main sound track played by the scene.
  132926. * It cotains your primary collection of sounds.
  132927. */
  132928. mainSoundTrack: SoundTrack;
  132929. /**
  132930. * The list of sound tracks added to the scene
  132931. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  132932. */
  132933. soundTracks: Nullable<Array<SoundTrack>>;
  132934. /**
  132935. * Gets a sound using a given name
  132936. * @param name defines the name to search for
  132937. * @return the found sound or null if not found at all.
  132938. */
  132939. getSoundByName(name: string): Nullable<Sound>;
  132940. /**
  132941. * Gets or sets if audio support is enabled
  132942. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  132943. */
  132944. audioEnabled: boolean;
  132945. /**
  132946. * Gets or sets if audio will be output to headphones
  132947. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  132948. */
  132949. headphone: boolean;
  132950. /**
  132951. * Gets or sets custom audio listener position provider
  132952. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  132953. */
  132954. audioListenerPositionProvider: Nullable<() => Vector3>;
  132955. /**
  132956. * Gets or sets a refresh rate when using 3D audio positioning
  132957. */
  132958. audioPositioningRefreshRate: number;
  132959. }
  132960. /**
  132961. * Defines the sound scene component responsible to manage any sounds
  132962. * in a given scene.
  132963. */
  132964. export class AudioSceneComponent implements ISceneSerializableComponent {
  132965. private static _CameraDirectionLH;
  132966. private static _CameraDirectionRH;
  132967. /**
  132968. * The component name helpfull to identify the component in the list of scene components.
  132969. */
  132970. readonly name: string;
  132971. /**
  132972. * The scene the component belongs to.
  132973. */
  132974. scene: Scene;
  132975. private _audioEnabled;
  132976. /**
  132977. * Gets whether audio is enabled or not.
  132978. * Please use related enable/disable method to switch state.
  132979. */
  132980. get audioEnabled(): boolean;
  132981. private _headphone;
  132982. /**
  132983. * Gets whether audio is outputing to headphone or not.
  132984. * Please use the according Switch methods to change output.
  132985. */
  132986. get headphone(): boolean;
  132987. /**
  132988. * Gets or sets a refresh rate when using 3D audio positioning
  132989. */
  132990. audioPositioningRefreshRate: number;
  132991. private _audioListenerPositionProvider;
  132992. /**
  132993. * Gets the current audio listener position provider
  132994. */
  132995. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  132996. /**
  132997. * Sets a custom listener position for all sounds in the scene
  132998. * By default, this is the position of the first active camera
  132999. */
  133000. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  133001. /**
  133002. * Creates a new instance of the component for the given scene
  133003. * @param scene Defines the scene to register the component in
  133004. */
  133005. constructor(scene: Scene);
  133006. /**
  133007. * Registers the component in a given scene
  133008. */
  133009. register(): void;
  133010. /**
  133011. * Rebuilds the elements related to this component in case of
  133012. * context lost for instance.
  133013. */
  133014. rebuild(): void;
  133015. /**
  133016. * Serializes the component data to the specified json object
  133017. * @param serializationObject The object to serialize to
  133018. */
  133019. serialize(serializationObject: any): void;
  133020. /**
  133021. * Adds all the elements from the container to the scene
  133022. * @param container the container holding the elements
  133023. */
  133024. addFromContainer(container: AbstractScene): void;
  133025. /**
  133026. * Removes all the elements in the container from the scene
  133027. * @param container contains the elements to remove
  133028. * @param dispose if the removed element should be disposed (default: false)
  133029. */
  133030. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  133031. /**
  133032. * Disposes the component and the associated ressources.
  133033. */
  133034. dispose(): void;
  133035. /**
  133036. * Disables audio in the associated scene.
  133037. */
  133038. disableAudio(): void;
  133039. /**
  133040. * Enables audio in the associated scene.
  133041. */
  133042. enableAudio(): void;
  133043. /**
  133044. * Switch audio to headphone output.
  133045. */
  133046. switchAudioModeForHeadphones(): void;
  133047. /**
  133048. * Switch audio to normal speakers.
  133049. */
  133050. switchAudioModeForNormalSpeakers(): void;
  133051. private _cachedCameraDirection;
  133052. private _cachedCameraPosition;
  133053. private _lastCheck;
  133054. private _afterRender;
  133055. }
  133056. }
  133057. declare module BABYLON {
  133058. /**
  133059. * Wraps one or more Sound objects and selects one with random weight for playback.
  133060. */
  133061. export class WeightedSound {
  133062. /** When true a Sound will be selected and played when the current playing Sound completes. */
  133063. loop: boolean;
  133064. private _coneInnerAngle;
  133065. private _coneOuterAngle;
  133066. private _volume;
  133067. /** A Sound is currently playing. */
  133068. isPlaying: boolean;
  133069. /** A Sound is currently paused. */
  133070. isPaused: boolean;
  133071. private _sounds;
  133072. private _weights;
  133073. private _currentIndex?;
  133074. /**
  133075. * Creates a new WeightedSound from the list of sounds given.
  133076. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  133077. * @param sounds Array of Sounds that will be selected from.
  133078. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  133079. */
  133080. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  133081. /**
  133082. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  133083. */
  133084. get directionalConeInnerAngle(): number;
  133085. /**
  133086. * The size of cone in degress for a directional sound in which there will be no attenuation.
  133087. */
  133088. set directionalConeInnerAngle(value: number);
  133089. /**
  133090. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  133091. * Listener angles between innerAngle and outerAngle will falloff linearly.
  133092. */
  133093. get directionalConeOuterAngle(): number;
  133094. /**
  133095. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  133096. * Listener angles between innerAngle and outerAngle will falloff linearly.
  133097. */
  133098. set directionalConeOuterAngle(value: number);
  133099. /**
  133100. * Playback volume.
  133101. */
  133102. get volume(): number;
  133103. /**
  133104. * Playback volume.
  133105. */
  133106. set volume(value: number);
  133107. private _onended;
  133108. /**
  133109. * Suspend playback
  133110. */
  133111. pause(): void;
  133112. /**
  133113. * Stop playback
  133114. */
  133115. stop(): void;
  133116. /**
  133117. * Start playback.
  133118. * @param startOffset Position the clip head at a specific time in seconds.
  133119. */
  133120. play(startOffset?: number): void;
  133121. }
  133122. }
  133123. declare module BABYLON {
  133124. /**
  133125. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  133126. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  133127. */
  133128. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  133129. /**
  133130. * Gets the name of the behavior.
  133131. */
  133132. get name(): string;
  133133. /**
  133134. * The easing function used by animations
  133135. */
  133136. static EasingFunction: BackEase;
  133137. /**
  133138. * The easing mode used by animations
  133139. */
  133140. static EasingMode: number;
  133141. /**
  133142. * The duration of the animation, in milliseconds
  133143. */
  133144. transitionDuration: number;
  133145. /**
  133146. * Length of the distance animated by the transition when lower radius is reached
  133147. */
  133148. lowerRadiusTransitionRange: number;
  133149. /**
  133150. * Length of the distance animated by the transition when upper radius is reached
  133151. */
  133152. upperRadiusTransitionRange: number;
  133153. private _autoTransitionRange;
  133154. /**
  133155. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  133156. */
  133157. get autoTransitionRange(): boolean;
  133158. /**
  133159. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  133160. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  133161. */
  133162. set autoTransitionRange(value: boolean);
  133163. private _attachedCamera;
  133164. private _onAfterCheckInputsObserver;
  133165. private _onMeshTargetChangedObserver;
  133166. /**
  133167. * Initializes the behavior.
  133168. */
  133169. init(): void;
  133170. /**
  133171. * Attaches the behavior to its arc rotate camera.
  133172. * @param camera Defines the camera to attach the behavior to
  133173. */
  133174. attach(camera: ArcRotateCamera): void;
  133175. /**
  133176. * Detaches the behavior from its current arc rotate camera.
  133177. */
  133178. detach(): void;
  133179. private _radiusIsAnimating;
  133180. private _radiusBounceTransition;
  133181. private _animatables;
  133182. private _cachedWheelPrecision;
  133183. /**
  133184. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  133185. * @param radiusLimit The limit to check against.
  133186. * @return Bool to indicate if at limit.
  133187. */
  133188. private _isRadiusAtLimit;
  133189. /**
  133190. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  133191. * @param radiusDelta The delta by which to animate to. Can be negative.
  133192. */
  133193. private _applyBoundRadiusAnimation;
  133194. /**
  133195. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  133196. */
  133197. protected _clearAnimationLocks(): void;
  133198. /**
  133199. * Stops and removes all animations that have been applied to the camera
  133200. */
  133201. stopAllAnimations(): void;
  133202. }
  133203. }
  133204. declare module BABYLON {
  133205. /**
  133206. * 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.
  133207. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  133208. */
  133209. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  133210. /**
  133211. * Gets the name of the behavior.
  133212. */
  133213. get name(): string;
  133214. private _mode;
  133215. private _radiusScale;
  133216. private _positionScale;
  133217. private _defaultElevation;
  133218. private _elevationReturnTime;
  133219. private _elevationReturnWaitTime;
  133220. private _zoomStopsAnimation;
  133221. private _framingTime;
  133222. /**
  133223. * The easing function used by animations
  133224. */
  133225. static EasingFunction: ExponentialEase;
  133226. /**
  133227. * The easing mode used by animations
  133228. */
  133229. static EasingMode: number;
  133230. /**
  133231. * Sets the current mode used by the behavior
  133232. */
  133233. set mode(mode: number);
  133234. /**
  133235. * Gets current mode used by the behavior.
  133236. */
  133237. get mode(): number;
  133238. /**
  133239. * Sets the scale applied to the radius (1 by default)
  133240. */
  133241. set radiusScale(radius: number);
  133242. /**
  133243. * Gets the scale applied to the radius
  133244. */
  133245. get radiusScale(): number;
  133246. /**
  133247. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  133248. */
  133249. set positionScale(scale: number);
  133250. /**
  133251. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  133252. */
  133253. get positionScale(): number;
  133254. /**
  133255. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  133256. * behaviour is triggered, in radians.
  133257. */
  133258. set defaultElevation(elevation: number);
  133259. /**
  133260. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  133261. * behaviour is triggered, in radians.
  133262. */
  133263. get defaultElevation(): number;
  133264. /**
  133265. * Sets the time (in milliseconds) taken to return to the default beta position.
  133266. * Negative value indicates camera should not return to default.
  133267. */
  133268. set elevationReturnTime(speed: number);
  133269. /**
  133270. * Gets the time (in milliseconds) taken to return to the default beta position.
  133271. * Negative value indicates camera should not return to default.
  133272. */
  133273. get elevationReturnTime(): number;
  133274. /**
  133275. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  133276. */
  133277. set elevationReturnWaitTime(time: number);
  133278. /**
  133279. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  133280. */
  133281. get elevationReturnWaitTime(): number;
  133282. /**
  133283. * Sets the flag that indicates if user zooming should stop animation.
  133284. */
  133285. set zoomStopsAnimation(flag: boolean);
  133286. /**
  133287. * Gets the flag that indicates if user zooming should stop animation.
  133288. */
  133289. get zoomStopsAnimation(): boolean;
  133290. /**
  133291. * Sets the transition time when framing the mesh, in milliseconds
  133292. */
  133293. set framingTime(time: number);
  133294. /**
  133295. * Gets the transition time when framing the mesh, in milliseconds
  133296. */
  133297. get framingTime(): number;
  133298. /**
  133299. * Define if the behavior should automatically change the configured
  133300. * camera limits and sensibilities.
  133301. */
  133302. autoCorrectCameraLimitsAndSensibility: boolean;
  133303. private _onPrePointerObservableObserver;
  133304. private _onAfterCheckInputsObserver;
  133305. private _onMeshTargetChangedObserver;
  133306. private _attachedCamera;
  133307. private _isPointerDown;
  133308. private _lastInteractionTime;
  133309. /**
  133310. * Initializes the behavior.
  133311. */
  133312. init(): void;
  133313. /**
  133314. * Attaches the behavior to its arc rotate camera.
  133315. * @param camera Defines the camera to attach the behavior to
  133316. */
  133317. attach(camera: ArcRotateCamera): void;
  133318. /**
  133319. * Detaches the behavior from its current arc rotate camera.
  133320. */
  133321. detach(): void;
  133322. private _animatables;
  133323. private _betaIsAnimating;
  133324. private _betaTransition;
  133325. private _radiusTransition;
  133326. private _vectorTransition;
  133327. /**
  133328. * Targets the given mesh and updates zoom level accordingly.
  133329. * @param mesh The mesh to target.
  133330. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  133331. * @param onAnimationEnd Callback triggered at the end of the framing animation
  133332. */
  133333. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  133334. /**
  133335. * Targets the given mesh with its children and updates zoom level accordingly.
  133336. * @param mesh The mesh to target.
  133337. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  133338. * @param onAnimationEnd Callback triggered at the end of the framing animation
  133339. */
  133340. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  133341. /**
  133342. * Targets the given meshes with their children and updates zoom level accordingly.
  133343. * @param meshes The mesh to target.
  133344. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  133345. * @param onAnimationEnd Callback triggered at the end of the framing animation
  133346. */
  133347. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  133348. /**
  133349. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  133350. * @param minimumWorld Determines the smaller position of the bounding box extend
  133351. * @param maximumWorld Determines the bigger position of the bounding box extend
  133352. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  133353. * @param onAnimationEnd Callback triggered at the end of the framing animation
  133354. */
  133355. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  133356. /**
  133357. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  133358. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  133359. * frustum width.
  133360. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  133361. * to fully enclose the mesh in the viewing frustum.
  133362. */
  133363. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  133364. /**
  133365. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  133366. * is automatically returned to its default position (expected to be above ground plane).
  133367. */
  133368. private _maintainCameraAboveGround;
  133369. /**
  133370. * Returns the frustum slope based on the canvas ratio and camera FOV
  133371. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  133372. */
  133373. private _getFrustumSlope;
  133374. /**
  133375. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  133376. */
  133377. private _clearAnimationLocks;
  133378. /**
  133379. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  133380. */
  133381. private _applyUserInteraction;
  133382. /**
  133383. * Stops and removes all animations that have been applied to the camera
  133384. */
  133385. stopAllAnimations(): void;
  133386. /**
  133387. * Gets a value indicating if the user is moving the camera
  133388. */
  133389. get isUserIsMoving(): boolean;
  133390. /**
  133391. * The camera can move all the way towards the mesh.
  133392. */
  133393. static IgnoreBoundsSizeMode: number;
  133394. /**
  133395. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  133396. */
  133397. static FitFrustumSidesMode: number;
  133398. }
  133399. }
  133400. declare module BABYLON {
  133401. /**
  133402. * Base class for Camera Pointer Inputs.
  133403. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  133404. * for example usage.
  133405. */
  133406. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  133407. /**
  133408. * Defines the camera the input is attached to.
  133409. */
  133410. abstract camera: Camera;
  133411. /**
  133412. * Whether keyboard modifier keys are pressed at time of last mouse event.
  133413. */
  133414. protected _altKey: boolean;
  133415. protected _ctrlKey: boolean;
  133416. protected _metaKey: boolean;
  133417. protected _shiftKey: boolean;
  133418. /**
  133419. * Which mouse buttons were pressed at time of last mouse event.
  133420. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  133421. */
  133422. protected _buttonsPressed: number;
  133423. /**
  133424. * Defines the buttons associated with the input to handle camera move.
  133425. */
  133426. buttons: number[];
  133427. /**
  133428. * Attach the input controls to a specific dom element to get the input from.
  133429. * @param element Defines the element the controls should be listened from
  133430. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  133431. */
  133432. attachControl(noPreventDefault?: boolean): void;
  133433. /**
  133434. * Detach the current controls from the specified dom element.
  133435. */
  133436. detachControl(): void;
  133437. /**
  133438. * Gets the class name of the current input.
  133439. * @returns the class name
  133440. */
  133441. getClassName(): string;
  133442. /**
  133443. * Get the friendly name associated with the input class.
  133444. * @returns the input friendly name
  133445. */
  133446. getSimpleName(): string;
  133447. /**
  133448. * Called on pointer POINTERDOUBLETAP event.
  133449. * Override this method to provide functionality on POINTERDOUBLETAP event.
  133450. */
  133451. protected onDoubleTap(type: string): void;
  133452. /**
  133453. * Called on pointer POINTERMOVE event if only a single touch is active.
  133454. * Override this method to provide functionality.
  133455. */
  133456. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  133457. /**
  133458. * Called on pointer POINTERMOVE event if multiple touches are active.
  133459. * Override this method to provide functionality.
  133460. */
  133461. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  133462. /**
  133463. * Called on JS contextmenu event.
  133464. * Override this method to provide functionality.
  133465. */
  133466. protected onContextMenu(evt: PointerEvent): void;
  133467. /**
  133468. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  133469. * press.
  133470. * Override this method to provide functionality.
  133471. */
  133472. protected onButtonDown(evt: PointerEvent): void;
  133473. /**
  133474. * Called each time a new POINTERUP event occurs. Ie, for each button
  133475. * release.
  133476. * Override this method to provide functionality.
  133477. */
  133478. protected onButtonUp(evt: PointerEvent): void;
  133479. /**
  133480. * Called when window becomes inactive.
  133481. * Override this method to provide functionality.
  133482. */
  133483. protected onLostFocus(): void;
  133484. private _pointerInput;
  133485. private _observer;
  133486. private _onLostFocus;
  133487. private pointA;
  133488. private pointB;
  133489. }
  133490. }
  133491. declare module BABYLON {
  133492. /**
  133493. * Manage the pointers inputs to control an arc rotate camera.
  133494. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  133495. */
  133496. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  133497. /**
  133498. * Defines the camera the input is attached to.
  133499. */
  133500. camera: ArcRotateCamera;
  133501. /**
  133502. * Gets the class name of the current input.
  133503. * @returns the class name
  133504. */
  133505. getClassName(): string;
  133506. /**
  133507. * Defines the buttons associated with the input to handle camera move.
  133508. */
  133509. buttons: number[];
  133510. /**
  133511. * Defines the pointer angular sensibility along the X axis or how fast is
  133512. * the camera rotating.
  133513. */
  133514. angularSensibilityX: number;
  133515. /**
  133516. * Defines the pointer angular sensibility along the Y axis or how fast is
  133517. * the camera rotating.
  133518. */
  133519. angularSensibilityY: number;
  133520. /**
  133521. * Defines the pointer pinch precision or how fast is the camera zooming.
  133522. */
  133523. pinchPrecision: number;
  133524. /**
  133525. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  133526. * from 0.
  133527. * It defines the percentage of current camera.radius to use as delta when
  133528. * pinch zoom is used.
  133529. */
  133530. pinchDeltaPercentage: number;
  133531. /**
  133532. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  133533. * that any object in the plane at the camera's target point will scale
  133534. * perfectly with finger motion.
  133535. * Overrides pinchDeltaPercentage and pinchPrecision.
  133536. */
  133537. useNaturalPinchZoom: boolean;
  133538. /**
  133539. * Defines the pointer panning sensibility or how fast is the camera moving.
  133540. */
  133541. panningSensibility: number;
  133542. /**
  133543. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  133544. */
  133545. multiTouchPanning: boolean;
  133546. /**
  133547. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  133548. * zoom (pinch) through multitouch.
  133549. */
  133550. multiTouchPanAndZoom: boolean;
  133551. /**
  133552. * Revers pinch action direction.
  133553. */
  133554. pinchInwards: boolean;
  133555. private _isPanClick;
  133556. private _twoFingerActivityCount;
  133557. private _isPinching;
  133558. /**
  133559. * Called on pointer POINTERMOVE event if only a single touch is active.
  133560. */
  133561. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  133562. /**
  133563. * Called on pointer POINTERDOUBLETAP event.
  133564. */
  133565. protected onDoubleTap(type: string): void;
  133566. /**
  133567. * Called on pointer POINTERMOVE event if multiple touches are active.
  133568. */
  133569. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  133570. /**
  133571. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  133572. * press.
  133573. */
  133574. protected onButtonDown(evt: PointerEvent): void;
  133575. /**
  133576. * Called each time a new POINTERUP event occurs. Ie, for each button
  133577. * release.
  133578. */
  133579. protected onButtonUp(evt: PointerEvent): void;
  133580. /**
  133581. * Called when window becomes inactive.
  133582. */
  133583. protected onLostFocus(): void;
  133584. }
  133585. }
  133586. declare module BABYLON {
  133587. /**
  133588. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  133589. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  133590. */
  133591. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  133592. /**
  133593. * Defines the camera the input is attached to.
  133594. */
  133595. camera: ArcRotateCamera;
  133596. /**
  133597. * Defines the list of key codes associated with the up action (increase alpha)
  133598. */
  133599. keysUp: number[];
  133600. /**
  133601. * Defines the list of key codes associated with the down action (decrease alpha)
  133602. */
  133603. keysDown: number[];
  133604. /**
  133605. * Defines the list of key codes associated with the left action (increase beta)
  133606. */
  133607. keysLeft: number[];
  133608. /**
  133609. * Defines the list of key codes associated with the right action (decrease beta)
  133610. */
  133611. keysRight: number[];
  133612. /**
  133613. * Defines the list of key codes associated with the reset action.
  133614. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  133615. */
  133616. keysReset: number[];
  133617. /**
  133618. * Defines the panning sensibility of the inputs.
  133619. * (How fast is the camera panning)
  133620. */
  133621. panningSensibility: number;
  133622. /**
  133623. * Defines the zooming sensibility of the inputs.
  133624. * (How fast is the camera zooming)
  133625. */
  133626. zoomingSensibility: number;
  133627. /**
  133628. * Defines whether maintaining the alt key down switch the movement mode from
  133629. * orientation to zoom.
  133630. */
  133631. useAltToZoom: boolean;
  133632. /**
  133633. * Rotation speed of the camera
  133634. */
  133635. angularSpeed: number;
  133636. private _keys;
  133637. private _ctrlPressed;
  133638. private _altPressed;
  133639. private _onCanvasBlurObserver;
  133640. private _onKeyboardObserver;
  133641. private _engine;
  133642. private _scene;
  133643. /**
  133644. * Attach the input controls to a specific dom element to get the input from.
  133645. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  133646. */
  133647. attachControl(noPreventDefault?: boolean): void;
  133648. /**
  133649. * Detach the current controls from the specified dom element.
  133650. */
  133651. detachControl(): void;
  133652. /**
  133653. * Update the current camera state depending on the inputs that have been used this frame.
  133654. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  133655. */
  133656. checkInputs(): void;
  133657. /**
  133658. * Gets the class name of the current intput.
  133659. * @returns the class name
  133660. */
  133661. getClassName(): string;
  133662. /**
  133663. * Get the friendly name associated with the input class.
  133664. * @returns the input friendly name
  133665. */
  133666. getSimpleName(): string;
  133667. }
  133668. }
  133669. declare module BABYLON {
  133670. /**
  133671. * Manage the mouse wheel inputs to control an arc rotate camera.
  133672. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  133673. */
  133674. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  133675. /**
  133676. * Defines the camera the input is attached to.
  133677. */
  133678. camera: ArcRotateCamera;
  133679. /**
  133680. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  133681. */
  133682. wheelPrecision: number;
  133683. /**
  133684. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  133685. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  133686. */
  133687. wheelDeltaPercentage: number;
  133688. private _wheel;
  133689. private _observer;
  133690. private computeDeltaFromMouseWheelLegacyEvent;
  133691. /**
  133692. * Attach the input controls to a specific dom element to get the input from.
  133693. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  133694. */
  133695. attachControl(noPreventDefault?: boolean): void;
  133696. /**
  133697. * Detach the current controls from the specified dom element.
  133698. */
  133699. detachControl(): void;
  133700. /**
  133701. * Gets the class name of the current intput.
  133702. * @returns the class name
  133703. */
  133704. getClassName(): string;
  133705. /**
  133706. * Get the friendly name associated with the input class.
  133707. * @returns the input friendly name
  133708. */
  133709. getSimpleName(): string;
  133710. }
  133711. }
  133712. declare module BABYLON {
  133713. /**
  133714. * Default Inputs manager for the ArcRotateCamera.
  133715. * It groups all the default supported inputs for ease of use.
  133716. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  133717. */
  133718. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  133719. /**
  133720. * Instantiates a new ArcRotateCameraInputsManager.
  133721. * @param camera Defines the camera the inputs belong to
  133722. */
  133723. constructor(camera: ArcRotateCamera);
  133724. /**
  133725. * Add mouse wheel input support to the input manager.
  133726. * @returns the current input manager
  133727. */
  133728. addMouseWheel(): ArcRotateCameraInputsManager;
  133729. /**
  133730. * Add pointers input support to the input manager.
  133731. * @returns the current input manager
  133732. */
  133733. addPointers(): ArcRotateCameraInputsManager;
  133734. /**
  133735. * Add keyboard input support to the input manager.
  133736. * @returns the current input manager
  133737. */
  133738. addKeyboard(): ArcRotateCameraInputsManager;
  133739. }
  133740. }
  133741. declare module BABYLON {
  133742. /**
  133743. * This represents an orbital type of camera.
  133744. *
  133745. * 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.
  133746. * 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.
  133747. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  133748. */
  133749. export class ArcRotateCamera extends TargetCamera {
  133750. /**
  133751. * Defines the rotation angle of the camera along the longitudinal axis.
  133752. */
  133753. alpha: number;
  133754. /**
  133755. * Defines the rotation angle of the camera along the latitudinal axis.
  133756. */
  133757. beta: number;
  133758. /**
  133759. * Defines the radius of the camera from it s target point.
  133760. */
  133761. radius: number;
  133762. protected _target: Vector3;
  133763. protected _targetHost: Nullable<AbstractMesh>;
  133764. /**
  133765. * Defines the target point of the camera.
  133766. * The camera looks towards it form the radius distance.
  133767. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  133768. */
  133769. get target(): Vector3;
  133770. set target(value: Vector3);
  133771. /**
  133772. * Define the current local position of the camera in the scene
  133773. */
  133774. get position(): Vector3;
  133775. set position(newPosition: Vector3);
  133776. protected _upToYMatrix: Matrix;
  133777. protected _YToUpMatrix: Matrix;
  133778. /**
  133779. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  133780. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  133781. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  133782. */
  133783. set upVector(vec: Vector3);
  133784. get upVector(): Vector3;
  133785. /**
  133786. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  133787. */
  133788. setMatUp(): void;
  133789. /**
  133790. * Current inertia value on the longitudinal axis.
  133791. * The bigger this number the longer it will take for the camera to stop.
  133792. */
  133793. inertialAlphaOffset: number;
  133794. /**
  133795. * Current inertia value on the latitudinal axis.
  133796. * The bigger this number the longer it will take for the camera to stop.
  133797. */
  133798. inertialBetaOffset: number;
  133799. /**
  133800. * Current inertia value on the radius axis.
  133801. * The bigger this number the longer it will take for the camera to stop.
  133802. */
  133803. inertialRadiusOffset: number;
  133804. /**
  133805. * Minimum allowed angle on the longitudinal axis.
  133806. * This can help limiting how the Camera is able to move in the scene.
  133807. */
  133808. lowerAlphaLimit: Nullable<number>;
  133809. /**
  133810. * Maximum allowed angle on the longitudinal axis.
  133811. * This can help limiting how the Camera is able to move in the scene.
  133812. */
  133813. upperAlphaLimit: Nullable<number>;
  133814. /**
  133815. * Minimum allowed angle on the latitudinal axis.
  133816. * This can help limiting how the Camera is able to move in the scene.
  133817. */
  133818. lowerBetaLimit: number;
  133819. /**
  133820. * Maximum allowed angle on the latitudinal axis.
  133821. * This can help limiting how the Camera is able to move in the scene.
  133822. */
  133823. upperBetaLimit: number;
  133824. /**
  133825. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  133826. * This can help limiting how the Camera is able to move in the scene.
  133827. */
  133828. lowerRadiusLimit: Nullable<number>;
  133829. /**
  133830. * Maximum allowed distance of the camera to the target (The camera can not get further).
  133831. * This can help limiting how the Camera is able to move in the scene.
  133832. */
  133833. upperRadiusLimit: Nullable<number>;
  133834. /**
  133835. * Defines the current inertia value used during panning of the camera along the X axis.
  133836. */
  133837. inertialPanningX: number;
  133838. /**
  133839. * Defines the current inertia value used during panning of the camera along the Y axis.
  133840. */
  133841. inertialPanningY: number;
  133842. /**
  133843. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  133844. * Basically if your fingers moves away from more than this distance you will be considered
  133845. * in pinch mode.
  133846. */
  133847. pinchToPanMaxDistance: number;
  133848. /**
  133849. * Defines the maximum distance the camera can pan.
  133850. * This could help keeping the cammera always in your scene.
  133851. */
  133852. panningDistanceLimit: Nullable<number>;
  133853. /**
  133854. * Defines the target of the camera before paning.
  133855. */
  133856. panningOriginTarget: Vector3;
  133857. /**
  133858. * Defines the value of the inertia used during panning.
  133859. * 0 would mean stop inertia and one would mean no decelleration at all.
  133860. */
  133861. panningInertia: number;
  133862. /**
  133863. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  133864. */
  133865. get angularSensibilityX(): number;
  133866. set angularSensibilityX(value: number);
  133867. /**
  133868. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  133869. */
  133870. get angularSensibilityY(): number;
  133871. set angularSensibilityY(value: number);
  133872. /**
  133873. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  133874. */
  133875. get pinchPrecision(): number;
  133876. set pinchPrecision(value: number);
  133877. /**
  133878. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  133879. * It will be used instead of pinchDeltaPrecision if different from 0.
  133880. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  133881. */
  133882. get pinchDeltaPercentage(): number;
  133883. set pinchDeltaPercentage(value: number);
  133884. /**
  133885. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  133886. * and pinch delta percentage.
  133887. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  133888. * that any object in the plane at the camera's target point will scale
  133889. * perfectly with finger motion.
  133890. */
  133891. get useNaturalPinchZoom(): boolean;
  133892. set useNaturalPinchZoom(value: boolean);
  133893. /**
  133894. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  133895. */
  133896. get panningSensibility(): number;
  133897. set panningSensibility(value: number);
  133898. /**
  133899. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  133900. */
  133901. get keysUp(): number[];
  133902. set keysUp(value: number[]);
  133903. /**
  133904. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  133905. */
  133906. get keysDown(): number[];
  133907. set keysDown(value: number[]);
  133908. /**
  133909. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  133910. */
  133911. get keysLeft(): number[];
  133912. set keysLeft(value: number[]);
  133913. /**
  133914. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  133915. */
  133916. get keysRight(): number[];
  133917. set keysRight(value: number[]);
  133918. /**
  133919. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  133920. */
  133921. get wheelPrecision(): number;
  133922. set wheelPrecision(value: number);
  133923. /**
  133924. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  133925. * It will be used instead of pinchDeltaPrecision if different from 0.
  133926. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  133927. */
  133928. get wheelDeltaPercentage(): number;
  133929. set wheelDeltaPercentage(value: number);
  133930. /**
  133931. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  133932. */
  133933. zoomOnFactor: number;
  133934. /**
  133935. * Defines a screen offset for the camera position.
  133936. */
  133937. targetScreenOffset: Vector2;
  133938. /**
  133939. * Allows the camera to be completely reversed.
  133940. * If false the camera can not arrive upside down.
  133941. */
  133942. allowUpsideDown: boolean;
  133943. /**
  133944. * Define if double tap/click is used to restore the previously saved state of the camera.
  133945. */
  133946. useInputToRestoreState: boolean;
  133947. /** @hidden */
  133948. _viewMatrix: Matrix;
  133949. /** @hidden */
  133950. _useCtrlForPanning: boolean;
  133951. /** @hidden */
  133952. _panningMouseButton: number;
  133953. /**
  133954. * Defines the input associated to the camera.
  133955. */
  133956. inputs: ArcRotateCameraInputsManager;
  133957. /** @hidden */
  133958. _reset: () => void;
  133959. /**
  133960. * Defines the allowed panning axis.
  133961. */
  133962. panningAxis: Vector3;
  133963. protected _transformedDirection: Vector3;
  133964. private _bouncingBehavior;
  133965. /**
  133966. * Gets the bouncing behavior of the camera if it has been enabled.
  133967. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  133968. */
  133969. get bouncingBehavior(): Nullable<BouncingBehavior>;
  133970. /**
  133971. * Defines if the bouncing behavior of the camera is enabled on the camera.
  133972. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  133973. */
  133974. get useBouncingBehavior(): boolean;
  133975. set useBouncingBehavior(value: boolean);
  133976. private _framingBehavior;
  133977. /**
  133978. * Gets the framing behavior of the camera if it has been enabled.
  133979. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  133980. */
  133981. get framingBehavior(): Nullable<FramingBehavior>;
  133982. /**
  133983. * Defines if the framing behavior of the camera is enabled on the camera.
  133984. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  133985. */
  133986. get useFramingBehavior(): boolean;
  133987. set useFramingBehavior(value: boolean);
  133988. private _autoRotationBehavior;
  133989. /**
  133990. * Gets the auto rotation behavior of the camera if it has been enabled.
  133991. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  133992. */
  133993. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  133994. /**
  133995. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  133996. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  133997. */
  133998. get useAutoRotationBehavior(): boolean;
  133999. set useAutoRotationBehavior(value: boolean);
  134000. /**
  134001. * Observable triggered when the mesh target has been changed on the camera.
  134002. */
  134003. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  134004. /**
  134005. * Event raised when the camera is colliding with a mesh.
  134006. */
  134007. onCollide: (collidedMesh: AbstractMesh) => void;
  134008. /**
  134009. * Defines whether the camera should check collision with the objects oh the scene.
  134010. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  134011. */
  134012. checkCollisions: boolean;
  134013. /**
  134014. * Defines the collision radius of the camera.
  134015. * This simulates a sphere around the camera.
  134016. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  134017. */
  134018. collisionRadius: Vector3;
  134019. protected _collider: Collider;
  134020. protected _previousPosition: Vector3;
  134021. protected _collisionVelocity: Vector3;
  134022. protected _newPosition: Vector3;
  134023. protected _previousAlpha: number;
  134024. protected _previousBeta: number;
  134025. protected _previousRadius: number;
  134026. protected _collisionTriggered: boolean;
  134027. protected _targetBoundingCenter: Nullable<Vector3>;
  134028. private _computationVector;
  134029. /**
  134030. * Instantiates a new ArcRotateCamera in a given scene
  134031. * @param name Defines the name of the camera
  134032. * @param alpha Defines the camera rotation along the logitudinal axis
  134033. * @param beta Defines the camera rotation along the latitudinal axis
  134034. * @param radius Defines the camera distance from its target
  134035. * @param target Defines the camera target
  134036. * @param scene Defines the scene the camera belongs to
  134037. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  134038. */
  134039. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  134040. /** @hidden */
  134041. _initCache(): void;
  134042. /** @hidden */
  134043. _updateCache(ignoreParentClass?: boolean): void;
  134044. protected _getTargetPosition(): Vector3;
  134045. private _storedAlpha;
  134046. private _storedBeta;
  134047. private _storedRadius;
  134048. private _storedTarget;
  134049. private _storedTargetScreenOffset;
  134050. /**
  134051. * Stores the current state of the camera (alpha, beta, radius and target)
  134052. * @returns the camera itself
  134053. */
  134054. storeState(): Camera;
  134055. /**
  134056. * @hidden
  134057. * Restored camera state. You must call storeState() first
  134058. */
  134059. _restoreStateValues(): boolean;
  134060. /** @hidden */
  134061. _isSynchronizedViewMatrix(): boolean;
  134062. /**
  134063. * Attach the input controls to a specific dom element to get the input from.
  134064. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  134065. */
  134066. attachControl(noPreventDefault?: boolean): void;
  134067. /**
  134068. * Attach the input controls to a specific dom element to get the input from.
  134069. * @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
  134070. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  134071. */
  134072. attachControl(ignored: any, noPreventDefault?: boolean): void;
  134073. /**
  134074. * Attached controls to the current camera.
  134075. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  134076. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  134077. */
  134078. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  134079. /**
  134080. * Attached controls to the current camera.
  134081. * @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
  134082. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  134083. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  134084. */
  134085. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  134086. /**
  134087. * Attached controls to the current camera.
  134088. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  134089. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  134090. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  134091. */
  134092. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  134093. /**
  134094. * Detach the current controls from the specified dom element.
  134095. */
  134096. detachControl(): void;
  134097. /**
  134098. * Detach the current controls from the specified dom element.
  134099. * @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
  134100. */
  134101. detachControl(ignored: any): void;
  134102. /** @hidden */
  134103. _checkInputs(): void;
  134104. protected _checkLimits(): void;
  134105. /**
  134106. * Rebuilds angles (alpha, beta) and radius from the give position and target
  134107. */
  134108. rebuildAnglesAndRadius(): void;
  134109. /**
  134110. * Use a position to define the current camera related information like alpha, beta and radius
  134111. * @param position Defines the position to set the camera at
  134112. */
  134113. setPosition(position: Vector3): void;
  134114. /**
  134115. * Defines the target the camera should look at.
  134116. * This will automatically adapt alpha beta and radius to fit within the new target.
  134117. * @param target Defines the new target as a Vector or a mesh
  134118. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  134119. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  134120. */
  134121. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  134122. /** @hidden */
  134123. _getViewMatrix(): Matrix;
  134124. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  134125. /**
  134126. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  134127. * @param meshes Defines the mesh to zoom on
  134128. * @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)
  134129. */
  134130. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  134131. /**
  134132. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  134133. * The target will be changed but the radius
  134134. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  134135. * @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)
  134136. */
  134137. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  134138. min: Vector3;
  134139. max: Vector3;
  134140. distance: number;
  134141. }, doNotUpdateMaxZ?: boolean): void;
  134142. /**
  134143. * @override
  134144. * Override Camera.createRigCamera
  134145. */
  134146. createRigCamera(name: string, cameraIndex: number): Camera;
  134147. /**
  134148. * @hidden
  134149. * @override
  134150. * Override Camera._updateRigCameras
  134151. */
  134152. _updateRigCameras(): void;
  134153. /**
  134154. * Destroy the camera and release the current resources hold by it.
  134155. */
  134156. dispose(): void;
  134157. /**
  134158. * Gets the current object class name.
  134159. * @return the class name
  134160. */
  134161. getClassName(): string;
  134162. }
  134163. }
  134164. declare module BABYLON {
  134165. /**
  134166. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  134167. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  134168. */
  134169. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  134170. /**
  134171. * Gets the name of the behavior.
  134172. */
  134173. get name(): string;
  134174. private _zoomStopsAnimation;
  134175. private _idleRotationSpeed;
  134176. private _idleRotationWaitTime;
  134177. private _idleRotationSpinupTime;
  134178. /**
  134179. * Sets the flag that indicates if user zooming should stop animation.
  134180. */
  134181. set zoomStopsAnimation(flag: boolean);
  134182. /**
  134183. * Gets the flag that indicates if user zooming should stop animation.
  134184. */
  134185. get zoomStopsAnimation(): boolean;
  134186. /**
  134187. * Sets the default speed at which the camera rotates around the model.
  134188. */
  134189. set idleRotationSpeed(speed: number);
  134190. /**
  134191. * Gets the default speed at which the camera rotates around the model.
  134192. */
  134193. get idleRotationSpeed(): number;
  134194. /**
  134195. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  134196. */
  134197. set idleRotationWaitTime(time: number);
  134198. /**
  134199. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  134200. */
  134201. get idleRotationWaitTime(): number;
  134202. /**
  134203. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  134204. */
  134205. set idleRotationSpinupTime(time: number);
  134206. /**
  134207. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  134208. */
  134209. get idleRotationSpinupTime(): number;
  134210. /**
  134211. * Gets a value indicating if the camera is currently rotating because of this behavior
  134212. */
  134213. get rotationInProgress(): boolean;
  134214. private _onPrePointerObservableObserver;
  134215. private _onAfterCheckInputsObserver;
  134216. private _attachedCamera;
  134217. private _isPointerDown;
  134218. private _lastFrameTime;
  134219. private _lastInteractionTime;
  134220. private _cameraRotationSpeed;
  134221. /**
  134222. * Initializes the behavior.
  134223. */
  134224. init(): void;
  134225. /**
  134226. * Attaches the behavior to its arc rotate camera.
  134227. * @param camera Defines the camera to attach the behavior to
  134228. */
  134229. attach(camera: ArcRotateCamera): void;
  134230. /**
  134231. * Detaches the behavior from its current arc rotate camera.
  134232. */
  134233. detach(): void;
  134234. /**
  134235. * Returns true if user is scrolling.
  134236. * @return true if user is scrolling.
  134237. */
  134238. private _userIsZooming;
  134239. private _lastFrameRadius;
  134240. private _shouldAnimationStopForInteraction;
  134241. /**
  134242. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  134243. */
  134244. private _applyUserInteraction;
  134245. private _userIsMoving;
  134246. }
  134247. }
  134248. declare module BABYLON {
  134249. /**
  134250. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  134251. */
  134252. export class AttachToBoxBehavior implements Behavior<Mesh> {
  134253. private ui;
  134254. /**
  134255. * The name of the behavior
  134256. */
  134257. name: string;
  134258. /**
  134259. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  134260. */
  134261. distanceAwayFromFace: number;
  134262. /**
  134263. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  134264. */
  134265. distanceAwayFromBottomOfFace: number;
  134266. private _faceVectors;
  134267. private _target;
  134268. private _scene;
  134269. private _onRenderObserver;
  134270. private _tmpMatrix;
  134271. private _tmpVector;
  134272. /**
  134273. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  134274. * @param ui The transform node that should be attched to the mesh
  134275. */
  134276. constructor(ui: TransformNode);
  134277. /**
  134278. * Initializes the behavior
  134279. */
  134280. init(): void;
  134281. private _closestFace;
  134282. private _zeroVector;
  134283. private _lookAtTmpMatrix;
  134284. private _lookAtToRef;
  134285. /**
  134286. * Attaches the AttachToBoxBehavior to the passed in mesh
  134287. * @param target The mesh that the specified node will be attached to
  134288. */
  134289. attach(target: Mesh): void;
  134290. /**
  134291. * Detaches the behavior from the mesh
  134292. */
  134293. detach(): void;
  134294. }
  134295. }
  134296. declare module BABYLON {
  134297. /**
  134298. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  134299. */
  134300. export class FadeInOutBehavior implements Behavior<Mesh> {
  134301. /**
  134302. * Time in milliseconds to delay before fading in (Default: 0)
  134303. */
  134304. delay: number;
  134305. /**
  134306. * Time in milliseconds for the mesh to fade in (Default: 300)
  134307. */
  134308. fadeInTime: number;
  134309. private _millisecondsPerFrame;
  134310. private _hovered;
  134311. private _hoverValue;
  134312. private _ownerNode;
  134313. /**
  134314. * Instatiates the FadeInOutBehavior
  134315. */
  134316. constructor();
  134317. /**
  134318. * The name of the behavior
  134319. */
  134320. get name(): string;
  134321. /**
  134322. * Initializes the behavior
  134323. */
  134324. init(): void;
  134325. /**
  134326. * Attaches the fade behavior on the passed in mesh
  134327. * @param ownerNode The mesh that will be faded in/out once attached
  134328. */
  134329. attach(ownerNode: Mesh): void;
  134330. /**
  134331. * Detaches the behavior from the mesh
  134332. */
  134333. detach(): void;
  134334. /**
  134335. * Triggers the mesh to begin fading in or out
  134336. * @param value if the object should fade in or out (true to fade in)
  134337. */
  134338. fadeIn(value: boolean): void;
  134339. private _update;
  134340. private _setAllVisibility;
  134341. }
  134342. }
  134343. declare module BABYLON {
  134344. /**
  134345. * Class containing a set of static utilities functions for managing Pivots
  134346. * @hidden
  134347. */
  134348. export class PivotTools {
  134349. private static _PivotCached;
  134350. private static _OldPivotPoint;
  134351. private static _PivotTranslation;
  134352. private static _PivotTmpVector;
  134353. private static _PivotPostMultiplyPivotMatrix;
  134354. /** @hidden */
  134355. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  134356. /** @hidden */
  134357. static _RestorePivotPoint(mesh: AbstractMesh): void;
  134358. }
  134359. }
  134360. declare module BABYLON {
  134361. /**
  134362. * Class containing static functions to help procedurally build meshes
  134363. */
  134364. export class PlaneBuilder {
  134365. /**
  134366. * Creates a plane mesh
  134367. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  134368. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  134369. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  134370. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134371. * * 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
  134372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134373. * @param name defines the name of the mesh
  134374. * @param options defines the options used to create the mesh
  134375. * @param scene defines the hosting scene
  134376. * @returns the plane mesh
  134377. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  134378. */
  134379. static CreatePlane(name: string, options: {
  134380. size?: number;
  134381. width?: number;
  134382. height?: number;
  134383. sideOrientation?: number;
  134384. frontUVs?: Vector4;
  134385. backUVs?: Vector4;
  134386. updatable?: boolean;
  134387. sourcePlane?: Plane;
  134388. }, scene?: Nullable<Scene>): Mesh;
  134389. }
  134390. }
  134391. declare module BABYLON {
  134392. /**
  134393. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  134394. */
  134395. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  134396. private static _AnyMouseID;
  134397. /**
  134398. * Abstract mesh the behavior is set on
  134399. */
  134400. attachedNode: AbstractMesh;
  134401. private _dragPlane;
  134402. private _scene;
  134403. private _pointerObserver;
  134404. private _beforeRenderObserver;
  134405. private static _planeScene;
  134406. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  134407. /**
  134408. * 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)
  134409. */
  134410. maxDragAngle: number;
  134411. /**
  134412. * @hidden
  134413. */
  134414. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  134415. /**
  134416. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  134417. */
  134418. currentDraggingPointerID: number;
  134419. /**
  134420. * The last position where the pointer hit the drag plane in world space
  134421. */
  134422. lastDragPosition: Vector3;
  134423. /**
  134424. * If the behavior is currently in a dragging state
  134425. */
  134426. dragging: boolean;
  134427. /**
  134428. * 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)
  134429. */
  134430. dragDeltaRatio: number;
  134431. /**
  134432. * If the drag plane orientation should be updated during the dragging (Default: true)
  134433. */
  134434. updateDragPlane: boolean;
  134435. private _debugMode;
  134436. private _moving;
  134437. /**
  134438. * Fires each time the attached mesh is dragged with the pointer
  134439. * * delta between last drag position and current drag position in world space
  134440. * * dragDistance along the drag axis
  134441. * * dragPlaneNormal normal of the current drag plane used during the drag
  134442. * * dragPlanePoint in world space where the drag intersects the drag plane
  134443. */
  134444. onDragObservable: Observable<{
  134445. delta: Vector3;
  134446. dragPlanePoint: Vector3;
  134447. dragPlaneNormal: Vector3;
  134448. dragDistance: number;
  134449. pointerId: number;
  134450. }>;
  134451. /**
  134452. * Fires each time a drag begins (eg. mouse down on mesh)
  134453. */
  134454. onDragStartObservable: Observable<{
  134455. dragPlanePoint: Vector3;
  134456. pointerId: number;
  134457. }>;
  134458. /**
  134459. * Fires each time a drag ends (eg. mouse release after drag)
  134460. */
  134461. onDragEndObservable: Observable<{
  134462. dragPlanePoint: Vector3;
  134463. pointerId: number;
  134464. }>;
  134465. /**
  134466. * If the attached mesh should be moved when dragged
  134467. */
  134468. moveAttached: boolean;
  134469. /**
  134470. * If the drag behavior will react to drag events (Default: true)
  134471. */
  134472. enabled: boolean;
  134473. /**
  134474. * If pointer events should start and release the drag (Default: true)
  134475. */
  134476. startAndReleaseDragOnPointerEvents: boolean;
  134477. /**
  134478. * If camera controls should be detached during the drag
  134479. */
  134480. detachCameraControls: boolean;
  134481. /**
  134482. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  134483. */
  134484. useObjectOrientationForDragging: boolean;
  134485. private _options;
  134486. /**
  134487. * Gets the options used by the behavior
  134488. */
  134489. get options(): {
  134490. dragAxis?: Vector3;
  134491. dragPlaneNormal?: Vector3;
  134492. };
  134493. /**
  134494. * Sets the options used by the behavior
  134495. */
  134496. set options(options: {
  134497. dragAxis?: Vector3;
  134498. dragPlaneNormal?: Vector3;
  134499. });
  134500. /**
  134501. * Creates a pointer drag behavior that can be attached to a mesh
  134502. * @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)
  134503. */
  134504. constructor(options?: {
  134505. dragAxis?: Vector3;
  134506. dragPlaneNormal?: Vector3;
  134507. });
  134508. /**
  134509. * Predicate to determine if it is valid to move the object to a new position when it is moved
  134510. */
  134511. validateDrag: (targetPosition: Vector3) => boolean;
  134512. /**
  134513. * The name of the behavior
  134514. */
  134515. get name(): string;
  134516. /**
  134517. * Initializes the behavior
  134518. */
  134519. init(): void;
  134520. private _tmpVector;
  134521. private _alternatePickedPoint;
  134522. private _worldDragAxis;
  134523. private _targetPosition;
  134524. private _attachedToElement;
  134525. /**
  134526. * Attaches the drag behavior the passed in mesh
  134527. * @param ownerNode The mesh that will be dragged around once attached
  134528. * @param predicate Predicate to use for pick filtering
  134529. */
  134530. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  134531. /**
  134532. * Force relase the drag action by code.
  134533. */
  134534. releaseDrag(): void;
  134535. private _startDragRay;
  134536. private _lastPointerRay;
  134537. /**
  134538. * Simulates the start of a pointer drag event on the behavior
  134539. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  134540. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  134541. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  134542. */
  134543. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  134544. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  134545. private _dragDelta;
  134546. protected _moveDrag(ray: Ray): void;
  134547. private _pickWithRayOnDragPlane;
  134548. private _pointA;
  134549. private _pointC;
  134550. private _localAxis;
  134551. private _lookAt;
  134552. private _updateDragPlanePosition;
  134553. /**
  134554. * Detaches the behavior from the mesh
  134555. */
  134556. detach(): void;
  134557. }
  134558. }
  134559. declare module BABYLON {
  134560. /**
  134561. * A behavior that when attached to a mesh will allow the mesh to be scaled
  134562. */
  134563. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  134564. private _dragBehaviorA;
  134565. private _dragBehaviorB;
  134566. private _startDistance;
  134567. private _initialScale;
  134568. private _targetScale;
  134569. private _ownerNode;
  134570. private _sceneRenderObserver;
  134571. /**
  134572. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  134573. */
  134574. constructor();
  134575. /**
  134576. * The name of the behavior
  134577. */
  134578. get name(): string;
  134579. /**
  134580. * Initializes the behavior
  134581. */
  134582. init(): void;
  134583. private _getCurrentDistance;
  134584. /**
  134585. * Attaches the scale behavior the passed in mesh
  134586. * @param ownerNode The mesh that will be scaled around once attached
  134587. */
  134588. attach(ownerNode: Mesh): void;
  134589. /**
  134590. * Detaches the behavior from the mesh
  134591. */
  134592. detach(): void;
  134593. }
  134594. }
  134595. declare module BABYLON {
  134596. /**
  134597. * 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
  134598. */
  134599. export class SixDofDragBehavior implements Behavior<Mesh> {
  134600. private static _virtualScene;
  134601. private _ownerNode;
  134602. private _sceneRenderObserver;
  134603. private _scene;
  134604. private _targetPosition;
  134605. private _virtualOriginMesh;
  134606. private _virtualDragMesh;
  134607. private _pointerObserver;
  134608. private _moving;
  134609. private _startingOrientation;
  134610. private _attachedToElement;
  134611. /**
  134612. * 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)
  134613. */
  134614. private zDragFactor;
  134615. /**
  134616. * If the object should rotate to face the drag origin
  134617. */
  134618. rotateDraggedObject: boolean;
  134619. /**
  134620. * If the behavior is currently in a dragging state
  134621. */
  134622. dragging: boolean;
  134623. /**
  134624. * 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)
  134625. */
  134626. dragDeltaRatio: number;
  134627. /**
  134628. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  134629. */
  134630. currentDraggingPointerID: number;
  134631. /**
  134632. * If camera controls should be detached during the drag
  134633. */
  134634. detachCameraControls: boolean;
  134635. /**
  134636. * Fires each time a drag starts
  134637. */
  134638. onDragStartObservable: Observable<{}>;
  134639. /**
  134640. * Fires each time a drag happens
  134641. */
  134642. onDragObservable: Observable<void>;
  134643. /**
  134644. * Fires each time a drag ends (eg. mouse release after drag)
  134645. */
  134646. onDragEndObservable: Observable<{}>;
  134647. /**
  134648. * 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
  134649. */
  134650. constructor();
  134651. /**
  134652. * The name of the behavior
  134653. */
  134654. get name(): string;
  134655. /**
  134656. * Initializes the behavior
  134657. */
  134658. init(): void;
  134659. /**
  134660. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  134661. */
  134662. private get _pointerCamera();
  134663. /**
  134664. * Attaches the scale behavior the passed in mesh
  134665. * @param ownerNode The mesh that will be scaled around once attached
  134666. */
  134667. attach(ownerNode: Mesh): void;
  134668. /**
  134669. * Detaches the behavior from the mesh
  134670. */
  134671. detach(): void;
  134672. }
  134673. }
  134674. declare module BABYLON {
  134675. /**
  134676. * Class used to apply inverse kinematics to bones
  134677. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  134678. */
  134679. export class BoneIKController {
  134680. private static _tmpVecs;
  134681. private static _tmpQuat;
  134682. private static _tmpMats;
  134683. /**
  134684. * Gets or sets the target mesh
  134685. */
  134686. targetMesh: AbstractMesh;
  134687. /** Gets or sets the mesh used as pole */
  134688. poleTargetMesh: AbstractMesh;
  134689. /**
  134690. * Gets or sets the bone used as pole
  134691. */
  134692. poleTargetBone: Nullable<Bone>;
  134693. /**
  134694. * Gets or sets the target position
  134695. */
  134696. targetPosition: Vector3;
  134697. /**
  134698. * Gets or sets the pole target position
  134699. */
  134700. poleTargetPosition: Vector3;
  134701. /**
  134702. * Gets or sets the pole target local offset
  134703. */
  134704. poleTargetLocalOffset: Vector3;
  134705. /**
  134706. * Gets or sets the pole angle
  134707. */
  134708. poleAngle: number;
  134709. /**
  134710. * Gets or sets the mesh associated with the controller
  134711. */
  134712. mesh: AbstractMesh;
  134713. /**
  134714. * 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)
  134715. */
  134716. slerpAmount: number;
  134717. private _bone1Quat;
  134718. private _bone1Mat;
  134719. private _bone2Ang;
  134720. private _bone1;
  134721. private _bone2;
  134722. private _bone1Length;
  134723. private _bone2Length;
  134724. private _maxAngle;
  134725. private _maxReach;
  134726. private _rightHandedSystem;
  134727. private _bendAxis;
  134728. private _slerping;
  134729. private _adjustRoll;
  134730. /**
  134731. * Gets or sets maximum allowed angle
  134732. */
  134733. get maxAngle(): number;
  134734. set maxAngle(value: number);
  134735. /**
  134736. * Creates a new BoneIKController
  134737. * @param mesh defines the mesh to control
  134738. * @param bone defines the bone to control
  134739. * @param options defines options to set up the controller
  134740. */
  134741. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  134742. targetMesh?: AbstractMesh;
  134743. poleTargetMesh?: AbstractMesh;
  134744. poleTargetBone?: Bone;
  134745. poleTargetLocalOffset?: Vector3;
  134746. poleAngle?: number;
  134747. bendAxis?: Vector3;
  134748. maxAngle?: number;
  134749. slerpAmount?: number;
  134750. });
  134751. private _setMaxAngle;
  134752. /**
  134753. * Force the controller to update the bones
  134754. */
  134755. update(): void;
  134756. }
  134757. }
  134758. declare module BABYLON {
  134759. /**
  134760. * Class used to make a bone look toward a point in space
  134761. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  134762. */
  134763. export class BoneLookController {
  134764. private static _tmpVecs;
  134765. private static _tmpQuat;
  134766. private static _tmpMats;
  134767. /**
  134768. * The target Vector3 that the bone will look at
  134769. */
  134770. target: Vector3;
  134771. /**
  134772. * The mesh that the bone is attached to
  134773. */
  134774. mesh: AbstractMesh;
  134775. /**
  134776. * The bone that will be looking to the target
  134777. */
  134778. bone: Bone;
  134779. /**
  134780. * The up axis of the coordinate system that is used when the bone is rotated
  134781. */
  134782. upAxis: Vector3;
  134783. /**
  134784. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  134785. */
  134786. upAxisSpace: Space;
  134787. /**
  134788. * Used to make an adjustment to the yaw of the bone
  134789. */
  134790. adjustYaw: number;
  134791. /**
  134792. * Used to make an adjustment to the pitch of the bone
  134793. */
  134794. adjustPitch: number;
  134795. /**
  134796. * Used to make an adjustment to the roll of the bone
  134797. */
  134798. adjustRoll: number;
  134799. /**
  134800. * 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)
  134801. */
  134802. slerpAmount: number;
  134803. private _minYaw;
  134804. private _maxYaw;
  134805. private _minPitch;
  134806. private _maxPitch;
  134807. private _minYawSin;
  134808. private _minYawCos;
  134809. private _maxYawSin;
  134810. private _maxYawCos;
  134811. private _midYawConstraint;
  134812. private _minPitchTan;
  134813. private _maxPitchTan;
  134814. private _boneQuat;
  134815. private _slerping;
  134816. private _transformYawPitch;
  134817. private _transformYawPitchInv;
  134818. private _firstFrameSkipped;
  134819. private _yawRange;
  134820. private _fowardAxis;
  134821. /**
  134822. * Gets or sets the minimum yaw angle that the bone can look to
  134823. */
  134824. get minYaw(): number;
  134825. set minYaw(value: number);
  134826. /**
  134827. * Gets or sets the maximum yaw angle that the bone can look to
  134828. */
  134829. get maxYaw(): number;
  134830. set maxYaw(value: number);
  134831. /**
  134832. * Gets or sets the minimum pitch angle that the bone can look to
  134833. */
  134834. get minPitch(): number;
  134835. set minPitch(value: number);
  134836. /**
  134837. * Gets or sets the maximum pitch angle that the bone can look to
  134838. */
  134839. get maxPitch(): number;
  134840. set maxPitch(value: number);
  134841. /**
  134842. * Create a BoneLookController
  134843. * @param mesh the mesh that the bone belongs to
  134844. * @param bone the bone that will be looking to the target
  134845. * @param target the target Vector3 to look at
  134846. * @param options optional settings:
  134847. * * maxYaw: the maximum angle the bone will yaw to
  134848. * * minYaw: the minimum angle the bone will yaw to
  134849. * * maxPitch: the maximum angle the bone will pitch to
  134850. * * minPitch: the minimum angle the bone will yaw to
  134851. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  134852. * * upAxis: the up axis of the coordinate system
  134853. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  134854. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  134855. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  134856. * * adjustYaw: used to make an adjustment to the yaw of the bone
  134857. * * adjustPitch: used to make an adjustment to the pitch of the bone
  134858. * * adjustRoll: used to make an adjustment to the roll of the bone
  134859. **/
  134860. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  134861. maxYaw?: number;
  134862. minYaw?: number;
  134863. maxPitch?: number;
  134864. minPitch?: number;
  134865. slerpAmount?: number;
  134866. upAxis?: Vector3;
  134867. upAxisSpace?: Space;
  134868. yawAxis?: Vector3;
  134869. pitchAxis?: Vector3;
  134870. adjustYaw?: number;
  134871. adjustPitch?: number;
  134872. adjustRoll?: number;
  134873. });
  134874. /**
  134875. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  134876. */
  134877. update(): void;
  134878. private _getAngleDiff;
  134879. private _getAngleBetween;
  134880. private _isAngleBetween;
  134881. }
  134882. }
  134883. declare module BABYLON {
  134884. /**
  134885. * Manage the gamepad inputs to control an arc rotate camera.
  134886. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  134887. */
  134888. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  134889. /**
  134890. * Defines the camera the input is attached to.
  134891. */
  134892. camera: ArcRotateCamera;
  134893. /**
  134894. * Defines the gamepad the input is gathering event from.
  134895. */
  134896. gamepad: Nullable<Gamepad>;
  134897. /**
  134898. * Defines the gamepad rotation sensiblity.
  134899. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  134900. */
  134901. gamepadRotationSensibility: number;
  134902. /**
  134903. * Defines the gamepad move sensiblity.
  134904. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  134905. */
  134906. gamepadMoveSensibility: number;
  134907. private _yAxisScale;
  134908. /**
  134909. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  134910. */
  134911. get invertYAxis(): boolean;
  134912. set invertYAxis(value: boolean);
  134913. private _onGamepadConnectedObserver;
  134914. private _onGamepadDisconnectedObserver;
  134915. /**
  134916. * Attach the input controls to a specific dom element to get the input from.
  134917. */
  134918. attachControl(): void;
  134919. /**
  134920. * Detach the current controls from the specified dom element.
  134921. */
  134922. detachControl(): void;
  134923. /**
  134924. * Update the current camera state depending on the inputs that have been used this frame.
  134925. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  134926. */
  134927. checkInputs(): void;
  134928. /**
  134929. * Gets the class name of the current intput.
  134930. * @returns the class name
  134931. */
  134932. getClassName(): string;
  134933. /**
  134934. * Get the friendly name associated with the input class.
  134935. * @returns the input friendly name
  134936. */
  134937. getSimpleName(): string;
  134938. }
  134939. }
  134940. declare module BABYLON {
  134941. interface ArcRotateCameraInputsManager {
  134942. /**
  134943. * Add orientation input support to the input manager.
  134944. * @returns the current input manager
  134945. */
  134946. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  134947. }
  134948. /**
  134949. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  134950. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  134951. */
  134952. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  134953. /**
  134954. * Defines the camera the input is attached to.
  134955. */
  134956. camera: ArcRotateCamera;
  134957. /**
  134958. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  134959. */
  134960. alphaCorrection: number;
  134961. /**
  134962. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  134963. */
  134964. gammaCorrection: number;
  134965. private _alpha;
  134966. private _gamma;
  134967. private _dirty;
  134968. private _deviceOrientationHandler;
  134969. /**
  134970. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  134971. */
  134972. constructor();
  134973. /**
  134974. * Attach the input controls to a specific dom element to get the input from.
  134975. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  134976. */
  134977. attachControl(noPreventDefault?: boolean): void;
  134978. /** @hidden */
  134979. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  134980. /**
  134981. * Update the current camera state depending on the inputs that have been used this frame.
  134982. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  134983. */
  134984. checkInputs(): void;
  134985. /**
  134986. * Detach the current controls from the specified dom element.
  134987. */
  134988. detachControl(): void;
  134989. /**
  134990. * Gets the class name of the current intput.
  134991. * @returns the class name
  134992. */
  134993. getClassName(): string;
  134994. /**
  134995. * Get the friendly name associated with the input class.
  134996. * @returns the input friendly name
  134997. */
  134998. getSimpleName(): string;
  134999. }
  135000. }
  135001. declare module BABYLON {
  135002. /**
  135003. * Listen to mouse events to control the camera.
  135004. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  135005. */
  135006. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  135007. /**
  135008. * Defines the camera the input is attached to.
  135009. */
  135010. camera: FlyCamera;
  135011. /**
  135012. * Defines if touch is enabled. (Default is true.)
  135013. */
  135014. touchEnabled: boolean;
  135015. /**
  135016. * Defines the buttons associated with the input to handle camera rotation.
  135017. */
  135018. buttons: number[];
  135019. /**
  135020. * Assign buttons for Yaw control.
  135021. */
  135022. buttonsYaw: number[];
  135023. /**
  135024. * Assign buttons for Pitch control.
  135025. */
  135026. buttonsPitch: number[];
  135027. /**
  135028. * Assign buttons for Roll control.
  135029. */
  135030. buttonsRoll: number[];
  135031. /**
  135032. * Detect if any button is being pressed while mouse is moved.
  135033. * -1 = Mouse locked.
  135034. * 0 = Left button.
  135035. * 1 = Middle Button.
  135036. * 2 = Right Button.
  135037. */
  135038. activeButton: number;
  135039. /**
  135040. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  135041. * Higher values reduce its sensitivity.
  135042. */
  135043. angularSensibility: number;
  135044. private _observer;
  135045. private _rollObserver;
  135046. private previousPosition;
  135047. private noPreventDefault;
  135048. private element;
  135049. /**
  135050. * Listen to mouse events to control the camera.
  135051. * @param touchEnabled Define if touch is enabled. (Default is true.)
  135052. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  135053. */
  135054. constructor(touchEnabled?: boolean);
  135055. /**
  135056. * Attach the mouse control to the HTML DOM element.
  135057. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  135058. */
  135059. attachControl(noPreventDefault?: boolean): void;
  135060. /**
  135061. * Detach the current controls from the specified dom element.
  135062. */
  135063. detachControl(): void;
  135064. /**
  135065. * Gets the class name of the current input.
  135066. * @returns the class name.
  135067. */
  135068. getClassName(): string;
  135069. /**
  135070. * Get the friendly name associated with the input class.
  135071. * @returns the input's friendly name.
  135072. */
  135073. getSimpleName(): string;
  135074. private _pointerInput;
  135075. private _onMouseMove;
  135076. /**
  135077. * Rotate camera by mouse offset.
  135078. */
  135079. private rotateCamera;
  135080. }
  135081. }
  135082. declare module BABYLON {
  135083. /**
  135084. * Default Inputs manager for the FlyCamera.
  135085. * It groups all the default supported inputs for ease of use.
  135086. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  135087. */
  135088. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  135089. /**
  135090. * Instantiates a new FlyCameraInputsManager.
  135091. * @param camera Defines the camera the inputs belong to.
  135092. */
  135093. constructor(camera: FlyCamera);
  135094. /**
  135095. * Add keyboard input support to the input manager.
  135096. * @returns the new FlyCameraKeyboardMoveInput().
  135097. */
  135098. addKeyboard(): FlyCameraInputsManager;
  135099. /**
  135100. * Add mouse input support to the input manager.
  135101. * @param touchEnabled Enable touch screen support.
  135102. * @returns the new FlyCameraMouseInput().
  135103. */
  135104. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  135105. }
  135106. }
  135107. declare module BABYLON {
  135108. /**
  135109. * This is a flying camera, designed for 3D movement and rotation in all directions,
  135110. * such as in a 3D Space Shooter or a Flight Simulator.
  135111. */
  135112. export class FlyCamera extends TargetCamera {
  135113. /**
  135114. * Define the collision ellipsoid of the camera.
  135115. * This is helpful for simulating a camera body, like a player's body.
  135116. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  135117. */
  135118. ellipsoid: Vector3;
  135119. /**
  135120. * Define an offset for the position of the ellipsoid around the camera.
  135121. * This can be helpful if the camera is attached away from the player's body center,
  135122. * such as at its head.
  135123. */
  135124. ellipsoidOffset: Vector3;
  135125. /**
  135126. * Enable or disable collisions of the camera with the rest of the scene objects.
  135127. */
  135128. checkCollisions: boolean;
  135129. /**
  135130. * Enable or disable gravity on the camera.
  135131. */
  135132. applyGravity: boolean;
  135133. /**
  135134. * Define the current direction the camera is moving to.
  135135. */
  135136. cameraDirection: Vector3;
  135137. /**
  135138. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  135139. * This overrides and empties cameraRotation.
  135140. */
  135141. rotationQuaternion: Quaternion;
  135142. /**
  135143. * Track Roll to maintain the wanted Rolling when looking around.
  135144. */
  135145. _trackRoll: number;
  135146. /**
  135147. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  135148. */
  135149. rollCorrect: number;
  135150. /**
  135151. * Mimic a banked turn, Rolling the camera when Yawing.
  135152. * It's recommended to use rollCorrect = 10 for faster banking correction.
  135153. */
  135154. bankedTurn: boolean;
  135155. /**
  135156. * Limit in radians for how much Roll banking will add. (Default: 90°)
  135157. */
  135158. bankedTurnLimit: number;
  135159. /**
  135160. * Value of 0 disables the banked Roll.
  135161. * Value of 1 is equal to the Yaw angle in radians.
  135162. */
  135163. bankedTurnMultiplier: number;
  135164. /**
  135165. * The inputs manager loads all the input sources, such as keyboard and mouse.
  135166. */
  135167. inputs: FlyCameraInputsManager;
  135168. /**
  135169. * Gets the input sensibility for mouse input.
  135170. * Higher values reduce sensitivity.
  135171. */
  135172. get angularSensibility(): number;
  135173. /**
  135174. * Sets the input sensibility for a mouse input.
  135175. * Higher values reduce sensitivity.
  135176. */
  135177. set angularSensibility(value: number);
  135178. /**
  135179. * Get the keys for camera movement forward.
  135180. */
  135181. get keysForward(): number[];
  135182. /**
  135183. * Set the keys for camera movement forward.
  135184. */
  135185. set keysForward(value: number[]);
  135186. /**
  135187. * Get the keys for camera movement backward.
  135188. */
  135189. get keysBackward(): number[];
  135190. set keysBackward(value: number[]);
  135191. /**
  135192. * Get the keys for camera movement up.
  135193. */
  135194. get keysUp(): number[];
  135195. /**
  135196. * Set the keys for camera movement up.
  135197. */
  135198. set keysUp(value: number[]);
  135199. /**
  135200. * Get the keys for camera movement down.
  135201. */
  135202. get keysDown(): number[];
  135203. /**
  135204. * Set the keys for camera movement down.
  135205. */
  135206. set keysDown(value: number[]);
  135207. /**
  135208. * Get the keys for camera movement left.
  135209. */
  135210. get keysLeft(): number[];
  135211. /**
  135212. * Set the keys for camera movement left.
  135213. */
  135214. set keysLeft(value: number[]);
  135215. /**
  135216. * Set the keys for camera movement right.
  135217. */
  135218. get keysRight(): number[];
  135219. /**
  135220. * Set the keys for camera movement right.
  135221. */
  135222. set keysRight(value: number[]);
  135223. /**
  135224. * Event raised when the camera collides with a mesh in the scene.
  135225. */
  135226. onCollide: (collidedMesh: AbstractMesh) => void;
  135227. private _collider;
  135228. private _needMoveForGravity;
  135229. private _oldPosition;
  135230. private _diffPosition;
  135231. private _newPosition;
  135232. /** @hidden */
  135233. _localDirection: Vector3;
  135234. /** @hidden */
  135235. _transformedDirection: Vector3;
  135236. /**
  135237. * Instantiates a FlyCamera.
  135238. * This is a flying camera, designed for 3D movement and rotation in all directions,
  135239. * such as in a 3D Space Shooter or a Flight Simulator.
  135240. * @param name Define the name of the camera in the scene.
  135241. * @param position Define the starting position of the camera in the scene.
  135242. * @param scene Define the scene the camera belongs to.
  135243. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  135244. */
  135245. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  135246. /**
  135247. * Attach the input controls to a specific dom element to get the input from.
  135248. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  135249. */
  135250. attachControl(noPreventDefault?: boolean): void;
  135251. /**
  135252. * Detach a control from the HTML DOM element.
  135253. * The camera will stop reacting to that input.
  135254. */
  135255. detachControl(): void;
  135256. private _collisionMask;
  135257. /**
  135258. * Get the mask that the camera ignores in collision events.
  135259. */
  135260. get collisionMask(): number;
  135261. /**
  135262. * Set the mask that the camera ignores in collision events.
  135263. */
  135264. set collisionMask(mask: number);
  135265. /** @hidden */
  135266. _collideWithWorld(displacement: Vector3): void;
  135267. /** @hidden */
  135268. private _onCollisionPositionChange;
  135269. /** @hidden */
  135270. _checkInputs(): void;
  135271. /** @hidden */
  135272. _decideIfNeedsToMove(): boolean;
  135273. /** @hidden */
  135274. _updatePosition(): void;
  135275. /**
  135276. * Restore the Roll to its target value at the rate specified.
  135277. * @param rate - Higher means slower restoring.
  135278. * @hidden
  135279. */
  135280. restoreRoll(rate: number): void;
  135281. /**
  135282. * Destroy the camera and release the current resources held by it.
  135283. */
  135284. dispose(): void;
  135285. /**
  135286. * Get the current object class name.
  135287. * @returns the class name.
  135288. */
  135289. getClassName(): string;
  135290. }
  135291. }
  135292. declare module BABYLON {
  135293. /**
  135294. * Listen to keyboard events to control the camera.
  135295. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  135296. */
  135297. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  135298. /**
  135299. * Defines the camera the input is attached to.
  135300. */
  135301. camera: FlyCamera;
  135302. /**
  135303. * The list of keyboard keys used to control the forward move of the camera.
  135304. */
  135305. keysForward: number[];
  135306. /**
  135307. * The list of keyboard keys used to control the backward move of the camera.
  135308. */
  135309. keysBackward: number[];
  135310. /**
  135311. * The list of keyboard keys used to control the forward move of the camera.
  135312. */
  135313. keysUp: number[];
  135314. /**
  135315. * The list of keyboard keys used to control the backward move of the camera.
  135316. */
  135317. keysDown: number[];
  135318. /**
  135319. * The list of keyboard keys used to control the right strafe move of the camera.
  135320. */
  135321. keysRight: number[];
  135322. /**
  135323. * The list of keyboard keys used to control the left strafe move of the camera.
  135324. */
  135325. keysLeft: number[];
  135326. private _keys;
  135327. private _onCanvasBlurObserver;
  135328. private _onKeyboardObserver;
  135329. private _engine;
  135330. private _scene;
  135331. /**
  135332. * Attach the input controls to a specific dom element to get the input from.
  135333. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  135334. */
  135335. attachControl(noPreventDefault?: boolean): void;
  135336. /**
  135337. * Detach the current controls from the specified dom element.
  135338. */
  135339. detachControl(): void;
  135340. /**
  135341. * Gets the class name of the current intput.
  135342. * @returns the class name
  135343. */
  135344. getClassName(): string;
  135345. /** @hidden */
  135346. _onLostFocus(e: FocusEvent): void;
  135347. /**
  135348. * Get the friendly name associated with the input class.
  135349. * @returns the input friendly name
  135350. */
  135351. getSimpleName(): string;
  135352. /**
  135353. * Update the current camera state depending on the inputs that have been used this frame.
  135354. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  135355. */
  135356. checkInputs(): void;
  135357. }
  135358. }
  135359. declare module BABYLON {
  135360. /**
  135361. * Manage the mouse wheel inputs to control a follow camera.
  135362. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  135363. */
  135364. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  135365. /**
  135366. * Defines the camera the input is attached to.
  135367. */
  135368. camera: FollowCamera;
  135369. /**
  135370. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  135371. */
  135372. axisControlRadius: boolean;
  135373. /**
  135374. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  135375. */
  135376. axisControlHeight: boolean;
  135377. /**
  135378. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  135379. */
  135380. axisControlRotation: boolean;
  135381. /**
  135382. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  135383. * relation to mouseWheel events.
  135384. */
  135385. wheelPrecision: number;
  135386. /**
  135387. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  135388. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  135389. */
  135390. wheelDeltaPercentage: number;
  135391. private _wheel;
  135392. private _observer;
  135393. /**
  135394. * Attach the input controls to a specific dom element to get the input from.
  135395. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  135396. */
  135397. attachControl(noPreventDefault?: boolean): void;
  135398. /**
  135399. * Detach the current controls from the specified dom element.
  135400. */
  135401. detachControl(): void;
  135402. /**
  135403. * Gets the class name of the current intput.
  135404. * @returns the class name
  135405. */
  135406. getClassName(): string;
  135407. /**
  135408. * Get the friendly name associated with the input class.
  135409. * @returns the input friendly name
  135410. */
  135411. getSimpleName(): string;
  135412. }
  135413. }
  135414. declare module BABYLON {
  135415. /**
  135416. * Manage the pointers inputs to control an follow camera.
  135417. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  135418. */
  135419. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  135420. /**
  135421. * Defines the camera the input is attached to.
  135422. */
  135423. camera: FollowCamera;
  135424. /**
  135425. * Gets the class name of the current input.
  135426. * @returns the class name
  135427. */
  135428. getClassName(): string;
  135429. /**
  135430. * Defines the pointer angular sensibility along the X axis or how fast is
  135431. * the camera rotating.
  135432. * A negative number will reverse the axis direction.
  135433. */
  135434. angularSensibilityX: number;
  135435. /**
  135436. * Defines the pointer angular sensibility along the Y axis or how fast is
  135437. * the camera rotating.
  135438. * A negative number will reverse the axis direction.
  135439. */
  135440. angularSensibilityY: number;
  135441. /**
  135442. * Defines the pointer pinch precision or how fast is the camera zooming.
  135443. * A negative number will reverse the axis direction.
  135444. */
  135445. pinchPrecision: number;
  135446. /**
  135447. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  135448. * from 0.
  135449. * It defines the percentage of current camera.radius to use as delta when
  135450. * pinch zoom is used.
  135451. */
  135452. pinchDeltaPercentage: number;
  135453. /**
  135454. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  135455. */
  135456. axisXControlRadius: boolean;
  135457. /**
  135458. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  135459. */
  135460. axisXControlHeight: boolean;
  135461. /**
  135462. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  135463. */
  135464. axisXControlRotation: boolean;
  135465. /**
  135466. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  135467. */
  135468. axisYControlRadius: boolean;
  135469. /**
  135470. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  135471. */
  135472. axisYControlHeight: boolean;
  135473. /**
  135474. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  135475. */
  135476. axisYControlRotation: boolean;
  135477. /**
  135478. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  135479. */
  135480. axisPinchControlRadius: boolean;
  135481. /**
  135482. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  135483. */
  135484. axisPinchControlHeight: boolean;
  135485. /**
  135486. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  135487. */
  135488. axisPinchControlRotation: boolean;
  135489. /**
  135490. * Log error messages if basic misconfiguration has occurred.
  135491. */
  135492. warningEnable: boolean;
  135493. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  135494. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  135495. private _warningCounter;
  135496. private _warning;
  135497. }
  135498. }
  135499. declare module BABYLON {
  135500. /**
  135501. * Default Inputs manager for the FollowCamera.
  135502. * It groups all the default supported inputs for ease of use.
  135503. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  135504. */
  135505. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  135506. /**
  135507. * Instantiates a new FollowCameraInputsManager.
  135508. * @param camera Defines the camera the inputs belong to
  135509. */
  135510. constructor(camera: FollowCamera);
  135511. /**
  135512. * Add keyboard input support to the input manager.
  135513. * @returns the current input manager
  135514. */
  135515. addKeyboard(): FollowCameraInputsManager;
  135516. /**
  135517. * Add mouse wheel input support to the input manager.
  135518. * @returns the current input manager
  135519. */
  135520. addMouseWheel(): FollowCameraInputsManager;
  135521. /**
  135522. * Add pointers input support to the input manager.
  135523. * @returns the current input manager
  135524. */
  135525. addPointers(): FollowCameraInputsManager;
  135526. /**
  135527. * Add orientation input support to the input manager.
  135528. * @returns the current input manager
  135529. */
  135530. addVRDeviceOrientation(): FollowCameraInputsManager;
  135531. }
  135532. }
  135533. declare module BABYLON {
  135534. /**
  135535. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  135536. * an arc rotate version arcFollowCamera are available.
  135537. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  135538. */
  135539. export class FollowCamera extends TargetCamera {
  135540. /**
  135541. * Distance the follow camera should follow an object at
  135542. */
  135543. radius: number;
  135544. /**
  135545. * Minimum allowed distance of the camera to the axis of rotation
  135546. * (The camera can not get closer).
  135547. * This can help limiting how the Camera is able to move in the scene.
  135548. */
  135549. lowerRadiusLimit: Nullable<number>;
  135550. /**
  135551. * Maximum allowed distance of the camera to the axis of rotation
  135552. * (The camera can not get further).
  135553. * This can help limiting how the Camera is able to move in the scene.
  135554. */
  135555. upperRadiusLimit: Nullable<number>;
  135556. /**
  135557. * Define a rotation offset between the camera and the object it follows
  135558. */
  135559. rotationOffset: number;
  135560. /**
  135561. * Minimum allowed angle to camera position relative to target object.
  135562. * This can help limiting how the Camera is able to move in the scene.
  135563. */
  135564. lowerRotationOffsetLimit: Nullable<number>;
  135565. /**
  135566. * Maximum allowed angle to camera position relative to target object.
  135567. * This can help limiting how the Camera is able to move in the scene.
  135568. */
  135569. upperRotationOffsetLimit: Nullable<number>;
  135570. /**
  135571. * Define a height offset between the camera and the object it follows.
  135572. * It can help following an object from the top (like a car chaing a plane)
  135573. */
  135574. heightOffset: number;
  135575. /**
  135576. * Minimum allowed height of camera position relative to target object.
  135577. * This can help limiting how the Camera is able to move in the scene.
  135578. */
  135579. lowerHeightOffsetLimit: Nullable<number>;
  135580. /**
  135581. * Maximum allowed height of camera position relative to target object.
  135582. * This can help limiting how the Camera is able to move in the scene.
  135583. */
  135584. upperHeightOffsetLimit: Nullable<number>;
  135585. /**
  135586. * Define how fast the camera can accelerate to follow it s target.
  135587. */
  135588. cameraAcceleration: number;
  135589. /**
  135590. * Define the speed limit of the camera following an object.
  135591. */
  135592. maxCameraSpeed: number;
  135593. /**
  135594. * Define the target of the camera.
  135595. */
  135596. lockedTarget: Nullable<AbstractMesh>;
  135597. /**
  135598. * Defines the input associated with the camera.
  135599. */
  135600. inputs: FollowCameraInputsManager;
  135601. /**
  135602. * Instantiates the follow camera.
  135603. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  135604. * @param name Define the name of the camera in the scene
  135605. * @param position Define the position of the camera
  135606. * @param scene Define the scene the camera belong to
  135607. * @param lockedTarget Define the target of the camera
  135608. */
  135609. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  135610. private _follow;
  135611. /**
  135612. * Attach the input controls to a specific dom element to get the input from.
  135613. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  135614. */
  135615. attachControl(noPreventDefault?: boolean): void;
  135616. /**
  135617. * Detach the current controls from the specified dom element.
  135618. */
  135619. detachControl(): void;
  135620. /** @hidden */
  135621. _checkInputs(): void;
  135622. private _checkLimits;
  135623. /**
  135624. * Gets the camera class name.
  135625. * @returns the class name
  135626. */
  135627. getClassName(): string;
  135628. }
  135629. /**
  135630. * Arc Rotate version of the follow camera.
  135631. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  135632. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  135633. */
  135634. export class ArcFollowCamera extends TargetCamera {
  135635. /** The longitudinal angle of the camera */
  135636. alpha: number;
  135637. /** The latitudinal angle of the camera */
  135638. beta: number;
  135639. /** The radius of the camera from its target */
  135640. radius: number;
  135641. private _cartesianCoordinates;
  135642. /** Define the camera target (the mesh it should follow) */
  135643. private _meshTarget;
  135644. /**
  135645. * Instantiates a new ArcFollowCamera
  135646. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  135647. * @param name Define the name of the camera
  135648. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  135649. * @param beta Define the rotation angle of the camera around the elevation axis
  135650. * @param radius Define the radius of the camera from its target point
  135651. * @param target Define the target of the camera
  135652. * @param scene Define the scene the camera belongs to
  135653. */
  135654. constructor(name: string,
  135655. /** The longitudinal angle of the camera */
  135656. alpha: number,
  135657. /** The latitudinal angle of the camera */
  135658. beta: number,
  135659. /** The radius of the camera from its target */
  135660. radius: number,
  135661. /** Define the camera target (the mesh it should follow) */
  135662. target: Nullable<AbstractMesh>, scene: Scene);
  135663. private _follow;
  135664. /** @hidden */
  135665. _checkInputs(): void;
  135666. /**
  135667. * Returns the class name of the object.
  135668. * It is mostly used internally for serialization purposes.
  135669. */
  135670. getClassName(): string;
  135671. }
  135672. }
  135673. declare module BABYLON {
  135674. /**
  135675. * Manage the keyboard inputs to control the movement of a follow camera.
  135676. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  135677. */
  135678. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  135679. /**
  135680. * Defines the camera the input is attached to.
  135681. */
  135682. camera: FollowCamera;
  135683. /**
  135684. * Defines the list of key codes associated with the up action (increase heightOffset)
  135685. */
  135686. keysHeightOffsetIncr: number[];
  135687. /**
  135688. * Defines the list of key codes associated with the down action (decrease heightOffset)
  135689. */
  135690. keysHeightOffsetDecr: number[];
  135691. /**
  135692. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  135693. */
  135694. keysHeightOffsetModifierAlt: boolean;
  135695. /**
  135696. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  135697. */
  135698. keysHeightOffsetModifierCtrl: boolean;
  135699. /**
  135700. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  135701. */
  135702. keysHeightOffsetModifierShift: boolean;
  135703. /**
  135704. * Defines the list of key codes associated with the left action (increase rotationOffset)
  135705. */
  135706. keysRotationOffsetIncr: number[];
  135707. /**
  135708. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  135709. */
  135710. keysRotationOffsetDecr: number[];
  135711. /**
  135712. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  135713. */
  135714. keysRotationOffsetModifierAlt: boolean;
  135715. /**
  135716. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  135717. */
  135718. keysRotationOffsetModifierCtrl: boolean;
  135719. /**
  135720. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  135721. */
  135722. keysRotationOffsetModifierShift: boolean;
  135723. /**
  135724. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  135725. */
  135726. keysRadiusIncr: number[];
  135727. /**
  135728. * Defines the list of key codes associated with the zoom-out action (increase radius)
  135729. */
  135730. keysRadiusDecr: number[];
  135731. /**
  135732. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  135733. */
  135734. keysRadiusModifierAlt: boolean;
  135735. /**
  135736. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  135737. */
  135738. keysRadiusModifierCtrl: boolean;
  135739. /**
  135740. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  135741. */
  135742. keysRadiusModifierShift: boolean;
  135743. /**
  135744. * Defines the rate of change of heightOffset.
  135745. */
  135746. heightSensibility: number;
  135747. /**
  135748. * Defines the rate of change of rotationOffset.
  135749. */
  135750. rotationSensibility: number;
  135751. /**
  135752. * Defines the rate of change of radius.
  135753. */
  135754. radiusSensibility: number;
  135755. private _keys;
  135756. private _ctrlPressed;
  135757. private _altPressed;
  135758. private _shiftPressed;
  135759. private _onCanvasBlurObserver;
  135760. private _onKeyboardObserver;
  135761. private _engine;
  135762. private _scene;
  135763. /**
  135764. * Attach the input controls to a specific dom element to get the input from.
  135765. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  135766. */
  135767. attachControl(noPreventDefault?: boolean): void;
  135768. /**
  135769. * Detach the current controls from the specified dom element.
  135770. */
  135771. detachControl(): void;
  135772. /**
  135773. * Update the current camera state depending on the inputs that have been used this frame.
  135774. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  135775. */
  135776. checkInputs(): void;
  135777. /**
  135778. * Gets the class name of the current input.
  135779. * @returns the class name
  135780. */
  135781. getClassName(): string;
  135782. /**
  135783. * Get the friendly name associated with the input class.
  135784. * @returns the input friendly name
  135785. */
  135786. getSimpleName(): string;
  135787. /**
  135788. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  135789. * allow modification of the heightOffset value.
  135790. */
  135791. private _modifierHeightOffset;
  135792. /**
  135793. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  135794. * allow modification of the rotationOffset value.
  135795. */
  135796. private _modifierRotationOffset;
  135797. /**
  135798. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  135799. * allow modification of the radius value.
  135800. */
  135801. private _modifierRadius;
  135802. }
  135803. }
  135804. declare module BABYLON {
  135805. interface FreeCameraInputsManager {
  135806. /**
  135807. * @hidden
  135808. */
  135809. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  135810. /**
  135811. * Add orientation input support to the input manager.
  135812. * @returns the current input manager
  135813. */
  135814. addDeviceOrientation(): FreeCameraInputsManager;
  135815. }
  135816. /**
  135817. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  135818. * Screen rotation is taken into account.
  135819. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  135820. */
  135821. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  135822. private _camera;
  135823. private _screenOrientationAngle;
  135824. private _constantTranform;
  135825. private _screenQuaternion;
  135826. private _alpha;
  135827. private _beta;
  135828. private _gamma;
  135829. /**
  135830. * Can be used to detect if a device orientation sensor is available on a device
  135831. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  135832. * @returns a promise that will resolve on orientation change
  135833. */
  135834. static WaitForOrientationChangeAsync(timeout?: number): Promise<void>;
  135835. /**
  135836. * @hidden
  135837. */
  135838. _onDeviceOrientationChangedObservable: Observable<void>;
  135839. /**
  135840. * Instantiates a new input
  135841. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  135842. */
  135843. constructor();
  135844. /**
  135845. * Define the camera controlled by the input.
  135846. */
  135847. get camera(): FreeCamera;
  135848. set camera(camera: FreeCamera);
  135849. /**
  135850. * Attach the input controls to a specific dom element to get the input from.
  135851. */
  135852. attachControl(): void;
  135853. private _orientationChanged;
  135854. private _deviceOrientation;
  135855. /**
  135856. * Detach the current controls from the specified dom element.
  135857. */
  135858. detachControl(): void;
  135859. /**
  135860. * Update the current camera state depending on the inputs that have been used this frame.
  135861. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  135862. */
  135863. checkInputs(): void;
  135864. /**
  135865. * Gets the class name of the current intput.
  135866. * @returns the class name
  135867. */
  135868. getClassName(): string;
  135869. /**
  135870. * Get the friendly name associated with the input class.
  135871. * @returns the input friendly name
  135872. */
  135873. getSimpleName(): string;
  135874. }
  135875. }
  135876. declare module BABYLON {
  135877. /**
  135878. * Manage the gamepad inputs to control a free camera.
  135879. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  135880. */
  135881. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  135882. /**
  135883. * Define the camera the input is attached to.
  135884. */
  135885. camera: FreeCamera;
  135886. /**
  135887. * Define the Gamepad controlling the input
  135888. */
  135889. gamepad: Nullable<Gamepad>;
  135890. /**
  135891. * Defines the gamepad rotation sensiblity.
  135892. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  135893. */
  135894. gamepadAngularSensibility: number;
  135895. /**
  135896. * Defines the gamepad move sensiblity.
  135897. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  135898. */
  135899. gamepadMoveSensibility: number;
  135900. private _yAxisScale;
  135901. /**
  135902. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  135903. */
  135904. get invertYAxis(): boolean;
  135905. set invertYAxis(value: boolean);
  135906. private _onGamepadConnectedObserver;
  135907. private _onGamepadDisconnectedObserver;
  135908. private _cameraTransform;
  135909. private _deltaTransform;
  135910. private _vector3;
  135911. private _vector2;
  135912. /**
  135913. * Attach the input controls to a specific dom element to get the input from.
  135914. */
  135915. attachControl(): void;
  135916. /**
  135917. * Detach the current controls from the specified dom element.
  135918. */
  135919. detachControl(): void;
  135920. /**
  135921. * Update the current camera state depending on the inputs that have been used this frame.
  135922. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  135923. */
  135924. checkInputs(): void;
  135925. /**
  135926. * Gets the class name of the current intput.
  135927. * @returns the class name
  135928. */
  135929. getClassName(): string;
  135930. /**
  135931. * Get the friendly name associated with the input class.
  135932. * @returns the input friendly name
  135933. */
  135934. getSimpleName(): string;
  135935. }
  135936. }
  135937. declare module BABYLON {
  135938. /**
  135939. * Defines the potential axis of a Joystick
  135940. */
  135941. export enum JoystickAxis {
  135942. /** X axis */
  135943. X = 0,
  135944. /** Y axis */
  135945. Y = 1,
  135946. /** Z axis */
  135947. Z = 2
  135948. }
  135949. /**
  135950. * Represents the different customization options available
  135951. * for VirtualJoystick
  135952. */
  135953. interface VirtualJoystickCustomizations {
  135954. /**
  135955. * Size of the joystick's puck
  135956. */
  135957. puckSize: number;
  135958. /**
  135959. * Size of the joystick's container
  135960. */
  135961. containerSize: number;
  135962. /**
  135963. * Color of the joystick && puck
  135964. */
  135965. color: string;
  135966. /**
  135967. * Image URL for the joystick's puck
  135968. */
  135969. puckImage?: string;
  135970. /**
  135971. * Image URL for the joystick's container
  135972. */
  135973. containerImage?: string;
  135974. /**
  135975. * Defines the unmoving position of the joystick container
  135976. */
  135977. position?: {
  135978. x: number;
  135979. y: number;
  135980. };
  135981. /**
  135982. * Defines whether or not the joystick container is always visible
  135983. */
  135984. alwaysVisible: boolean;
  135985. /**
  135986. * Defines whether or not to limit the movement of the puck to the joystick's container
  135987. */
  135988. limitToContainer: boolean;
  135989. }
  135990. /**
  135991. * Class used to define virtual joystick (used in touch mode)
  135992. */
  135993. export class VirtualJoystick {
  135994. /**
  135995. * Gets or sets a boolean indicating that left and right values must be inverted
  135996. */
  135997. reverseLeftRight: boolean;
  135998. /**
  135999. * Gets or sets a boolean indicating that up and down values must be inverted
  136000. */
  136001. reverseUpDown: boolean;
  136002. /**
  136003. * Gets the offset value for the position (ie. the change of the position value)
  136004. */
  136005. deltaPosition: Vector3;
  136006. /**
  136007. * Gets a boolean indicating if the virtual joystick was pressed
  136008. */
  136009. pressed: boolean;
  136010. /**
  136011. * Canvas the virtual joystick will render onto, default z-index of this is 5
  136012. */
  136013. static Canvas: Nullable<HTMLCanvasElement>;
  136014. /**
  136015. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  136016. */
  136017. limitToContainer: boolean;
  136018. private static _globalJoystickIndex;
  136019. private static _alwaysVisibleSticks;
  136020. private static vjCanvasContext;
  136021. private static vjCanvasWidth;
  136022. private static vjCanvasHeight;
  136023. private static halfWidth;
  136024. private static _GetDefaultOptions;
  136025. private _action;
  136026. private _axisTargetedByLeftAndRight;
  136027. private _axisTargetedByUpAndDown;
  136028. private _joystickSensibility;
  136029. private _inversedSensibility;
  136030. private _joystickPointerID;
  136031. private _joystickColor;
  136032. private _joystickPointerPos;
  136033. private _joystickPreviousPointerPos;
  136034. private _joystickPointerStartPos;
  136035. private _deltaJoystickVector;
  136036. private _leftJoystick;
  136037. private _touches;
  136038. private _joystickPosition;
  136039. private _alwaysVisible;
  136040. private _puckImage;
  136041. private _containerImage;
  136042. private _joystickPuckSize;
  136043. private _joystickContainerSize;
  136044. private _clearPuckSize;
  136045. private _clearContainerSize;
  136046. private _clearPuckSizeOffset;
  136047. private _clearContainerSizeOffset;
  136048. private _onPointerDownHandlerRef;
  136049. private _onPointerMoveHandlerRef;
  136050. private _onPointerUpHandlerRef;
  136051. private _onResize;
  136052. /**
  136053. * Creates a new virtual joystick
  136054. * @param leftJoystick defines that the joystick is for left hand (false by default)
  136055. * @param customizations Defines the options we want to customize the VirtualJoystick
  136056. */
  136057. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  136058. /**
  136059. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  136060. * @param newJoystickSensibility defines the new sensibility
  136061. */
  136062. setJoystickSensibility(newJoystickSensibility: number): void;
  136063. private _onPointerDown;
  136064. private _onPointerMove;
  136065. private _onPointerUp;
  136066. /**
  136067. * Change the color of the virtual joystick
  136068. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  136069. */
  136070. setJoystickColor(newColor: string): void;
  136071. /**
  136072. * Size of the joystick's container
  136073. */
  136074. set containerSize(newSize: number);
  136075. get containerSize(): number;
  136076. /**
  136077. * Size of the joystick's puck
  136078. */
  136079. set puckSize(newSize: number);
  136080. get puckSize(): number;
  136081. /**
  136082. * Clears the set position of the joystick
  136083. */
  136084. clearPosition(): void;
  136085. /**
  136086. * Defines whether or not the joystick container is always visible
  136087. */
  136088. set alwaysVisible(value: boolean);
  136089. get alwaysVisible(): boolean;
  136090. /**
  136091. * Sets the constant position of the Joystick container
  136092. * @param x X axis coordinate
  136093. * @param y Y axis coordinate
  136094. */
  136095. setPosition(x: number, y: number): void;
  136096. /**
  136097. * Defines a callback to call when the joystick is touched
  136098. * @param action defines the callback
  136099. */
  136100. setActionOnTouch(action: () => any): void;
  136101. /**
  136102. * Defines which axis you'd like to control for left & right
  136103. * @param axis defines the axis to use
  136104. */
  136105. setAxisForLeftRight(axis: JoystickAxis): void;
  136106. /**
  136107. * Defines which axis you'd like to control for up & down
  136108. * @param axis defines the axis to use
  136109. */
  136110. setAxisForUpDown(axis: JoystickAxis): void;
  136111. /**
  136112. * Clears the canvas from the previous puck / container draw
  136113. */
  136114. private _clearPreviousDraw;
  136115. /**
  136116. * Loads `urlPath` to be used for the container's image
  136117. * @param urlPath defines the urlPath of an image to use
  136118. */
  136119. setContainerImage(urlPath: string): void;
  136120. /**
  136121. * Loads `urlPath` to be used for the puck's image
  136122. * @param urlPath defines the urlPath of an image to use
  136123. */
  136124. setPuckImage(urlPath: string): void;
  136125. /**
  136126. * Draws the Virtual Joystick's container
  136127. */
  136128. private _drawContainer;
  136129. /**
  136130. * Draws the Virtual Joystick's puck
  136131. */
  136132. private _drawPuck;
  136133. private _drawVirtualJoystick;
  136134. /**
  136135. * Release internal HTML canvas
  136136. */
  136137. releaseCanvas(): void;
  136138. }
  136139. }
  136140. declare module BABYLON {
  136141. interface FreeCameraInputsManager {
  136142. /**
  136143. * Add virtual joystick input support to the input manager.
  136144. * @returns the current input manager
  136145. */
  136146. addVirtualJoystick(): FreeCameraInputsManager;
  136147. }
  136148. /**
  136149. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  136150. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  136151. */
  136152. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  136153. /**
  136154. * Defines the camera the input is attached to.
  136155. */
  136156. camera: FreeCamera;
  136157. private _leftjoystick;
  136158. private _rightjoystick;
  136159. /**
  136160. * Gets the left stick of the virtual joystick.
  136161. * @returns The virtual Joystick
  136162. */
  136163. getLeftJoystick(): VirtualJoystick;
  136164. /**
  136165. * Gets the right stick of the virtual joystick.
  136166. * @returns The virtual Joystick
  136167. */
  136168. getRightJoystick(): VirtualJoystick;
  136169. /**
  136170. * Update the current camera state depending on the inputs that have been used this frame.
  136171. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  136172. */
  136173. checkInputs(): void;
  136174. /**
  136175. * Attach the input controls to a specific dom element to get the input from.
  136176. */
  136177. attachControl(): void;
  136178. /**
  136179. * Detach the current controls from the specified dom element.
  136180. */
  136181. detachControl(): void;
  136182. /**
  136183. * Gets the class name of the current intput.
  136184. * @returns the class name
  136185. */
  136186. getClassName(): string;
  136187. /**
  136188. * Get the friendly name associated with the input class.
  136189. * @returns the input friendly name
  136190. */
  136191. getSimpleName(): string;
  136192. }
  136193. }
  136194. declare module BABYLON {
  136195. /**
  136196. * This represents a FPS type of camera controlled by touch.
  136197. * This is like a universal camera minus the Gamepad controls.
  136198. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  136199. */
  136200. export class TouchCamera extends FreeCamera {
  136201. /**
  136202. * Defines the touch sensibility for rotation.
  136203. * The higher the faster.
  136204. */
  136205. get touchAngularSensibility(): number;
  136206. set touchAngularSensibility(value: number);
  136207. /**
  136208. * Defines the touch sensibility for move.
  136209. * The higher the faster.
  136210. */
  136211. get touchMoveSensibility(): number;
  136212. set touchMoveSensibility(value: number);
  136213. /**
  136214. * Instantiates a new touch camera.
  136215. * This represents a FPS type of camera controlled by touch.
  136216. * This is like a universal camera minus the Gamepad controls.
  136217. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  136218. * @param name Define the name of the camera in the scene
  136219. * @param position Define the start position of the camera in the scene
  136220. * @param scene Define the scene the camera belongs to
  136221. */
  136222. constructor(name: string, position: Vector3, scene: Scene);
  136223. /**
  136224. * Gets the current object class name.
  136225. * @return the class name
  136226. */
  136227. getClassName(): string;
  136228. /** @hidden */
  136229. _setupInputs(): void;
  136230. }
  136231. }
  136232. declare module BABYLON {
  136233. /**
  136234. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  136235. * being tilted forward or back and left or right.
  136236. */
  136237. export class DeviceOrientationCamera extends FreeCamera {
  136238. private _initialQuaternion;
  136239. private _quaternionCache;
  136240. private _tmpDragQuaternion;
  136241. private _disablePointerInputWhenUsingDeviceOrientation;
  136242. /**
  136243. * Creates a new device orientation camera
  136244. * @param name The name of the camera
  136245. * @param position The start position camera
  136246. * @param scene The scene the camera belongs to
  136247. */
  136248. constructor(name: string, position: Vector3, scene: Scene);
  136249. /**
  136250. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  136251. */
  136252. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  136253. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  136254. private _dragFactor;
  136255. /**
  136256. * Enabled turning on the y axis when the orientation sensor is active
  136257. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  136258. */
  136259. enableHorizontalDragging(dragFactor?: number): void;
  136260. /**
  136261. * Gets the current instance class name ("DeviceOrientationCamera").
  136262. * This helps avoiding instanceof at run time.
  136263. * @returns the class name
  136264. */
  136265. getClassName(): string;
  136266. /**
  136267. * @hidden
  136268. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  136269. */
  136270. _checkInputs(): void;
  136271. /**
  136272. * Reset the camera to its default orientation on the specified axis only.
  136273. * @param axis The axis to reset
  136274. */
  136275. resetToCurrentRotation(axis?: Axis): void;
  136276. }
  136277. }
  136278. declare module BABYLON {
  136279. /**
  136280. * Defines supported buttons for XBox360 compatible gamepads
  136281. */
  136282. export enum Xbox360Button {
  136283. /** A */
  136284. A = 0,
  136285. /** B */
  136286. B = 1,
  136287. /** X */
  136288. X = 2,
  136289. /** Y */
  136290. Y = 3,
  136291. /** Left button */
  136292. LB = 4,
  136293. /** Right button */
  136294. RB = 5,
  136295. /** Back */
  136296. Back = 8,
  136297. /** Start */
  136298. Start = 9,
  136299. /** Left stick */
  136300. LeftStick = 10,
  136301. /** Right stick */
  136302. RightStick = 11
  136303. }
  136304. /** Defines values for XBox360 DPad */
  136305. export enum Xbox360Dpad {
  136306. /** Up */
  136307. Up = 12,
  136308. /** Down */
  136309. Down = 13,
  136310. /** Left */
  136311. Left = 14,
  136312. /** Right */
  136313. Right = 15
  136314. }
  136315. /**
  136316. * Defines a XBox360 gamepad
  136317. */
  136318. export class Xbox360Pad extends Gamepad {
  136319. private _leftTrigger;
  136320. private _rightTrigger;
  136321. private _onlefttriggerchanged;
  136322. private _onrighttriggerchanged;
  136323. private _onbuttondown;
  136324. private _onbuttonup;
  136325. private _ondpaddown;
  136326. private _ondpadup;
  136327. /** Observable raised when a button is pressed */
  136328. onButtonDownObservable: Observable<Xbox360Button>;
  136329. /** Observable raised when a button is released */
  136330. onButtonUpObservable: Observable<Xbox360Button>;
  136331. /** Observable raised when a pad is pressed */
  136332. onPadDownObservable: Observable<Xbox360Dpad>;
  136333. /** Observable raised when a pad is released */
  136334. onPadUpObservable: Observable<Xbox360Dpad>;
  136335. private _buttonA;
  136336. private _buttonB;
  136337. private _buttonX;
  136338. private _buttonY;
  136339. private _buttonBack;
  136340. private _buttonStart;
  136341. private _buttonLB;
  136342. private _buttonRB;
  136343. private _buttonLeftStick;
  136344. private _buttonRightStick;
  136345. private _dPadUp;
  136346. private _dPadDown;
  136347. private _dPadLeft;
  136348. private _dPadRight;
  136349. private _isXboxOnePad;
  136350. /**
  136351. * Creates a new XBox360 gamepad object
  136352. * @param id defines the id of this gamepad
  136353. * @param index defines its index
  136354. * @param gamepad defines the internal HTML gamepad object
  136355. * @param xboxOne defines if it is a XBox One gamepad
  136356. */
  136357. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  136358. /**
  136359. * Defines the callback to call when left trigger is pressed
  136360. * @param callback defines the callback to use
  136361. */
  136362. onlefttriggerchanged(callback: (value: number) => void): void;
  136363. /**
  136364. * Defines the callback to call when right trigger is pressed
  136365. * @param callback defines the callback to use
  136366. */
  136367. onrighttriggerchanged(callback: (value: number) => void): void;
  136368. /**
  136369. * Gets the left trigger value
  136370. */
  136371. get leftTrigger(): number;
  136372. /**
  136373. * Sets the left trigger value
  136374. */
  136375. set leftTrigger(newValue: number);
  136376. /**
  136377. * Gets the right trigger value
  136378. */
  136379. get rightTrigger(): number;
  136380. /**
  136381. * Sets the right trigger value
  136382. */
  136383. set rightTrigger(newValue: number);
  136384. /**
  136385. * Defines the callback to call when a button is pressed
  136386. * @param callback defines the callback to use
  136387. */
  136388. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  136389. /**
  136390. * Defines the callback to call when a button is released
  136391. * @param callback defines the callback to use
  136392. */
  136393. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  136394. /**
  136395. * Defines the callback to call when a pad is pressed
  136396. * @param callback defines the callback to use
  136397. */
  136398. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  136399. /**
  136400. * Defines the callback to call when a pad is released
  136401. * @param callback defines the callback to use
  136402. */
  136403. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  136404. private _setButtonValue;
  136405. private _setDPadValue;
  136406. /**
  136407. * Gets the value of the `A` button
  136408. */
  136409. get buttonA(): number;
  136410. /**
  136411. * Sets the value of the `A` button
  136412. */
  136413. set buttonA(value: number);
  136414. /**
  136415. * Gets the value of the `B` button
  136416. */
  136417. get buttonB(): number;
  136418. /**
  136419. * Sets the value of the `B` button
  136420. */
  136421. set buttonB(value: number);
  136422. /**
  136423. * Gets the value of the `X` button
  136424. */
  136425. get buttonX(): number;
  136426. /**
  136427. * Sets the value of the `X` button
  136428. */
  136429. set buttonX(value: number);
  136430. /**
  136431. * Gets the value of the `Y` button
  136432. */
  136433. get buttonY(): number;
  136434. /**
  136435. * Sets the value of the `Y` button
  136436. */
  136437. set buttonY(value: number);
  136438. /**
  136439. * Gets the value of the `Start` button
  136440. */
  136441. get buttonStart(): number;
  136442. /**
  136443. * Sets the value of the `Start` button
  136444. */
  136445. set buttonStart(value: number);
  136446. /**
  136447. * Gets the value of the `Back` button
  136448. */
  136449. get buttonBack(): number;
  136450. /**
  136451. * Sets the value of the `Back` button
  136452. */
  136453. set buttonBack(value: number);
  136454. /**
  136455. * Gets the value of the `Left` button
  136456. */
  136457. get buttonLB(): number;
  136458. /**
  136459. * Sets the value of the `Left` button
  136460. */
  136461. set buttonLB(value: number);
  136462. /**
  136463. * Gets the value of the `Right` button
  136464. */
  136465. get buttonRB(): number;
  136466. /**
  136467. * Sets the value of the `Right` button
  136468. */
  136469. set buttonRB(value: number);
  136470. /**
  136471. * Gets the value of the Left joystick
  136472. */
  136473. get buttonLeftStick(): number;
  136474. /**
  136475. * Sets the value of the Left joystick
  136476. */
  136477. set buttonLeftStick(value: number);
  136478. /**
  136479. * Gets the value of the Right joystick
  136480. */
  136481. get buttonRightStick(): number;
  136482. /**
  136483. * Sets the value of the Right joystick
  136484. */
  136485. set buttonRightStick(value: number);
  136486. /**
  136487. * Gets the value of D-pad up
  136488. */
  136489. get dPadUp(): number;
  136490. /**
  136491. * Sets the value of D-pad up
  136492. */
  136493. set dPadUp(value: number);
  136494. /**
  136495. * Gets the value of D-pad down
  136496. */
  136497. get dPadDown(): number;
  136498. /**
  136499. * Sets the value of D-pad down
  136500. */
  136501. set dPadDown(value: number);
  136502. /**
  136503. * Gets the value of D-pad left
  136504. */
  136505. get dPadLeft(): number;
  136506. /**
  136507. * Sets the value of D-pad left
  136508. */
  136509. set dPadLeft(value: number);
  136510. /**
  136511. * Gets the value of D-pad right
  136512. */
  136513. get dPadRight(): number;
  136514. /**
  136515. * Sets the value of D-pad right
  136516. */
  136517. set dPadRight(value: number);
  136518. /**
  136519. * Force the gamepad to synchronize with device values
  136520. */
  136521. update(): void;
  136522. /**
  136523. * Disposes the gamepad
  136524. */
  136525. dispose(): void;
  136526. }
  136527. }
  136528. declare module BABYLON {
  136529. /**
  136530. * Defines supported buttons for DualShock compatible gamepads
  136531. */
  136532. export enum DualShockButton {
  136533. /** Cross */
  136534. Cross = 0,
  136535. /** Circle */
  136536. Circle = 1,
  136537. /** Square */
  136538. Square = 2,
  136539. /** Triangle */
  136540. Triangle = 3,
  136541. /** L1 */
  136542. L1 = 4,
  136543. /** R1 */
  136544. R1 = 5,
  136545. /** Share */
  136546. Share = 8,
  136547. /** Options */
  136548. Options = 9,
  136549. /** Left stick */
  136550. LeftStick = 10,
  136551. /** Right stick */
  136552. RightStick = 11
  136553. }
  136554. /** Defines values for DualShock DPad */
  136555. export enum DualShockDpad {
  136556. /** Up */
  136557. Up = 12,
  136558. /** Down */
  136559. Down = 13,
  136560. /** Left */
  136561. Left = 14,
  136562. /** Right */
  136563. Right = 15
  136564. }
  136565. /**
  136566. * Defines a DualShock gamepad
  136567. */
  136568. export class DualShockPad extends Gamepad {
  136569. private _leftTrigger;
  136570. private _rightTrigger;
  136571. private _onlefttriggerchanged;
  136572. private _onrighttriggerchanged;
  136573. private _onbuttondown;
  136574. private _onbuttonup;
  136575. private _ondpaddown;
  136576. private _ondpadup;
  136577. /** Observable raised when a button is pressed */
  136578. onButtonDownObservable: Observable<DualShockButton>;
  136579. /** Observable raised when a button is released */
  136580. onButtonUpObservable: Observable<DualShockButton>;
  136581. /** Observable raised when a pad is pressed */
  136582. onPadDownObservable: Observable<DualShockDpad>;
  136583. /** Observable raised when a pad is released */
  136584. onPadUpObservable: Observable<DualShockDpad>;
  136585. private _buttonCross;
  136586. private _buttonCircle;
  136587. private _buttonSquare;
  136588. private _buttonTriangle;
  136589. private _buttonShare;
  136590. private _buttonOptions;
  136591. private _buttonL1;
  136592. private _buttonR1;
  136593. private _buttonLeftStick;
  136594. private _buttonRightStick;
  136595. private _dPadUp;
  136596. private _dPadDown;
  136597. private _dPadLeft;
  136598. private _dPadRight;
  136599. /**
  136600. * Creates a new DualShock gamepad object
  136601. * @param id defines the id of this gamepad
  136602. * @param index defines its index
  136603. * @param gamepad defines the internal HTML gamepad object
  136604. */
  136605. constructor(id: string, index: number, gamepad: any);
  136606. /**
  136607. * Defines the callback to call when left trigger is pressed
  136608. * @param callback defines the callback to use
  136609. */
  136610. onlefttriggerchanged(callback: (value: number) => void): void;
  136611. /**
  136612. * Defines the callback to call when right trigger is pressed
  136613. * @param callback defines the callback to use
  136614. */
  136615. onrighttriggerchanged(callback: (value: number) => void): void;
  136616. /**
  136617. * Gets the left trigger value
  136618. */
  136619. get leftTrigger(): number;
  136620. /**
  136621. * Sets the left trigger value
  136622. */
  136623. set leftTrigger(newValue: number);
  136624. /**
  136625. * Gets the right trigger value
  136626. */
  136627. get rightTrigger(): number;
  136628. /**
  136629. * Sets the right trigger value
  136630. */
  136631. set rightTrigger(newValue: number);
  136632. /**
  136633. * Defines the callback to call when a button is pressed
  136634. * @param callback defines the callback to use
  136635. */
  136636. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  136637. /**
  136638. * Defines the callback to call when a button is released
  136639. * @param callback defines the callback to use
  136640. */
  136641. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  136642. /**
  136643. * Defines the callback to call when a pad is pressed
  136644. * @param callback defines the callback to use
  136645. */
  136646. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  136647. /**
  136648. * Defines the callback to call when a pad is released
  136649. * @param callback defines the callback to use
  136650. */
  136651. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  136652. private _setButtonValue;
  136653. private _setDPadValue;
  136654. /**
  136655. * Gets the value of the `Cross` button
  136656. */
  136657. get buttonCross(): number;
  136658. /**
  136659. * Sets the value of the `Cross` button
  136660. */
  136661. set buttonCross(value: number);
  136662. /**
  136663. * Gets the value of the `Circle` button
  136664. */
  136665. get buttonCircle(): number;
  136666. /**
  136667. * Sets the value of the `Circle` button
  136668. */
  136669. set buttonCircle(value: number);
  136670. /**
  136671. * Gets the value of the `Square` button
  136672. */
  136673. get buttonSquare(): number;
  136674. /**
  136675. * Sets the value of the `Square` button
  136676. */
  136677. set buttonSquare(value: number);
  136678. /**
  136679. * Gets the value of the `Triangle` button
  136680. */
  136681. get buttonTriangle(): number;
  136682. /**
  136683. * Sets the value of the `Triangle` button
  136684. */
  136685. set buttonTriangle(value: number);
  136686. /**
  136687. * Gets the value of the `Options` button
  136688. */
  136689. get buttonOptions(): number;
  136690. /**
  136691. * Sets the value of the `Options` button
  136692. */
  136693. set buttonOptions(value: number);
  136694. /**
  136695. * Gets the value of the `Share` button
  136696. */
  136697. get buttonShare(): number;
  136698. /**
  136699. * Sets the value of the `Share` button
  136700. */
  136701. set buttonShare(value: number);
  136702. /**
  136703. * Gets the value of the `L1` button
  136704. */
  136705. get buttonL1(): number;
  136706. /**
  136707. * Sets the value of the `L1` button
  136708. */
  136709. set buttonL1(value: number);
  136710. /**
  136711. * Gets the value of the `R1` button
  136712. */
  136713. get buttonR1(): number;
  136714. /**
  136715. * Sets the value of the `R1` button
  136716. */
  136717. set buttonR1(value: number);
  136718. /**
  136719. * Gets the value of the Left joystick
  136720. */
  136721. get buttonLeftStick(): number;
  136722. /**
  136723. * Sets the value of the Left joystick
  136724. */
  136725. set buttonLeftStick(value: number);
  136726. /**
  136727. * Gets the value of the Right joystick
  136728. */
  136729. get buttonRightStick(): number;
  136730. /**
  136731. * Sets the value of the Right joystick
  136732. */
  136733. set buttonRightStick(value: number);
  136734. /**
  136735. * Gets the value of D-pad up
  136736. */
  136737. get dPadUp(): number;
  136738. /**
  136739. * Sets the value of D-pad up
  136740. */
  136741. set dPadUp(value: number);
  136742. /**
  136743. * Gets the value of D-pad down
  136744. */
  136745. get dPadDown(): number;
  136746. /**
  136747. * Sets the value of D-pad down
  136748. */
  136749. set dPadDown(value: number);
  136750. /**
  136751. * Gets the value of D-pad left
  136752. */
  136753. get dPadLeft(): number;
  136754. /**
  136755. * Sets the value of D-pad left
  136756. */
  136757. set dPadLeft(value: number);
  136758. /**
  136759. * Gets the value of D-pad right
  136760. */
  136761. get dPadRight(): number;
  136762. /**
  136763. * Sets the value of D-pad right
  136764. */
  136765. set dPadRight(value: number);
  136766. /**
  136767. * Force the gamepad to synchronize with device values
  136768. */
  136769. update(): void;
  136770. /**
  136771. * Disposes the gamepad
  136772. */
  136773. dispose(): void;
  136774. }
  136775. }
  136776. declare module BABYLON {
  136777. /**
  136778. * Manager for handling gamepads
  136779. */
  136780. export class GamepadManager {
  136781. private _scene?;
  136782. private _babylonGamepads;
  136783. private _oneGamepadConnected;
  136784. /** @hidden */
  136785. _isMonitoring: boolean;
  136786. private _gamepadEventSupported;
  136787. private _gamepadSupport?;
  136788. /**
  136789. * observable to be triggered when the gamepad controller has been connected
  136790. */
  136791. onGamepadConnectedObservable: Observable<Gamepad>;
  136792. /**
  136793. * observable to be triggered when the gamepad controller has been disconnected
  136794. */
  136795. onGamepadDisconnectedObservable: Observable<Gamepad>;
  136796. private _onGamepadConnectedEvent;
  136797. private _onGamepadDisconnectedEvent;
  136798. /**
  136799. * Initializes the gamepad manager
  136800. * @param _scene BabylonJS scene
  136801. */
  136802. constructor(_scene?: Scene | undefined);
  136803. /**
  136804. * The gamepads in the game pad manager
  136805. */
  136806. get gamepads(): Gamepad[];
  136807. /**
  136808. * Get the gamepad controllers based on type
  136809. * @param type The type of gamepad controller
  136810. * @returns Nullable gamepad
  136811. */
  136812. getGamepadByType(type?: number): Nullable<Gamepad>;
  136813. /**
  136814. * Disposes the gamepad manager
  136815. */
  136816. dispose(): void;
  136817. private _addNewGamepad;
  136818. private _startMonitoringGamepads;
  136819. private _stopMonitoringGamepads;
  136820. /** @hidden */
  136821. _checkGamepadsStatus(): void;
  136822. private _updateGamepadObjects;
  136823. }
  136824. }
  136825. declare module BABYLON {
  136826. interface Scene {
  136827. /** @hidden */
  136828. _gamepadManager: Nullable<GamepadManager>;
  136829. /**
  136830. * Gets the gamepad manager associated with the scene
  136831. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  136832. */
  136833. gamepadManager: GamepadManager;
  136834. }
  136835. /**
  136836. * Interface representing a free camera inputs manager
  136837. */
  136838. interface FreeCameraInputsManager {
  136839. /**
  136840. * Adds gamepad input support to the FreeCameraInputsManager.
  136841. * @returns the FreeCameraInputsManager
  136842. */
  136843. addGamepad(): FreeCameraInputsManager;
  136844. }
  136845. /**
  136846. * Interface representing an arc rotate camera inputs manager
  136847. */
  136848. interface ArcRotateCameraInputsManager {
  136849. /**
  136850. * Adds gamepad input support to the ArcRotateCamera InputManager.
  136851. * @returns the camera inputs manager
  136852. */
  136853. addGamepad(): ArcRotateCameraInputsManager;
  136854. }
  136855. /**
  136856. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  136857. */
  136858. export class GamepadSystemSceneComponent implements ISceneComponent {
  136859. /**
  136860. * The component name helpfull to identify the component in the list of scene components.
  136861. */
  136862. readonly name: string;
  136863. /**
  136864. * The scene the component belongs to.
  136865. */
  136866. scene: Scene;
  136867. /**
  136868. * Creates a new instance of the component for the given scene
  136869. * @param scene Defines the scene to register the component in
  136870. */
  136871. constructor(scene: Scene);
  136872. /**
  136873. * Registers the component in a given scene
  136874. */
  136875. register(): void;
  136876. /**
  136877. * Rebuilds the elements related to this component in case of
  136878. * context lost for instance.
  136879. */
  136880. rebuild(): void;
  136881. /**
  136882. * Disposes the component and the associated ressources
  136883. */
  136884. dispose(): void;
  136885. private _beforeCameraUpdate;
  136886. }
  136887. }
  136888. declare module BABYLON {
  136889. /**
  136890. * 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,
  136891. * which still works and will still be found in many Playgrounds.
  136892. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  136893. */
  136894. export class UniversalCamera extends TouchCamera {
  136895. /**
  136896. * Defines the gamepad rotation sensiblity.
  136897. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  136898. */
  136899. get gamepadAngularSensibility(): number;
  136900. set gamepadAngularSensibility(value: number);
  136901. /**
  136902. * Defines the gamepad move sensiblity.
  136903. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  136904. */
  136905. get gamepadMoveSensibility(): number;
  136906. set gamepadMoveSensibility(value: number);
  136907. /**
  136908. * 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,
  136909. * which still works and will still be found in many Playgrounds.
  136910. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  136911. * @param name Define the name of the camera in the scene
  136912. * @param position Define the start position of the camera in the scene
  136913. * @param scene Define the scene the camera belongs to
  136914. */
  136915. constructor(name: string, position: Vector3, scene: Scene);
  136916. /**
  136917. * Gets the current object class name.
  136918. * @return the class name
  136919. */
  136920. getClassName(): string;
  136921. }
  136922. }
  136923. declare module BABYLON {
  136924. /**
  136925. * This represents a FPS type of camera. This is only here for back compat purpose.
  136926. * Please use the UniversalCamera instead as both are identical.
  136927. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  136928. */
  136929. export class GamepadCamera extends UniversalCamera {
  136930. /**
  136931. * Instantiates a new Gamepad Camera
  136932. * This represents a FPS type of camera. This is only here for back compat purpose.
  136933. * Please use the UniversalCamera instead as both are identical.
  136934. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  136935. * @param name Define the name of the camera in the scene
  136936. * @param position Define the start position of the camera in the scene
  136937. * @param scene Define the scene the camera belongs to
  136938. */
  136939. constructor(name: string, position: Vector3, scene: Scene);
  136940. /**
  136941. * Gets the current object class name.
  136942. * @return the class name
  136943. */
  136944. getClassName(): string;
  136945. }
  136946. }
  136947. declare module BABYLON {
  136948. /** @hidden */
  136949. export var anaglyphPixelShader: {
  136950. name: string;
  136951. shader: string;
  136952. };
  136953. }
  136954. declare module BABYLON {
  136955. /**
  136956. * Postprocess used to generate anaglyphic rendering
  136957. */
  136958. export class AnaglyphPostProcess extends PostProcess {
  136959. private _passedProcess;
  136960. /**
  136961. * Gets a string identifying the name of the class
  136962. * @returns "AnaglyphPostProcess" string
  136963. */
  136964. getClassName(): string;
  136965. /**
  136966. * Creates a new AnaglyphPostProcess
  136967. * @param name defines postprocess name
  136968. * @param options defines creation options or target ratio scale
  136969. * @param rigCameras defines cameras using this postprocess
  136970. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  136971. * @param engine defines hosting engine
  136972. * @param reusable defines if the postprocess will be reused multiple times per frame
  136973. */
  136974. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  136975. }
  136976. }
  136977. declare module BABYLON {
  136978. /**
  136979. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  136980. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  136981. */
  136982. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  136983. /**
  136984. * Creates a new AnaglyphArcRotateCamera
  136985. * @param name defines camera name
  136986. * @param alpha defines alpha angle (in radians)
  136987. * @param beta defines beta angle (in radians)
  136988. * @param radius defines radius
  136989. * @param target defines camera target
  136990. * @param interaxialDistance defines distance between each color axis
  136991. * @param scene defines the hosting scene
  136992. */
  136993. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  136994. /**
  136995. * Gets camera class name
  136996. * @returns AnaglyphArcRotateCamera
  136997. */
  136998. getClassName(): string;
  136999. }
  137000. }
  137001. declare module BABYLON {
  137002. /**
  137003. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  137004. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  137005. */
  137006. export class AnaglyphFreeCamera extends FreeCamera {
  137007. /**
  137008. * Creates a new AnaglyphFreeCamera
  137009. * @param name defines camera name
  137010. * @param position defines initial position
  137011. * @param interaxialDistance defines distance between each color axis
  137012. * @param scene defines the hosting scene
  137013. */
  137014. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  137015. /**
  137016. * Gets camera class name
  137017. * @returns AnaglyphFreeCamera
  137018. */
  137019. getClassName(): string;
  137020. }
  137021. }
  137022. declare module BABYLON {
  137023. /**
  137024. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  137025. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  137026. */
  137027. export class AnaglyphGamepadCamera extends GamepadCamera {
  137028. /**
  137029. * Creates a new AnaglyphGamepadCamera
  137030. * @param name defines camera name
  137031. * @param position defines initial position
  137032. * @param interaxialDistance defines distance between each color axis
  137033. * @param scene defines the hosting scene
  137034. */
  137035. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  137036. /**
  137037. * Gets camera class name
  137038. * @returns AnaglyphGamepadCamera
  137039. */
  137040. getClassName(): string;
  137041. }
  137042. }
  137043. declare module BABYLON {
  137044. /**
  137045. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  137046. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  137047. */
  137048. export class AnaglyphUniversalCamera extends UniversalCamera {
  137049. /**
  137050. * Creates a new AnaglyphUniversalCamera
  137051. * @param name defines camera name
  137052. * @param position defines initial position
  137053. * @param interaxialDistance defines distance between each color axis
  137054. * @param scene defines the hosting scene
  137055. */
  137056. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  137057. /**
  137058. * Gets camera class name
  137059. * @returns AnaglyphUniversalCamera
  137060. */
  137061. getClassName(): string;
  137062. }
  137063. }
  137064. declare module BABYLON {
  137065. /**
  137066. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  137067. * @see https://doc.babylonjs.com/features/cameras
  137068. */
  137069. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  137070. /**
  137071. * Creates a new StereoscopicArcRotateCamera
  137072. * @param name defines camera name
  137073. * @param alpha defines alpha angle (in radians)
  137074. * @param beta defines beta angle (in radians)
  137075. * @param radius defines radius
  137076. * @param target defines camera target
  137077. * @param interaxialDistance defines distance between each color axis
  137078. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  137079. * @param scene defines the hosting scene
  137080. */
  137081. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  137082. /**
  137083. * Gets camera class name
  137084. * @returns StereoscopicArcRotateCamera
  137085. */
  137086. getClassName(): string;
  137087. }
  137088. }
  137089. declare module BABYLON {
  137090. /**
  137091. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  137092. * @see https://doc.babylonjs.com/features/cameras
  137093. */
  137094. export class StereoscopicFreeCamera extends FreeCamera {
  137095. /**
  137096. * Creates a new StereoscopicFreeCamera
  137097. * @param name defines camera name
  137098. * @param position defines initial position
  137099. * @param interaxialDistance defines distance between each color axis
  137100. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  137101. * @param scene defines the hosting scene
  137102. */
  137103. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  137104. /**
  137105. * Gets camera class name
  137106. * @returns StereoscopicFreeCamera
  137107. */
  137108. getClassName(): string;
  137109. }
  137110. }
  137111. declare module BABYLON {
  137112. /**
  137113. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  137114. * @see https://doc.babylonjs.com/features/cameras
  137115. */
  137116. export class StereoscopicGamepadCamera extends GamepadCamera {
  137117. /**
  137118. * Creates a new StereoscopicGamepadCamera
  137119. * @param name defines camera name
  137120. * @param position defines initial position
  137121. * @param interaxialDistance defines distance between each color axis
  137122. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  137123. * @param scene defines the hosting scene
  137124. */
  137125. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  137126. /**
  137127. * Gets camera class name
  137128. * @returns StereoscopicGamepadCamera
  137129. */
  137130. getClassName(): string;
  137131. }
  137132. }
  137133. declare module BABYLON {
  137134. /**
  137135. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  137136. * @see https://doc.babylonjs.com/features/cameras
  137137. */
  137138. export class StereoscopicUniversalCamera extends UniversalCamera {
  137139. /**
  137140. * Creates a new StereoscopicUniversalCamera
  137141. * @param name defines camera name
  137142. * @param position defines initial position
  137143. * @param interaxialDistance defines distance between each color axis
  137144. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  137145. * @param scene defines the hosting scene
  137146. */
  137147. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  137148. /**
  137149. * Gets camera class name
  137150. * @returns StereoscopicUniversalCamera
  137151. */
  137152. getClassName(): string;
  137153. }
  137154. }
  137155. declare module BABYLON {
  137156. /**
  137157. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  137158. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  137159. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  137160. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  137161. */
  137162. export class VirtualJoysticksCamera extends FreeCamera {
  137163. /**
  137164. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  137165. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  137166. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  137167. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  137168. * @param name Define the name of the camera in the scene
  137169. * @param position Define the start position of the camera in the scene
  137170. * @param scene Define the scene the camera belongs to
  137171. */
  137172. constructor(name: string, position: Vector3, scene: Scene);
  137173. /**
  137174. * Gets the current object class name.
  137175. * @return the class name
  137176. */
  137177. getClassName(): string;
  137178. }
  137179. }
  137180. declare module BABYLON {
  137181. /**
  137182. * This represents all the required metrics to create a VR camera.
  137183. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  137184. */
  137185. export class VRCameraMetrics {
  137186. /**
  137187. * Define the horizontal resolution off the screen.
  137188. */
  137189. hResolution: number;
  137190. /**
  137191. * Define the vertical resolution off the screen.
  137192. */
  137193. vResolution: number;
  137194. /**
  137195. * Define the horizontal screen size.
  137196. */
  137197. hScreenSize: number;
  137198. /**
  137199. * Define the vertical screen size.
  137200. */
  137201. vScreenSize: number;
  137202. /**
  137203. * Define the vertical screen center position.
  137204. */
  137205. vScreenCenter: number;
  137206. /**
  137207. * Define the distance of the eyes to the screen.
  137208. */
  137209. eyeToScreenDistance: number;
  137210. /**
  137211. * Define the distance between both lenses
  137212. */
  137213. lensSeparationDistance: number;
  137214. /**
  137215. * Define the distance between both viewer's eyes.
  137216. */
  137217. interpupillaryDistance: number;
  137218. /**
  137219. * Define the distortion factor of the VR postprocess.
  137220. * Please, touch with care.
  137221. */
  137222. distortionK: number[];
  137223. /**
  137224. * Define the chromatic aberration correction factors for the VR post process.
  137225. */
  137226. chromaAbCorrection: number[];
  137227. /**
  137228. * Define the scale factor of the post process.
  137229. * The smaller the better but the slower.
  137230. */
  137231. postProcessScaleFactor: number;
  137232. /**
  137233. * Define an offset for the lens center.
  137234. */
  137235. lensCenterOffset: number;
  137236. /**
  137237. * Define if the current vr camera should compensate the distortion of the lense or not.
  137238. */
  137239. compensateDistortion: boolean;
  137240. /**
  137241. * Defines if multiview should be enabled when rendering (Default: false)
  137242. */
  137243. multiviewEnabled: boolean;
  137244. /**
  137245. * Gets the rendering aspect ratio based on the provided resolutions.
  137246. */
  137247. get aspectRatio(): number;
  137248. /**
  137249. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  137250. */
  137251. get aspectRatioFov(): number;
  137252. /**
  137253. * @hidden
  137254. */
  137255. get leftHMatrix(): Matrix;
  137256. /**
  137257. * @hidden
  137258. */
  137259. get rightHMatrix(): Matrix;
  137260. /**
  137261. * @hidden
  137262. */
  137263. get leftPreViewMatrix(): Matrix;
  137264. /**
  137265. * @hidden
  137266. */
  137267. get rightPreViewMatrix(): Matrix;
  137268. /**
  137269. * Get the default VRMetrics based on the most generic setup.
  137270. * @returns the default vr metrics
  137271. */
  137272. static GetDefault(): VRCameraMetrics;
  137273. }
  137274. }
  137275. declare module BABYLON {
  137276. /** @hidden */
  137277. export var vrDistortionCorrectionPixelShader: {
  137278. name: string;
  137279. shader: string;
  137280. };
  137281. }
  137282. declare module BABYLON {
  137283. /**
  137284. * VRDistortionCorrectionPostProcess used for mobile VR
  137285. */
  137286. export class VRDistortionCorrectionPostProcess extends PostProcess {
  137287. private _isRightEye;
  137288. private _distortionFactors;
  137289. private _postProcessScaleFactor;
  137290. private _lensCenterOffset;
  137291. private _scaleIn;
  137292. private _scaleFactor;
  137293. private _lensCenter;
  137294. /**
  137295. * Gets a string identifying the name of the class
  137296. * @returns "VRDistortionCorrectionPostProcess" string
  137297. */
  137298. getClassName(): string;
  137299. /**
  137300. * Initializes the VRDistortionCorrectionPostProcess
  137301. * @param name The name of the effect.
  137302. * @param camera The camera to apply the render pass to.
  137303. * @param isRightEye If this is for the right eye distortion
  137304. * @param vrMetrics All the required metrics for the VR camera
  137305. */
  137306. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  137307. }
  137308. }
  137309. declare module BABYLON {
  137310. /**
  137311. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  137312. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  137313. */
  137314. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  137315. /**
  137316. * Creates a new VRDeviceOrientationArcRotateCamera
  137317. * @param name defines camera name
  137318. * @param alpha defines the camera rotation along the logitudinal axis
  137319. * @param beta defines the camera rotation along the latitudinal axis
  137320. * @param radius defines the camera distance from its target
  137321. * @param target defines the camera target
  137322. * @param scene defines the scene the camera belongs to
  137323. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  137324. * @param vrCameraMetrics defines the vr metrics associated to the camera
  137325. */
  137326. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  137327. /**
  137328. * Gets camera class name
  137329. * @returns VRDeviceOrientationArcRotateCamera
  137330. */
  137331. getClassName(): string;
  137332. }
  137333. }
  137334. declare module BABYLON {
  137335. /**
  137336. * Camera used to simulate VR rendering (based on FreeCamera)
  137337. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  137338. */
  137339. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  137340. /**
  137341. * Creates a new VRDeviceOrientationFreeCamera
  137342. * @param name defines camera name
  137343. * @param position defines the start position of the camera
  137344. * @param scene defines the scene the camera belongs to
  137345. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  137346. * @param vrCameraMetrics defines the vr metrics associated to the camera
  137347. */
  137348. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  137349. /**
  137350. * Gets camera class name
  137351. * @returns VRDeviceOrientationFreeCamera
  137352. */
  137353. getClassName(): string;
  137354. }
  137355. }
  137356. declare module BABYLON {
  137357. /**
  137358. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  137359. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  137360. */
  137361. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  137362. /**
  137363. * Creates a new VRDeviceOrientationGamepadCamera
  137364. * @param name defines camera name
  137365. * @param position defines the start position of the camera
  137366. * @param scene defines the scene the camera belongs to
  137367. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  137368. * @param vrCameraMetrics defines the vr metrics associated to the camera
  137369. */
  137370. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  137371. /**
  137372. * Gets camera class name
  137373. * @returns VRDeviceOrientationGamepadCamera
  137374. */
  137375. getClassName(): string;
  137376. }
  137377. }
  137378. declare module BABYLON {
  137379. /**
  137380. * A class extending Texture allowing drawing on a texture
  137381. * @see https://doc.babylonjs.com/how_to/dynamictexture
  137382. */
  137383. export class DynamicTexture extends Texture {
  137384. private _generateMipMaps;
  137385. private _canvas;
  137386. private _context;
  137387. /**
  137388. * Creates a DynamicTexture
  137389. * @param name defines the name of the texture
  137390. * @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
  137391. * @param scene defines the scene where you want the texture
  137392. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  137393. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  137394. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  137395. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  137396. */
  137397. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  137398. /**
  137399. * Get the current class name of the texture useful for serialization or dynamic coding.
  137400. * @returns "DynamicTexture"
  137401. */
  137402. getClassName(): string;
  137403. /**
  137404. * Gets the current state of canRescale
  137405. */
  137406. get canRescale(): boolean;
  137407. private _recreate;
  137408. /**
  137409. * Scales the texture
  137410. * @param ratio the scale factor to apply to both width and height
  137411. */
  137412. scale(ratio: number): void;
  137413. /**
  137414. * Resizes the texture
  137415. * @param width the new width
  137416. * @param height the new height
  137417. */
  137418. scaleTo(width: number, height: number): void;
  137419. /**
  137420. * Gets the context of the canvas used by the texture
  137421. * @returns the canvas context of the dynamic texture
  137422. */
  137423. getContext(): CanvasRenderingContext2D;
  137424. /**
  137425. * Clears the texture
  137426. */
  137427. clear(): void;
  137428. /**
  137429. * Updates the texture
  137430. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  137431. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  137432. */
  137433. update(invertY?: boolean, premulAlpha?: boolean): void;
  137434. /**
  137435. * Draws text onto the texture
  137436. * @param text defines the text to be drawn
  137437. * @param x defines the placement of the text from the left
  137438. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  137439. * @param font defines the font to be used with font-style, font-size, font-name
  137440. * @param color defines the color used for the text
  137441. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  137442. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  137443. * @param update defines whether texture is immediately update (default is true)
  137444. */
  137445. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  137446. /**
  137447. * Clones the texture
  137448. * @returns the clone of the texture.
  137449. */
  137450. clone(): DynamicTexture;
  137451. /**
  137452. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  137453. * @returns a serialized dynamic texture object
  137454. */
  137455. serialize(): any;
  137456. private _IsCanvasElement;
  137457. /** @hidden */
  137458. _rebuild(): void;
  137459. }
  137460. }
  137461. declare module BABYLON {
  137462. /**
  137463. * Class containing static functions to help procedurally build meshes
  137464. */
  137465. export class GroundBuilder {
  137466. /**
  137467. * Creates a ground mesh
  137468. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  137469. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  137470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137471. * @param name defines the name of the mesh
  137472. * @param options defines the options used to create the mesh
  137473. * @param scene defines the hosting scene
  137474. * @returns the ground mesh
  137475. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  137476. */
  137477. static CreateGround(name: string, options: {
  137478. width?: number;
  137479. height?: number;
  137480. subdivisions?: number;
  137481. subdivisionsX?: number;
  137482. subdivisionsY?: number;
  137483. updatable?: boolean;
  137484. }, scene: any): Mesh;
  137485. /**
  137486. * Creates a tiled ground mesh
  137487. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  137488. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  137489. * * 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
  137490. * * 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
  137491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  137492. * @param name defines the name of the mesh
  137493. * @param options defines the options used to create the mesh
  137494. * @param scene defines the hosting scene
  137495. * @returns the tiled ground mesh
  137496. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  137497. */
  137498. static CreateTiledGround(name: string, options: {
  137499. xmin: number;
  137500. zmin: number;
  137501. xmax: number;
  137502. zmax: number;
  137503. subdivisions?: {
  137504. w: number;
  137505. h: number;
  137506. };
  137507. precision?: {
  137508. w: number;
  137509. h: number;
  137510. };
  137511. updatable?: boolean;
  137512. }, scene?: Nullable<Scene>): Mesh;
  137513. /**
  137514. * Creates a ground mesh from a height map
  137515. * * The parameter `url` sets the URL of the height map image resource.
  137516. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  137517. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  137518. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  137519. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  137520. * * 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.
  137521. * * 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).
  137522. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  137523. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  137524. * @param name defines the name of the mesh
  137525. * @param url defines the url to the height map
  137526. * @param options defines the options used to create the mesh
  137527. * @param scene defines the hosting scene
  137528. * @returns the ground mesh
  137529. * @see https://doc.babylonjs.com/babylon101/height_map
  137530. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  137531. */
  137532. static CreateGroundFromHeightMap(name: string, url: string, options: {
  137533. width?: number;
  137534. height?: number;
  137535. subdivisions?: number;
  137536. minHeight?: number;
  137537. maxHeight?: number;
  137538. colorFilter?: Color3;
  137539. alphaFilter?: number;
  137540. updatable?: boolean;
  137541. onReady?: (mesh: GroundMesh) => void;
  137542. }, scene?: Nullable<Scene>): GroundMesh;
  137543. }
  137544. }
  137545. declare module BABYLON {
  137546. /**
  137547. * Class containing static functions to help procedurally build meshes
  137548. */
  137549. export class TorusBuilder {
  137550. /**
  137551. * Creates a torus mesh
  137552. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  137553. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  137554. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  137555. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137556. * * 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
  137557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  137558. * @param name defines the name of the mesh
  137559. * @param options defines the options used to create the mesh
  137560. * @param scene defines the hosting scene
  137561. * @returns the torus mesh
  137562. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  137563. */
  137564. static CreateTorus(name: string, options: {
  137565. diameter?: number;
  137566. thickness?: number;
  137567. tessellation?: number;
  137568. updatable?: boolean;
  137569. sideOrientation?: number;
  137570. frontUVs?: Vector4;
  137571. backUVs?: Vector4;
  137572. }, scene: any): Mesh;
  137573. }
  137574. }
  137575. declare module BABYLON {
  137576. /**
  137577. * Class containing static functions to help procedurally build meshes
  137578. */
  137579. export class CylinderBuilder {
  137580. /**
  137581. * Creates a cylinder or a cone mesh
  137582. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  137583. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  137584. * * 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.
  137585. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  137586. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  137587. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  137588. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  137589. * * 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).
  137590. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  137591. * * 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).
  137592. * * 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
  137593. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  137594. * * 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
  137595. * * 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.
  137596. * * If `enclose` is false, a ring surface is one element.
  137597. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  137598. * * 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
  137599. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137600. * * 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
  137601. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  137602. * @param name defines the name of the mesh
  137603. * @param options defines the options used to create the mesh
  137604. * @param scene defines the hosting scene
  137605. * @returns the cylinder mesh
  137606. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  137607. */
  137608. static CreateCylinder(name: string, options: {
  137609. height?: number;
  137610. diameterTop?: number;
  137611. diameterBottom?: number;
  137612. diameter?: number;
  137613. tessellation?: number;
  137614. subdivisions?: number;
  137615. arc?: number;
  137616. faceColors?: Color4[];
  137617. faceUV?: Vector4[];
  137618. updatable?: boolean;
  137619. hasRings?: boolean;
  137620. enclose?: boolean;
  137621. cap?: number;
  137622. sideOrientation?: number;
  137623. frontUVs?: Vector4;
  137624. backUVs?: Vector4;
  137625. }, scene: any): Mesh;
  137626. }
  137627. }
  137628. declare module BABYLON {
  137629. /**
  137630. * States of the webXR experience
  137631. */
  137632. export enum WebXRState {
  137633. /**
  137634. * Transitioning to being in XR mode
  137635. */
  137636. ENTERING_XR = 0,
  137637. /**
  137638. * Transitioning to non XR mode
  137639. */
  137640. EXITING_XR = 1,
  137641. /**
  137642. * In XR mode and presenting
  137643. */
  137644. IN_XR = 2,
  137645. /**
  137646. * Not entered XR mode
  137647. */
  137648. NOT_IN_XR = 3
  137649. }
  137650. /**
  137651. * The state of the XR camera's tracking
  137652. */
  137653. export enum WebXRTrackingState {
  137654. /**
  137655. * No transformation received, device is not being tracked
  137656. */
  137657. NOT_TRACKING = 0,
  137658. /**
  137659. * Tracking lost - using emulated position
  137660. */
  137661. TRACKING_LOST = 1,
  137662. /**
  137663. * Transformation tracking works normally
  137664. */
  137665. TRACKING = 2
  137666. }
  137667. /**
  137668. * Abstraction of the XR render target
  137669. */
  137670. export interface WebXRRenderTarget extends IDisposable {
  137671. /**
  137672. * xrpresent context of the canvas which can be used to display/mirror xr content
  137673. */
  137674. canvasContext: WebGLRenderingContext;
  137675. /**
  137676. * xr layer for the canvas
  137677. */
  137678. xrLayer: Nullable<XRWebGLLayer>;
  137679. /**
  137680. * Initializes the xr layer for the session
  137681. * @param xrSession xr session
  137682. * @returns a promise that will resolve once the XR Layer has been created
  137683. */
  137684. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  137685. }
  137686. }
  137687. declare module BABYLON {
  137688. /**
  137689. * COnfiguration object for WebXR output canvas
  137690. */
  137691. export class WebXRManagedOutputCanvasOptions {
  137692. /**
  137693. * An optional canvas in case you wish to create it yourself and provide it here.
  137694. * If not provided, a new canvas will be created
  137695. */
  137696. canvasElement?: HTMLCanvasElement;
  137697. /**
  137698. * Options for this XR Layer output
  137699. */
  137700. canvasOptions?: XRWebGLLayerInit;
  137701. /**
  137702. * CSS styling for a newly created canvas (if not provided)
  137703. */
  137704. newCanvasCssStyle?: string;
  137705. /**
  137706. * Get the default values of the configuration object
  137707. * @param engine defines the engine to use (can be null)
  137708. * @returns default values of this configuration object
  137709. */
  137710. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  137711. }
  137712. /**
  137713. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  137714. */
  137715. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  137716. private _options;
  137717. private _canvas;
  137718. private _engine;
  137719. private _originalCanvasSize;
  137720. /**
  137721. * Rendering context of the canvas which can be used to display/mirror xr content
  137722. */
  137723. canvasContext: WebGLRenderingContext;
  137724. /**
  137725. * xr layer for the canvas
  137726. */
  137727. xrLayer: Nullable<XRWebGLLayer>;
  137728. /**
  137729. * Obseervers registered here will be triggered when the xr layer was initialized
  137730. */
  137731. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  137732. /**
  137733. * Initializes the canvas to be added/removed upon entering/exiting xr
  137734. * @param _xrSessionManager The XR Session manager
  137735. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  137736. */
  137737. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  137738. /**
  137739. * Disposes of the object
  137740. */
  137741. dispose(): void;
  137742. /**
  137743. * Initializes the xr layer for the session
  137744. * @param xrSession xr session
  137745. * @returns a promise that will resolve once the XR Layer has been created
  137746. */
  137747. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  137748. private _addCanvas;
  137749. private _removeCanvas;
  137750. private _setCanvasSize;
  137751. private _setManagedOutputCanvas;
  137752. }
  137753. }
  137754. declare module BABYLON {
  137755. /**
  137756. * Manages an XRSession to work with Babylon's engine
  137757. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  137758. */
  137759. export class WebXRSessionManager implements IDisposable {
  137760. /** The scene which the session should be created for */
  137761. scene: Scene;
  137762. private _referenceSpace;
  137763. private _rttProvider;
  137764. private _sessionEnded;
  137765. private _xrNavigator;
  137766. private baseLayer;
  137767. /**
  137768. * The base reference space from which the session started. good if you want to reset your
  137769. * reference space
  137770. */
  137771. baseReferenceSpace: XRReferenceSpace;
  137772. /**
  137773. * Current XR frame
  137774. */
  137775. currentFrame: Nullable<XRFrame>;
  137776. /** WebXR timestamp updated every frame */
  137777. currentTimestamp: number;
  137778. /**
  137779. * Used just in case of a failure to initialize an immersive session.
  137780. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  137781. */
  137782. defaultHeightCompensation: number;
  137783. /**
  137784. * Fires every time a new xrFrame arrives which can be used to update the camera
  137785. */
  137786. onXRFrameObservable: Observable<XRFrame>;
  137787. /**
  137788. * Fires when the reference space changed
  137789. */
  137790. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  137791. /**
  137792. * Fires when the xr session is ended either by the device or manually done
  137793. */
  137794. onXRSessionEnded: Observable<any>;
  137795. /**
  137796. * Fires when the xr session is ended either by the device or manually done
  137797. */
  137798. onXRSessionInit: Observable<XRSession>;
  137799. /**
  137800. * Underlying xr session
  137801. */
  137802. session: XRSession;
  137803. /**
  137804. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  137805. * or get the offset the player is currently at.
  137806. */
  137807. viewerReferenceSpace: XRReferenceSpace;
  137808. /**
  137809. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  137810. * @param scene The scene which the session should be created for
  137811. */
  137812. constructor(
  137813. /** The scene which the session should be created for */
  137814. scene: Scene);
  137815. /**
  137816. * The current reference space used in this session. This reference space can constantly change!
  137817. * It is mainly used to offset the camera's position.
  137818. */
  137819. get referenceSpace(): XRReferenceSpace;
  137820. /**
  137821. * Set a new reference space and triggers the observable
  137822. */
  137823. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  137824. /**
  137825. * Disposes of the session manager
  137826. */
  137827. dispose(): void;
  137828. /**
  137829. * Stops the xrSession and restores the render loop
  137830. * @returns Promise which resolves after it exits XR
  137831. */
  137832. exitXRAsync(): Promise<void>;
  137833. /**
  137834. * Gets the correct render target texture to be rendered this frame for this eye
  137835. * @param eye the eye for which to get the render target
  137836. * @returns the render target for the specified eye
  137837. */
  137838. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  137839. /**
  137840. * Creates a WebXRRenderTarget object for the XR session
  137841. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  137842. * @param options optional options to provide when creating a new render target
  137843. * @returns a WebXR render target to which the session can render
  137844. */
  137845. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  137846. /**
  137847. * Initializes the manager
  137848. * After initialization enterXR can be called to start an XR session
  137849. * @returns Promise which resolves after it is initialized
  137850. */
  137851. initializeAsync(): Promise<void>;
  137852. /**
  137853. * Initializes an xr session
  137854. * @param xrSessionMode mode to initialize
  137855. * @param xrSessionInit defines optional and required values to pass to the session builder
  137856. * @returns a promise which will resolve once the session has been initialized
  137857. */
  137858. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  137859. /**
  137860. * Checks if a session would be supported for the creation options specified
  137861. * @param sessionMode session mode to check if supported eg. immersive-vr
  137862. * @returns A Promise that resolves to true if supported and false if not
  137863. */
  137864. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  137865. /**
  137866. * Resets the reference space to the one started the session
  137867. */
  137868. resetReferenceSpace(): void;
  137869. /**
  137870. * Starts rendering to the xr layer
  137871. */
  137872. runXRRenderLoop(): void;
  137873. /**
  137874. * Sets the reference space on the xr session
  137875. * @param referenceSpaceType space to set
  137876. * @returns a promise that will resolve once the reference space has been set
  137877. */
  137878. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  137879. /**
  137880. * Updates the render state of the session
  137881. * @param state state to set
  137882. * @returns a promise that resolves once the render state has been updated
  137883. */
  137884. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  137885. /**
  137886. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  137887. * @param sessionMode defines the session to test
  137888. * @returns a promise with boolean as final value
  137889. */
  137890. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  137891. /**
  137892. * Returns true if Babylon.js is using the BabylonNative backend, otherwise false
  137893. */
  137894. get isNative(): boolean;
  137895. private _createRenderTargetTexture;
  137896. }
  137897. }
  137898. declare module BABYLON {
  137899. /**
  137900. * WebXR Camera which holds the views for the xrSession
  137901. * @see https://doc.babylonjs.com/how_to/webxr_camera
  137902. */
  137903. export class WebXRCamera extends FreeCamera {
  137904. private _xrSessionManager;
  137905. private _firstFrame;
  137906. private _referenceQuaternion;
  137907. private _referencedPosition;
  137908. private _xrInvPositionCache;
  137909. private _xrInvQuaternionCache;
  137910. private _trackingState;
  137911. /**
  137912. * Observable raised before camera teleportation
  137913. */
  137914. onBeforeCameraTeleport: Observable<Vector3>;
  137915. /**
  137916. * Observable raised after camera teleportation
  137917. */
  137918. onAfterCameraTeleport: Observable<Vector3>;
  137919. /**
  137920. * Notifies when the camera's tracking state has changed.
  137921. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  137922. */
  137923. onTrackingStateChanged: Observable<WebXRTrackingState>;
  137924. /**
  137925. * Should position compensation execute on first frame.
  137926. * This is used when copying the position from a native (non XR) camera
  137927. */
  137928. compensateOnFirstFrame: boolean;
  137929. /**
  137930. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  137931. * @param name the name of the camera
  137932. * @param scene the scene to add the camera to
  137933. * @param _xrSessionManager a constructed xr session manager
  137934. */
  137935. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  137936. /**
  137937. * Get the current XR tracking state of the camera
  137938. */
  137939. get trackingState(): WebXRTrackingState;
  137940. private _setTrackingState;
  137941. /**
  137942. * Return the user's height, unrelated to the current ground.
  137943. * This will be the y position of this camera, when ground level is 0.
  137944. */
  137945. get realWorldHeight(): number;
  137946. /** @hidden */
  137947. _updateForDualEyeDebugging(): void;
  137948. /**
  137949. * Sets this camera's transformation based on a non-vr camera
  137950. * @param otherCamera the non-vr camera to copy the transformation from
  137951. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  137952. */
  137953. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  137954. /**
  137955. * Gets the current instance class name ("WebXRCamera").
  137956. * @returns the class name
  137957. */
  137958. getClassName(): string;
  137959. private _rotate180;
  137960. private _updateFromXRSession;
  137961. private _updateNumberOfRigCameras;
  137962. private _updateReferenceSpace;
  137963. private _updateReferenceSpaceOffset;
  137964. }
  137965. }
  137966. declare module BABYLON {
  137967. /**
  137968. * Defining the interface required for a (webxr) feature
  137969. */
  137970. export interface IWebXRFeature extends IDisposable {
  137971. /**
  137972. * Is this feature attached
  137973. */
  137974. attached: boolean;
  137975. /**
  137976. * Should auto-attach be disabled?
  137977. */
  137978. disableAutoAttach: boolean;
  137979. /**
  137980. * Attach the feature to the session
  137981. * Will usually be called by the features manager
  137982. *
  137983. * @param force should attachment be forced (even when already attached)
  137984. * @returns true if successful.
  137985. */
  137986. attach(force?: boolean): boolean;
  137987. /**
  137988. * Detach the feature from the session
  137989. * Will usually be called by the features manager
  137990. *
  137991. * @returns true if successful.
  137992. */
  137993. detach(): boolean;
  137994. /**
  137995. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  137996. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  137997. *
  137998. * @returns whether or not the feature is compatible in this environment
  137999. */
  138000. isCompatible(): boolean;
  138001. /**
  138002. * Was this feature disposed;
  138003. */
  138004. isDisposed: boolean;
  138005. /**
  138006. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  138007. */
  138008. xrNativeFeatureName?: string;
  138009. /**
  138010. * A list of (Babylon WebXR) features this feature depends on
  138011. */
  138012. dependsOn?: string[];
  138013. }
  138014. /**
  138015. * A list of the currently available features without referencing them
  138016. */
  138017. export class WebXRFeatureName {
  138018. /**
  138019. * The name of the anchor system feature
  138020. */
  138021. static readonly ANCHOR_SYSTEM: string;
  138022. /**
  138023. * The name of the background remover feature
  138024. */
  138025. static readonly BACKGROUND_REMOVER: string;
  138026. /**
  138027. * The name of the hit test feature
  138028. */
  138029. static readonly HIT_TEST: string;
  138030. /**
  138031. * The name of the mesh detection feature
  138032. */
  138033. static readonly MESH_DETECTION: string;
  138034. /**
  138035. * physics impostors for xr controllers feature
  138036. */
  138037. static readonly PHYSICS_CONTROLLERS: string;
  138038. /**
  138039. * The name of the plane detection feature
  138040. */
  138041. static readonly PLANE_DETECTION: string;
  138042. /**
  138043. * The name of the pointer selection feature
  138044. */
  138045. static readonly POINTER_SELECTION: string;
  138046. /**
  138047. * The name of the teleportation feature
  138048. */
  138049. static readonly TELEPORTATION: string;
  138050. /**
  138051. * The name of the feature points feature.
  138052. */
  138053. static readonly FEATURE_POINTS: string;
  138054. /**
  138055. * The name of the hand tracking feature.
  138056. */
  138057. static readonly HAND_TRACKING: string;
  138058. }
  138059. /**
  138060. * Defining the constructor of a feature. Used to register the modules.
  138061. */
  138062. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  138063. /**
  138064. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  138065. * It is mainly used in AR sessions.
  138066. *
  138067. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  138068. */
  138069. export class WebXRFeaturesManager implements IDisposable {
  138070. private _xrSessionManager;
  138071. private static readonly _AvailableFeatures;
  138072. private _features;
  138073. /**
  138074. * constructs a new features manages.
  138075. *
  138076. * @param _xrSessionManager an instance of WebXRSessionManager
  138077. */
  138078. constructor(_xrSessionManager: WebXRSessionManager);
  138079. /**
  138080. * Used to register a module. After calling this function a developer can use this feature in the scene.
  138081. * Mainly used internally.
  138082. *
  138083. * @param featureName the name of the feature to register
  138084. * @param constructorFunction the function used to construct the module
  138085. * @param version the (babylon) version of the module
  138086. * @param stable is that a stable version of this module
  138087. */
  138088. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  138089. /**
  138090. * Returns a constructor of a specific feature.
  138091. *
  138092. * @param featureName the name of the feature to construct
  138093. * @param version the version of the feature to load
  138094. * @param xrSessionManager the xrSessionManager. Used to construct the module
  138095. * @param options optional options provided to the module.
  138096. * @returns a function that, when called, will return a new instance of this feature
  138097. */
  138098. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  138099. /**
  138100. * Can be used to return the list of features currently registered
  138101. *
  138102. * @returns an Array of available features
  138103. */
  138104. static GetAvailableFeatures(): string[];
  138105. /**
  138106. * Gets the versions available for a specific feature
  138107. * @param featureName the name of the feature
  138108. * @returns an array with the available versions
  138109. */
  138110. static GetAvailableVersions(featureName: string): string[];
  138111. /**
  138112. * Return the latest unstable version of this feature
  138113. * @param featureName the name of the feature to search
  138114. * @returns the version number. if not found will return -1
  138115. */
  138116. static GetLatestVersionOfFeature(featureName: string): number;
  138117. /**
  138118. * Return the latest stable version of this feature
  138119. * @param featureName the name of the feature to search
  138120. * @returns the version number. if not found will return -1
  138121. */
  138122. static GetStableVersionOfFeature(featureName: string): number;
  138123. /**
  138124. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  138125. * Can be used during a session to start a feature
  138126. * @param featureName the name of feature to attach
  138127. */
  138128. attachFeature(featureName: string): void;
  138129. /**
  138130. * Can be used inside a session or when the session ends to detach a specific feature
  138131. * @param featureName the name of the feature to detach
  138132. */
  138133. detachFeature(featureName: string): void;
  138134. /**
  138135. * Used to disable an already-enabled feature
  138136. * The feature will be disposed and will be recreated once enabled.
  138137. * @param featureName the feature to disable
  138138. * @returns true if disable was successful
  138139. */
  138140. disableFeature(featureName: string | {
  138141. Name: string;
  138142. }): boolean;
  138143. /**
  138144. * dispose this features manager
  138145. */
  138146. dispose(): void;
  138147. /**
  138148. * 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.
  138149. * 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.
  138150. *
  138151. * @param featureName the name of the feature to load or the class of the feature
  138152. * @param version optional version to load. if not provided the latest version will be enabled
  138153. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  138154. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  138155. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  138156. * @returns a new constructed feature or throws an error if feature not found.
  138157. */
  138158. enableFeature(featureName: string | {
  138159. Name: string;
  138160. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  138161. /**
  138162. * get the implementation of an enabled feature.
  138163. * @param featureName the name of the feature to load
  138164. * @returns the feature class, if found
  138165. */
  138166. getEnabledFeature(featureName: string): IWebXRFeature;
  138167. /**
  138168. * Get the list of enabled features
  138169. * @returns an array of enabled features
  138170. */
  138171. getEnabledFeatures(): string[];
  138172. /**
  138173. * This function will exten the session creation configuration object with enabled features.
  138174. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  138175. * according to the defined "required" variable, provided during enableFeature call
  138176. * @param xrSessionInit the xr Session init object to extend
  138177. *
  138178. * @returns an extended XRSessionInit object
  138179. */
  138180. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  138181. }
  138182. }
  138183. declare module BABYLON {
  138184. /**
  138185. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  138186. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  138187. */
  138188. export class WebXRExperienceHelper implements IDisposable {
  138189. private scene;
  138190. private _nonVRCamera;
  138191. private _originalSceneAutoClear;
  138192. private _supported;
  138193. /**
  138194. * Camera used to render xr content
  138195. */
  138196. camera: WebXRCamera;
  138197. /** A features manager for this xr session */
  138198. featuresManager: WebXRFeaturesManager;
  138199. /**
  138200. * Observers registered here will be triggered after the camera's initial transformation is set
  138201. * This can be used to set a different ground level or an extra rotation.
  138202. *
  138203. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  138204. * to the position set after this observable is done executing.
  138205. */
  138206. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  138207. /**
  138208. * Fires when the state of the experience helper has changed
  138209. */
  138210. onStateChangedObservable: Observable<WebXRState>;
  138211. /** Session manager used to keep track of xr session */
  138212. sessionManager: WebXRSessionManager;
  138213. /**
  138214. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  138215. */
  138216. state: WebXRState;
  138217. /**
  138218. * Creates a WebXRExperienceHelper
  138219. * @param scene The scene the helper should be created in
  138220. */
  138221. private constructor();
  138222. /**
  138223. * Creates the experience helper
  138224. * @param scene the scene to attach the experience helper to
  138225. * @returns a promise for the experience helper
  138226. */
  138227. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  138228. /**
  138229. * Disposes of the experience helper
  138230. */
  138231. dispose(): void;
  138232. /**
  138233. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  138234. * @param sessionMode options for the XR session
  138235. * @param referenceSpaceType frame of reference of the XR session
  138236. * @param renderTarget the output canvas that will be used to enter XR mode
  138237. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  138238. * @returns promise that resolves after xr mode has entered
  138239. */
  138240. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  138241. /**
  138242. * Exits XR mode and returns the scene to its original state
  138243. * @returns promise that resolves after xr mode has exited
  138244. */
  138245. exitXRAsync(): Promise<void>;
  138246. private _nonXRToXRCamera;
  138247. private _setState;
  138248. }
  138249. }
  138250. declare module BABYLON {
  138251. /**
  138252. * X-Y values for axes in WebXR
  138253. */
  138254. export interface IWebXRMotionControllerAxesValue {
  138255. /**
  138256. * The value of the x axis
  138257. */
  138258. x: number;
  138259. /**
  138260. * The value of the y-axis
  138261. */
  138262. y: number;
  138263. }
  138264. /**
  138265. * changed / previous values for the values of this component
  138266. */
  138267. export interface IWebXRMotionControllerComponentChangesValues<T> {
  138268. /**
  138269. * current (this frame) value
  138270. */
  138271. current: T;
  138272. /**
  138273. * previous (last change) value
  138274. */
  138275. previous: T;
  138276. }
  138277. /**
  138278. * Represents changes in the component between current frame and last values recorded
  138279. */
  138280. export interface IWebXRMotionControllerComponentChanges {
  138281. /**
  138282. * will be populated with previous and current values if axes changed
  138283. */
  138284. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  138285. /**
  138286. * will be populated with previous and current values if pressed changed
  138287. */
  138288. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  138289. /**
  138290. * will be populated with previous and current values if touched changed
  138291. */
  138292. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  138293. /**
  138294. * will be populated with previous and current values if value changed
  138295. */
  138296. value?: IWebXRMotionControllerComponentChangesValues<number>;
  138297. }
  138298. /**
  138299. * This class represents a single component (for example button or thumbstick) of a motion controller
  138300. */
  138301. export class WebXRControllerComponent implements IDisposable {
  138302. /**
  138303. * the id of this component
  138304. */
  138305. id: string;
  138306. /**
  138307. * the type of the component
  138308. */
  138309. type: MotionControllerComponentType;
  138310. private _buttonIndex;
  138311. private _axesIndices;
  138312. private _axes;
  138313. private _changes;
  138314. private _currentValue;
  138315. private _hasChanges;
  138316. private _pressed;
  138317. private _touched;
  138318. /**
  138319. * button component type
  138320. */
  138321. static BUTTON_TYPE: MotionControllerComponentType;
  138322. /**
  138323. * squeeze component type
  138324. */
  138325. static SQUEEZE_TYPE: MotionControllerComponentType;
  138326. /**
  138327. * Thumbstick component type
  138328. */
  138329. static THUMBSTICK_TYPE: MotionControllerComponentType;
  138330. /**
  138331. * Touchpad component type
  138332. */
  138333. static TOUCHPAD_TYPE: MotionControllerComponentType;
  138334. /**
  138335. * trigger component type
  138336. */
  138337. static TRIGGER_TYPE: MotionControllerComponentType;
  138338. /**
  138339. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  138340. * the axes data changes
  138341. */
  138342. onAxisValueChangedObservable: Observable<{
  138343. x: number;
  138344. y: number;
  138345. }>;
  138346. /**
  138347. * Observers registered here will be triggered when the state of a button changes
  138348. * State change is either pressed / touched / value
  138349. */
  138350. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  138351. /**
  138352. * Creates a new component for a motion controller.
  138353. * It is created by the motion controller itself
  138354. *
  138355. * @param id the id of this component
  138356. * @param type the type of the component
  138357. * @param _buttonIndex index in the buttons array of the gamepad
  138358. * @param _axesIndices indices of the values in the axes array of the gamepad
  138359. */
  138360. constructor(
  138361. /**
  138362. * the id of this component
  138363. */
  138364. id: string,
  138365. /**
  138366. * the type of the component
  138367. */
  138368. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  138369. /**
  138370. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  138371. */
  138372. get axes(): IWebXRMotionControllerAxesValue;
  138373. /**
  138374. * Get the changes. Elements will be populated only if they changed with their previous and current value
  138375. */
  138376. get changes(): IWebXRMotionControllerComponentChanges;
  138377. /**
  138378. * Return whether or not the component changed the last frame
  138379. */
  138380. get hasChanges(): boolean;
  138381. /**
  138382. * is the button currently pressed
  138383. */
  138384. get pressed(): boolean;
  138385. /**
  138386. * is the button currently touched
  138387. */
  138388. get touched(): boolean;
  138389. /**
  138390. * Get the current value of this component
  138391. */
  138392. get value(): number;
  138393. /**
  138394. * Dispose this component
  138395. */
  138396. dispose(): void;
  138397. /**
  138398. * Are there axes correlating to this component
  138399. * @return true is axes data is available
  138400. */
  138401. isAxes(): boolean;
  138402. /**
  138403. * Is this component a button (hence - pressable)
  138404. * @returns true if can be pressed
  138405. */
  138406. isButton(): boolean;
  138407. /**
  138408. * update this component using the gamepad object it is in. Called on every frame
  138409. * @param nativeController the native gamepad controller object
  138410. */
  138411. update(nativeController: IMinimalMotionControllerObject): void;
  138412. }
  138413. }
  138414. declare module BABYLON {
  138415. /**
  138416. * Type used for the success callback of ImportMesh
  138417. */
  138418. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  138419. /**
  138420. * Interface used for the result of ImportMeshAsync
  138421. */
  138422. export interface ISceneLoaderAsyncResult {
  138423. /**
  138424. * The array of loaded meshes
  138425. */
  138426. readonly meshes: AbstractMesh[];
  138427. /**
  138428. * The array of loaded particle systems
  138429. */
  138430. readonly particleSystems: IParticleSystem[];
  138431. /**
  138432. * The array of loaded skeletons
  138433. */
  138434. readonly skeletons: Skeleton[];
  138435. /**
  138436. * The array of loaded animation groups
  138437. */
  138438. readonly animationGroups: AnimationGroup[];
  138439. /**
  138440. * The array of loaded transform nodes
  138441. */
  138442. readonly transformNodes: TransformNode[];
  138443. /**
  138444. * The array of loaded geometries
  138445. */
  138446. readonly geometries: Geometry[];
  138447. /**
  138448. * The array of loaded lights
  138449. */
  138450. readonly lights: Light[];
  138451. }
  138452. /**
  138453. * Interface used to represent data loading progression
  138454. */
  138455. export interface ISceneLoaderProgressEvent {
  138456. /**
  138457. * Defines if data length to load can be evaluated
  138458. */
  138459. readonly lengthComputable: boolean;
  138460. /**
  138461. * Defines the loaded data length
  138462. */
  138463. readonly loaded: number;
  138464. /**
  138465. * Defines the data length to load
  138466. */
  138467. readonly total: number;
  138468. }
  138469. /**
  138470. * Interface used by SceneLoader plugins to define supported file extensions
  138471. */
  138472. export interface ISceneLoaderPluginExtensions {
  138473. /**
  138474. * Defines the list of supported extensions
  138475. */
  138476. [extension: string]: {
  138477. isBinary: boolean;
  138478. };
  138479. }
  138480. /**
  138481. * Interface used by SceneLoader plugin factory
  138482. */
  138483. export interface ISceneLoaderPluginFactory {
  138484. /**
  138485. * Defines the name of the factory
  138486. */
  138487. name: string;
  138488. /**
  138489. * Function called to create a new plugin
  138490. * @return the new plugin
  138491. */
  138492. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  138493. /**
  138494. * The callback that returns true if the data can be directly loaded.
  138495. * @param data string containing the file data
  138496. * @returns if the data can be loaded directly
  138497. */
  138498. canDirectLoad?(data: string): boolean;
  138499. }
  138500. /**
  138501. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  138502. */
  138503. export interface ISceneLoaderPluginBase {
  138504. /**
  138505. * The friendly name of this plugin.
  138506. */
  138507. name: string;
  138508. /**
  138509. * The file extensions supported by this plugin.
  138510. */
  138511. extensions: string | ISceneLoaderPluginExtensions;
  138512. /**
  138513. * The callback called when loading from a url.
  138514. * @param scene scene loading this url
  138515. * @param url url to load
  138516. * @param onSuccess callback called when the file successfully loads
  138517. * @param onProgress callback called while file is loading (if the server supports this mode)
  138518. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  138519. * @param onError callback called when the file fails to load
  138520. * @returns a file request object
  138521. */
  138522. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  138523. /**
  138524. * The callback called when loading from a file object.
  138525. * @param scene scene loading this file
  138526. * @param file defines the file to load
  138527. * @param onSuccess defines the callback to call when data is loaded
  138528. * @param onProgress defines the callback to call during loading process
  138529. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  138530. * @param onError defines the callback to call when an error occurs
  138531. * @returns a file request object
  138532. */
  138533. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  138534. /**
  138535. * The callback that returns true if the data can be directly loaded.
  138536. * @param data string containing the file data
  138537. * @returns if the data can be loaded directly
  138538. */
  138539. canDirectLoad?(data: string): boolean;
  138540. /**
  138541. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  138542. * @param scene scene loading this data
  138543. * @param data string containing the data
  138544. * @returns data to pass to the plugin
  138545. */
  138546. directLoad?(scene: Scene, data: string): any;
  138547. /**
  138548. * The callback that allows custom handling of the root url based on the response url.
  138549. * @param rootUrl the original root url
  138550. * @param responseURL the response url if available
  138551. * @returns the new root url
  138552. */
  138553. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  138554. }
  138555. /**
  138556. * Interface used to define a SceneLoader plugin
  138557. */
  138558. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  138559. /**
  138560. * Import meshes into a scene.
  138561. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  138562. * @param scene The scene to import into
  138563. * @param data The data to import
  138564. * @param rootUrl The root url for scene and resources
  138565. * @param meshes The meshes array to import into
  138566. * @param particleSystems The particle systems array to import into
  138567. * @param skeletons The skeletons array to import into
  138568. * @param onError The callback when import fails
  138569. * @returns True if successful or false otherwise
  138570. */
  138571. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  138572. /**
  138573. * Load into a scene.
  138574. * @param scene The scene to load into
  138575. * @param data The data to import
  138576. * @param rootUrl The root url for scene and resources
  138577. * @param onError The callback when import fails
  138578. * @returns True if successful or false otherwise
  138579. */
  138580. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  138581. /**
  138582. * Load into an asset container.
  138583. * @param scene The scene to load into
  138584. * @param data The data to import
  138585. * @param rootUrl The root url for scene and resources
  138586. * @param onError The callback when import fails
  138587. * @returns The loaded asset container
  138588. */
  138589. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  138590. }
  138591. /**
  138592. * Interface used to define an async SceneLoader plugin
  138593. */
  138594. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  138595. /**
  138596. * Import meshes into a scene.
  138597. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  138598. * @param scene The scene to import into
  138599. * @param data The data to import
  138600. * @param rootUrl The root url for scene and resources
  138601. * @param onProgress The callback when the load progresses
  138602. * @param fileName Defines the name of the file to load
  138603. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  138604. */
  138605. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  138606. /**
  138607. * Load into a scene.
  138608. * @param scene The scene to load into
  138609. * @param data The data to import
  138610. * @param rootUrl The root url for scene and resources
  138611. * @param onProgress The callback when the load progresses
  138612. * @param fileName Defines the name of the file to load
  138613. * @returns Nothing
  138614. */
  138615. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  138616. /**
  138617. * Load into an asset container.
  138618. * @param scene The scene to load into
  138619. * @param data The data to import
  138620. * @param rootUrl The root url for scene and resources
  138621. * @param onProgress The callback when the load progresses
  138622. * @param fileName Defines the name of the file to load
  138623. * @returns The loaded asset container
  138624. */
  138625. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  138626. }
  138627. /**
  138628. * Mode that determines how to handle old animation groups before loading new ones.
  138629. */
  138630. export enum SceneLoaderAnimationGroupLoadingMode {
  138631. /**
  138632. * Reset all old animations to initial state then dispose them.
  138633. */
  138634. Clean = 0,
  138635. /**
  138636. * Stop all old animations.
  138637. */
  138638. Stop = 1,
  138639. /**
  138640. * Restart old animations from first frame.
  138641. */
  138642. Sync = 2,
  138643. /**
  138644. * Old animations remains untouched.
  138645. */
  138646. NoSync = 3
  138647. }
  138648. /**
  138649. * Defines a plugin registered by the SceneLoader
  138650. */
  138651. interface IRegisteredPlugin {
  138652. /**
  138653. * Defines the plugin to use
  138654. */
  138655. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  138656. /**
  138657. * Defines if the plugin supports binary data
  138658. */
  138659. isBinary: boolean;
  138660. }
  138661. /**
  138662. * Class used to load scene from various file formats using registered plugins
  138663. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  138664. */
  138665. export class SceneLoader {
  138666. /**
  138667. * No logging while loading
  138668. */
  138669. static readonly NO_LOGGING: number;
  138670. /**
  138671. * Minimal logging while loading
  138672. */
  138673. static readonly MINIMAL_LOGGING: number;
  138674. /**
  138675. * Summary logging while loading
  138676. */
  138677. static readonly SUMMARY_LOGGING: number;
  138678. /**
  138679. * Detailled logging while loading
  138680. */
  138681. static readonly DETAILED_LOGGING: number;
  138682. /**
  138683. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  138684. */
  138685. static get ForceFullSceneLoadingForIncremental(): boolean;
  138686. static set ForceFullSceneLoadingForIncremental(value: boolean);
  138687. /**
  138688. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  138689. */
  138690. static get ShowLoadingScreen(): boolean;
  138691. static set ShowLoadingScreen(value: boolean);
  138692. /**
  138693. * Defines the current logging level (while loading the scene)
  138694. * @ignorenaming
  138695. */
  138696. static get loggingLevel(): number;
  138697. static set loggingLevel(value: number);
  138698. /**
  138699. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  138700. */
  138701. static get CleanBoneMatrixWeights(): boolean;
  138702. static set CleanBoneMatrixWeights(value: boolean);
  138703. /**
  138704. * Event raised when a plugin is used to load a scene
  138705. */
  138706. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  138707. private static _registeredPlugins;
  138708. private static _showingLoadingScreen;
  138709. /**
  138710. * Gets the default plugin (used to load Babylon files)
  138711. * @returns the .babylon plugin
  138712. */
  138713. static GetDefaultPlugin(): IRegisteredPlugin;
  138714. private static _GetPluginForExtension;
  138715. private static _GetPluginForDirectLoad;
  138716. private static _GetPluginForFilename;
  138717. private static _GetDirectLoad;
  138718. private static _LoadData;
  138719. private static _GetFileInfo;
  138720. /**
  138721. * Gets a plugin that can load the given extension
  138722. * @param extension defines the extension to load
  138723. * @returns a plugin or null if none works
  138724. */
  138725. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  138726. /**
  138727. * Gets a boolean indicating that the given extension can be loaded
  138728. * @param extension defines the extension to load
  138729. * @returns true if the extension is supported
  138730. */
  138731. static IsPluginForExtensionAvailable(extension: string): boolean;
  138732. /**
  138733. * Adds a new plugin to the list of registered plugins
  138734. * @param plugin defines the plugin to add
  138735. */
  138736. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  138737. /**
  138738. * Import meshes into a scene
  138739. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  138740. * @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)
  138741. * @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)
  138742. * @param scene the instance of BABYLON.Scene to append to
  138743. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  138744. * @param onProgress a callback with a progress event for each file being loaded
  138745. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  138746. * @param pluginExtension the extension used to determine the plugin
  138747. * @returns The loaded plugin
  138748. */
  138749. 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>;
  138750. /**
  138751. * Import meshes into a scene
  138752. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  138753. * @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)
  138754. * @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)
  138755. * @param scene the instance of BABYLON.Scene to append to
  138756. * @param onProgress a callback with a progress event for each file being loaded
  138757. * @param pluginExtension the extension used to determine the plugin
  138758. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  138759. */
  138760. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  138761. /**
  138762. * Load a scene
  138763. * @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)
  138764. * @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)
  138765. * @param engine is the instance of BABYLON.Engine to use to create the scene
  138766. * @param onSuccess a callback with the scene when import succeeds
  138767. * @param onProgress a callback with a progress event for each file being loaded
  138768. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  138769. * @param pluginExtension the extension used to determine the plugin
  138770. * @returns The loaded plugin
  138771. */
  138772. 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>;
  138773. /**
  138774. * Load a scene
  138775. * @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)
  138776. * @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)
  138777. * @param engine is the instance of BABYLON.Engine to use to create the scene
  138778. * @param onProgress a callback with a progress event for each file being loaded
  138779. * @param pluginExtension the extension used to determine the plugin
  138780. * @returns The loaded scene
  138781. */
  138782. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  138783. /**
  138784. * Append a scene
  138785. * @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)
  138786. * @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)
  138787. * @param scene is the instance of BABYLON.Scene to append to
  138788. * @param onSuccess a callback with the scene when import succeeds
  138789. * @param onProgress a callback with a progress event for each file being loaded
  138790. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  138791. * @param pluginExtension the extension used to determine the plugin
  138792. * @returns The loaded plugin
  138793. */
  138794. 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>;
  138795. /**
  138796. * Append a scene
  138797. * @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)
  138798. * @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)
  138799. * @param scene is the instance of BABYLON.Scene to append to
  138800. * @param onProgress a callback with a progress event for each file being loaded
  138801. * @param pluginExtension the extension used to determine the plugin
  138802. * @returns The given scene
  138803. */
  138804. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  138805. /**
  138806. * Load a scene into an asset container
  138807. * @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)
  138808. * @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)
  138809. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  138810. * @param onSuccess a callback with the scene when import succeeds
  138811. * @param onProgress a callback with a progress event for each file being loaded
  138812. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  138813. * @param pluginExtension the extension used to determine the plugin
  138814. * @returns The loaded plugin
  138815. */
  138816. 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>;
  138817. /**
  138818. * Load a scene into an asset container
  138819. * @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)
  138820. * @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)
  138821. * @param scene is the instance of Scene to append to
  138822. * @param onProgress a callback with a progress event for each file being loaded
  138823. * @param pluginExtension the extension used to determine the plugin
  138824. * @returns The loaded asset container
  138825. */
  138826. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  138827. /**
  138828. * Import animations from a file into a scene
  138829. * @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)
  138830. * @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)
  138831. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  138832. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  138833. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  138834. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  138835. * @param onSuccess a callback with the scene when import succeeds
  138836. * @param onProgress a callback with a progress event for each file being loaded
  138837. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  138838. * @param pluginExtension the extension used to determine the plugin
  138839. */
  138840. 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;
  138841. /**
  138842. * Import animations from a file into a scene
  138843. * @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)
  138844. * @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)
  138845. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  138846. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  138847. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  138848. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  138849. * @param onSuccess a callback with the scene when import succeeds
  138850. * @param onProgress a callback with a progress event for each file being loaded
  138851. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  138852. * @param pluginExtension the extension used to determine the plugin
  138853. * @returns the updated scene with imported animations
  138854. */
  138855. 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>;
  138856. }
  138857. }
  138858. declare module BABYLON {
  138859. /**
  138860. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  138861. */
  138862. export type MotionControllerHandedness = "none" | "left" | "right";
  138863. /**
  138864. * The type of components available in motion controllers.
  138865. * This is not the name of the component.
  138866. */
  138867. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  138868. /**
  138869. * The state of a controller component
  138870. */
  138871. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  138872. /**
  138873. * The schema of motion controller layout.
  138874. * No object will be initialized using this interface
  138875. * This is used just to define the profile.
  138876. */
  138877. export interface IMotionControllerLayout {
  138878. /**
  138879. * Path to load the assets. Usually relative to the base path
  138880. */
  138881. assetPath: string;
  138882. /**
  138883. * Available components (unsorted)
  138884. */
  138885. components: {
  138886. /**
  138887. * A map of component Ids
  138888. */
  138889. [componentId: string]: {
  138890. /**
  138891. * The type of input the component outputs
  138892. */
  138893. type: MotionControllerComponentType;
  138894. /**
  138895. * The indices of this component in the gamepad object
  138896. */
  138897. gamepadIndices: {
  138898. /**
  138899. * Index of button
  138900. */
  138901. button?: number;
  138902. /**
  138903. * If available, index of x-axis
  138904. */
  138905. xAxis?: number;
  138906. /**
  138907. * If available, index of y-axis
  138908. */
  138909. yAxis?: number;
  138910. };
  138911. /**
  138912. * The mesh's root node name
  138913. */
  138914. rootNodeName: string;
  138915. /**
  138916. * Animation definitions for this model
  138917. */
  138918. visualResponses: {
  138919. [stateKey: string]: {
  138920. /**
  138921. * What property will be animated
  138922. */
  138923. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  138924. /**
  138925. * What states influence this visual response
  138926. */
  138927. states: MotionControllerComponentStateType[];
  138928. /**
  138929. * Type of animation - movement or visibility
  138930. */
  138931. valueNodeProperty: "transform" | "visibility";
  138932. /**
  138933. * Base node name to move. Its position will be calculated according to the min and max nodes
  138934. */
  138935. valueNodeName?: string;
  138936. /**
  138937. * Minimum movement node
  138938. */
  138939. minNodeName?: string;
  138940. /**
  138941. * Max movement node
  138942. */
  138943. maxNodeName?: string;
  138944. };
  138945. };
  138946. /**
  138947. * If touch enabled, what is the name of node to display user feedback
  138948. */
  138949. touchPointNodeName?: string;
  138950. };
  138951. };
  138952. /**
  138953. * Is it xr standard mapping or not
  138954. */
  138955. gamepadMapping: "" | "xr-standard";
  138956. /**
  138957. * Base root node of this entire model
  138958. */
  138959. rootNodeName: string;
  138960. /**
  138961. * Defines the main button component id
  138962. */
  138963. selectComponentId: string;
  138964. }
  138965. /**
  138966. * A definition for the layout map in the input profile
  138967. */
  138968. export interface IMotionControllerLayoutMap {
  138969. /**
  138970. * Layouts with handedness type as a key
  138971. */
  138972. [handedness: string]: IMotionControllerLayout;
  138973. }
  138974. /**
  138975. * The XR Input profile schema
  138976. * Profiles can be found here:
  138977. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  138978. */
  138979. export interface IMotionControllerProfile {
  138980. /**
  138981. * fallback profiles for this profileId
  138982. */
  138983. fallbackProfileIds: string[];
  138984. /**
  138985. * The layout map, with handedness as key
  138986. */
  138987. layouts: IMotionControllerLayoutMap;
  138988. /**
  138989. * The id of this profile
  138990. * correlates to the profile(s) in the xrInput.profiles array
  138991. */
  138992. profileId: string;
  138993. }
  138994. /**
  138995. * A helper-interface for the 3 meshes needed for controller button animation
  138996. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  138997. */
  138998. export interface IMotionControllerButtonMeshMap {
  138999. /**
  139000. * the mesh that defines the pressed value mesh position.
  139001. * This is used to find the max-position of this button
  139002. */
  139003. pressedMesh: AbstractMesh;
  139004. /**
  139005. * the mesh that defines the unpressed value mesh position.
  139006. * This is used to find the min (or initial) position of this button
  139007. */
  139008. unpressedMesh: AbstractMesh;
  139009. /**
  139010. * The mesh that will be changed when value changes
  139011. */
  139012. valueMesh: AbstractMesh;
  139013. }
  139014. /**
  139015. * A helper-interface for the 3 meshes needed for controller axis animation.
  139016. * This will be expanded when touchpad animations are fully supported
  139017. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  139018. */
  139019. export interface IMotionControllerMeshMap {
  139020. /**
  139021. * the mesh that defines the maximum value mesh position.
  139022. */
  139023. maxMesh?: AbstractMesh;
  139024. /**
  139025. * the mesh that defines the minimum value mesh position.
  139026. */
  139027. minMesh?: AbstractMesh;
  139028. /**
  139029. * The mesh that will be changed when axis value changes
  139030. */
  139031. valueMesh?: AbstractMesh;
  139032. }
  139033. /**
  139034. * The elements needed for change-detection of the gamepad objects in motion controllers
  139035. */
  139036. export interface IMinimalMotionControllerObject {
  139037. /**
  139038. * Available axes of this controller
  139039. */
  139040. axes: number[];
  139041. /**
  139042. * An array of available buttons
  139043. */
  139044. buttons: Array<{
  139045. /**
  139046. * Value of the button/trigger
  139047. */
  139048. value: number;
  139049. /**
  139050. * If the button/trigger is currently touched
  139051. */
  139052. touched: boolean;
  139053. /**
  139054. * If the button/trigger is currently pressed
  139055. */
  139056. pressed: boolean;
  139057. }>;
  139058. /**
  139059. * EXPERIMENTAL haptic support.
  139060. */
  139061. hapticActuators?: Array<{
  139062. pulse: (value: number, duration: number) => Promise<boolean>;
  139063. }>;
  139064. }
  139065. /**
  139066. * An Abstract Motion controller
  139067. * This class receives an xrInput and a profile layout and uses those to initialize the components
  139068. * Each component has an observable to check for changes in value and state
  139069. */
  139070. export abstract class WebXRAbstractMotionController implements IDisposable {
  139071. protected scene: Scene;
  139072. protected layout: IMotionControllerLayout;
  139073. /**
  139074. * The gamepad object correlating to this controller
  139075. */
  139076. gamepadObject: IMinimalMotionControllerObject;
  139077. /**
  139078. * handedness (left/right/none) of this controller
  139079. */
  139080. handedness: MotionControllerHandedness;
  139081. private _initComponent;
  139082. private _modelReady;
  139083. /**
  139084. * A map of components (WebXRControllerComponent) in this motion controller
  139085. * Components have a ComponentType and can also have both button and axis definitions
  139086. */
  139087. readonly components: {
  139088. [id: string]: WebXRControllerComponent;
  139089. };
  139090. /**
  139091. * Disable the model's animation. Can be set at any time.
  139092. */
  139093. disableAnimation: boolean;
  139094. /**
  139095. * Observers registered here will be triggered when the model of this controller is done loading
  139096. */
  139097. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  139098. /**
  139099. * The profile id of this motion controller
  139100. */
  139101. abstract profileId: string;
  139102. /**
  139103. * The root mesh of the model. It is null if the model was not yet initialized
  139104. */
  139105. rootMesh: Nullable<AbstractMesh>;
  139106. /**
  139107. * constructs a new abstract motion controller
  139108. * @param scene the scene to which the model of the controller will be added
  139109. * @param layout The profile layout to load
  139110. * @param gamepadObject The gamepad object correlating to this controller
  139111. * @param handedness handedness (left/right/none) of this controller
  139112. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  139113. */
  139114. constructor(scene: Scene, layout: IMotionControllerLayout,
  139115. /**
  139116. * The gamepad object correlating to this controller
  139117. */
  139118. gamepadObject: IMinimalMotionControllerObject,
  139119. /**
  139120. * handedness (left/right/none) of this controller
  139121. */
  139122. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  139123. /**
  139124. * Dispose this controller, the model mesh and all its components
  139125. */
  139126. dispose(): void;
  139127. /**
  139128. * Returns all components of specific type
  139129. * @param type the type to search for
  139130. * @return an array of components with this type
  139131. */
  139132. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  139133. /**
  139134. * get a component based an its component id as defined in layout.components
  139135. * @param id the id of the component
  139136. * @returns the component correlates to the id or undefined if not found
  139137. */
  139138. getComponent(id: string): WebXRControllerComponent;
  139139. /**
  139140. * Get the list of components available in this motion controller
  139141. * @returns an array of strings correlating to available components
  139142. */
  139143. getComponentIds(): string[];
  139144. /**
  139145. * Get the first component of specific type
  139146. * @param type type of component to find
  139147. * @return a controller component or null if not found
  139148. */
  139149. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  139150. /**
  139151. * Get the main (Select) component of this controller as defined in the layout
  139152. * @returns the main component of this controller
  139153. */
  139154. getMainComponent(): WebXRControllerComponent;
  139155. /**
  139156. * Loads the model correlating to this controller
  139157. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  139158. * @returns A promise fulfilled with the result of the model loading
  139159. */
  139160. loadModel(): Promise<boolean>;
  139161. /**
  139162. * Update this model using the current XRFrame
  139163. * @param xrFrame the current xr frame to use and update the model
  139164. */
  139165. updateFromXRFrame(xrFrame: XRFrame): void;
  139166. /**
  139167. * Backwards compatibility due to a deeply-integrated typo
  139168. */
  139169. get handness(): XREye;
  139170. /**
  139171. * Pulse (vibrate) this controller
  139172. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  139173. * Consecutive calls to this function will cancel the last pulse call
  139174. *
  139175. * @param value the strength of the pulse in 0.0...1.0 range
  139176. * @param duration Duration of the pulse in milliseconds
  139177. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  139178. * @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
  139179. */
  139180. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  139181. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  139182. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  139183. /**
  139184. * Moves the axis on the controller mesh based on its current state
  139185. * @param axis the index of the axis
  139186. * @param axisValue the value of the axis which determines the meshes new position
  139187. * @hidden
  139188. */
  139189. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  139190. /**
  139191. * Update the model itself with the current frame data
  139192. * @param xrFrame the frame to use for updating the model mesh
  139193. */
  139194. protected updateModel(xrFrame: XRFrame): void;
  139195. /**
  139196. * Get the filename and path for this controller's model
  139197. * @returns a map of filename and path
  139198. */
  139199. protected abstract _getFilenameAndPath(): {
  139200. filename: string;
  139201. path: string;
  139202. };
  139203. /**
  139204. * This function is called before the mesh is loaded. It checks for loading constraints.
  139205. * For example, this function can check if the GLB loader is available
  139206. * If this function returns false, the generic controller will be loaded instead
  139207. * @returns Is the client ready to load the mesh
  139208. */
  139209. protected abstract _getModelLoadingConstraints(): boolean;
  139210. /**
  139211. * This function will be called after the model was successfully loaded and can be used
  139212. * for mesh transformations before it is available for the user
  139213. * @param meshes the loaded meshes
  139214. */
  139215. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  139216. /**
  139217. * Set the root mesh for this controller. Important for the WebXR controller class
  139218. * @param meshes the loaded meshes
  139219. */
  139220. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  139221. /**
  139222. * A function executed each frame that updates the mesh (if needed)
  139223. * @param xrFrame the current xrFrame
  139224. */
  139225. protected abstract _updateModel(xrFrame: XRFrame): void;
  139226. private _getGenericFilenameAndPath;
  139227. private _getGenericParentMesh;
  139228. }
  139229. }
  139230. declare module BABYLON {
  139231. /**
  139232. * A generic trigger-only motion controller for WebXR
  139233. */
  139234. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  139235. /**
  139236. * Static version of the profile id of this controller
  139237. */
  139238. static ProfileId: string;
  139239. profileId: string;
  139240. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  139241. protected _getFilenameAndPath(): {
  139242. filename: string;
  139243. path: string;
  139244. };
  139245. protected _getModelLoadingConstraints(): boolean;
  139246. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  139247. protected _setRootMesh(meshes: AbstractMesh[]): void;
  139248. protected _updateModel(): void;
  139249. }
  139250. }
  139251. declare module BABYLON {
  139252. /**
  139253. * Class containing static functions to help procedurally build meshes
  139254. */
  139255. export class SphereBuilder {
  139256. /**
  139257. * Creates a sphere mesh
  139258. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  139259. * * 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`)
  139260. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  139261. * * 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
  139262. * * 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)
  139263. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  139264. * * 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
  139265. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  139266. * @param name defines the name of the mesh
  139267. * @param options defines the options used to create the mesh
  139268. * @param scene defines the hosting scene
  139269. * @returns the sphere mesh
  139270. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  139271. */
  139272. static CreateSphere(name: string, options: {
  139273. segments?: number;
  139274. diameter?: number;
  139275. diameterX?: number;
  139276. diameterY?: number;
  139277. diameterZ?: number;
  139278. arc?: number;
  139279. slice?: number;
  139280. sideOrientation?: number;
  139281. frontUVs?: Vector4;
  139282. backUVs?: Vector4;
  139283. updatable?: boolean;
  139284. }, scene?: Nullable<Scene>): Mesh;
  139285. }
  139286. }
  139287. declare module BABYLON {
  139288. /**
  139289. * A profiled motion controller has its profile loaded from an online repository.
  139290. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  139291. */
  139292. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  139293. private _repositoryUrl;
  139294. private _buttonMeshMapping;
  139295. private _touchDots;
  139296. /**
  139297. * The profile ID of this controller. Will be populated when the controller initializes.
  139298. */
  139299. profileId: string;
  139300. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  139301. dispose(): void;
  139302. protected _getFilenameAndPath(): {
  139303. filename: string;
  139304. path: string;
  139305. };
  139306. protected _getModelLoadingConstraints(): boolean;
  139307. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  139308. protected _setRootMesh(meshes: AbstractMesh[]): void;
  139309. protected _updateModel(_xrFrame: XRFrame): void;
  139310. }
  139311. }
  139312. declare module BABYLON {
  139313. /**
  139314. * A construction function type to create a new controller based on an xrInput object
  139315. */
  139316. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  139317. /**
  139318. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  139319. *
  139320. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  139321. * it should be replaced with auto-loaded controllers.
  139322. *
  139323. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  139324. */
  139325. export class WebXRMotionControllerManager {
  139326. private static _AvailableControllers;
  139327. private static _Fallbacks;
  139328. private static _ProfileLoadingPromises;
  139329. private static _ProfilesList;
  139330. /**
  139331. * The base URL of the online controller repository. Can be changed at any time.
  139332. */
  139333. static BaseRepositoryUrl: string;
  139334. /**
  139335. * Which repository gets priority - local or online
  139336. */
  139337. static PrioritizeOnlineRepository: boolean;
  139338. /**
  139339. * Use the online repository, or use only locally-defined controllers
  139340. */
  139341. static UseOnlineRepository: boolean;
  139342. /**
  139343. * Clear the cache used for profile loading and reload when requested again
  139344. */
  139345. static ClearProfilesCache(): void;
  139346. /**
  139347. * Register the default fallbacks.
  139348. * This function is called automatically when this file is imported.
  139349. */
  139350. static DefaultFallbacks(): void;
  139351. /**
  139352. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  139353. * @param profileId the profile to which a fallback needs to be found
  139354. * @return an array with corresponding fallback profiles
  139355. */
  139356. static FindFallbackWithProfileId(profileId: string): string[];
  139357. /**
  139358. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  139359. * The order of search:
  139360. *
  139361. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  139362. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  139363. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  139364. * 4) return the generic trigger controller if none were found
  139365. *
  139366. * @param xrInput the xrInput to which a new controller is initialized
  139367. * @param scene the scene to which the model will be added
  139368. * @param forceProfile force a certain profile for this controller
  139369. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  139370. */
  139371. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  139372. /**
  139373. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  139374. *
  139375. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  139376. *
  139377. * @param type the profile type to register
  139378. * @param constructFunction the function to be called when loading this profile
  139379. */
  139380. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  139381. /**
  139382. * Register a fallback to a specific profile.
  139383. * @param profileId the profileId that will receive the fallbacks
  139384. * @param fallbacks A list of fallback profiles
  139385. */
  139386. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  139387. /**
  139388. * Will update the list of profiles available in the repository
  139389. * @return a promise that resolves to a map of profiles available online
  139390. */
  139391. static UpdateProfilesList(): Promise<{
  139392. [profile: string]: string;
  139393. }>;
  139394. private static _LoadProfileFromRepository;
  139395. private static _LoadProfilesFromAvailableControllers;
  139396. }
  139397. }
  139398. declare module BABYLON {
  139399. /**
  139400. * Configuration options for the WebXR controller creation
  139401. */
  139402. export interface IWebXRControllerOptions {
  139403. /**
  139404. * Should the controller mesh be animated when a user interacts with it
  139405. * The pressed buttons / thumbstick and touchpad animations will be disabled
  139406. */
  139407. disableMotionControllerAnimation?: boolean;
  139408. /**
  139409. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  139410. */
  139411. doNotLoadControllerMesh?: boolean;
  139412. /**
  139413. * Force a specific controller type for this controller.
  139414. * This can be used when creating your own profile or when testing different controllers
  139415. */
  139416. forceControllerProfile?: string;
  139417. /**
  139418. * Defines a rendering group ID for meshes that will be loaded.
  139419. * This is for the default controllers only.
  139420. */
  139421. renderingGroupId?: number;
  139422. }
  139423. /**
  139424. * Represents an XR controller
  139425. */
  139426. export class WebXRInputSource {
  139427. private _scene;
  139428. /** The underlying input source for the controller */
  139429. inputSource: XRInputSource;
  139430. private _options;
  139431. private _tmpVector;
  139432. private _uniqueId;
  139433. private _disposed;
  139434. /**
  139435. * 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
  139436. */
  139437. grip?: AbstractMesh;
  139438. /**
  139439. * If available, this is the gamepad object related to this controller.
  139440. * Using this object it is possible to get click events and trackpad changes of the
  139441. * webxr controller that is currently being used.
  139442. */
  139443. motionController?: WebXRAbstractMotionController;
  139444. /**
  139445. * Event that fires when the controller is removed/disposed.
  139446. * The object provided as event data is this controller, after associated assets were disposed.
  139447. * uniqueId is still available.
  139448. */
  139449. onDisposeObservable: Observable<WebXRInputSource>;
  139450. /**
  139451. * Will be triggered when the mesh associated with the motion controller is done loading.
  139452. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  139453. * A shortened version of controller -> motion controller -> on mesh loaded.
  139454. */
  139455. onMeshLoadedObservable: Observable<AbstractMesh>;
  139456. /**
  139457. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  139458. */
  139459. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  139460. /**
  139461. * Pointer which can be used to select objects or attach a visible laser to
  139462. */
  139463. pointer: AbstractMesh;
  139464. /**
  139465. * Creates the input source object
  139466. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  139467. * @param _scene the scene which the controller should be associated to
  139468. * @param inputSource the underlying input source for the controller
  139469. * @param _options options for this controller creation
  139470. */
  139471. constructor(_scene: Scene,
  139472. /** The underlying input source for the controller */
  139473. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  139474. /**
  139475. * Get this controllers unique id
  139476. */
  139477. get uniqueId(): string;
  139478. /**
  139479. * Disposes of the object
  139480. */
  139481. dispose(): void;
  139482. /**
  139483. * Gets a world space ray coming from the pointer or grip
  139484. * @param result the resulting ray
  139485. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  139486. */
  139487. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  139488. /**
  139489. * Updates the controller pose based on the given XRFrame
  139490. * @param xrFrame xr frame to update the pose with
  139491. * @param referenceSpace reference space to use
  139492. */
  139493. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  139494. }
  139495. }
  139496. declare module BABYLON {
  139497. /**
  139498. * The schema for initialization options of the XR Input class
  139499. */
  139500. export interface IWebXRInputOptions {
  139501. /**
  139502. * If set to true no model will be automatically loaded
  139503. */
  139504. doNotLoadControllerMeshes?: boolean;
  139505. /**
  139506. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  139507. * If not found, the xr input profile data will be used.
  139508. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  139509. */
  139510. forceInputProfile?: string;
  139511. /**
  139512. * Do not send a request to the controller repository to load the profile.
  139513. *
  139514. * Instead, use the controllers available in babylon itself.
  139515. */
  139516. disableOnlineControllerRepository?: boolean;
  139517. /**
  139518. * A custom URL for the controllers repository
  139519. */
  139520. customControllersRepositoryURL?: string;
  139521. /**
  139522. * Should the controller model's components not move according to the user input
  139523. */
  139524. disableControllerAnimation?: boolean;
  139525. /**
  139526. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  139527. */
  139528. controllerOptions?: IWebXRControllerOptions;
  139529. }
  139530. /**
  139531. * XR input used to track XR inputs such as controllers/rays
  139532. */
  139533. export class WebXRInput implements IDisposable {
  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;
  139542. private readonly options;
  139543. /**
  139544. * XR controllers being tracked
  139545. */
  139546. controllers: Array<WebXRInputSource>;
  139547. private _frameObserver;
  139548. private _sessionEndedObserver;
  139549. private _sessionInitObserver;
  139550. /**
  139551. * Event when a controller has been connected/added
  139552. */
  139553. onControllerAddedObservable: Observable<WebXRInputSource>;
  139554. /**
  139555. * Event when a controller has been removed/disconnected
  139556. */
  139557. onControllerRemovedObservable: Observable<WebXRInputSource>;
  139558. /**
  139559. * Initializes the WebXRInput
  139560. * @param xrSessionManager the xr session manager for this session
  139561. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  139562. * @param options = initialization options for this xr input
  139563. */
  139564. constructor(
  139565. /**
  139566. * the xr session manager for this session
  139567. */
  139568. xrSessionManager: WebXRSessionManager,
  139569. /**
  139570. * the WebXR camera for this session. Mainly used for teleportation
  139571. */
  139572. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  139573. private _onInputSourcesChange;
  139574. private _addAndRemoveControllers;
  139575. /**
  139576. * Disposes of the object
  139577. */
  139578. dispose(): void;
  139579. }
  139580. }
  139581. declare module BABYLON {
  139582. /**
  139583. * This is the base class for all WebXR features.
  139584. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  139585. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  139586. */
  139587. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  139588. protected _xrSessionManager: WebXRSessionManager;
  139589. private _attached;
  139590. private _removeOnDetach;
  139591. /**
  139592. * Is this feature disposed?
  139593. */
  139594. isDisposed: boolean;
  139595. /**
  139596. * Should auto-attach be disabled?
  139597. */
  139598. disableAutoAttach: boolean;
  139599. /**
  139600. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  139601. */
  139602. xrNativeFeatureName: string;
  139603. /**
  139604. * Construct a new (abstract) WebXR feature
  139605. * @param _xrSessionManager the xr session manager for this feature
  139606. */
  139607. constructor(_xrSessionManager: WebXRSessionManager);
  139608. /**
  139609. * Is this feature attached
  139610. */
  139611. get attached(): boolean;
  139612. /**
  139613. * attach this feature
  139614. *
  139615. * @param force should attachment be forced (even when already attached)
  139616. * @returns true if successful, false is failed or already attached
  139617. */
  139618. attach(force?: boolean): boolean;
  139619. /**
  139620. * detach this feature.
  139621. *
  139622. * @returns true if successful, false if failed or already detached
  139623. */
  139624. detach(): boolean;
  139625. /**
  139626. * Dispose this feature and all of the resources attached
  139627. */
  139628. dispose(): void;
  139629. /**
  139630. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  139631. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  139632. *
  139633. * @returns whether or not the feature is compatible in this environment
  139634. */
  139635. isCompatible(): boolean;
  139636. /**
  139637. * This is used to register callbacks that will automatically be removed when detach is called.
  139638. * @param observable the observable to which the observer will be attached
  139639. * @param callback the callback to register
  139640. */
  139641. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  139642. /**
  139643. * Code in this function will be executed on each xrFrame received from the browser.
  139644. * This function will not execute after the feature is detached.
  139645. * @param _xrFrame the current frame
  139646. */
  139647. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  139648. }
  139649. }
  139650. declare module BABYLON {
  139651. /**
  139652. * Renders a layer on top of an existing scene
  139653. */
  139654. export class UtilityLayerRenderer implements IDisposable {
  139655. /** the original scene that will be rendered on top of */
  139656. originalScene: Scene;
  139657. private _pointerCaptures;
  139658. private _lastPointerEvents;
  139659. private static _DefaultUtilityLayer;
  139660. private static _DefaultKeepDepthUtilityLayer;
  139661. private _sharedGizmoLight;
  139662. private _renderCamera;
  139663. /**
  139664. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  139665. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  139666. * @returns the camera that is used when rendering the utility layer
  139667. */
  139668. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  139669. /**
  139670. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  139671. * @param cam the camera that should be used when rendering the utility layer
  139672. */
  139673. setRenderCamera(cam: Nullable<Camera>): void;
  139674. /**
  139675. * @hidden
  139676. * Light which used by gizmos to get light shading
  139677. */
  139678. _getSharedGizmoLight(): HemisphericLight;
  139679. /**
  139680. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  139681. */
  139682. pickUtilitySceneFirst: boolean;
  139683. /**
  139684. * 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)
  139685. */
  139686. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  139687. /**
  139688. * 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)
  139689. */
  139690. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  139691. /**
  139692. * The scene that is rendered on top of the original scene
  139693. */
  139694. utilityLayerScene: Scene;
  139695. /**
  139696. * If the utility layer should automatically be rendered on top of existing scene
  139697. */
  139698. shouldRender: boolean;
  139699. /**
  139700. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  139701. */
  139702. onlyCheckPointerDownEvents: boolean;
  139703. /**
  139704. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  139705. */
  139706. processAllEvents: boolean;
  139707. /**
  139708. * Observable raised when the pointer move from the utility layer scene to the main scene
  139709. */
  139710. onPointerOutObservable: Observable<number>;
  139711. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  139712. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  139713. private _afterRenderObserver;
  139714. private _sceneDisposeObserver;
  139715. private _originalPointerObserver;
  139716. /**
  139717. * Instantiates a UtilityLayerRenderer
  139718. * @param originalScene the original scene that will be rendered on top of
  139719. * @param handleEvents boolean indicating if the utility layer should handle events
  139720. */
  139721. constructor(
  139722. /** the original scene that will be rendered on top of */
  139723. originalScene: Scene, handleEvents?: boolean);
  139724. private _notifyObservers;
  139725. /**
  139726. * Renders the utility layers scene on top of the original scene
  139727. */
  139728. render(): void;
  139729. /**
  139730. * Disposes of the renderer
  139731. */
  139732. dispose(): void;
  139733. private _updateCamera;
  139734. }
  139735. }
  139736. declare module BABYLON {
  139737. /**
  139738. * Options interface for the pointer selection module
  139739. */
  139740. export interface IWebXRControllerPointerSelectionOptions {
  139741. /**
  139742. * if provided, this scene will be used to render meshes.
  139743. */
  139744. customUtilityLayerScene?: Scene;
  139745. /**
  139746. * 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)
  139747. * If not disabled, the last picked point will be used to execute a pointer up event
  139748. * If disabled, pointer up event will be triggered right after the pointer down event.
  139749. * Used in screen and gaze target ray mode only
  139750. */
  139751. disablePointerUpOnTouchOut: boolean;
  139752. /**
  139753. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  139754. */
  139755. forceGazeMode: boolean;
  139756. /**
  139757. * 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
  139758. * to start a new countdown to the pointer down event.
  139759. * Defaults to 1.
  139760. */
  139761. gazeModePointerMovedFactor?: number;
  139762. /**
  139763. * Different button type to use instead of the main component
  139764. */
  139765. overrideButtonId?: string;
  139766. /**
  139767. * use this rendering group id for the meshes (optional)
  139768. */
  139769. renderingGroupId?: number;
  139770. /**
  139771. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  139772. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  139773. * 3000 means 3 seconds between pointing at something and selecting it
  139774. */
  139775. timeToSelect?: number;
  139776. /**
  139777. * Should meshes created here be added to a utility layer or the main scene
  139778. */
  139779. useUtilityLayer?: boolean;
  139780. /**
  139781. * Optional WebXR camera to be used for gaze selection
  139782. */
  139783. gazeCamera?: WebXRCamera;
  139784. /**
  139785. * the xr input to use with this pointer selection
  139786. */
  139787. xrInput: WebXRInput;
  139788. /**
  139789. * Should the scene pointerX and pointerY update be disabled
  139790. * This is required for fullscreen AR GUI, but might slow down other experiences.
  139791. * Disable in VR, if not needed.
  139792. * The first rig camera (left eye) will be used to calculate the projection
  139793. */
  139794. disableScenePointerVectorUpdate: boolean;
  139795. /**
  139796. * Enable pointer selection on all controllers instead of switching between them
  139797. */
  139798. enablePointerSelectionOnAllControllers?: boolean;
  139799. /**
  139800. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  139801. * If switch is enabled, it will still allow the user to switch between the different controllers
  139802. */
  139803. preferredHandedness?: XRHandedness;
  139804. /**
  139805. * Disable switching the pointer selection from one controller to the other.
  139806. * 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
  139807. */
  139808. disableSwitchOnClick?: boolean;
  139809. /**
  139810. * The maximum distance of the pointer selection feature. Defaults to 100.
  139811. */
  139812. maxPointerDistance?: number;
  139813. }
  139814. /**
  139815. * A module that will enable pointer selection for motion controllers of XR Input Sources
  139816. */
  139817. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  139818. private readonly _options;
  139819. private static _idCounter;
  139820. private _attachController;
  139821. private _controllers;
  139822. private _scene;
  139823. private _tmpVectorForPickCompare;
  139824. private _attachedController;
  139825. /**
  139826. * The module's name
  139827. */
  139828. static readonly Name: string;
  139829. /**
  139830. * The (Babylon) version of this module.
  139831. * This is an integer representing the implementation version.
  139832. * This number does not correspond to the WebXR specs version
  139833. */
  139834. static readonly Version: number;
  139835. /**
  139836. * Disable lighting on the laser pointer (so it will always be visible)
  139837. */
  139838. disablePointerLighting: boolean;
  139839. /**
  139840. * Disable lighting on the selection mesh (so it will always be visible)
  139841. */
  139842. disableSelectionMeshLighting: boolean;
  139843. /**
  139844. * Should the laser pointer be displayed
  139845. */
  139846. displayLaserPointer: boolean;
  139847. /**
  139848. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  139849. */
  139850. displaySelectionMesh: boolean;
  139851. /**
  139852. * This color will be set to the laser pointer when selection is triggered
  139853. */
  139854. laserPointerPickedColor: Color3;
  139855. /**
  139856. * Default color of the laser pointer
  139857. */
  139858. laserPointerDefaultColor: Color3;
  139859. /**
  139860. * default color of the selection ring
  139861. */
  139862. selectionMeshDefaultColor: Color3;
  139863. /**
  139864. * This color will be applied to the selection ring when selection is triggered
  139865. */
  139866. selectionMeshPickedColor: Color3;
  139867. /**
  139868. * Optional filter to be used for ray selection. This predicate shares behavior with
  139869. * scene.pointerMovePredicate which takes priority if it is also assigned.
  139870. */
  139871. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  139872. /**
  139873. * constructs a new background remover module
  139874. * @param _xrSessionManager the session manager for this module
  139875. * @param _options read-only options to be used in this module
  139876. */
  139877. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  139878. /**
  139879. * attach this feature
  139880. * Will usually be called by the features manager
  139881. *
  139882. * @returns true if successful.
  139883. */
  139884. attach(): boolean;
  139885. /**
  139886. * detach this feature.
  139887. * Will usually be called by the features manager
  139888. *
  139889. * @returns true if successful.
  139890. */
  139891. detach(): boolean;
  139892. /**
  139893. * Will get the mesh under a specific pointer.
  139894. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  139895. * @param controllerId the controllerId to check
  139896. * @returns The mesh under pointer or null if no mesh is under the pointer
  139897. */
  139898. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  139899. /**
  139900. * Get the xr controller that correlates to the pointer id in the pointer event
  139901. *
  139902. * @param id the pointer id to search for
  139903. * @returns the controller that correlates to this id or null if not found
  139904. */
  139905. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  139906. private _identityMatrix;
  139907. private _screenCoordinatesRef;
  139908. private _viewportRef;
  139909. protected _onXRFrame(_xrFrame: XRFrame): void;
  139910. private _attachGazeMode;
  139911. private _attachScreenRayMode;
  139912. private _attachTrackedPointerRayMode;
  139913. private _convertNormalToDirectionOfRay;
  139914. private _detachController;
  139915. private _generateNewMeshPair;
  139916. private _pickingMoved;
  139917. private _updatePointerDistance;
  139918. /** @hidden */
  139919. get lasterPointerDefaultColor(): Color3;
  139920. }
  139921. }
  139922. declare module BABYLON {
  139923. /**
  139924. * Button which can be used to enter a different mode of XR
  139925. */
  139926. export class WebXREnterExitUIButton {
  139927. /** button element */
  139928. element: HTMLElement;
  139929. /** XR initialization options for the button */
  139930. sessionMode: XRSessionMode;
  139931. /** Reference space type */
  139932. referenceSpaceType: XRReferenceSpaceType;
  139933. /**
  139934. * Creates a WebXREnterExitUIButton
  139935. * @param element button element
  139936. * @param sessionMode XR initialization session mode
  139937. * @param referenceSpaceType the type of reference space to be used
  139938. */
  139939. constructor(
  139940. /** button element */
  139941. element: HTMLElement,
  139942. /** XR initialization options for the button */
  139943. sessionMode: XRSessionMode,
  139944. /** Reference space type */
  139945. referenceSpaceType: XRReferenceSpaceType);
  139946. /**
  139947. * Extendable function which can be used to update the button's visuals when the state changes
  139948. * @param activeButton the current active button in the UI
  139949. */
  139950. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  139951. }
  139952. /**
  139953. * Options to create the webXR UI
  139954. */
  139955. export class WebXREnterExitUIOptions {
  139956. /**
  139957. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  139958. */
  139959. customButtons?: Array<WebXREnterExitUIButton>;
  139960. /**
  139961. * A reference space type to use when creating the default button.
  139962. * Default is local-floor
  139963. */
  139964. referenceSpaceType?: XRReferenceSpaceType;
  139965. /**
  139966. * Context to enter xr with
  139967. */
  139968. renderTarget?: Nullable<WebXRRenderTarget>;
  139969. /**
  139970. * A session mode to use when creating the default button.
  139971. * Default is immersive-vr
  139972. */
  139973. sessionMode?: XRSessionMode;
  139974. /**
  139975. * A list of optional features to init the session with
  139976. */
  139977. optionalFeatures?: string[];
  139978. /**
  139979. * A list of optional features to init the session with
  139980. */
  139981. requiredFeatures?: string[];
  139982. /**
  139983. * If defined, this function will be executed if the UI encounters an error when entering XR
  139984. */
  139985. onError?: (error: any) => void;
  139986. }
  139987. /**
  139988. * UI to allow the user to enter/exit XR mode
  139989. */
  139990. export class WebXREnterExitUI implements IDisposable {
  139991. private scene;
  139992. /** version of the options passed to this UI */
  139993. options: WebXREnterExitUIOptions;
  139994. private _activeButton;
  139995. private _buttons;
  139996. /**
  139997. * The HTML Div Element to which buttons are added.
  139998. */
  139999. readonly overlay: HTMLDivElement;
  140000. /**
  140001. * Fired every time the active button is changed.
  140002. *
  140003. * When xr is entered via a button that launches xr that button will be the callback parameter
  140004. *
  140005. * When exiting xr the callback parameter will be null)
  140006. */
  140007. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  140008. /**
  140009. *
  140010. * @param scene babylon scene object to use
  140011. * @param options (read-only) version of the options passed to this UI
  140012. */
  140013. private constructor();
  140014. /**
  140015. * Creates UI to allow the user to enter/exit XR mode
  140016. * @param scene the scene to add the ui to
  140017. * @param helper the xr experience helper to enter/exit xr with
  140018. * @param options options to configure the UI
  140019. * @returns the created ui
  140020. */
  140021. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  140022. /**
  140023. * Disposes of the XR UI component
  140024. */
  140025. dispose(): void;
  140026. private _updateButtons;
  140027. }
  140028. }
  140029. declare module BABYLON {
  140030. /**
  140031. * Class containing static functions to help procedurally build meshes
  140032. */
  140033. export class LinesBuilder {
  140034. /**
  140035. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  140036. * * 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
  140037. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  140038. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  140039. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  140040. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  140041. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  140042. * * 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
  140043. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  140044. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140045. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  140046. * @param name defines the name of the new line system
  140047. * @param options defines the options used to create the line system
  140048. * @param scene defines the hosting scene
  140049. * @returns a new line system mesh
  140050. */
  140051. static CreateLineSystem(name: string, options: {
  140052. lines: Vector3[][];
  140053. updatable?: boolean;
  140054. instance?: Nullable<LinesMesh>;
  140055. colors?: Nullable<Color4[][]>;
  140056. useVertexAlpha?: boolean;
  140057. }, scene: Nullable<Scene>): LinesMesh;
  140058. /**
  140059. * Creates a line mesh
  140060. * 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
  140061. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  140062. * * The parameter `points` is an array successive Vector3
  140063. * * 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
  140064. * * The optional parameter `colors` is an array of successive Color4, one per line point
  140065. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  140066. * * When updating an instance, remember that only point positions can change, not the number of points
  140067. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140068. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  140069. * @param name defines the name of the new line system
  140070. * @param options defines the options used to create the line system
  140071. * @param scene defines the hosting scene
  140072. * @returns a new line mesh
  140073. */
  140074. static CreateLines(name: string, options: {
  140075. points: Vector3[];
  140076. updatable?: boolean;
  140077. instance?: Nullable<LinesMesh>;
  140078. colors?: Color4[];
  140079. useVertexAlpha?: boolean;
  140080. }, scene?: Nullable<Scene>): LinesMesh;
  140081. /**
  140082. * Creates a dashed line mesh
  140083. * * 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
  140084. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  140085. * * The parameter `points` is an array successive Vector3
  140086. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  140087. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  140088. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  140089. * * 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
  140090. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  140091. * * When updating an instance, remember that only point positions can change, not the number of points
  140092. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  140093. * @param name defines the name of the mesh
  140094. * @param options defines the options used to create the mesh
  140095. * @param scene defines the hosting scene
  140096. * @returns the dashed line mesh
  140097. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  140098. */
  140099. static CreateDashedLines(name: string, options: {
  140100. points: Vector3[];
  140101. dashSize?: number;
  140102. gapSize?: number;
  140103. dashNb?: number;
  140104. updatable?: boolean;
  140105. instance?: LinesMesh;
  140106. useVertexAlpha?: boolean;
  140107. }, scene?: Nullable<Scene>): LinesMesh;
  140108. }
  140109. }
  140110. declare module BABYLON {
  140111. /**
  140112. * Construction options for a timer
  140113. */
  140114. export interface ITimerOptions<T> {
  140115. /**
  140116. * Time-to-end
  140117. */
  140118. timeout: number;
  140119. /**
  140120. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  140121. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  140122. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  140123. */
  140124. contextObservable: Observable<T>;
  140125. /**
  140126. * Optional parameters when adding an observer to the observable
  140127. */
  140128. observableParameters?: {
  140129. mask?: number;
  140130. insertFirst?: boolean;
  140131. scope?: any;
  140132. };
  140133. /**
  140134. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  140135. */
  140136. breakCondition?: (data?: ITimerData<T>) => boolean;
  140137. /**
  140138. * Will be triggered when the time condition has met
  140139. */
  140140. onEnded?: (data: ITimerData<any>) => void;
  140141. /**
  140142. * Will be triggered when the break condition has met (prematurely ended)
  140143. */
  140144. onAborted?: (data: ITimerData<any>) => void;
  140145. /**
  140146. * Optional function to execute on each tick (or count)
  140147. */
  140148. onTick?: (data: ITimerData<any>) => void;
  140149. }
  140150. /**
  140151. * An interface defining the data sent by the timer
  140152. */
  140153. export interface ITimerData<T> {
  140154. /**
  140155. * When did it start
  140156. */
  140157. startTime: number;
  140158. /**
  140159. * Time now
  140160. */
  140161. currentTime: number;
  140162. /**
  140163. * Time passed since started
  140164. */
  140165. deltaTime: number;
  140166. /**
  140167. * How much is completed, in [0.0...1.0].
  140168. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  140169. */
  140170. completeRate: number;
  140171. /**
  140172. * What the registered observable sent in the last count
  140173. */
  140174. payload: T;
  140175. }
  140176. /**
  140177. * The current state of the timer
  140178. */
  140179. export enum TimerState {
  140180. /**
  140181. * Timer initialized, not yet started
  140182. */
  140183. INIT = 0,
  140184. /**
  140185. * Timer started and counting
  140186. */
  140187. STARTED = 1,
  140188. /**
  140189. * Timer ended (whether aborted or time reached)
  140190. */
  140191. ENDED = 2
  140192. }
  140193. /**
  140194. * A simple version of the timer. Will take options and start the timer immediately after calling it
  140195. *
  140196. * @param options options with which to initialize this timer
  140197. */
  140198. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  140199. /**
  140200. * An advanced implementation of a timer class
  140201. */
  140202. export class AdvancedTimer<T = any> implements IDisposable {
  140203. /**
  140204. * Will notify each time the timer calculates the remaining time
  140205. */
  140206. onEachCountObservable: Observable<ITimerData<T>>;
  140207. /**
  140208. * Will trigger when the timer was aborted due to the break condition
  140209. */
  140210. onTimerAbortedObservable: Observable<ITimerData<T>>;
  140211. /**
  140212. * Will trigger when the timer ended successfully
  140213. */
  140214. onTimerEndedObservable: Observable<ITimerData<T>>;
  140215. /**
  140216. * Will trigger when the timer state has changed
  140217. */
  140218. onStateChangedObservable: Observable<TimerState>;
  140219. private _observer;
  140220. private _contextObservable;
  140221. private _observableParameters;
  140222. private _startTime;
  140223. private _timer;
  140224. private _state;
  140225. private _breakCondition;
  140226. private _timeToEnd;
  140227. private _breakOnNextTick;
  140228. /**
  140229. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  140230. * @param options construction options for this advanced timer
  140231. */
  140232. constructor(options: ITimerOptions<T>);
  140233. /**
  140234. * set a breaking condition for this timer. Default is to never break during count
  140235. * @param predicate the new break condition. Returns true to break, false otherwise
  140236. */
  140237. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  140238. /**
  140239. * Reset ALL associated observables in this advanced timer
  140240. */
  140241. clearObservables(): void;
  140242. /**
  140243. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  140244. *
  140245. * @param timeToEnd how much time to measure until timer ended
  140246. */
  140247. start(timeToEnd?: number): void;
  140248. /**
  140249. * Will force a stop on the next tick.
  140250. */
  140251. stop(): void;
  140252. /**
  140253. * Dispose this timer, clearing all resources
  140254. */
  140255. dispose(): void;
  140256. private _setState;
  140257. private _tick;
  140258. private _stop;
  140259. }
  140260. }
  140261. declare module BABYLON {
  140262. /**
  140263. * The options container for the teleportation module
  140264. */
  140265. export interface IWebXRTeleportationOptions {
  140266. /**
  140267. * if provided, this scene will be used to render meshes.
  140268. */
  140269. customUtilityLayerScene?: Scene;
  140270. /**
  140271. * Values to configure the default target mesh
  140272. */
  140273. defaultTargetMeshOptions?: {
  140274. /**
  140275. * Fill color of the teleportation area
  140276. */
  140277. teleportationFillColor?: string;
  140278. /**
  140279. * Border color for the teleportation area
  140280. */
  140281. teleportationBorderColor?: string;
  140282. /**
  140283. * Disable the mesh's animation sequence
  140284. */
  140285. disableAnimation?: boolean;
  140286. /**
  140287. * Disable lighting on the material or the ring and arrow
  140288. */
  140289. disableLighting?: boolean;
  140290. /**
  140291. * Override the default material of the torus and arrow
  140292. */
  140293. torusArrowMaterial?: Material;
  140294. };
  140295. /**
  140296. * A list of meshes to use as floor meshes.
  140297. * Meshes can be added and removed after initializing the feature using the
  140298. * addFloorMesh and removeFloorMesh functions
  140299. * If empty, rotation will still work
  140300. */
  140301. floorMeshes?: AbstractMesh[];
  140302. /**
  140303. * use this rendering group id for the meshes (optional)
  140304. */
  140305. renderingGroupId?: number;
  140306. /**
  140307. * Should teleportation move only to snap points
  140308. */
  140309. snapPointsOnly?: boolean;
  140310. /**
  140311. * An array of points to which the teleportation will snap to.
  140312. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  140313. */
  140314. snapPositions?: Vector3[];
  140315. /**
  140316. * How close should the teleportation ray be in order to snap to position.
  140317. * Default to 0.8 units (meters)
  140318. */
  140319. snapToPositionRadius?: number;
  140320. /**
  140321. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  140322. * If you want to support rotation, make sure your mesh has a direction indicator.
  140323. *
  140324. * When left untouched, the default mesh will be initialized.
  140325. */
  140326. teleportationTargetMesh?: AbstractMesh;
  140327. /**
  140328. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  140329. */
  140330. timeToTeleport?: number;
  140331. /**
  140332. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  140333. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  140334. */
  140335. useMainComponentOnly?: boolean;
  140336. /**
  140337. * Should meshes created here be added to a utility layer or the main scene
  140338. */
  140339. useUtilityLayer?: boolean;
  140340. /**
  140341. * Babylon XR Input class for controller
  140342. */
  140343. xrInput: WebXRInput;
  140344. /**
  140345. * Meshes that the teleportation ray cannot go through
  140346. */
  140347. pickBlockerMeshes?: AbstractMesh[];
  140348. /**
  140349. * Should teleport work only on a specific hand?
  140350. */
  140351. forceHandedness?: XRHandedness;
  140352. /**
  140353. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  140354. */
  140355. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  140356. }
  140357. /**
  140358. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  140359. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  140360. * the input of the attached controllers.
  140361. */
  140362. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  140363. private _options;
  140364. private _controllers;
  140365. private _currentTeleportationControllerId;
  140366. private _floorMeshes;
  140367. private _quadraticBezierCurve;
  140368. private _selectionFeature;
  140369. private _snapToPositions;
  140370. private _snappedToPoint;
  140371. private _teleportationRingMaterial?;
  140372. private _tmpRay;
  140373. private _tmpVector;
  140374. private _tmpQuaternion;
  140375. /**
  140376. * The module's name
  140377. */
  140378. static readonly Name: string;
  140379. /**
  140380. * The (Babylon) version of this module.
  140381. * This is an integer representing the implementation version.
  140382. * This number does not correspond to the webxr specs version
  140383. */
  140384. static readonly Version: number;
  140385. /**
  140386. * Is movement backwards enabled
  140387. */
  140388. backwardsMovementEnabled: boolean;
  140389. /**
  140390. * Distance to travel when moving backwards
  140391. */
  140392. backwardsTeleportationDistance: number;
  140393. /**
  140394. * The distance from the user to the inspection point in the direction of the controller
  140395. * A higher number will allow the user to move further
  140396. * defaults to 5 (meters, in xr units)
  140397. */
  140398. parabolicCheckRadius: number;
  140399. /**
  140400. * Should the module support parabolic ray on top of direct ray
  140401. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  140402. * Very helpful when moving between floors / different heights
  140403. */
  140404. parabolicRayEnabled: boolean;
  140405. /**
  140406. * The second type of ray - straight line.
  140407. * Should it be enabled or should the parabolic line be the only one.
  140408. */
  140409. straightRayEnabled: boolean;
  140410. /**
  140411. * How much rotation should be applied when rotating right and left
  140412. */
  140413. rotationAngle: number;
  140414. private _rotationEnabled;
  140415. /**
  140416. * Is rotation enabled when moving forward?
  140417. * Disabling this feature will prevent the user from deciding the direction when teleporting
  140418. */
  140419. get rotationEnabled(): boolean;
  140420. /**
  140421. * Sets wether rotation is enabled or not
  140422. * @param enabled is rotation enabled when teleportation is shown
  140423. */
  140424. set rotationEnabled(enabled: boolean);
  140425. /**
  140426. * Exposes the currently set teleportation target mesh.
  140427. */
  140428. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  140429. /**
  140430. * constructs a new anchor system
  140431. * @param _xrSessionManager an instance of WebXRSessionManager
  140432. * @param _options configuration object for this feature
  140433. */
  140434. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  140435. /**
  140436. * Get the snapPointsOnly flag
  140437. */
  140438. get snapPointsOnly(): boolean;
  140439. /**
  140440. * Sets the snapPointsOnly flag
  140441. * @param snapToPoints should teleportation be exclusively to snap points
  140442. */
  140443. set snapPointsOnly(snapToPoints: boolean);
  140444. /**
  140445. * Add a new mesh to the floor meshes array
  140446. * @param mesh the mesh to use as floor mesh
  140447. */
  140448. addFloorMesh(mesh: AbstractMesh): void;
  140449. /**
  140450. * Add a new snap-to point to fix teleportation to this position
  140451. * @param newSnapPoint The new Snap-To point
  140452. */
  140453. addSnapPoint(newSnapPoint: Vector3): void;
  140454. attach(): boolean;
  140455. detach(): boolean;
  140456. dispose(): void;
  140457. /**
  140458. * Remove a mesh from the floor meshes array
  140459. * @param mesh the mesh to remove
  140460. */
  140461. removeFloorMesh(mesh: AbstractMesh): void;
  140462. /**
  140463. * Remove a mesh from the floor meshes array using its name
  140464. * @param name the mesh name to remove
  140465. */
  140466. removeFloorMeshByName(name: string): void;
  140467. /**
  140468. * 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
  140469. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  140470. * @returns was the point found and removed or not
  140471. */
  140472. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  140473. /**
  140474. * This function sets a selection feature that will be disabled when
  140475. * the forward ray is shown and will be reattached when hidden.
  140476. * This is used to remove the selection rays when moving.
  140477. * @param selectionFeature the feature to disable when forward movement is enabled
  140478. */
  140479. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  140480. protected _onXRFrame(_xrFrame: XRFrame): void;
  140481. private _attachController;
  140482. private _createDefaultTargetMesh;
  140483. private _detachController;
  140484. private _findClosestSnapPointWithRadius;
  140485. private _setTargetMeshPosition;
  140486. private _setTargetMeshVisibility;
  140487. private _showParabolicPath;
  140488. private _teleportForward;
  140489. }
  140490. }
  140491. declare module BABYLON {
  140492. /**
  140493. * Options for the default xr helper
  140494. */
  140495. export class WebXRDefaultExperienceOptions {
  140496. /**
  140497. * Enable or disable default UI to enter XR
  140498. */
  140499. disableDefaultUI?: boolean;
  140500. /**
  140501. * Should teleportation not initialize. defaults to false.
  140502. */
  140503. disableTeleportation?: boolean;
  140504. /**
  140505. * Floor meshes that will be used for teleport
  140506. */
  140507. floorMeshes?: Array<AbstractMesh>;
  140508. /**
  140509. * If set to true, the first frame will not be used to reset position
  140510. * The first frame is mainly used when copying transformation from the old camera
  140511. * Mainly used in AR
  140512. */
  140513. ignoreNativeCameraTransformation?: boolean;
  140514. /**
  140515. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  140516. */
  140517. inputOptions?: IWebXRInputOptions;
  140518. /**
  140519. * optional configuration for the output canvas
  140520. */
  140521. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  140522. /**
  140523. * optional UI options. This can be used among other to change session mode and reference space type
  140524. */
  140525. uiOptions?: WebXREnterExitUIOptions;
  140526. /**
  140527. * When loading teleportation and pointer select, use stable versions instead of latest.
  140528. */
  140529. useStablePlugins?: boolean;
  140530. /**
  140531. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  140532. */
  140533. renderingGroupId?: number;
  140534. /**
  140535. * A list of optional features to init the session with
  140536. * If set to true, all features we support will be added
  140537. */
  140538. optionalFeatures?: boolean | string[];
  140539. }
  140540. /**
  140541. * Default experience which provides a similar setup to the previous webVRExperience
  140542. */
  140543. export class WebXRDefaultExperience {
  140544. /**
  140545. * Base experience
  140546. */
  140547. baseExperience: WebXRExperienceHelper;
  140548. /**
  140549. * Enables ui for entering/exiting xr
  140550. */
  140551. enterExitUI: WebXREnterExitUI;
  140552. /**
  140553. * Input experience extension
  140554. */
  140555. input: WebXRInput;
  140556. /**
  140557. * Enables laser pointer and selection
  140558. */
  140559. pointerSelection: WebXRControllerPointerSelection;
  140560. /**
  140561. * Default target xr should render to
  140562. */
  140563. renderTarget: WebXRRenderTarget;
  140564. /**
  140565. * Enables teleportation
  140566. */
  140567. teleportation: WebXRMotionControllerTeleportation;
  140568. private constructor();
  140569. /**
  140570. * Creates the default xr experience
  140571. * @param scene scene
  140572. * @param options options for basic configuration
  140573. * @returns resulting WebXRDefaultExperience
  140574. */
  140575. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  140576. /**
  140577. * DIsposes of the experience helper
  140578. */
  140579. dispose(): void;
  140580. }
  140581. }
  140582. declare module BABYLON {
  140583. /**
  140584. * Options to modify the vr teleportation behavior.
  140585. */
  140586. export interface VRTeleportationOptions {
  140587. /**
  140588. * The name of the mesh which should be used as the teleportation floor. (default: null)
  140589. */
  140590. floorMeshName?: string;
  140591. /**
  140592. * A list of meshes to be used as the teleportation floor. (default: empty)
  140593. */
  140594. floorMeshes?: Mesh[];
  140595. /**
  140596. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  140597. */
  140598. teleportationMode?: number;
  140599. /**
  140600. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  140601. */
  140602. teleportationTime?: number;
  140603. /**
  140604. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  140605. */
  140606. teleportationSpeed?: number;
  140607. /**
  140608. * The easing function used in the animation or null for Linear. (default CircleEase)
  140609. */
  140610. easingFunction?: EasingFunction;
  140611. }
  140612. /**
  140613. * Options to modify the vr experience helper's behavior.
  140614. */
  140615. export interface VRExperienceHelperOptions extends WebVROptions {
  140616. /**
  140617. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  140618. */
  140619. createDeviceOrientationCamera?: boolean;
  140620. /**
  140621. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  140622. */
  140623. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  140624. /**
  140625. * Uses the main button on the controller to toggle the laser casted. (default: true)
  140626. */
  140627. laserToggle?: boolean;
  140628. /**
  140629. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  140630. */
  140631. floorMeshes?: Mesh[];
  140632. /**
  140633. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  140634. */
  140635. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  140636. /**
  140637. * Defines if WebXR should be used instead of WebVR (if available)
  140638. */
  140639. useXR?: boolean;
  140640. }
  140641. /**
  140642. * Event containing information after VR has been entered
  140643. */
  140644. export class OnAfterEnteringVRObservableEvent {
  140645. /**
  140646. * If entering vr was successful
  140647. */
  140648. success: boolean;
  140649. }
  140650. /**
  140651. * Helps to quickly add VR support to an existing scene.
  140652. * See https://doc.babylonjs.com/how_to/webvr_helper
  140653. */
  140654. export class VRExperienceHelper {
  140655. /** Options to modify the vr experience helper's behavior. */
  140656. webVROptions: VRExperienceHelperOptions;
  140657. private _scene;
  140658. private _position;
  140659. private _btnVR;
  140660. private _btnVRDisplayed;
  140661. private _webVRsupported;
  140662. private _webVRready;
  140663. private _webVRrequesting;
  140664. private _webVRpresenting;
  140665. private _hasEnteredVR;
  140666. private _fullscreenVRpresenting;
  140667. private _inputElement;
  140668. private _webVRCamera;
  140669. private _vrDeviceOrientationCamera;
  140670. private _deviceOrientationCamera;
  140671. private _existingCamera;
  140672. private _onKeyDown;
  140673. private _onVrDisplayPresentChange;
  140674. private _onVRDisplayChanged;
  140675. private _onVRRequestPresentStart;
  140676. private _onVRRequestPresentComplete;
  140677. /**
  140678. * 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)
  140679. */
  140680. enableGazeEvenWhenNoPointerLock: boolean;
  140681. /**
  140682. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  140683. */
  140684. exitVROnDoubleTap: boolean;
  140685. /**
  140686. * Observable raised right before entering VR.
  140687. */
  140688. onEnteringVRObservable: Observable<VRExperienceHelper>;
  140689. /**
  140690. * Observable raised when entering VR has completed.
  140691. */
  140692. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  140693. /**
  140694. * Observable raised when exiting VR.
  140695. */
  140696. onExitingVRObservable: Observable<VRExperienceHelper>;
  140697. /**
  140698. * Observable raised when controller mesh is loaded.
  140699. */
  140700. onControllerMeshLoadedObservable: Observable<WebVRController>;
  140701. /** Return this.onEnteringVRObservable
  140702. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  140703. */
  140704. get onEnteringVR(): Observable<VRExperienceHelper>;
  140705. /** Return this.onExitingVRObservable
  140706. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  140707. */
  140708. get onExitingVR(): Observable<VRExperienceHelper>;
  140709. /** Return this.onControllerMeshLoadedObservable
  140710. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  140711. */
  140712. get onControllerMeshLoaded(): Observable<WebVRController>;
  140713. private _rayLength;
  140714. private _useCustomVRButton;
  140715. private _teleportationRequested;
  140716. private _teleportActive;
  140717. private _floorMeshName;
  140718. private _floorMeshesCollection;
  140719. private _teleportationMode;
  140720. private _teleportationTime;
  140721. private _teleportationSpeed;
  140722. private _teleportationEasing;
  140723. private _rotationAllowed;
  140724. private _teleportBackwardsVector;
  140725. private _teleportationTarget;
  140726. private _isDefaultTeleportationTarget;
  140727. private _postProcessMove;
  140728. private _teleportationFillColor;
  140729. private _teleportationBorderColor;
  140730. private _rotationAngle;
  140731. private _haloCenter;
  140732. private _cameraGazer;
  140733. private _padSensibilityUp;
  140734. private _padSensibilityDown;
  140735. private _leftController;
  140736. private _rightController;
  140737. private _gazeColor;
  140738. private _laserColor;
  140739. private _pickedLaserColor;
  140740. private _pickedGazeColor;
  140741. /**
  140742. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  140743. */
  140744. onNewMeshSelected: Observable<AbstractMesh>;
  140745. /**
  140746. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  140747. * This observable will provide the mesh and the controller used to select the mesh
  140748. */
  140749. onMeshSelectedWithController: Observable<{
  140750. mesh: AbstractMesh;
  140751. controller: WebVRController;
  140752. }>;
  140753. /**
  140754. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  140755. */
  140756. onNewMeshPicked: Observable<PickingInfo>;
  140757. private _circleEase;
  140758. /**
  140759. * Observable raised before camera teleportation
  140760. */
  140761. onBeforeCameraTeleport: Observable<Vector3>;
  140762. /**
  140763. * Observable raised after camera teleportation
  140764. */
  140765. onAfterCameraTeleport: Observable<Vector3>;
  140766. /**
  140767. * Observable raised when current selected mesh gets unselected
  140768. */
  140769. onSelectedMeshUnselected: Observable<AbstractMesh>;
  140770. private _raySelectionPredicate;
  140771. /**
  140772. * To be optionaly changed by user to define custom ray selection
  140773. */
  140774. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  140775. /**
  140776. * To be optionaly changed by user to define custom selection logic (after ray selection)
  140777. */
  140778. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  140779. /**
  140780. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  140781. */
  140782. teleportationEnabled: boolean;
  140783. private _defaultHeight;
  140784. private _teleportationInitialized;
  140785. private _interactionsEnabled;
  140786. private _interactionsRequested;
  140787. private _displayGaze;
  140788. private _displayLaserPointer;
  140789. /**
  140790. * The mesh used to display where the user is going to teleport.
  140791. */
  140792. get teleportationTarget(): Mesh;
  140793. /**
  140794. * Sets the mesh to be used to display where the user is going to teleport.
  140795. */
  140796. set teleportationTarget(value: Mesh);
  140797. /**
  140798. * 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
  140799. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  140800. * See https://doc.babylonjs.com/resources/baking_transformations
  140801. */
  140802. get gazeTrackerMesh(): Mesh;
  140803. set gazeTrackerMesh(value: Mesh);
  140804. /**
  140805. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  140806. */
  140807. updateGazeTrackerScale: boolean;
  140808. /**
  140809. * If the gaze trackers color should be updated when selecting meshes
  140810. */
  140811. updateGazeTrackerColor: boolean;
  140812. /**
  140813. * If the controller laser color should be updated when selecting meshes
  140814. */
  140815. updateControllerLaserColor: boolean;
  140816. /**
  140817. * The gaze tracking mesh corresponding to the left controller
  140818. */
  140819. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  140820. /**
  140821. * The gaze tracking mesh corresponding to the right controller
  140822. */
  140823. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  140824. /**
  140825. * If the ray of the gaze should be displayed.
  140826. */
  140827. get displayGaze(): boolean;
  140828. /**
  140829. * Sets if the ray of the gaze should be displayed.
  140830. */
  140831. set displayGaze(value: boolean);
  140832. /**
  140833. * If the ray of the LaserPointer should be displayed.
  140834. */
  140835. get displayLaserPointer(): boolean;
  140836. /**
  140837. * Sets if the ray of the LaserPointer should be displayed.
  140838. */
  140839. set displayLaserPointer(value: boolean);
  140840. /**
  140841. * The deviceOrientationCamera used as the camera when not in VR.
  140842. */
  140843. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  140844. /**
  140845. * Based on the current WebVR support, returns the current VR camera used.
  140846. */
  140847. get currentVRCamera(): Nullable<Camera>;
  140848. /**
  140849. * The webVRCamera which is used when in VR.
  140850. */
  140851. get webVRCamera(): WebVRFreeCamera;
  140852. /**
  140853. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  140854. */
  140855. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  140856. /**
  140857. * The html button that is used to trigger entering into VR.
  140858. */
  140859. get vrButton(): Nullable<HTMLButtonElement>;
  140860. private get _teleportationRequestInitiated();
  140861. /**
  140862. * Defines whether or not Pointer lock should be requested when switching to
  140863. * full screen.
  140864. */
  140865. requestPointerLockOnFullScreen: boolean;
  140866. /**
  140867. * If asking to force XR, this will be populated with the default xr experience
  140868. */
  140869. xr: WebXRDefaultExperience;
  140870. /**
  140871. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  140872. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  140873. */
  140874. xrTestDone: boolean;
  140875. /**
  140876. * Instantiates a VRExperienceHelper.
  140877. * Helps to quickly add VR support to an existing scene.
  140878. * @param scene The scene the VRExperienceHelper belongs to.
  140879. * @param webVROptions Options to modify the vr experience helper's behavior.
  140880. */
  140881. constructor(scene: Scene,
  140882. /** Options to modify the vr experience helper's behavior. */
  140883. webVROptions?: VRExperienceHelperOptions);
  140884. private completeVRInit;
  140885. private _onDefaultMeshLoaded;
  140886. private _onResize;
  140887. private _onFullscreenChange;
  140888. /**
  140889. * Gets a value indicating if we are currently in VR mode.
  140890. */
  140891. get isInVRMode(): boolean;
  140892. private onVrDisplayPresentChange;
  140893. private onVRDisplayChanged;
  140894. private moveButtonToBottomRight;
  140895. private displayVRButton;
  140896. private updateButtonVisibility;
  140897. private _cachedAngularSensibility;
  140898. /**
  140899. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  140900. * Otherwise, will use the fullscreen API.
  140901. */
  140902. enterVR(): void;
  140903. /**
  140904. * Attempt to exit VR, or fullscreen.
  140905. */
  140906. exitVR(): void;
  140907. /**
  140908. * The position of the vr experience helper.
  140909. */
  140910. get position(): Vector3;
  140911. /**
  140912. * Sets the position of the vr experience helper.
  140913. */
  140914. set position(value: Vector3);
  140915. /**
  140916. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  140917. */
  140918. enableInteractions(): void;
  140919. private get _noControllerIsActive();
  140920. private beforeRender;
  140921. private _isTeleportationFloor;
  140922. /**
  140923. * Adds a floor mesh to be used for teleportation.
  140924. * @param floorMesh the mesh to be used for teleportation.
  140925. */
  140926. addFloorMesh(floorMesh: Mesh): void;
  140927. /**
  140928. * Removes a floor mesh from being used for teleportation.
  140929. * @param floorMesh the mesh to be removed.
  140930. */
  140931. removeFloorMesh(floorMesh: Mesh): void;
  140932. /**
  140933. * Enables interactions and teleportation using the VR controllers and gaze.
  140934. * @param vrTeleportationOptions options to modify teleportation behavior.
  140935. */
  140936. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  140937. private _onNewGamepadConnected;
  140938. private _tryEnableInteractionOnController;
  140939. private _onNewGamepadDisconnected;
  140940. private _enableInteractionOnController;
  140941. private _checkTeleportWithRay;
  140942. private _checkRotate;
  140943. private _checkTeleportBackwards;
  140944. private _enableTeleportationOnController;
  140945. private _createTeleportationCircles;
  140946. private _displayTeleportationTarget;
  140947. private _hideTeleportationTarget;
  140948. private _rotateCamera;
  140949. private _moveTeleportationSelectorTo;
  140950. private _workingVector;
  140951. private _workingQuaternion;
  140952. private _workingMatrix;
  140953. /**
  140954. * Time Constant Teleportation Mode
  140955. */
  140956. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  140957. /**
  140958. * Speed Constant Teleportation Mode
  140959. */
  140960. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  140961. /**
  140962. * Teleports the users feet to the desired location
  140963. * @param location The location where the user's feet should be placed
  140964. */
  140965. teleportCamera(location: Vector3): void;
  140966. private _convertNormalToDirectionOfRay;
  140967. private _castRayAndSelectObject;
  140968. private _notifySelectedMeshUnselected;
  140969. /**
  140970. * Permanently set new colors for the laser pointer
  140971. * @param color the new laser color
  140972. * @param pickedColor the new laser color when picked mesh detected
  140973. */
  140974. setLaserColor(color: Color3, pickedColor?: Color3): void;
  140975. /**
  140976. * Set lighting enabled / disabled on the laser pointer of both controllers
  140977. * @param enabled should the lighting be enabled on the laser pointer
  140978. */
  140979. setLaserLightingState(enabled?: boolean): void;
  140980. /**
  140981. * Permanently set new colors for the gaze pointer
  140982. * @param color the new gaze color
  140983. * @param pickedColor the new gaze color when picked mesh detected
  140984. */
  140985. setGazeColor(color: Color3, pickedColor?: Color3): void;
  140986. /**
  140987. * Sets the color of the laser ray from the vr controllers.
  140988. * @param color new color for the ray.
  140989. */
  140990. changeLaserColor(color: Color3): void;
  140991. /**
  140992. * Sets the color of the ray from the vr headsets gaze.
  140993. * @param color new color for the ray.
  140994. */
  140995. changeGazeColor(color: Color3): void;
  140996. /**
  140997. * Exits VR and disposes of the vr experience helper
  140998. */
  140999. dispose(): void;
  141000. /**
  141001. * Gets the name of the VRExperienceHelper class
  141002. * @returns "VRExperienceHelper"
  141003. */
  141004. getClassName(): string;
  141005. }
  141006. }
  141007. declare module BABYLON {
  141008. /**
  141009. * Contains an array of blocks representing the octree
  141010. */
  141011. export interface IOctreeContainer<T> {
  141012. /**
  141013. * Blocks within the octree
  141014. */
  141015. blocks: Array<OctreeBlock<T>>;
  141016. }
  141017. /**
  141018. * Class used to store a cell in an octree
  141019. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  141020. */
  141021. export class OctreeBlock<T> {
  141022. /**
  141023. * Gets the content of the current block
  141024. */
  141025. entries: T[];
  141026. /**
  141027. * Gets the list of block children
  141028. */
  141029. blocks: Array<OctreeBlock<T>>;
  141030. private _depth;
  141031. private _maxDepth;
  141032. private _capacity;
  141033. private _minPoint;
  141034. private _maxPoint;
  141035. private _boundingVectors;
  141036. private _creationFunc;
  141037. /**
  141038. * Creates a new block
  141039. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  141040. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  141041. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  141042. * @param depth defines the current depth of this block in the octree
  141043. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  141044. * @param creationFunc defines a callback to call when an element is added to the block
  141045. */
  141046. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  141047. /**
  141048. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  141049. */
  141050. get capacity(): number;
  141051. /**
  141052. * Gets the minimum vector (in world space) of the block's bounding box
  141053. */
  141054. get minPoint(): Vector3;
  141055. /**
  141056. * Gets the maximum vector (in world space) of the block's bounding box
  141057. */
  141058. get maxPoint(): Vector3;
  141059. /**
  141060. * Add a new element to this block
  141061. * @param entry defines the element to add
  141062. */
  141063. addEntry(entry: T): void;
  141064. /**
  141065. * Remove an element from this block
  141066. * @param entry defines the element to remove
  141067. */
  141068. removeEntry(entry: T): void;
  141069. /**
  141070. * Add an array of elements to this block
  141071. * @param entries defines the array of elements to add
  141072. */
  141073. addEntries(entries: T[]): void;
  141074. /**
  141075. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  141076. * @param frustumPlanes defines the frustum planes to test
  141077. * @param selection defines the array to store current content if selection is positive
  141078. * @param allowDuplicate defines if the selection array can contains duplicated entries
  141079. */
  141080. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  141081. /**
  141082. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  141083. * @param sphereCenter defines the bounding sphere center
  141084. * @param sphereRadius defines the bounding sphere radius
  141085. * @param selection defines the array to store current content if selection is positive
  141086. * @param allowDuplicate defines if the selection array can contains duplicated entries
  141087. */
  141088. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  141089. /**
  141090. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  141091. * @param ray defines the ray to test with
  141092. * @param selection defines the array to store current content if selection is positive
  141093. */
  141094. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  141095. /**
  141096. * Subdivide the content into child blocks (this block will then be empty)
  141097. */
  141098. createInnerBlocks(): void;
  141099. /**
  141100. * @hidden
  141101. */
  141102. 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;
  141103. }
  141104. }
  141105. declare module BABYLON {
  141106. /**
  141107. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  141108. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  141109. */
  141110. export class Octree<T> {
  141111. /** 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.) */
  141112. maxDepth: number;
  141113. /**
  141114. * Blocks within the octree containing objects
  141115. */
  141116. blocks: Array<OctreeBlock<T>>;
  141117. /**
  141118. * Content stored in the octree
  141119. */
  141120. dynamicContent: T[];
  141121. private _maxBlockCapacity;
  141122. private _selectionContent;
  141123. private _creationFunc;
  141124. /**
  141125. * Creates a octree
  141126. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  141127. * @param creationFunc function to be used to instatiate the octree
  141128. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  141129. * @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.)
  141130. */
  141131. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  141132. /** 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.) */
  141133. maxDepth?: number);
  141134. /**
  141135. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  141136. * @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);
  141137. * @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);
  141138. * @param entries meshes to be added to the octree blocks
  141139. */
  141140. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  141141. /**
  141142. * Adds a mesh to the octree
  141143. * @param entry Mesh to add to the octree
  141144. */
  141145. addMesh(entry: T): void;
  141146. /**
  141147. * Remove an element from the octree
  141148. * @param entry defines the element to remove
  141149. */
  141150. removeMesh(entry: T): void;
  141151. /**
  141152. * Selects an array of meshes within the frustum
  141153. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  141154. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  141155. * @returns array of meshes within the frustum
  141156. */
  141157. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  141158. /**
  141159. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  141160. * @param sphereCenter defines the bounding sphere center
  141161. * @param sphereRadius defines the bounding sphere radius
  141162. * @param allowDuplicate defines if the selection array can contains duplicated entries
  141163. * @returns an array of objects that intersect the sphere
  141164. */
  141165. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  141166. /**
  141167. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  141168. * @param ray defines the ray to test with
  141169. * @returns array of intersected objects
  141170. */
  141171. intersectsRay(ray: Ray): SmartArray<T>;
  141172. /**
  141173. * Adds a mesh into the octree block if it intersects the block
  141174. */
  141175. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  141176. /**
  141177. * Adds a submesh into the octree block if it intersects the block
  141178. */
  141179. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  141180. }
  141181. }
  141182. declare module BABYLON {
  141183. interface Scene {
  141184. /**
  141185. * @hidden
  141186. * Backing Filed
  141187. */
  141188. _selectionOctree: Octree<AbstractMesh>;
  141189. /**
  141190. * Gets the octree used to boost mesh selection (picking)
  141191. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  141192. */
  141193. selectionOctree: Octree<AbstractMesh>;
  141194. /**
  141195. * Creates or updates the octree used to boost selection (picking)
  141196. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  141197. * @param maxCapacity defines the maximum capacity per leaf
  141198. * @param maxDepth defines the maximum depth of the octree
  141199. * @returns an octree of AbstractMesh
  141200. */
  141201. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  141202. }
  141203. interface AbstractMesh {
  141204. /**
  141205. * @hidden
  141206. * Backing Field
  141207. */
  141208. _submeshesOctree: Octree<SubMesh>;
  141209. /**
  141210. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  141211. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  141212. * @param maxCapacity defines the maximum size of each block (64 by default)
  141213. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  141214. * @returns the new octree
  141215. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  141216. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  141217. */
  141218. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  141219. }
  141220. /**
  141221. * Defines the octree scene component responsible to manage any octrees
  141222. * in a given scene.
  141223. */
  141224. export class OctreeSceneComponent {
  141225. /**
  141226. * The component name help to identify the component in the list of scene components.
  141227. */
  141228. readonly name: string;
  141229. /**
  141230. * The scene the component belongs to.
  141231. */
  141232. scene: Scene;
  141233. /**
  141234. * Indicates if the meshes have been checked to make sure they are isEnabled()
  141235. */
  141236. readonly checksIsEnabled: boolean;
  141237. /**
  141238. * Creates a new instance of the component for the given scene
  141239. * @param scene Defines the scene to register the component in
  141240. */
  141241. constructor(scene: Scene);
  141242. /**
  141243. * Registers the component in a given scene
  141244. */
  141245. register(): void;
  141246. /**
  141247. * Return the list of active meshes
  141248. * @returns the list of active meshes
  141249. */
  141250. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  141251. /**
  141252. * Return the list of active sub meshes
  141253. * @param mesh The mesh to get the candidates sub meshes from
  141254. * @returns the list of active sub meshes
  141255. */
  141256. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  141257. private _tempRay;
  141258. /**
  141259. * Return the list of sub meshes intersecting with a given local ray
  141260. * @param mesh defines the mesh to find the submesh for
  141261. * @param localRay defines the ray in local space
  141262. * @returns the list of intersecting sub meshes
  141263. */
  141264. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  141265. /**
  141266. * Return the list of sub meshes colliding with a collider
  141267. * @param mesh defines the mesh to find the submesh for
  141268. * @param collider defines the collider to evaluate the collision against
  141269. * @returns the list of colliding sub meshes
  141270. */
  141271. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  141272. /**
  141273. * Rebuilds the elements related to this component in case of
  141274. * context lost for instance.
  141275. */
  141276. rebuild(): void;
  141277. /**
  141278. * Disposes the component and the associated ressources.
  141279. */
  141280. dispose(): void;
  141281. }
  141282. }
  141283. declare module BABYLON {
  141284. /**
  141285. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  141286. */
  141287. export interface GizmoAxisCache {
  141288. /** Mesh used to runder the Gizmo */
  141289. gizmoMeshes: Mesh[];
  141290. /** Mesh used to detect user interaction with Gizmo */
  141291. colliderMeshes: Mesh[];
  141292. /** Material used to inicate color of gizmo mesh */
  141293. material: StandardMaterial;
  141294. /** Material used to inicate hover state of the Gizmo */
  141295. hoverMaterial: StandardMaterial;
  141296. /** Material used to inicate disabled state of the Gizmo */
  141297. disableMaterial: StandardMaterial;
  141298. /** Used to indicate Active state of the Gizmo */
  141299. active: boolean;
  141300. }
  141301. /**
  141302. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  141303. */
  141304. export class Gizmo implements IDisposable {
  141305. /** The utility layer the gizmo will be added to */
  141306. gizmoLayer: UtilityLayerRenderer;
  141307. /**
  141308. * The root mesh of the gizmo
  141309. */
  141310. _rootMesh: Mesh;
  141311. private _attachedMesh;
  141312. private _attachedNode;
  141313. /**
  141314. * Ratio for the scale of the gizmo (Default: 1)
  141315. */
  141316. protected _scaleRatio: number;
  141317. /**
  141318. * boolean updated by pointermove when a gizmo mesh is hovered
  141319. */
  141320. protected _isHovered: boolean;
  141321. /**
  141322. * Ratio for the scale of the gizmo (Default: 1)
  141323. */
  141324. set scaleRatio(value: number);
  141325. get scaleRatio(): number;
  141326. /**
  141327. * True when the mouse pointer is hovered a gizmo mesh
  141328. */
  141329. get isHovered(): boolean;
  141330. /**
  141331. * If a custom mesh has been set (Default: false)
  141332. */
  141333. protected _customMeshSet: boolean;
  141334. /**
  141335. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  141336. * * When set, interactions will be enabled
  141337. */
  141338. get attachedMesh(): Nullable<AbstractMesh>;
  141339. set attachedMesh(value: Nullable<AbstractMesh>);
  141340. /**
  141341. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  141342. * * When set, interactions will be enabled
  141343. */
  141344. get attachedNode(): Nullable<Node>;
  141345. set attachedNode(value: Nullable<Node>);
  141346. /**
  141347. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  141348. * @param mesh The mesh to replace the default mesh of the gizmo
  141349. */
  141350. setCustomMesh(mesh: Mesh): void;
  141351. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  141352. /**
  141353. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  141354. */
  141355. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  141356. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  141357. /**
  141358. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  141359. */
  141360. updateGizmoPositionToMatchAttachedMesh: boolean;
  141361. /**
  141362. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  141363. */
  141364. updateScale: boolean;
  141365. protected _interactionsEnabled: boolean;
  141366. protected _attachedNodeChanged(value: Nullable<Node>): void;
  141367. private _beforeRenderObserver;
  141368. private _tempQuaternion;
  141369. private _tempVector;
  141370. private _tempVector2;
  141371. private _tempMatrix1;
  141372. private _tempMatrix2;
  141373. private _rightHandtoLeftHandMatrix;
  141374. /**
  141375. * Creates a gizmo
  141376. * @param gizmoLayer The utility layer the gizmo will be added to
  141377. */
  141378. constructor(
  141379. /** The utility layer the gizmo will be added to */
  141380. gizmoLayer?: UtilityLayerRenderer);
  141381. /**
  141382. * Updates the gizmo to match the attached mesh's position/rotation
  141383. */
  141384. protected _update(): void;
  141385. /**
  141386. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  141387. * @param value Node, TransformNode or mesh
  141388. */
  141389. protected _matrixChanged(): void;
  141390. /**
  141391. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  141392. * @param gizmoLayer The utility layer the gizmo will be added to
  141393. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  141394. * @returns {Observer<PointerInfo>} pointerObserver
  141395. */
  141396. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  141397. /**
  141398. * Disposes of the gizmo
  141399. */
  141400. dispose(): void;
  141401. }
  141402. }
  141403. declare module BABYLON {
  141404. /**
  141405. * Single plane drag gizmo
  141406. */
  141407. export class PlaneDragGizmo extends Gizmo {
  141408. /**
  141409. * Drag behavior responsible for the gizmos dragging interactions
  141410. */
  141411. dragBehavior: PointerDragBehavior;
  141412. private _pointerObserver;
  141413. /**
  141414. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  141415. */
  141416. snapDistance: number;
  141417. /**
  141418. * Event that fires each time the gizmo snaps to a new location.
  141419. * * snapDistance is the the change in distance
  141420. */
  141421. onSnapObservable: Observable<{
  141422. snapDistance: number;
  141423. }>;
  141424. private _gizmoMesh;
  141425. private _coloredMaterial;
  141426. private _hoverMaterial;
  141427. private _disableMaterial;
  141428. private _isEnabled;
  141429. private _parent;
  141430. private _dragging;
  141431. /** @hidden */
  141432. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  141433. /**
  141434. * Creates a PlaneDragGizmo
  141435. * @param gizmoLayer The utility layer the gizmo will be added to
  141436. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  141437. * @param color The color of the gizmo
  141438. */
  141439. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  141440. protected _attachedNodeChanged(value: Nullable<Node>): void;
  141441. /**
  141442. * If the gizmo is enabled
  141443. */
  141444. set isEnabled(value: boolean);
  141445. get isEnabled(): boolean;
  141446. /**
  141447. * Disposes of the gizmo
  141448. */
  141449. dispose(): void;
  141450. }
  141451. }
  141452. declare module BABYLON {
  141453. /**
  141454. * Single plane rotation gizmo
  141455. */
  141456. export class PlaneRotationGizmo extends Gizmo {
  141457. /**
  141458. * Drag behavior responsible for the gizmos dragging interactions
  141459. */
  141460. dragBehavior: PointerDragBehavior;
  141461. private _pointerObserver;
  141462. /**
  141463. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  141464. */
  141465. snapDistance: number;
  141466. /**
  141467. * Event that fires each time the gizmo snaps to a new location.
  141468. * * snapDistance is the the change in distance
  141469. */
  141470. onSnapObservable: Observable<{
  141471. snapDistance: number;
  141472. }>;
  141473. private _isEnabled;
  141474. private _parent;
  141475. private _coloredMaterial;
  141476. private _hoverMaterial;
  141477. private _disableMaterial;
  141478. private _gizmoMesh;
  141479. private _rotationCircle;
  141480. private _dragging;
  141481. private static _CircleConstants;
  141482. /**
  141483. * Creates a PlaneRotationGizmo
  141484. * @param gizmoLayer The utility layer the gizmo will be added to
  141485. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  141486. * @param color The color of the gizmo
  141487. * @param tessellation Amount of tessellation to be used when creating rotation circles
  141488. * @param useEulerRotation Use and update Euler angle instead of quaternion
  141489. * @param thickness display gizmo axis thickness
  141490. */
  141491. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  141492. /** Create Geometry for Gizmo */
  141493. private _createGizmoMesh;
  141494. protected _attachedNodeChanged(value: Nullable<Node>): void;
  141495. private setupRotationCircle;
  141496. private updateRotationPath;
  141497. private updateRotationCircle;
  141498. /**
  141499. * If the gizmo is enabled
  141500. */
  141501. set isEnabled(value: boolean);
  141502. get isEnabled(): boolean;
  141503. /**
  141504. * Disposes of the gizmo
  141505. */
  141506. dispose(): void;
  141507. }
  141508. }
  141509. declare module BABYLON {
  141510. /**
  141511. * Gizmo that enables rotating a mesh along 3 axis
  141512. */
  141513. export class RotationGizmo extends Gizmo {
  141514. /**
  141515. * Internal gizmo used for interactions on the x axis
  141516. */
  141517. xGizmo: PlaneRotationGizmo;
  141518. /**
  141519. * Internal gizmo used for interactions on the y axis
  141520. */
  141521. yGizmo: PlaneRotationGizmo;
  141522. /**
  141523. * Internal gizmo used for interactions on the z axis
  141524. */
  141525. zGizmo: PlaneRotationGizmo;
  141526. /** Fires an event when any of it's sub gizmos are dragged */
  141527. onDragStartObservable: Observable<unknown>;
  141528. /** Fires an event when any of it's sub gizmos are released from dragging */
  141529. onDragEndObservable: Observable<unknown>;
  141530. private _meshAttached;
  141531. private _nodeAttached;
  141532. private _observables;
  141533. /** Node Caching for quick lookup */
  141534. private _gizmoAxisCache;
  141535. get attachedMesh(): Nullable<AbstractMesh>;
  141536. set attachedMesh(mesh: Nullable<AbstractMesh>);
  141537. get attachedNode(): Nullable<Node>;
  141538. set attachedNode(node: Nullable<Node>);
  141539. protected _checkBillboardTransform(): void;
  141540. /**
  141541. * True when the mouse pointer is hovering a gizmo mesh
  141542. */
  141543. get isHovered(): boolean;
  141544. /**
  141545. * Creates a RotationGizmo
  141546. * @param gizmoLayer The utility layer the gizmo will be added to
  141547. * @param tessellation Amount of tessellation to be used when creating rotation circles
  141548. * @param useEulerRotation Use and update Euler angle instead of quaternion
  141549. * @param thickness display gizmo axis thickness
  141550. */
  141551. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  141552. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  141553. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  141554. /**
  141555. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  141556. */
  141557. set snapDistance(value: number);
  141558. get snapDistance(): number;
  141559. /**
  141560. * Ratio for the scale of the gizmo (Default: 1)
  141561. */
  141562. set scaleRatio(value: number);
  141563. get scaleRatio(): number;
  141564. /**
  141565. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  141566. * @param mesh Axis gizmo mesh
  141567. * @param cache Gizmo axis definition used for reactive gizmo UI
  141568. */
  141569. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  141570. /**
  141571. * Disposes of the gizmo
  141572. */
  141573. dispose(): void;
  141574. /**
  141575. * CustomMeshes are not supported by this gizmo
  141576. * @param mesh The mesh to replace the default mesh of the gizmo
  141577. */
  141578. setCustomMesh(mesh: Mesh): void;
  141579. }
  141580. }
  141581. declare module BABYLON {
  141582. /**
  141583. * Class containing static functions to help procedurally build meshes
  141584. */
  141585. export class PolyhedronBuilder {
  141586. /**
  141587. * Creates a polyhedron mesh
  141588. * * 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
  141589. * * The parameter `size` (positive float, default 1) sets the polygon size
  141590. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  141591. * * 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`
  141592. * * 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
  141593. * * 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)`)
  141594. * * 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
  141595. * * 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
  141596. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141597. * * 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
  141598. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141599. * @param name defines the name of the mesh
  141600. * @param options defines the options used to create the mesh
  141601. * @param scene defines the hosting scene
  141602. * @returns the polyhedron mesh
  141603. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  141604. */
  141605. static CreatePolyhedron(name: string, options: {
  141606. type?: number;
  141607. size?: number;
  141608. sizeX?: number;
  141609. sizeY?: number;
  141610. sizeZ?: number;
  141611. custom?: any;
  141612. faceUV?: Vector4[];
  141613. faceColors?: Color4[];
  141614. flat?: boolean;
  141615. updatable?: boolean;
  141616. sideOrientation?: number;
  141617. frontUVs?: Vector4;
  141618. backUVs?: Vector4;
  141619. }, scene?: Nullable<Scene>): Mesh;
  141620. }
  141621. }
  141622. declare module BABYLON {
  141623. /**
  141624. * Class containing static functions to help procedurally build meshes
  141625. */
  141626. export class BoxBuilder {
  141627. /**
  141628. * Creates a box mesh
  141629. * * The parameter `size` sets the size (float) of each box side (default 1)
  141630. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  141631. * * 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)
  141632. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  141633. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141634. * * 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
  141635. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141636. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  141637. * @param name defines the name of the mesh
  141638. * @param options defines the options used to create the mesh
  141639. * @param scene defines the hosting scene
  141640. * @returns the box mesh
  141641. */
  141642. static CreateBox(name: string, options: {
  141643. size?: number;
  141644. width?: number;
  141645. height?: number;
  141646. depth?: number;
  141647. faceUV?: Vector4[];
  141648. faceColors?: Color4[];
  141649. sideOrientation?: number;
  141650. frontUVs?: Vector4;
  141651. backUVs?: Vector4;
  141652. wrap?: boolean;
  141653. topBaseAt?: number;
  141654. bottomBaseAt?: number;
  141655. updatable?: boolean;
  141656. }, scene?: Nullable<Scene>): Mesh;
  141657. }
  141658. }
  141659. declare module BABYLON {
  141660. /**
  141661. * Single axis scale gizmo
  141662. */
  141663. export class AxisScaleGizmo extends Gizmo {
  141664. /**
  141665. * Drag behavior responsible for the gizmos dragging interactions
  141666. */
  141667. dragBehavior: PointerDragBehavior;
  141668. private _pointerObserver;
  141669. /**
  141670. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  141671. */
  141672. snapDistance: number;
  141673. /**
  141674. * Event that fires each time the gizmo snaps to a new location.
  141675. * * snapDistance is the the change in distance
  141676. */
  141677. onSnapObservable: Observable<{
  141678. snapDistance: number;
  141679. }>;
  141680. /**
  141681. * If the scaling operation should be done on all axis (default: false)
  141682. */
  141683. uniformScaling: boolean;
  141684. /**
  141685. * Custom sensitivity value for the drag strength
  141686. */
  141687. sensitivity: number;
  141688. private _isEnabled;
  141689. private _parent;
  141690. private _gizmoMesh;
  141691. private _coloredMaterial;
  141692. private _hoverMaterial;
  141693. private _disableMaterial;
  141694. private _dragging;
  141695. private _tmpVector;
  141696. private _tmpMatrix;
  141697. private _tmpMatrix2;
  141698. /**
  141699. * Creates an AxisScaleGizmo
  141700. * @param gizmoLayer The utility layer the gizmo will be added to
  141701. * @param dragAxis The axis which the gizmo will be able to scale on
  141702. * @param color The color of the gizmo
  141703. * @param thickness display gizmo axis thickness
  141704. */
  141705. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  141706. /** Create Geometry for Gizmo */
  141707. private _createGizmoMesh;
  141708. protected _attachedNodeChanged(value: Nullable<Node>): void;
  141709. /**
  141710. * If the gizmo is enabled
  141711. */
  141712. set isEnabled(value: boolean);
  141713. get isEnabled(): boolean;
  141714. /**
  141715. * Disposes of the gizmo
  141716. */
  141717. dispose(): void;
  141718. /**
  141719. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  141720. * @param mesh The mesh to replace the default mesh of the gizmo
  141721. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  141722. */
  141723. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  141724. }
  141725. }
  141726. declare module BABYLON {
  141727. /**
  141728. * Gizmo that enables scaling a mesh along 3 axis
  141729. */
  141730. export class ScaleGizmo extends Gizmo {
  141731. /**
  141732. * Internal gizmo used for interactions on the x axis
  141733. */
  141734. xGizmo: AxisScaleGizmo;
  141735. /**
  141736. * Internal gizmo used for interactions on the y axis
  141737. */
  141738. yGizmo: AxisScaleGizmo;
  141739. /**
  141740. * Internal gizmo used for interactions on the z axis
  141741. */
  141742. zGizmo: AxisScaleGizmo;
  141743. /**
  141744. * Internal gizmo used to scale all axis equally
  141745. */
  141746. uniformScaleGizmo: AxisScaleGizmo;
  141747. private _meshAttached;
  141748. private _nodeAttached;
  141749. private _snapDistance;
  141750. private _uniformScalingMesh;
  141751. private _octahedron;
  141752. private _sensitivity;
  141753. private _coloredMaterial;
  141754. private _hoverMaterial;
  141755. private _disableMaterial;
  141756. private _observables;
  141757. /** Node Caching for quick lookup */
  141758. private _gizmoAxisCache;
  141759. /** Fires an event when any of it's sub gizmos are dragged */
  141760. onDragStartObservable: Observable<unknown>;
  141761. /** Fires an event when any of it's sub gizmos are released from dragging */
  141762. onDragEndObservable: Observable<unknown>;
  141763. get attachedMesh(): Nullable<AbstractMesh>;
  141764. set attachedMesh(mesh: Nullable<AbstractMesh>);
  141765. get attachedNode(): Nullable<Node>;
  141766. set attachedNode(node: Nullable<Node>);
  141767. /**
  141768. * True when the mouse pointer is hovering a gizmo mesh
  141769. */
  141770. get isHovered(): boolean;
  141771. /**
  141772. * Creates a ScaleGizmo
  141773. * @param gizmoLayer The utility layer the gizmo will be added to
  141774. * @param thickness display gizmo axis thickness
  141775. */
  141776. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  141777. /** Create Geometry for Gizmo */
  141778. private _createUniformScaleMesh;
  141779. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  141780. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  141781. /**
  141782. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  141783. */
  141784. set snapDistance(value: number);
  141785. get snapDistance(): number;
  141786. /**
  141787. * Ratio for the scale of the gizmo (Default: 1)
  141788. */
  141789. set scaleRatio(value: number);
  141790. get scaleRatio(): number;
  141791. /**
  141792. * Sensitivity factor for dragging (Default: 1)
  141793. */
  141794. set sensitivity(value: number);
  141795. get sensitivity(): number;
  141796. /**
  141797. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  141798. * @param mesh Axis gizmo mesh
  141799. * @param cache Gizmo axis definition used for reactive gizmo UI
  141800. */
  141801. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  141802. /**
  141803. * Disposes of the gizmo
  141804. */
  141805. dispose(): void;
  141806. }
  141807. }
  141808. declare module BABYLON {
  141809. /**
  141810. * Bounding box gizmo
  141811. */
  141812. export class BoundingBoxGizmo extends Gizmo {
  141813. private _lineBoundingBox;
  141814. private _rotateSpheresParent;
  141815. private _scaleBoxesParent;
  141816. private _boundingDimensions;
  141817. private _renderObserver;
  141818. private _pointerObserver;
  141819. private _scaleDragSpeed;
  141820. private _tmpQuaternion;
  141821. private _tmpVector;
  141822. private _tmpRotationMatrix;
  141823. /**
  141824. * 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)
  141825. */
  141826. ignoreChildren: boolean;
  141827. /**
  141828. * 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)
  141829. */
  141830. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  141831. /**
  141832. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  141833. */
  141834. rotationSphereSize: number;
  141835. /**
  141836. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  141837. */
  141838. scaleBoxSize: number;
  141839. /**
  141840. * 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)
  141841. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  141842. */
  141843. fixedDragMeshScreenSize: boolean;
  141844. /**
  141845. * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box
  141846. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  141847. */
  141848. fixedDragMeshBoundsSize: boolean;
  141849. /**
  141850. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  141851. */
  141852. fixedDragMeshScreenSizeDistanceFactor: number;
  141853. /**
  141854. * Fired when a rotation sphere or scale box is dragged
  141855. */
  141856. onDragStartObservable: Observable<{}>;
  141857. /**
  141858. * Fired when a scale box is dragged
  141859. */
  141860. onScaleBoxDragObservable: Observable<{}>;
  141861. /**
  141862. * Fired when a scale box drag is ended
  141863. */
  141864. onScaleBoxDragEndObservable: Observable<{}>;
  141865. /**
  141866. * Fired when a rotation sphere is dragged
  141867. */
  141868. onRotationSphereDragObservable: Observable<{}>;
  141869. /**
  141870. * Fired when a rotation sphere drag is ended
  141871. */
  141872. onRotationSphereDragEndObservable: Observable<{}>;
  141873. /**
  141874. * 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)
  141875. */
  141876. scalePivot: Nullable<Vector3>;
  141877. /**
  141878. * Mesh used as a pivot to rotate the attached node
  141879. */
  141880. private _anchorMesh;
  141881. private _existingMeshScale;
  141882. private _dragMesh;
  141883. private pointerDragBehavior;
  141884. private coloredMaterial;
  141885. private hoverColoredMaterial;
  141886. /**
  141887. * Sets the color of the bounding box gizmo
  141888. * @param color the color to set
  141889. */
  141890. setColor(color: Color3): void;
  141891. /**
  141892. * Creates an BoundingBoxGizmo
  141893. * @param gizmoLayer The utility layer the gizmo will be added to
  141894. * @param color The color of the gizmo
  141895. */
  141896. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  141897. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  141898. private _selectNode;
  141899. /**
  141900. * Updates the bounding box information for the Gizmo
  141901. */
  141902. updateBoundingBox(): void;
  141903. private _updateRotationSpheres;
  141904. private _updateScaleBoxes;
  141905. /**
  141906. * Enables rotation on the specified axis and disables rotation on the others
  141907. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  141908. */
  141909. setEnabledRotationAxis(axis: string): void;
  141910. /**
  141911. * Enables/disables scaling
  141912. * @param enable if scaling should be enabled
  141913. * @param homogeneousScaling defines if scaling should only be homogeneous
  141914. */
  141915. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  141916. private _updateDummy;
  141917. /**
  141918. * Enables a pointer drag behavior on the bounding box of the gizmo
  141919. */
  141920. enableDragBehavior(): void;
  141921. /**
  141922. * Disposes of the gizmo
  141923. */
  141924. dispose(): void;
  141925. /**
  141926. * 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)
  141927. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  141928. * @returns the bounding box mesh with the passed in mesh as a child
  141929. */
  141930. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  141931. /**
  141932. * CustomMeshes are not supported by this gizmo
  141933. * @param mesh The mesh to replace the default mesh of the gizmo
  141934. */
  141935. setCustomMesh(mesh: Mesh): void;
  141936. }
  141937. }
  141938. declare module BABYLON {
  141939. /**
  141940. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  141941. */
  141942. export class GizmoManager implements IDisposable {
  141943. private scene;
  141944. /**
  141945. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  141946. */
  141947. gizmos: {
  141948. positionGizmo: Nullable<PositionGizmo>;
  141949. rotationGizmo: Nullable<RotationGizmo>;
  141950. scaleGizmo: Nullable<ScaleGizmo>;
  141951. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  141952. };
  141953. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  141954. clearGizmoOnEmptyPointerEvent: boolean;
  141955. /** Fires an event when the manager is attached to a mesh */
  141956. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  141957. /** Fires an event when the manager is attached to a node */
  141958. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  141959. private _gizmosEnabled;
  141960. private _pointerObservers;
  141961. private _attachedMesh;
  141962. private _attachedNode;
  141963. private _boundingBoxColor;
  141964. private _defaultUtilityLayer;
  141965. private _defaultKeepDepthUtilityLayer;
  141966. private _thickness;
  141967. /** Node Caching for quick lookup */
  141968. private _gizmoAxisCache;
  141969. /**
  141970. * When bounding box gizmo is enabled, this can be used to track drag/end events
  141971. */
  141972. boundingBoxDragBehavior: SixDofDragBehavior;
  141973. /**
  141974. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  141975. */
  141976. attachableMeshes: Nullable<Array<AbstractMesh>>;
  141977. /**
  141978. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  141979. */
  141980. attachableNodes: Nullable<Array<Node>>;
  141981. /**
  141982. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  141983. */
  141984. usePointerToAttachGizmos: boolean;
  141985. /**
  141986. * Utility layer that the bounding box gizmo belongs to
  141987. */
  141988. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  141989. /**
  141990. * Utility layer that all gizmos besides bounding box belong to
  141991. */
  141992. get utilityLayer(): UtilityLayerRenderer;
  141993. /**
  141994. * True when the mouse pointer is hovering a gizmo mesh
  141995. */
  141996. get isHovered(): boolean;
  141997. /**
  141998. * Instatiates a gizmo manager
  141999. * @param scene the scene to overlay the gizmos on top of
  142000. * @param thickness display gizmo axis thickness
  142001. * @param utilityLayer the layer where gizmos are rendered
  142002. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  142003. */
  142004. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  142005. /**
  142006. * Subscribes to pointer down events, for attaching and detaching mesh
  142007. * @param scene The sceme layer the observer will be added to
  142008. */
  142009. private _attachToMeshPointerObserver;
  142010. /**
  142011. * Attaches a set of gizmos to the specified mesh
  142012. * @param mesh The mesh the gizmo's should be attached to
  142013. */
  142014. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  142015. /**
  142016. * Attaches a set of gizmos to the specified node
  142017. * @param node The node the gizmo's should be attached to
  142018. */
  142019. attachToNode(node: Nullable<Node>): void;
  142020. /**
  142021. * If the position gizmo is enabled
  142022. */
  142023. set positionGizmoEnabled(value: boolean);
  142024. get positionGizmoEnabled(): boolean;
  142025. /**
  142026. * If the rotation gizmo is enabled
  142027. */
  142028. set rotationGizmoEnabled(value: boolean);
  142029. get rotationGizmoEnabled(): boolean;
  142030. /**
  142031. * If the scale gizmo is enabled
  142032. */
  142033. set scaleGizmoEnabled(value: boolean);
  142034. get scaleGizmoEnabled(): boolean;
  142035. /**
  142036. * If the boundingBox gizmo is enabled
  142037. */
  142038. set boundingBoxGizmoEnabled(value: boolean);
  142039. get boundingBoxGizmoEnabled(): boolean;
  142040. /**
  142041. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  142042. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  142043. */
  142044. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  142045. /**
  142046. * Disposes of the gizmo manager
  142047. */
  142048. dispose(): void;
  142049. }
  142050. }
  142051. declare module BABYLON {
  142052. /**
  142053. * Gizmo that enables dragging a mesh along 3 axis
  142054. */
  142055. export class PositionGizmo extends Gizmo {
  142056. /**
  142057. * Internal gizmo used for interactions on the x axis
  142058. */
  142059. xGizmo: AxisDragGizmo;
  142060. /**
  142061. * Internal gizmo used for interactions on the y axis
  142062. */
  142063. yGizmo: AxisDragGizmo;
  142064. /**
  142065. * Internal gizmo used for interactions on the z axis
  142066. */
  142067. zGizmo: AxisDragGizmo;
  142068. /**
  142069. * Internal gizmo used for interactions on the yz plane
  142070. */
  142071. xPlaneGizmo: PlaneDragGizmo;
  142072. /**
  142073. * Internal gizmo used for interactions on the xz plane
  142074. */
  142075. yPlaneGizmo: PlaneDragGizmo;
  142076. /**
  142077. * Internal gizmo used for interactions on the xy plane
  142078. */
  142079. zPlaneGizmo: PlaneDragGizmo;
  142080. /**
  142081. * private variables
  142082. */
  142083. private _meshAttached;
  142084. private _nodeAttached;
  142085. private _snapDistance;
  142086. private _observables;
  142087. /** Node Caching for quick lookup */
  142088. private _gizmoAxisCache;
  142089. /** Fires an event when any of it's sub gizmos are dragged */
  142090. onDragStartObservable: Observable<unknown>;
  142091. /** Fires an event when any of it's sub gizmos are released from dragging */
  142092. onDragEndObservable: Observable<unknown>;
  142093. /**
  142094. * If set to true, planar drag is enabled
  142095. */
  142096. private _planarGizmoEnabled;
  142097. get attachedMesh(): Nullable<AbstractMesh>;
  142098. set attachedMesh(mesh: Nullable<AbstractMesh>);
  142099. get attachedNode(): Nullable<Node>;
  142100. set attachedNode(node: Nullable<Node>);
  142101. /**
  142102. * True when the mouse pointer is hovering a gizmo mesh
  142103. */
  142104. get isHovered(): boolean;
  142105. /**
  142106. * Creates a PositionGizmo
  142107. * @param gizmoLayer The utility layer the gizmo will be added to
  142108. @param thickness display gizmo axis thickness
  142109. */
  142110. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  142111. /**
  142112. * If the planar drag gizmo is enabled
  142113. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  142114. */
  142115. set planarGizmoEnabled(value: boolean);
  142116. get planarGizmoEnabled(): boolean;
  142117. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  142118. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  142119. /**
  142120. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  142121. */
  142122. set snapDistance(value: number);
  142123. get snapDistance(): number;
  142124. /**
  142125. * Ratio for the scale of the gizmo (Default: 1)
  142126. */
  142127. set scaleRatio(value: number);
  142128. get scaleRatio(): number;
  142129. /**
  142130. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  142131. * @param mesh Axis gizmo mesh
  142132. * @param cache Gizmo axis definition used for reactive gizmo UI
  142133. */
  142134. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  142135. /**
  142136. * Disposes of the gizmo
  142137. */
  142138. dispose(): void;
  142139. /**
  142140. * CustomMeshes are not supported by this gizmo
  142141. * @param mesh The mesh to replace the default mesh of the gizmo
  142142. */
  142143. setCustomMesh(mesh: Mesh): void;
  142144. }
  142145. }
  142146. declare module BABYLON {
  142147. /**
  142148. * Single axis drag gizmo
  142149. */
  142150. export class AxisDragGizmo extends Gizmo {
  142151. /**
  142152. * Drag behavior responsible for the gizmos dragging interactions
  142153. */
  142154. dragBehavior: PointerDragBehavior;
  142155. private _pointerObserver;
  142156. /**
  142157. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  142158. */
  142159. snapDistance: number;
  142160. /**
  142161. * Event that fires each time the gizmo snaps to a new location.
  142162. * * snapDistance is the the change in distance
  142163. */
  142164. onSnapObservable: Observable<{
  142165. snapDistance: number;
  142166. }>;
  142167. private _isEnabled;
  142168. private _parent;
  142169. private _gizmoMesh;
  142170. private _coloredMaterial;
  142171. private _hoverMaterial;
  142172. private _disableMaterial;
  142173. private _dragging;
  142174. /** @hidden */
  142175. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  142176. /** @hidden */
  142177. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  142178. /**
  142179. * Creates an AxisDragGizmo
  142180. * @param gizmoLayer The utility layer the gizmo will be added to
  142181. * @param dragAxis The axis which the gizmo will be able to drag on
  142182. * @param color The color of the gizmo
  142183. * @param thickness display gizmo axis thickness
  142184. */
  142185. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  142186. protected _attachedNodeChanged(value: Nullable<Node>): void;
  142187. /**
  142188. * If the gizmo is enabled
  142189. */
  142190. set isEnabled(value: boolean);
  142191. get isEnabled(): boolean;
  142192. /**
  142193. * Disposes of the gizmo
  142194. */
  142195. dispose(): void;
  142196. }
  142197. }
  142198. declare module BABYLON.Debug {
  142199. /**
  142200. * The Axes viewer will show 3 axes in a specific point in space
  142201. */
  142202. export class AxesViewer {
  142203. private _xAxis;
  142204. private _yAxis;
  142205. private _zAxis;
  142206. private _scaleLinesFactor;
  142207. private _instanced;
  142208. /**
  142209. * Gets the hosting scene
  142210. */
  142211. scene: Nullable<Scene>;
  142212. /**
  142213. * Gets or sets a number used to scale line length
  142214. */
  142215. scaleLines: number;
  142216. /** Gets the node hierarchy used to render x-axis */
  142217. get xAxis(): TransformNode;
  142218. /** Gets the node hierarchy used to render y-axis */
  142219. get yAxis(): TransformNode;
  142220. /** Gets the node hierarchy used to render z-axis */
  142221. get zAxis(): TransformNode;
  142222. /**
  142223. * Creates a new AxesViewer
  142224. * @param scene defines the hosting scene
  142225. * @param scaleLines defines a number used to scale line length (1 by default)
  142226. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  142227. * @param xAxis defines the node hierarchy used to render the x-axis
  142228. * @param yAxis defines the node hierarchy used to render the y-axis
  142229. * @param zAxis defines the node hierarchy used to render the z-axis
  142230. */
  142231. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  142232. /**
  142233. * Force the viewer to update
  142234. * @param position defines the position of the viewer
  142235. * @param xaxis defines the x axis of the viewer
  142236. * @param yaxis defines the y axis of the viewer
  142237. * @param zaxis defines the z axis of the viewer
  142238. */
  142239. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  142240. /**
  142241. * Creates an instance of this axes viewer.
  142242. * @returns a new axes viewer with instanced meshes
  142243. */
  142244. createInstance(): AxesViewer;
  142245. /** Releases resources */
  142246. dispose(): void;
  142247. private static _SetRenderingGroupId;
  142248. }
  142249. }
  142250. declare module BABYLON.Debug {
  142251. /**
  142252. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  142253. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  142254. */
  142255. export class BoneAxesViewer extends AxesViewer {
  142256. /**
  142257. * Gets or sets the target mesh where to display the axes viewer
  142258. */
  142259. mesh: Nullable<Mesh>;
  142260. /**
  142261. * Gets or sets the target bone where to display the axes viewer
  142262. */
  142263. bone: Nullable<Bone>;
  142264. /** Gets current position */
  142265. pos: Vector3;
  142266. /** Gets direction of X axis */
  142267. xaxis: Vector3;
  142268. /** Gets direction of Y axis */
  142269. yaxis: Vector3;
  142270. /** Gets direction of Z axis */
  142271. zaxis: Vector3;
  142272. /**
  142273. * Creates a new BoneAxesViewer
  142274. * @param scene defines the hosting scene
  142275. * @param bone defines the target bone
  142276. * @param mesh defines the target mesh
  142277. * @param scaleLines defines a scaling factor for line length (1 by default)
  142278. */
  142279. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  142280. /**
  142281. * Force the viewer to update
  142282. */
  142283. update(): void;
  142284. /** Releases resources */
  142285. dispose(): void;
  142286. }
  142287. }
  142288. declare module BABYLON {
  142289. /**
  142290. * Interface used to define scene explorer extensibility option
  142291. */
  142292. export interface IExplorerExtensibilityOption {
  142293. /**
  142294. * Define the option label
  142295. */
  142296. label: string;
  142297. /**
  142298. * Defines the action to execute on click
  142299. */
  142300. action: (entity: any) => void;
  142301. }
  142302. /**
  142303. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  142304. */
  142305. export interface IExplorerExtensibilityGroup {
  142306. /**
  142307. * Defines a predicate to test if a given type mut be extended
  142308. */
  142309. predicate: (entity: any) => boolean;
  142310. /**
  142311. * Gets the list of options added to a type
  142312. */
  142313. entries: IExplorerExtensibilityOption[];
  142314. }
  142315. /**
  142316. * Interface used to define the options to use to create the Inspector
  142317. */
  142318. export interface IInspectorOptions {
  142319. /**
  142320. * Display in overlay mode (default: false)
  142321. */
  142322. overlay?: boolean;
  142323. /**
  142324. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  142325. */
  142326. globalRoot?: HTMLElement;
  142327. /**
  142328. * Display the Scene explorer
  142329. */
  142330. showExplorer?: boolean;
  142331. /**
  142332. * Display the property inspector
  142333. */
  142334. showInspector?: boolean;
  142335. /**
  142336. * Display in embed mode (both panes on the right)
  142337. */
  142338. embedMode?: boolean;
  142339. /**
  142340. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  142341. */
  142342. handleResize?: boolean;
  142343. /**
  142344. * Allow the panes to popup (default: true)
  142345. */
  142346. enablePopup?: boolean;
  142347. /**
  142348. * Allow the panes to be closed by users (default: true)
  142349. */
  142350. enableClose?: boolean;
  142351. /**
  142352. * Optional list of extensibility entries
  142353. */
  142354. explorerExtensibility?: IExplorerExtensibilityGroup[];
  142355. /**
  142356. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  142357. */
  142358. inspectorURL?: string;
  142359. /**
  142360. * Optional initial tab (default to DebugLayerTab.Properties)
  142361. */
  142362. initialTab?: DebugLayerTab;
  142363. }
  142364. interface Scene {
  142365. /**
  142366. * @hidden
  142367. * Backing field
  142368. */
  142369. _debugLayer: DebugLayer;
  142370. /**
  142371. * Gets the debug layer (aka Inspector) associated with the scene
  142372. * @see https://doc.babylonjs.com/features/playground_debuglayer
  142373. */
  142374. debugLayer: DebugLayer;
  142375. }
  142376. /**
  142377. * Enum of inspector action tab
  142378. */
  142379. export enum DebugLayerTab {
  142380. /**
  142381. * Properties tag (default)
  142382. */
  142383. Properties = 0,
  142384. /**
  142385. * Debug tab
  142386. */
  142387. Debug = 1,
  142388. /**
  142389. * Statistics tab
  142390. */
  142391. Statistics = 2,
  142392. /**
  142393. * Tools tab
  142394. */
  142395. Tools = 3,
  142396. /**
  142397. * Settings tab
  142398. */
  142399. Settings = 4
  142400. }
  142401. /**
  142402. * The debug layer (aka Inspector) is the go to tool in order to better understand
  142403. * what is happening in your scene
  142404. * @see https://doc.babylonjs.com/features/playground_debuglayer
  142405. */
  142406. export class DebugLayer {
  142407. /**
  142408. * Define the url to get the inspector script from.
  142409. * By default it uses the babylonjs CDN.
  142410. * @ignoreNaming
  142411. */
  142412. static InspectorURL: string;
  142413. private _scene;
  142414. private BJSINSPECTOR;
  142415. private _onPropertyChangedObservable?;
  142416. /**
  142417. * Observable triggered when a property is changed through the inspector.
  142418. */
  142419. get onPropertyChangedObservable(): any;
  142420. /**
  142421. * Instantiates a new debug layer.
  142422. * The debug layer (aka Inspector) is the go to tool in order to better understand
  142423. * what is happening in your scene
  142424. * @see https://doc.babylonjs.com/features/playground_debuglayer
  142425. * @param scene Defines the scene to inspect
  142426. */
  142427. constructor(scene: Scene);
  142428. /** Creates the inspector window. */
  142429. private _createInspector;
  142430. /**
  142431. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  142432. * @param entity defines the entity to select
  142433. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  142434. */
  142435. select(entity: any, lineContainerTitles?: string | string[]): void;
  142436. /** Get the inspector from bundle or global */
  142437. private _getGlobalInspector;
  142438. /**
  142439. * Get if the inspector is visible or not.
  142440. * @returns true if visible otherwise, false
  142441. */
  142442. isVisible(): boolean;
  142443. /**
  142444. * Hide the inspector and close its window.
  142445. */
  142446. hide(): void;
  142447. /**
  142448. * Update the scene in the inspector
  142449. */
  142450. setAsActiveScene(): void;
  142451. /**
  142452. * Launch the debugLayer.
  142453. * @param config Define the configuration of the inspector
  142454. * @return a promise fulfilled when the debug layer is visible
  142455. */
  142456. show(config?: IInspectorOptions): Promise<DebugLayer>;
  142457. }
  142458. }
  142459. declare module BABYLON.Debug {
  142460. /**
  142461. * Used to show the physics impostor around the specific mesh
  142462. */
  142463. export class PhysicsViewer {
  142464. /** @hidden */
  142465. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  142466. /** @hidden */
  142467. protected _meshes: Array<Nullable<AbstractMesh>>;
  142468. /** @hidden */
  142469. protected _scene: Nullable<Scene>;
  142470. /** @hidden */
  142471. protected _numMeshes: number;
  142472. /** @hidden */
  142473. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  142474. private _renderFunction;
  142475. private _utilityLayer;
  142476. private _debugBoxMesh;
  142477. private _debugSphereMesh;
  142478. private _debugCylinderMesh;
  142479. private _debugMaterial;
  142480. private _debugMeshMeshes;
  142481. /**
  142482. * Creates a new PhysicsViewer
  142483. * @param scene defines the hosting scene
  142484. */
  142485. constructor(scene: Scene);
  142486. /** @hidden */
  142487. protected _updateDebugMeshes(): void;
  142488. /**
  142489. * Renders a specified physic impostor
  142490. * @param impostor defines the impostor to render
  142491. * @param targetMesh defines the mesh represented by the impostor
  142492. * @returns the new debug mesh used to render the impostor
  142493. */
  142494. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  142495. /**
  142496. * Hides a specified physic impostor
  142497. * @param impostor defines the impostor to hide
  142498. */
  142499. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  142500. private _getDebugMaterial;
  142501. private _getDebugBoxMesh;
  142502. private _getDebugSphereMesh;
  142503. private _getDebugCylinderMesh;
  142504. private _getDebugMeshMesh;
  142505. private _getDebugMesh;
  142506. /** Releases all resources */
  142507. dispose(): void;
  142508. }
  142509. }
  142510. declare module BABYLON {
  142511. /**
  142512. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  142513. * in order to better appreciate the issue one might have.
  142514. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  142515. */
  142516. export class RayHelper {
  142517. /**
  142518. * Defines the ray we are currently tryin to visualize.
  142519. */
  142520. ray: Nullable<Ray>;
  142521. private _renderPoints;
  142522. private _renderLine;
  142523. private _renderFunction;
  142524. private _scene;
  142525. private _onAfterRenderObserver;
  142526. private _onAfterStepObserver;
  142527. private _attachedToMesh;
  142528. private _meshSpaceDirection;
  142529. private _meshSpaceOrigin;
  142530. /**
  142531. * Helper function to create a colored helper in a scene in one line.
  142532. * @param ray Defines the ray we are currently tryin to visualize
  142533. * @param scene Defines the scene the ray is used in
  142534. * @param color Defines the color we want to see the ray in
  142535. * @returns The newly created ray helper.
  142536. */
  142537. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  142538. /**
  142539. * Instantiate a new ray helper.
  142540. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  142541. * in order to better appreciate the issue one might have.
  142542. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  142543. * @param ray Defines the ray we are currently tryin to visualize
  142544. */
  142545. constructor(ray: Ray);
  142546. /**
  142547. * Shows the ray we are willing to debug.
  142548. * @param scene Defines the scene the ray needs to be rendered in
  142549. * @param color Defines the color the ray needs to be rendered in
  142550. */
  142551. show(scene: Scene, color?: Color3): void;
  142552. /**
  142553. * Hides the ray we are debugging.
  142554. */
  142555. hide(): void;
  142556. private _render;
  142557. /**
  142558. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  142559. * @param mesh Defines the mesh we want the helper attached to
  142560. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  142561. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  142562. * @param length Defines the length of the ray
  142563. */
  142564. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  142565. /**
  142566. * Detach the ray helper from the mesh it has previously been attached to.
  142567. */
  142568. detachFromMesh(): void;
  142569. private _updateToMesh;
  142570. /**
  142571. * Dispose the helper and release its associated resources.
  142572. */
  142573. dispose(): void;
  142574. }
  142575. }
  142576. declare module BABYLON {
  142577. /**
  142578. * Defines the options associated with the creation of a SkeletonViewer.
  142579. */
  142580. export interface ISkeletonViewerOptions {
  142581. /** Should the system pause animations before building the Viewer? */
  142582. pauseAnimations: boolean;
  142583. /** Should the system return the skeleton to rest before building? */
  142584. returnToRest: boolean;
  142585. /** public Display Mode of the Viewer */
  142586. displayMode: number;
  142587. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  142588. displayOptions: ISkeletonViewerDisplayOptions;
  142589. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  142590. computeBonesUsingShaders: boolean;
  142591. /** Flag ignore non weighted bones */
  142592. useAllBones: boolean;
  142593. }
  142594. /**
  142595. * Defines how to display the various bone meshes for the viewer.
  142596. */
  142597. export interface ISkeletonViewerDisplayOptions {
  142598. /** How far down to start tapering the bone spurs */
  142599. midStep?: number;
  142600. /** How big is the midStep? */
  142601. midStepFactor?: number;
  142602. /** Base for the Sphere Size */
  142603. sphereBaseSize?: number;
  142604. /** The ratio of the sphere to the longest bone in units */
  142605. sphereScaleUnit?: number;
  142606. /** Ratio for the Sphere Size */
  142607. sphereFactor?: number;
  142608. /** Whether a spur should attach its far end to the child bone position */
  142609. spurFollowsChild?: boolean;
  142610. /** Whether to show local axes or not */
  142611. showLocalAxes?: boolean;
  142612. /** Length of each local axis */
  142613. localAxesSize?: number;
  142614. }
  142615. /**
  142616. * Defines the constructor options for the BoneWeight Shader.
  142617. */
  142618. export interface IBoneWeightShaderOptions {
  142619. /** Skeleton to Map */
  142620. skeleton: Skeleton;
  142621. /** Colors for Uninfluenced bones */
  142622. colorBase?: Color3;
  142623. /** Colors for 0.0-0.25 Weight bones */
  142624. colorZero?: Color3;
  142625. /** Color for 0.25-0.5 Weight Influence */
  142626. colorQuarter?: Color3;
  142627. /** Color for 0.5-0.75 Weight Influence */
  142628. colorHalf?: Color3;
  142629. /** Color for 0.75-1 Weight Influence */
  142630. colorFull?: Color3;
  142631. /** Color for Zero Weight Influence */
  142632. targetBoneIndex?: number;
  142633. }
  142634. /**
  142635. * Simple structure of the gradient steps for the Color Map.
  142636. */
  142637. export interface ISkeletonMapShaderColorMapKnot {
  142638. /** Color of the Knot */
  142639. color: Color3;
  142640. /** Location of the Knot */
  142641. location: number;
  142642. }
  142643. /**
  142644. * Defines the constructor options for the SkeletonMap Shader.
  142645. */
  142646. export interface ISkeletonMapShaderOptions {
  142647. /** Skeleton to Map */
  142648. skeleton: Skeleton;
  142649. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  142650. colorMap?: ISkeletonMapShaderColorMapKnot[];
  142651. }
  142652. }
  142653. declare module BABYLON {
  142654. /**
  142655. * Class containing static functions to help procedurally build meshes
  142656. */
  142657. export class RibbonBuilder {
  142658. /**
  142659. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  142660. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  142661. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  142662. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  142663. * * 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
  142664. * * 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
  142665. * * 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
  142666. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142667. * * 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
  142668. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142669. * * 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
  142670. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  142671. * * 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
  142672. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  142673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142674. * @param name defines the name of the mesh
  142675. * @param options defines the options used to create the mesh
  142676. * @param scene defines the hosting scene
  142677. * @returns the ribbon mesh
  142678. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  142679. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  142680. */
  142681. static CreateRibbon(name: string, options: {
  142682. pathArray: Vector3[][];
  142683. closeArray?: boolean;
  142684. closePath?: boolean;
  142685. offset?: number;
  142686. updatable?: boolean;
  142687. sideOrientation?: number;
  142688. frontUVs?: Vector4;
  142689. backUVs?: Vector4;
  142690. instance?: Mesh;
  142691. invertUV?: boolean;
  142692. uvs?: Vector2[];
  142693. colors?: Color4[];
  142694. }, scene?: Nullable<Scene>): Mesh;
  142695. }
  142696. }
  142697. declare module BABYLON {
  142698. /**
  142699. * Class containing static functions to help procedurally build meshes
  142700. */
  142701. export class ShapeBuilder {
  142702. /**
  142703. * 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.
  142704. * * 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.
  142705. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  142706. * * 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.
  142707. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  142708. * * 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
  142709. * * 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
  142710. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  142711. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142712. * * 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
  142713. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  142714. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142715. * @param name defines the name of the mesh
  142716. * @param options defines the options used to create the mesh
  142717. * @param scene defines the hosting scene
  142718. * @returns the extruded shape mesh
  142719. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  142720. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  142721. */
  142722. static ExtrudeShape(name: string, options: {
  142723. shape: Vector3[];
  142724. path: Vector3[];
  142725. scale?: number;
  142726. rotation?: number;
  142727. cap?: number;
  142728. updatable?: boolean;
  142729. sideOrientation?: number;
  142730. frontUVs?: Vector4;
  142731. backUVs?: Vector4;
  142732. instance?: Mesh;
  142733. invertUV?: boolean;
  142734. }, scene?: Nullable<Scene>): Mesh;
  142735. /**
  142736. * Creates an custom extruded shape mesh.
  142737. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  142738. * * 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.
  142739. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  142740. * * 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
  142741. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  142742. * * 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
  142743. * * It must returns a float value that will be the scale value applied to the shape on each path point
  142744. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  142745. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  142746. * * 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
  142747. * * 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
  142748. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  142749. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142750. * * 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
  142751. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142752. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142753. * @param name defines the name of the mesh
  142754. * @param options defines the options used to create the mesh
  142755. * @param scene defines the hosting scene
  142756. * @returns the custom extruded shape mesh
  142757. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  142758. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  142759. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  142760. */
  142761. static ExtrudeShapeCustom(name: string, options: {
  142762. shape: Vector3[];
  142763. path: Vector3[];
  142764. scaleFunction?: any;
  142765. rotationFunction?: any;
  142766. ribbonCloseArray?: boolean;
  142767. ribbonClosePath?: boolean;
  142768. cap?: number;
  142769. updatable?: boolean;
  142770. sideOrientation?: number;
  142771. frontUVs?: Vector4;
  142772. backUVs?: Vector4;
  142773. instance?: Mesh;
  142774. invertUV?: boolean;
  142775. }, scene?: Nullable<Scene>): Mesh;
  142776. private static _ExtrudeShapeGeneric;
  142777. }
  142778. }
  142779. declare module BABYLON.Debug {
  142780. /**
  142781. * Class used to render a debug view of a given skeleton
  142782. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  142783. */
  142784. export class SkeletonViewer {
  142785. /** defines the skeleton to render */
  142786. skeleton: Skeleton;
  142787. /** defines the mesh attached to the skeleton */
  142788. mesh: AbstractMesh;
  142789. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  142790. autoUpdateBonesMatrices: boolean;
  142791. /** defines the rendering group id to use with the viewer */
  142792. renderingGroupId: number;
  142793. /** is the options for the viewer */
  142794. options: Partial<ISkeletonViewerOptions>;
  142795. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  142796. static readonly DISPLAY_LINES: number;
  142797. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  142798. static readonly DISPLAY_SPHERES: number;
  142799. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  142800. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  142801. /** public static method to create a BoneWeight Shader
  142802. * @param options The constructor options
  142803. * @param scene The scene that the shader is scoped to
  142804. * @returns The created ShaderMaterial
  142805. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  142806. */
  142807. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  142808. /** public static method to create a BoneWeight Shader
  142809. * @param options The constructor options
  142810. * @param scene The scene that the shader is scoped to
  142811. * @returns The created ShaderMaterial
  142812. */
  142813. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  142814. /** private static method to create a BoneWeight Shader
  142815. * @param size The size of the buffer to create (usually the bone count)
  142816. * @param colorMap The gradient data to generate
  142817. * @param scene The scene that the shader is scoped to
  142818. * @returns an Array of floats from the color gradient values
  142819. */
  142820. private static _CreateBoneMapColorBuffer;
  142821. /** If SkeletonViewer scene scope. */
  142822. private _scene;
  142823. /** Gets or sets the color used to render the skeleton */
  142824. color: Color3;
  142825. /** Array of the points of the skeleton fo the line view. */
  142826. private _debugLines;
  142827. /** The SkeletonViewers Mesh. */
  142828. private _debugMesh;
  142829. /** The local axes Meshes. */
  142830. private _localAxes;
  142831. /** If SkeletonViewer is enabled. */
  142832. private _isEnabled;
  142833. /** If SkeletonViewer is ready. */
  142834. private _ready;
  142835. /** SkeletonViewer render observable. */
  142836. private _obs;
  142837. /** The Utility Layer to render the gizmos in. */
  142838. private _utilityLayer;
  142839. private _boneIndices;
  142840. /** Gets the Scene. */
  142841. get scene(): Scene;
  142842. /** Gets the utilityLayer. */
  142843. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  142844. /** Checks Ready Status. */
  142845. get isReady(): Boolean;
  142846. /** Sets Ready Status. */
  142847. set ready(value: boolean);
  142848. /** Gets the debugMesh */
  142849. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  142850. /** Sets the debugMesh */
  142851. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  142852. /** Gets the displayMode */
  142853. get displayMode(): number;
  142854. /** Sets the displayMode */
  142855. set displayMode(value: number);
  142856. /**
  142857. * Creates a new SkeletonViewer
  142858. * @param skeleton defines the skeleton to render
  142859. * @param mesh defines the mesh attached to the skeleton
  142860. * @param scene defines the hosting scene
  142861. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  142862. * @param renderingGroupId defines the rendering group id to use with the viewer
  142863. * @param options All of the extra constructor options for the SkeletonViewer
  142864. */
  142865. constructor(
  142866. /** defines the skeleton to render */
  142867. skeleton: Skeleton,
  142868. /** defines the mesh attached to the skeleton */
  142869. mesh: AbstractMesh,
  142870. /** The Scene scope*/
  142871. scene: Scene,
  142872. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  142873. autoUpdateBonesMatrices?: boolean,
  142874. /** defines the rendering group id to use with the viewer */
  142875. renderingGroupId?: number,
  142876. /** is the options for the viewer */
  142877. options?: Partial<ISkeletonViewerOptions>);
  142878. /** The Dynamic bindings for the update functions */
  142879. private _bindObs;
  142880. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  142881. update(): void;
  142882. /** Gets or sets a boolean indicating if the viewer is enabled */
  142883. set isEnabled(value: boolean);
  142884. get isEnabled(): boolean;
  142885. private _getBonePosition;
  142886. private _getLinesForBonesWithLength;
  142887. private _getLinesForBonesNoLength;
  142888. /** function to revert the mesh and scene back to the initial state. */
  142889. private _revert;
  142890. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  142891. private _getAbsoluteBindPoseToRef;
  142892. /** function to build and bind sphere joint points and spur bone representations. */
  142893. private _buildSpheresAndSpurs;
  142894. private _buildLocalAxes;
  142895. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  142896. private _displayLinesUpdate;
  142897. /** Changes the displayMode of the skeleton viewer
  142898. * @param mode The displayMode numerical value
  142899. */
  142900. changeDisplayMode(mode: number): void;
  142901. /** Sets a display option of the skeleton viewer
  142902. *
  142903. * | Option | Type | Default | Description |
  142904. * | ---------------- | ------- | ------- | ----------- |
  142905. * | 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`. |
  142906. * | 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`. |
  142907. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  142908. * | 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`. |
  142909. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  142910. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  142911. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  142912. *
  142913. * @param option String of the option name
  142914. * @param value The numerical option value
  142915. */
  142916. changeDisplayOptions(option: string, value: number): void;
  142917. /** Release associated resources */
  142918. dispose(): void;
  142919. }
  142920. }
  142921. declare module BABYLON {
  142922. /**
  142923. * Enum for Device Types
  142924. */
  142925. export enum DeviceType {
  142926. /** Generic */
  142927. Generic = 0,
  142928. /** Keyboard */
  142929. Keyboard = 1,
  142930. /** Mouse */
  142931. Mouse = 2,
  142932. /** Touch Pointers */
  142933. Touch = 3,
  142934. /** PS4 Dual Shock */
  142935. DualShock = 4,
  142936. /** Xbox */
  142937. Xbox = 5,
  142938. /** Switch Controller */
  142939. Switch = 6
  142940. }
  142941. /**
  142942. * Enum for All Pointers (Touch/Mouse)
  142943. */
  142944. export enum PointerInput {
  142945. /** Horizontal Axis */
  142946. Horizontal = 0,
  142947. /** Vertical Axis */
  142948. Vertical = 1,
  142949. /** Left Click or Touch */
  142950. LeftClick = 2,
  142951. /** Middle Click */
  142952. MiddleClick = 3,
  142953. /** Right Click */
  142954. RightClick = 4,
  142955. /** Browser Back */
  142956. BrowserBack = 5,
  142957. /** Browser Forward */
  142958. BrowserForward = 6
  142959. }
  142960. /**
  142961. * Enum for Dual Shock Gamepad
  142962. */
  142963. export enum DualShockInput {
  142964. /** Cross */
  142965. Cross = 0,
  142966. /** Circle */
  142967. Circle = 1,
  142968. /** Square */
  142969. Square = 2,
  142970. /** Triangle */
  142971. Triangle = 3,
  142972. /** L1 */
  142973. L1 = 4,
  142974. /** R1 */
  142975. R1 = 5,
  142976. /** L2 */
  142977. L2 = 6,
  142978. /** R2 */
  142979. R2 = 7,
  142980. /** Share */
  142981. Share = 8,
  142982. /** Options */
  142983. Options = 9,
  142984. /** L3 */
  142985. L3 = 10,
  142986. /** R3 */
  142987. R3 = 11,
  142988. /** DPadUp */
  142989. DPadUp = 12,
  142990. /** DPadDown */
  142991. DPadDown = 13,
  142992. /** DPadLeft */
  142993. DPadLeft = 14,
  142994. /** DRight */
  142995. DPadRight = 15,
  142996. /** Home */
  142997. Home = 16,
  142998. /** TouchPad */
  142999. TouchPad = 17,
  143000. /** LStickXAxis */
  143001. LStickXAxis = 18,
  143002. /** LStickYAxis */
  143003. LStickYAxis = 19,
  143004. /** RStickXAxis */
  143005. RStickXAxis = 20,
  143006. /** RStickYAxis */
  143007. RStickYAxis = 21
  143008. }
  143009. /**
  143010. * Enum for Xbox Gamepad
  143011. */
  143012. export enum XboxInput {
  143013. /** A */
  143014. A = 0,
  143015. /** B */
  143016. B = 1,
  143017. /** X */
  143018. X = 2,
  143019. /** Y */
  143020. Y = 3,
  143021. /** LB */
  143022. LB = 4,
  143023. /** RB */
  143024. RB = 5,
  143025. /** LT */
  143026. LT = 6,
  143027. /** RT */
  143028. RT = 7,
  143029. /** Back */
  143030. Back = 8,
  143031. /** Start */
  143032. Start = 9,
  143033. /** LS */
  143034. LS = 10,
  143035. /** RS */
  143036. RS = 11,
  143037. /** DPadUp */
  143038. DPadUp = 12,
  143039. /** DPadDown */
  143040. DPadDown = 13,
  143041. /** DPadLeft */
  143042. DPadLeft = 14,
  143043. /** DRight */
  143044. DPadRight = 15,
  143045. /** Home */
  143046. Home = 16,
  143047. /** LStickXAxis */
  143048. LStickXAxis = 17,
  143049. /** LStickYAxis */
  143050. LStickYAxis = 18,
  143051. /** RStickXAxis */
  143052. RStickXAxis = 19,
  143053. /** RStickYAxis */
  143054. RStickYAxis = 20
  143055. }
  143056. /**
  143057. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  143058. */
  143059. export enum SwitchInput {
  143060. /** B */
  143061. B = 0,
  143062. /** A */
  143063. A = 1,
  143064. /** Y */
  143065. Y = 2,
  143066. /** X */
  143067. X = 3,
  143068. /** L */
  143069. L = 4,
  143070. /** R */
  143071. R = 5,
  143072. /** ZL */
  143073. ZL = 6,
  143074. /** ZR */
  143075. ZR = 7,
  143076. /** Minus */
  143077. Minus = 8,
  143078. /** Plus */
  143079. Plus = 9,
  143080. /** LS */
  143081. LS = 10,
  143082. /** RS */
  143083. RS = 11,
  143084. /** DPadUp */
  143085. DPadUp = 12,
  143086. /** DPadDown */
  143087. DPadDown = 13,
  143088. /** DPadLeft */
  143089. DPadLeft = 14,
  143090. /** DRight */
  143091. DPadRight = 15,
  143092. /** Home */
  143093. Home = 16,
  143094. /** Capture */
  143095. Capture = 17,
  143096. /** LStickXAxis */
  143097. LStickXAxis = 18,
  143098. /** LStickYAxis */
  143099. LStickYAxis = 19,
  143100. /** RStickXAxis */
  143101. RStickXAxis = 20,
  143102. /** RStickYAxis */
  143103. RStickYAxis = 21
  143104. }
  143105. }
  143106. declare module BABYLON {
  143107. /**
  143108. * This class will take all inputs from Keyboard, Pointer, and
  143109. * any Gamepads and provide a polling system that all devices
  143110. * will use. This class assumes that there will only be one
  143111. * pointer device and one keyboard.
  143112. */
  143113. export class DeviceInputSystem implements IDisposable {
  143114. /**
  143115. * Returns onDeviceConnected callback property
  143116. * @returns Callback with function to execute when a device is connected
  143117. */
  143118. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  143119. /**
  143120. * Sets callback function when a device is connected and executes against all connected devices
  143121. * @param callback Function to execute when a device is connected
  143122. */
  143123. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  143124. /**
  143125. * Callback to be triggered when a device is disconnected
  143126. */
  143127. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  143128. /**
  143129. * Callback to be triggered when event driven input is updated
  143130. */
  143131. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  143132. private _inputs;
  143133. private _gamepads;
  143134. private _keyboardActive;
  143135. private _pointerActive;
  143136. private _elementToAttachTo;
  143137. private _keyboardDownEvent;
  143138. private _keyboardUpEvent;
  143139. private _pointerMoveEvent;
  143140. private _pointerDownEvent;
  143141. private _pointerUpEvent;
  143142. private _gamepadConnectedEvent;
  143143. private _gamepadDisconnectedEvent;
  143144. private _onDeviceConnected;
  143145. private static _MAX_KEYCODES;
  143146. private static _MAX_POINTER_INPUTS;
  143147. private constructor();
  143148. /**
  143149. * Creates a new DeviceInputSystem instance
  143150. * @param engine Engine to pull input element from
  143151. * @returns The new instance
  143152. */
  143153. static Create(engine: Engine): DeviceInputSystem;
  143154. /**
  143155. * Checks for current device input value, given an id and input index
  143156. * @param deviceName Id of connected device
  143157. * @param inputIndex Index of device input
  143158. * @returns Current value of input
  143159. */
  143160. /**
  143161. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  143162. * @param deviceType Enum specifiying device type
  143163. * @param deviceSlot "Slot" or index that device is referenced in
  143164. * @param inputIndex Id of input to be checked
  143165. * @returns Current value of input
  143166. */
  143167. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  143168. /**
  143169. * Dispose of all the eventlisteners
  143170. */
  143171. dispose(): void;
  143172. /**
  143173. * Checks for existing connections to devices and register them, if necessary
  143174. * Currently handles gamepads and mouse
  143175. */
  143176. private _checkForConnectedDevices;
  143177. /**
  143178. * Add a gamepad to the DeviceInputSystem
  143179. * @param gamepad A single DOM Gamepad object
  143180. */
  143181. private _addGamePad;
  143182. /**
  143183. * Add pointer device to DeviceInputSystem
  143184. * @param deviceType Type of Pointer to add
  143185. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  143186. * @param currentX Current X at point of adding
  143187. * @param currentY Current Y at point of adding
  143188. */
  143189. private _addPointerDevice;
  143190. /**
  143191. * Add device and inputs to device array
  143192. * @param deviceType Enum specifiying device type
  143193. * @param deviceSlot "Slot" or index that device is referenced in
  143194. * @param numberOfInputs Number of input entries to create for given device
  143195. */
  143196. private _registerDevice;
  143197. /**
  143198. * Given a specific device name, remove that device from the device map
  143199. * @param deviceType Enum specifiying device type
  143200. * @param deviceSlot "Slot" or index that device is referenced in
  143201. */
  143202. private _unregisterDevice;
  143203. /**
  143204. * Handle all actions that come from keyboard interaction
  143205. */
  143206. private _handleKeyActions;
  143207. /**
  143208. * Handle all actions that come from pointer interaction
  143209. */
  143210. private _handlePointerActions;
  143211. /**
  143212. * Handle all actions that come from gamepad interaction
  143213. */
  143214. private _handleGamepadActions;
  143215. /**
  143216. * Update all non-event based devices with each frame
  143217. * @param deviceType Enum specifiying device type
  143218. * @param deviceSlot "Slot" or index that device is referenced in
  143219. * @param inputIndex Id of input to be checked
  143220. */
  143221. private _updateDevice;
  143222. /**
  143223. * Gets DeviceType from the device name
  143224. * @param deviceName Name of Device from DeviceInputSystem
  143225. * @returns DeviceType enum value
  143226. */
  143227. private _getGamepadDeviceType;
  143228. }
  143229. }
  143230. declare module BABYLON {
  143231. /**
  143232. * Type to handle enforcement of inputs
  143233. */
  143234. 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;
  143235. }
  143236. declare module BABYLON {
  143237. /**
  143238. * Class that handles all input for a specific device
  143239. */
  143240. export class DeviceSource<T extends DeviceType> {
  143241. /** Type of device */
  143242. readonly deviceType: DeviceType;
  143243. /** "Slot" or index that device is referenced in */
  143244. readonly deviceSlot: number;
  143245. /**
  143246. * Observable to handle device input changes per device
  143247. */
  143248. readonly onInputChangedObservable: Observable<{
  143249. inputIndex: DeviceInput<T>;
  143250. previousState: Nullable<number>;
  143251. currentState: Nullable<number>;
  143252. }>;
  143253. private readonly _deviceInputSystem;
  143254. /**
  143255. * Default Constructor
  143256. * @param deviceInputSystem Reference to DeviceInputSystem
  143257. * @param deviceType Type of device
  143258. * @param deviceSlot "Slot" or index that device is referenced in
  143259. */
  143260. constructor(deviceInputSystem: DeviceInputSystem,
  143261. /** Type of device */
  143262. deviceType: DeviceType,
  143263. /** "Slot" or index that device is referenced in */
  143264. deviceSlot?: number);
  143265. /**
  143266. * Get input for specific input
  143267. * @param inputIndex index of specific input on device
  143268. * @returns Input value from DeviceInputSystem
  143269. */
  143270. getInput(inputIndex: DeviceInput<T>): number;
  143271. }
  143272. /**
  143273. * Class to keep track of devices
  143274. */
  143275. export class DeviceSourceManager implements IDisposable {
  143276. /**
  143277. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  143278. */
  143279. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  143280. /**
  143281. * Observable to be triggered when after a device is disconnected
  143282. */
  143283. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  143284. private readonly _devices;
  143285. private readonly _firstDevice;
  143286. private readonly _deviceInputSystem;
  143287. /**
  143288. * Default Constructor
  143289. * @param engine engine to pull input element from
  143290. */
  143291. constructor(engine: Engine);
  143292. /**
  143293. * Gets a DeviceSource, given a type and slot
  143294. * @param deviceType Enum specifying device type
  143295. * @param deviceSlot "Slot" or index that device is referenced in
  143296. * @returns DeviceSource object
  143297. */
  143298. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  143299. /**
  143300. * Gets an array of DeviceSource objects for a given device type
  143301. * @param deviceType Enum specifying device type
  143302. * @returns Array of DeviceSource objects
  143303. */
  143304. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  143305. /**
  143306. * Returns a read-only list of all available devices
  143307. * @returns Read-only array with active devices
  143308. */
  143309. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  143310. /**
  143311. * Dispose of DeviceInputSystem and other parts
  143312. */
  143313. dispose(): void;
  143314. /**
  143315. * Function to add device name to device list
  143316. * @param deviceType Enum specifying device type
  143317. * @param deviceSlot "Slot" or index that device is referenced in
  143318. */
  143319. private _addDevice;
  143320. /**
  143321. * Function to remove device name to device list
  143322. * @param deviceType Enum specifying device type
  143323. * @param deviceSlot "Slot" or index that device is referenced in
  143324. */
  143325. private _removeDevice;
  143326. /**
  143327. * Updates array storing first connected device of each type
  143328. * @param type Type of Device
  143329. */
  143330. private _updateFirstDevices;
  143331. }
  143332. }
  143333. declare module BABYLON {
  143334. /**
  143335. * Options to create the null engine
  143336. */
  143337. export class NullEngineOptions {
  143338. /**
  143339. * Render width (Default: 512)
  143340. */
  143341. renderWidth: number;
  143342. /**
  143343. * Render height (Default: 256)
  143344. */
  143345. renderHeight: number;
  143346. /**
  143347. * Texture size (Default: 512)
  143348. */
  143349. textureSize: number;
  143350. /**
  143351. * If delta time between frames should be constant
  143352. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  143353. */
  143354. deterministicLockstep: boolean;
  143355. /**
  143356. * Maximum about of steps between frames (Default: 4)
  143357. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  143358. */
  143359. lockstepMaxSteps: number;
  143360. /**
  143361. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  143362. */
  143363. useHighPrecisionMatrix?: boolean;
  143364. }
  143365. /**
  143366. * The null engine class provides support for headless version of babylon.js.
  143367. * This can be used in server side scenario or for testing purposes
  143368. */
  143369. export class NullEngine extends Engine {
  143370. private _options;
  143371. /**
  143372. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  143373. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  143374. * @returns true if engine is in deterministic lock step mode
  143375. */
  143376. isDeterministicLockStep(): boolean;
  143377. /**
  143378. * Gets the max steps when engine is running in deterministic lock step
  143379. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  143380. * @returns the max steps
  143381. */
  143382. getLockstepMaxSteps(): number;
  143383. /**
  143384. * Gets the current hardware scaling level.
  143385. * By default the hardware scaling level is computed from the window device ratio.
  143386. * 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.
  143387. * @returns a number indicating the current hardware scaling level
  143388. */
  143389. getHardwareScalingLevel(): number;
  143390. constructor(options?: NullEngineOptions);
  143391. /**
  143392. * Creates a vertex buffer
  143393. * @param vertices the data for the vertex buffer
  143394. * @returns the new WebGL static buffer
  143395. */
  143396. createVertexBuffer(vertices: FloatArray): DataBuffer;
  143397. /**
  143398. * Creates a new index buffer
  143399. * @param indices defines the content of the index buffer
  143400. * @param updatable defines if the index buffer must be updatable
  143401. * @returns a new webGL buffer
  143402. */
  143403. createIndexBuffer(indices: IndicesArray): DataBuffer;
  143404. /**
  143405. * Clear the current render buffer or the current render target (if any is set up)
  143406. * @param color defines the color to use
  143407. * @param backBuffer defines if the back buffer must be cleared
  143408. * @param depth defines if the depth buffer must be cleared
  143409. * @param stencil defines if the stencil buffer must be cleared
  143410. */
  143411. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  143412. /**
  143413. * Gets the current render width
  143414. * @param useScreen defines if screen size must be used (or the current render target if any)
  143415. * @returns a number defining the current render width
  143416. */
  143417. getRenderWidth(useScreen?: boolean): number;
  143418. /**
  143419. * Gets the current render height
  143420. * @param useScreen defines if screen size must be used (or the current render target if any)
  143421. * @returns a number defining the current render height
  143422. */
  143423. getRenderHeight(useScreen?: boolean): number;
  143424. /**
  143425. * Set the WebGL's viewport
  143426. * @param viewport defines the viewport element to be used
  143427. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  143428. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  143429. */
  143430. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  143431. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  143432. /**
  143433. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  143434. * @param pipelineContext defines the pipeline context to use
  143435. * @param uniformsNames defines the list of uniform names
  143436. * @returns an array of webGL uniform locations
  143437. */
  143438. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  143439. /**
  143440. * Gets the lsit of active attributes for a given webGL program
  143441. * @param pipelineContext defines the pipeline context to use
  143442. * @param attributesNames defines the list of attribute names to get
  143443. * @returns an array of indices indicating the offset of each attribute
  143444. */
  143445. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  143446. /**
  143447. * Binds an effect to the webGL context
  143448. * @param effect defines the effect to bind
  143449. */
  143450. bindSamplers(effect: Effect): void;
  143451. /**
  143452. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  143453. * @param effect defines the effect to activate
  143454. */
  143455. enableEffect(effect: Effect): void;
  143456. /**
  143457. * Set various states to the webGL context
  143458. * @param culling defines backface culling state
  143459. * @param zOffset defines the value to apply to zOffset (0 by default)
  143460. * @param force defines if states must be applied even if cache is up to date
  143461. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  143462. */
  143463. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  143464. /**
  143465. * Set the value of an uniform to an array of int32
  143466. * @param uniform defines the webGL uniform location where to store the value
  143467. * @param array defines the array of int32 to store
  143468. * @returns true if value was set
  143469. */
  143470. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  143471. /**
  143472. * Set the value of an uniform to an array of int32 (stored as vec2)
  143473. * @param uniform defines the webGL uniform location where to store the value
  143474. * @param array defines the array of int32 to store
  143475. * @returns true if value was set
  143476. */
  143477. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  143478. /**
  143479. * Set the value of an uniform to an array of int32 (stored as vec3)
  143480. * @param uniform defines the webGL uniform location where to store the value
  143481. * @param array defines the array of int32 to store
  143482. * @returns true if value was set
  143483. */
  143484. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  143485. /**
  143486. * Set the value of an uniform to an array of int32 (stored as vec4)
  143487. * @param uniform defines the webGL uniform location where to store the value
  143488. * @param array defines the array of int32 to store
  143489. * @returns true if value was set
  143490. */
  143491. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  143492. /**
  143493. * Set the value of an uniform to an array of float32
  143494. * @param uniform defines the webGL uniform location where to store the value
  143495. * @param array defines the array of float32 to store
  143496. * @returns true if value was set
  143497. */
  143498. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  143499. /**
  143500. * Set the value of an uniform to an array of float32 (stored as vec2)
  143501. * @param uniform defines the webGL uniform location where to store the value
  143502. * @param array defines the array of float32 to store
  143503. * @returns true if value was set
  143504. */
  143505. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  143506. /**
  143507. * Set the value of an uniform to an array of float32 (stored as vec3)
  143508. * @param uniform defines the webGL uniform location where to store the value
  143509. * @param array defines the array of float32 to store
  143510. * @returns true if value was set
  143511. */
  143512. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  143513. /**
  143514. * Set the value of an uniform to an array of float32 (stored as vec4)
  143515. * @param uniform defines the webGL uniform location where to store the value
  143516. * @param array defines the array of float32 to store
  143517. * @returns true if value was set
  143518. */
  143519. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  143520. /**
  143521. * Set the value of an uniform to an array of number
  143522. * @param uniform defines the webGL uniform location where to store the value
  143523. * @param array defines the array of number to store
  143524. * @returns true if value was set
  143525. */
  143526. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  143527. /**
  143528. * Set the value of an uniform to an array of number (stored as vec2)
  143529. * @param uniform defines the webGL uniform location where to store the value
  143530. * @param array defines the array of number to store
  143531. * @returns true if value was set
  143532. */
  143533. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  143534. /**
  143535. * Set the value of an uniform to an array of number (stored as vec3)
  143536. * @param uniform defines the webGL uniform location where to store the value
  143537. * @param array defines the array of number to store
  143538. * @returns true if value was set
  143539. */
  143540. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  143541. /**
  143542. * Set the value of an uniform to an array of number (stored as vec4)
  143543. * @param uniform defines the webGL uniform location where to store the value
  143544. * @param array defines the array of number to store
  143545. * @returns true if value was set
  143546. */
  143547. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  143548. /**
  143549. * Set the value of an uniform to an array of float32 (stored as matrices)
  143550. * @param uniform defines the webGL uniform location where to store the value
  143551. * @param matrices defines the array of float32 to store
  143552. * @returns true if value was set
  143553. */
  143554. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  143555. /**
  143556. * Set the value of an uniform to a matrix (3x3)
  143557. * @param uniform defines the webGL uniform location where to store the value
  143558. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  143559. * @returns true if value was set
  143560. */
  143561. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  143562. /**
  143563. * Set the value of an uniform to a matrix (2x2)
  143564. * @param uniform defines the webGL uniform location where to store the value
  143565. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  143566. * @returns true if value was set
  143567. */
  143568. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  143569. /**
  143570. * Set the value of an uniform to a number (float)
  143571. * @param uniform defines the webGL uniform location where to store the value
  143572. * @param value defines the float number to store
  143573. * @returns true if value was set
  143574. */
  143575. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  143576. /**
  143577. * Set the value of an uniform to a vec2
  143578. * @param uniform defines the webGL uniform location where to store the value
  143579. * @param x defines the 1st component of the value
  143580. * @param y defines the 2nd component of the value
  143581. * @returns true if value was set
  143582. */
  143583. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  143584. /**
  143585. * Set the value of an uniform to a vec3
  143586. * @param uniform defines the webGL uniform location where to store the value
  143587. * @param x defines the 1st component of the value
  143588. * @param y defines the 2nd component of the value
  143589. * @param z defines the 3rd component of the value
  143590. * @returns true if value was set
  143591. */
  143592. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  143593. /**
  143594. * Set the value of an uniform to a boolean
  143595. * @param uniform defines the webGL uniform location where to store the value
  143596. * @param bool defines the boolean to store
  143597. * @returns true if value was set
  143598. */
  143599. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  143600. /**
  143601. * Set the value of an uniform to a vec4
  143602. * @param uniform defines the webGL uniform location where to store the value
  143603. * @param x defines the 1st component of the value
  143604. * @param y defines the 2nd component of the value
  143605. * @param z defines the 3rd component of the value
  143606. * @param w defines the 4th component of the value
  143607. * @returns true if value was set
  143608. */
  143609. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  143610. /**
  143611. * Sets the current alpha mode
  143612. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  143613. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  143614. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  143615. */
  143616. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  143617. /**
  143618. * Bind webGl buffers directly to the webGL context
  143619. * @param vertexBuffers defines the vertex buffer to bind
  143620. * @param indexBuffer defines the index buffer to bind
  143621. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  143622. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  143623. * @param effect defines the effect associated with the vertex buffer
  143624. */
  143625. bindBuffers(vertexBuffers: {
  143626. [key: string]: VertexBuffer;
  143627. }, indexBuffer: DataBuffer, effect: Effect): void;
  143628. /**
  143629. * Force the entire cache to be cleared
  143630. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  143631. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  143632. */
  143633. wipeCaches(bruteForce?: boolean): void;
  143634. /**
  143635. * Send a draw order
  143636. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  143637. * @param indexStart defines the starting index
  143638. * @param indexCount defines the number of index to draw
  143639. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  143640. */
  143641. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  143642. /**
  143643. * Draw a list of indexed primitives
  143644. * @param fillMode defines the primitive to use
  143645. * @param indexStart defines the starting index
  143646. * @param indexCount defines the number of index to draw
  143647. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  143648. */
  143649. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  143650. /**
  143651. * Draw a list of unindexed primitives
  143652. * @param fillMode defines the primitive to use
  143653. * @param verticesStart defines the index of first vertex to draw
  143654. * @param verticesCount defines the count of vertices to draw
  143655. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  143656. */
  143657. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  143658. /** @hidden */
  143659. protected _createTexture(): WebGLTexture;
  143660. /** @hidden */
  143661. _releaseTexture(texture: InternalTexture): void;
  143662. /**
  143663. * Usually called from Texture.ts.
  143664. * Passed information to create a WebGLTexture
  143665. * @param urlArg defines a value which contains one of the following:
  143666. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  143667. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  143668. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  143669. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  143670. * @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)
  143671. * @param scene needed for loading to the correct scene
  143672. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  143673. * @param onLoad optional callback to be called upon successful completion
  143674. * @param onError optional callback to be called upon failure
  143675. * @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
  143676. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  143677. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  143678. * @param forcedExtension defines the extension to use to pick the right loader
  143679. * @param mimeType defines an optional mime type
  143680. * @returns a InternalTexture for assignment back into BABYLON.Texture
  143681. */
  143682. 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;
  143683. /**
  143684. * Creates a new render target texture
  143685. * @param size defines the size of the texture
  143686. * @param options defines the options used to create the texture
  143687. * @returns a new render target texture stored in an InternalTexture
  143688. */
  143689. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  143690. /**
  143691. * Update the sampling mode of a given texture
  143692. * @param samplingMode defines the required sampling mode
  143693. * @param texture defines the texture to update
  143694. */
  143695. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  143696. /**
  143697. * Binds the frame buffer to the specified texture.
  143698. * @param texture The texture to render to or null for the default canvas
  143699. * @param faceIndex The face of the texture to render to in case of cube texture
  143700. * @param requiredWidth The width of the target to render to
  143701. * @param requiredHeight The height of the target to render to
  143702. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  143703. * @param lodLevel defines le lod level to bind to the frame buffer
  143704. */
  143705. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  143706. /**
  143707. * Unbind the current render target texture from the webGL context
  143708. * @param texture defines the render target texture to unbind
  143709. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  143710. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  143711. */
  143712. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  143713. /**
  143714. * Creates a dynamic vertex buffer
  143715. * @param vertices the data for the dynamic vertex buffer
  143716. * @returns the new WebGL dynamic buffer
  143717. */
  143718. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  143719. /**
  143720. * Update the content of a dynamic texture
  143721. * @param texture defines the texture to update
  143722. * @param canvas defines the canvas containing the source
  143723. * @param invertY defines if data must be stored with Y axis inverted
  143724. * @param premulAlpha defines if alpha is stored as premultiplied
  143725. * @param format defines the format of the data
  143726. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  143727. */
  143728. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  143729. /**
  143730. * Gets a boolean indicating if all created effects are ready
  143731. * @returns true if all effects are ready
  143732. */
  143733. areAllEffectsReady(): boolean;
  143734. /**
  143735. * @hidden
  143736. * Get the current error code of the webGL context
  143737. * @returns the error code
  143738. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  143739. */
  143740. getError(): number;
  143741. /** @hidden */
  143742. _getUnpackAlignement(): number;
  143743. /** @hidden */
  143744. _unpackFlipY(value: boolean): void;
  143745. /**
  143746. * Update a dynamic index buffer
  143747. * @param indexBuffer defines the target index buffer
  143748. * @param indices defines the data to update
  143749. * @param offset defines the offset in the target index buffer where update should start
  143750. */
  143751. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  143752. /**
  143753. * Updates a dynamic vertex buffer.
  143754. * @param vertexBuffer the vertex buffer to update
  143755. * @param vertices the data used to update the vertex buffer
  143756. * @param byteOffset the byte offset of the data (optional)
  143757. * @param byteLength the byte length of the data (optional)
  143758. */
  143759. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  143760. /** @hidden */
  143761. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  143762. /** @hidden */
  143763. _bindTexture(channel: number, texture: InternalTexture): void;
  143764. protected _deleteBuffer(buffer: WebGLBuffer): void;
  143765. /**
  143766. * 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
  143767. */
  143768. releaseEffects(): void;
  143769. displayLoadingUI(): void;
  143770. hideLoadingUI(): void;
  143771. /** @hidden */
  143772. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  143773. /** @hidden */
  143774. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  143775. /** @hidden */
  143776. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  143777. /** @hidden */
  143778. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  143779. }
  143780. }
  143781. declare module BABYLON {
  143782. /** @hidden */
  143783. export class _OcclusionDataStorage {
  143784. /** @hidden */
  143785. occlusionInternalRetryCounter: number;
  143786. /** @hidden */
  143787. isOcclusionQueryInProgress: boolean;
  143788. /** @hidden */
  143789. isOccluded: boolean;
  143790. /** @hidden */
  143791. occlusionRetryCount: number;
  143792. /** @hidden */
  143793. occlusionType: number;
  143794. /** @hidden */
  143795. occlusionQueryAlgorithmType: number;
  143796. }
  143797. interface Engine {
  143798. /**
  143799. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  143800. * @return the new query
  143801. */
  143802. createQuery(): WebGLQuery;
  143803. /**
  143804. * Delete and release a webGL query
  143805. * @param query defines the query to delete
  143806. * @return the current engine
  143807. */
  143808. deleteQuery(query: WebGLQuery): Engine;
  143809. /**
  143810. * Check if a given query has resolved and got its value
  143811. * @param query defines the query to check
  143812. * @returns true if the query got its value
  143813. */
  143814. isQueryResultAvailable(query: WebGLQuery): boolean;
  143815. /**
  143816. * Gets the value of a given query
  143817. * @param query defines the query to check
  143818. * @returns the value of the query
  143819. */
  143820. getQueryResult(query: WebGLQuery): number;
  143821. /**
  143822. * Initiates an occlusion query
  143823. * @param algorithmType defines the algorithm to use
  143824. * @param query defines the query to use
  143825. * @returns the current engine
  143826. * @see https://doc.babylonjs.com/features/occlusionquery
  143827. */
  143828. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  143829. /**
  143830. * Ends an occlusion query
  143831. * @see https://doc.babylonjs.com/features/occlusionquery
  143832. * @param algorithmType defines the algorithm to use
  143833. * @returns the current engine
  143834. */
  143835. endOcclusionQuery(algorithmType: number): Engine;
  143836. /**
  143837. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  143838. * Please note that only one query can be issued at a time
  143839. * @returns a time token used to track the time span
  143840. */
  143841. startTimeQuery(): Nullable<_TimeToken>;
  143842. /**
  143843. * Ends a time query
  143844. * @param token defines the token used to measure the time span
  143845. * @returns the time spent (in ns)
  143846. */
  143847. endTimeQuery(token: _TimeToken): int;
  143848. /** @hidden */
  143849. _currentNonTimestampToken: Nullable<_TimeToken>;
  143850. /** @hidden */
  143851. _createTimeQuery(): WebGLQuery;
  143852. /** @hidden */
  143853. _deleteTimeQuery(query: WebGLQuery): void;
  143854. /** @hidden */
  143855. _getGlAlgorithmType(algorithmType: number): number;
  143856. /** @hidden */
  143857. _getTimeQueryResult(query: WebGLQuery): any;
  143858. /** @hidden */
  143859. _getTimeQueryAvailability(query: WebGLQuery): any;
  143860. }
  143861. interface AbstractMesh {
  143862. /**
  143863. * Backing filed
  143864. * @hidden
  143865. */
  143866. __occlusionDataStorage: _OcclusionDataStorage;
  143867. /**
  143868. * Access property
  143869. * @hidden
  143870. */
  143871. _occlusionDataStorage: _OcclusionDataStorage;
  143872. /**
  143873. * 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.
  143874. * The default value is -1 which means don't break the query and wait till the result
  143875. * @see https://doc.babylonjs.com/features/occlusionquery
  143876. */
  143877. occlusionRetryCount: number;
  143878. /**
  143879. * 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:
  143880. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  143881. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  143882. * * 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.
  143883. * @see https://doc.babylonjs.com/features/occlusionquery
  143884. */
  143885. occlusionType: number;
  143886. /**
  143887. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  143888. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  143889. * * 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.
  143890. * @see https://doc.babylonjs.com/features/occlusionquery
  143891. */
  143892. occlusionQueryAlgorithmType: number;
  143893. /**
  143894. * 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
  143895. * @see https://doc.babylonjs.com/features/occlusionquery
  143896. */
  143897. isOccluded: boolean;
  143898. /**
  143899. * Flag to check the progress status of the query
  143900. * @see https://doc.babylonjs.com/features/occlusionquery
  143901. */
  143902. isOcclusionQueryInProgress: boolean;
  143903. }
  143904. }
  143905. declare module BABYLON {
  143906. /** @hidden */
  143907. export var _forceTransformFeedbackToBundle: boolean;
  143908. interface Engine {
  143909. /**
  143910. * Creates a webGL transform feedback object
  143911. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  143912. * @returns the webGL transform feedback object
  143913. */
  143914. createTransformFeedback(): WebGLTransformFeedback;
  143915. /**
  143916. * Delete a webGL transform feedback object
  143917. * @param value defines the webGL transform feedback object to delete
  143918. */
  143919. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  143920. /**
  143921. * Bind a webGL transform feedback object to the webgl context
  143922. * @param value defines the webGL transform feedback object to bind
  143923. */
  143924. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  143925. /**
  143926. * Begins a transform feedback operation
  143927. * @param usePoints defines if points or triangles must be used
  143928. */
  143929. beginTransformFeedback(usePoints: boolean): void;
  143930. /**
  143931. * Ends a transform feedback operation
  143932. */
  143933. endTransformFeedback(): void;
  143934. /**
  143935. * Specify the varyings to use with transform feedback
  143936. * @param program defines the associated webGL program
  143937. * @param value defines the list of strings representing the varying names
  143938. */
  143939. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  143940. /**
  143941. * Bind a webGL buffer for a transform feedback operation
  143942. * @param value defines the webGL buffer to bind
  143943. */
  143944. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  143945. }
  143946. }
  143947. declare module BABYLON {
  143948. /**
  143949. * Class used to define an additional view for the engine
  143950. * @see https://doc.babylonjs.com/how_to/multi_canvases
  143951. */
  143952. export class EngineView {
  143953. /** Defines the canvas where to render the view */
  143954. target: HTMLCanvasElement;
  143955. /** Defines an optional camera used to render the view (will use active camera else) */
  143956. camera?: Camera;
  143957. }
  143958. interface Engine {
  143959. /**
  143960. * Gets or sets the HTML element to use for attaching events
  143961. */
  143962. inputElement: Nullable<HTMLElement>;
  143963. /**
  143964. * Gets the current engine view
  143965. * @see https://doc.babylonjs.com/how_to/multi_canvases
  143966. */
  143967. activeView: Nullable<EngineView>;
  143968. /** Gets or sets the list of views */
  143969. views: EngineView[];
  143970. /**
  143971. * Register a new child canvas
  143972. * @param canvas defines the canvas to register
  143973. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  143974. * @returns the associated view
  143975. */
  143976. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  143977. /**
  143978. * Remove a registered child canvas
  143979. * @param canvas defines the canvas to remove
  143980. * @returns the current engine
  143981. */
  143982. unRegisterView(canvas: HTMLCanvasElement): Engine;
  143983. }
  143984. }
  143985. declare module BABYLON {
  143986. interface Engine {
  143987. /** @hidden */
  143988. _excludedCompressedTextures: string[];
  143989. /** @hidden */
  143990. _textureFormatInUse: string;
  143991. /**
  143992. * Gets the list of texture formats supported
  143993. */
  143994. readonly texturesSupported: Array<string>;
  143995. /**
  143996. * Gets the texture format in use
  143997. */
  143998. readonly textureFormatInUse: Nullable<string>;
  143999. /**
  144000. * Set the compressed texture extensions or file names to skip.
  144001. *
  144002. * @param skippedFiles defines the list of those texture files you want to skip
  144003. * Example: [".dds", ".env", "myfile.png"]
  144004. */
  144005. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  144006. /**
  144007. * Set the compressed texture format to use, based on the formats you have, and the formats
  144008. * supported by the hardware / browser.
  144009. *
  144010. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  144011. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  144012. * to API arguments needed to compressed textures. This puts the burden on the container
  144013. * generator to house the arcane code for determining these for current & future formats.
  144014. *
  144015. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  144016. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  144017. *
  144018. * Note: The result of this call is not taken into account when a texture is base64.
  144019. *
  144020. * @param formatsAvailable defines the list of those format families you have created
  144021. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  144022. *
  144023. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  144024. * @returns The extension selected.
  144025. */
  144026. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  144027. }
  144028. }
  144029. declare module BABYLON {
  144030. /** @hidden */
  144031. export var rgbdEncodePixelShader: {
  144032. name: string;
  144033. shader: string;
  144034. };
  144035. }
  144036. declare module BABYLON {
  144037. /**
  144038. * Raw texture data and descriptor sufficient for WebGL texture upload
  144039. */
  144040. export interface EnvironmentTextureInfo {
  144041. /**
  144042. * Version of the environment map
  144043. */
  144044. version: number;
  144045. /**
  144046. * Width of image
  144047. */
  144048. width: number;
  144049. /**
  144050. * Irradiance information stored in the file.
  144051. */
  144052. irradiance: any;
  144053. /**
  144054. * Specular information stored in the file.
  144055. */
  144056. specular: any;
  144057. }
  144058. /**
  144059. * Defines One Image in the file. It requires only the position in the file
  144060. * as well as the length.
  144061. */
  144062. interface BufferImageData {
  144063. /**
  144064. * Length of the image data.
  144065. */
  144066. length: number;
  144067. /**
  144068. * Position of the data from the null terminator delimiting the end of the JSON.
  144069. */
  144070. position: number;
  144071. }
  144072. /**
  144073. * Defines the specular data enclosed in the file.
  144074. * This corresponds to the version 1 of the data.
  144075. */
  144076. export interface EnvironmentTextureSpecularInfoV1 {
  144077. /**
  144078. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  144079. */
  144080. specularDataPosition?: number;
  144081. /**
  144082. * This contains all the images data needed to reconstruct the cubemap.
  144083. */
  144084. mipmaps: Array<BufferImageData>;
  144085. /**
  144086. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  144087. */
  144088. lodGenerationScale: number;
  144089. }
  144090. /**
  144091. * Sets of helpers addressing the serialization and deserialization of environment texture
  144092. * stored in a BabylonJS env file.
  144093. * Those files are usually stored as .env files.
  144094. */
  144095. export class EnvironmentTextureTools {
  144096. /**
  144097. * Magic number identifying the env file.
  144098. */
  144099. private static _MagicBytes;
  144100. /**
  144101. * Gets the environment info from an env file.
  144102. * @param data The array buffer containing the .env bytes.
  144103. * @returns the environment file info (the json header) if successfully parsed.
  144104. */
  144105. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  144106. /**
  144107. * Creates an environment texture from a loaded cube texture.
  144108. * @param texture defines the cube texture to convert in env file
  144109. * @return a promise containing the environment data if succesfull.
  144110. */
  144111. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  144112. /**
  144113. * Creates a JSON representation of the spherical data.
  144114. * @param texture defines the texture containing the polynomials
  144115. * @return the JSON representation of the spherical info
  144116. */
  144117. private static _CreateEnvTextureIrradiance;
  144118. /**
  144119. * Creates the ArrayBufferViews used for initializing environment texture image data.
  144120. * @param data the image data
  144121. * @param info parameters that determine what views will be created for accessing the underlying buffer
  144122. * @return the views described by info providing access to the underlying buffer
  144123. */
  144124. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  144125. /**
  144126. * Uploads the texture info contained in the env file to the GPU.
  144127. * @param texture defines the internal texture to upload to
  144128. * @param data defines the data to load
  144129. * @param info defines the texture info retrieved through the GetEnvInfo method
  144130. * @returns a promise
  144131. */
  144132. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  144133. private static _OnImageReadyAsync;
  144134. /**
  144135. * Uploads the levels of image data to the GPU.
  144136. * @param texture defines the internal texture to upload to
  144137. * @param imageData defines the array buffer views of image data [mipmap][face]
  144138. * @returns a promise
  144139. */
  144140. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  144141. /**
  144142. * Uploads spherical polynomials information to the texture.
  144143. * @param texture defines the texture we are trying to upload the information to
  144144. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  144145. */
  144146. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  144147. /** @hidden */
  144148. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  144149. }
  144150. }
  144151. declare module BABYLON {
  144152. /**
  144153. * Container for accessors for natively-stored mesh data buffers.
  144154. */
  144155. class NativeDataBuffer extends DataBuffer {
  144156. /**
  144157. * Accessor value used to identify/retrieve a natively-stored index buffer.
  144158. */
  144159. nativeIndexBuffer?: any;
  144160. /**
  144161. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  144162. */
  144163. nativeVertexBuffer?: any;
  144164. }
  144165. /** @hidden */
  144166. class NativeTexture extends InternalTexture {
  144167. getInternalTexture(): InternalTexture;
  144168. getViewCount(): number;
  144169. }
  144170. /** @hidden */
  144171. export class NativeEngine extends Engine {
  144172. private readonly _native;
  144173. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  144174. private readonly INVALID_HANDLE;
  144175. private _boundBuffersVertexArray;
  144176. private _currentDepthTest;
  144177. getHardwareScalingLevel(): number;
  144178. constructor();
  144179. dispose(): void;
  144180. /**
  144181. * Can be used to override the current requestAnimationFrame requester.
  144182. * @hidden
  144183. */
  144184. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  144185. /**
  144186. * Override default engine behavior.
  144187. * @param color
  144188. * @param backBuffer
  144189. * @param depth
  144190. * @param stencil
  144191. */
  144192. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  144193. /**
  144194. * Gets host document
  144195. * @returns the host document object
  144196. */
  144197. getHostDocument(): Nullable<Document>;
  144198. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  144199. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  144200. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  144201. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  144202. [key: string]: VertexBuffer;
  144203. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  144204. bindBuffers(vertexBuffers: {
  144205. [key: string]: VertexBuffer;
  144206. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  144207. recordVertexArrayObject(vertexBuffers: {
  144208. [key: string]: VertexBuffer;
  144209. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  144210. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  144211. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  144212. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  144213. /**
  144214. * Draw a list of indexed primitives
  144215. * @param fillMode defines the primitive to use
  144216. * @param indexStart defines the starting index
  144217. * @param indexCount defines the number of index to draw
  144218. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  144219. */
  144220. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  144221. /**
  144222. * Draw a list of unindexed primitives
  144223. * @param fillMode defines the primitive to use
  144224. * @param verticesStart defines the index of first vertex to draw
  144225. * @param verticesCount defines the count of vertices to draw
  144226. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  144227. */
  144228. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  144229. createPipelineContext(): IPipelineContext;
  144230. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  144231. /** @hidden */
  144232. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  144233. /** @hidden */
  144234. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  144235. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  144236. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  144237. protected _setProgram(program: WebGLProgram): void;
  144238. _releaseEffect(effect: Effect): void;
  144239. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  144240. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  144241. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  144242. bindSamplers(effect: Effect): void;
  144243. setMatrix(uniform: WebGLUniformLocation, matrix: IMatrixLike): void;
  144244. getRenderWidth(useScreen?: boolean): number;
  144245. getRenderHeight(useScreen?: boolean): number;
  144246. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  144247. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  144248. /**
  144249. * Set the z offset to apply to current rendering
  144250. * @param value defines the offset to apply
  144251. */
  144252. setZOffset(value: number): void;
  144253. /**
  144254. * Gets the current value of the zOffset
  144255. * @returns the current zOffset state
  144256. */
  144257. getZOffset(): number;
  144258. /**
  144259. * Enable or disable depth buffering
  144260. * @param enable defines the state to set
  144261. */
  144262. setDepthBuffer(enable: boolean): void;
  144263. /**
  144264. * Gets a boolean indicating if depth writing is enabled
  144265. * @returns the current depth writing state
  144266. */
  144267. getDepthWrite(): boolean;
  144268. setDepthFunctionToGreater(): void;
  144269. setDepthFunctionToGreaterOrEqual(): void;
  144270. setDepthFunctionToLess(): void;
  144271. setDepthFunctionToLessOrEqual(): void;
  144272. /**
  144273. * Enable or disable depth writing
  144274. * @param enable defines the state to set
  144275. */
  144276. setDepthWrite(enable: boolean): void;
  144277. /**
  144278. * Enable or disable color writing
  144279. * @param enable defines the state to set
  144280. */
  144281. setColorWrite(enable: boolean): void;
  144282. /**
  144283. * Gets a boolean indicating if color writing is enabled
  144284. * @returns the current color writing state
  144285. */
  144286. getColorWrite(): boolean;
  144287. /**
  144288. * Sets alpha constants used by some alpha blending modes
  144289. * @param r defines the red component
  144290. * @param g defines the green component
  144291. * @param b defines the blue component
  144292. * @param a defines the alpha component
  144293. */
  144294. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  144295. /**
  144296. * Sets the current alpha mode
  144297. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  144298. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  144299. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  144300. */
  144301. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  144302. /**
  144303. * Gets the current alpha mode
  144304. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  144305. * @returns the current alpha mode
  144306. */
  144307. getAlphaMode(): number;
  144308. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  144309. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  144310. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  144311. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  144312. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  144313. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  144314. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  144315. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  144316. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  144317. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  144318. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  144319. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  144320. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  144321. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  144322. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  144323. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  144324. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  144325. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  144326. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  144327. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  144328. setColor3(uniform: WebGLUniformLocation, color3: IColor3Like): boolean;
  144329. setColor4(uniform: WebGLUniformLocation, color3: IColor3Like, alpha: number): boolean;
  144330. wipeCaches(bruteForce?: boolean): void;
  144331. protected _createTexture(): WebGLTexture;
  144332. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  144333. /**
  144334. * Update the content of a dynamic texture
  144335. * @param texture defines the texture to update
  144336. * @param canvas defines the canvas containing the source
  144337. * @param invertY defines if data must be stored with Y axis inverted
  144338. * @param premulAlpha defines if alpha is stored as premultiplied
  144339. * @param format defines the format of the data
  144340. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  144341. */
  144342. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  144343. /**
  144344. * Usually called from Texture.ts.
  144345. * Passed information to create a WebGLTexture
  144346. * @param url defines a value which contains one of the following:
  144347. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  144348. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  144349. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  144350. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  144351. * @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)
  144352. * @param scene needed for loading to the correct scene
  144353. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  144354. * @param onLoad optional callback to be called upon successful completion
  144355. * @param onError optional callback to be called upon failure
  144356. * @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
  144357. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  144358. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  144359. * @param forcedExtension defines the extension to use to pick the right loader
  144360. * @param mimeType defines an optional mime type
  144361. * @param loaderOptions options to be passed to the loader
  144362. * @returns a InternalTexture for assignment back into BABYLON.Texture
  144363. */
  144364. 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;
  144365. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  144366. _releaseFramebufferObjects(texture: InternalTexture): void;
  144367. /**
  144368. * Creates a cube texture
  144369. * @param rootUrl defines the url where the files to load is located
  144370. * @param scene defines the current scene
  144371. * @param files defines the list of files to load (1 per face)
  144372. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  144373. * @param onLoad defines an optional callback raised when the texture is loaded
  144374. * @param onError defines an optional callback raised if there is an issue to load the texture
  144375. * @param format defines the format of the data
  144376. * @param forcedExtension defines the extension to use to pick the right loader
  144377. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  144378. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  144379. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  144380. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  144381. * @returns the cube texture as an InternalTexture
  144382. */
  144383. 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;
  144384. createRenderTargetTexture(size: number | {
  144385. width: number;
  144386. height: number;
  144387. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  144388. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  144389. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  144390. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  144391. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  144392. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  144393. /**
  144394. * Updates a dynamic vertex buffer.
  144395. * @param vertexBuffer the vertex buffer to update
  144396. * @param data the data used to update the vertex buffer
  144397. * @param byteOffset the byte offset of the data (optional)
  144398. * @param byteLength the byte length of the data (optional)
  144399. */
  144400. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  144401. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  144402. private _updateAnisotropicLevel;
  144403. private _getAddressMode;
  144404. /** @hidden */
  144405. _bindTexture(channel: number, texture: InternalTexture): void;
  144406. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  144407. releaseEffects(): void;
  144408. /** @hidden */
  144409. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  144410. /** @hidden */
  144411. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  144412. /** @hidden */
  144413. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  144414. /** @hidden */
  144415. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  144416. private _getNativeSamplingMode;
  144417. private _getNativeTextureFormat;
  144418. private _getNativeAlphaMode;
  144419. private _getNativeAttribType;
  144420. }
  144421. }
  144422. declare module BABYLON {
  144423. /**
  144424. * Gather the list of clipboard event types as constants.
  144425. */
  144426. export class ClipboardEventTypes {
  144427. /**
  144428. * The clipboard event is fired when a copy command is active (pressed).
  144429. */
  144430. static readonly COPY: number;
  144431. /**
  144432. * The clipboard event is fired when a cut command is active (pressed).
  144433. */
  144434. static readonly CUT: number;
  144435. /**
  144436. * The clipboard event is fired when a paste command is active (pressed).
  144437. */
  144438. static readonly PASTE: number;
  144439. }
  144440. /**
  144441. * This class is used to store clipboard related info for the onClipboardObservable event.
  144442. */
  144443. export class ClipboardInfo {
  144444. /**
  144445. * Defines the type of event (BABYLON.ClipboardEventTypes)
  144446. */
  144447. type: number;
  144448. /**
  144449. * Defines the related dom event
  144450. */
  144451. event: ClipboardEvent;
  144452. /**
  144453. *Creates an instance of ClipboardInfo.
  144454. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  144455. * @param event Defines the related dom event
  144456. */
  144457. constructor(
  144458. /**
  144459. * Defines the type of event (BABYLON.ClipboardEventTypes)
  144460. */
  144461. type: number,
  144462. /**
  144463. * Defines the related dom event
  144464. */
  144465. event: ClipboardEvent);
  144466. /**
  144467. * Get the clipboard event's type from the keycode.
  144468. * @param keyCode Defines the keyCode for the current keyboard event.
  144469. * @return {number}
  144470. */
  144471. static GetTypeFromCharacter(keyCode: number): number;
  144472. }
  144473. }
  144474. declare module BABYLON {
  144475. /**
  144476. * Google Daydream controller
  144477. */
  144478. export class DaydreamController extends WebVRController {
  144479. /**
  144480. * Base Url for the controller model.
  144481. */
  144482. static MODEL_BASE_URL: string;
  144483. /**
  144484. * File name for the controller model.
  144485. */
  144486. static MODEL_FILENAME: string;
  144487. /**
  144488. * Gamepad Id prefix used to identify Daydream Controller.
  144489. */
  144490. static readonly GAMEPAD_ID_PREFIX: string;
  144491. /**
  144492. * Creates a new DaydreamController from a gamepad
  144493. * @param vrGamepad the gamepad that the controller should be created from
  144494. */
  144495. constructor(vrGamepad: any);
  144496. /**
  144497. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  144498. * @param scene scene in which to add meshes
  144499. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  144500. */
  144501. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  144502. /**
  144503. * Called once for each button that changed state since the last frame
  144504. * @param buttonIdx Which button index changed
  144505. * @param state New state of the button
  144506. * @param changes Which properties on the state changed since last frame
  144507. */
  144508. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  144509. }
  144510. }
  144511. declare module BABYLON {
  144512. /**
  144513. * Gear VR Controller
  144514. */
  144515. export class GearVRController extends WebVRController {
  144516. /**
  144517. * Base Url for the controller model.
  144518. */
  144519. static MODEL_BASE_URL: string;
  144520. /**
  144521. * File name for the controller model.
  144522. */
  144523. static MODEL_FILENAME: string;
  144524. /**
  144525. * Gamepad Id prefix used to identify this controller.
  144526. */
  144527. static readonly GAMEPAD_ID_PREFIX: string;
  144528. private readonly _buttonIndexToObservableNameMap;
  144529. /**
  144530. * Creates a new GearVRController from a gamepad
  144531. * @param vrGamepad the gamepad that the controller should be created from
  144532. */
  144533. constructor(vrGamepad: any);
  144534. /**
  144535. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  144536. * @param scene scene in which to add meshes
  144537. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  144538. */
  144539. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  144540. /**
  144541. * Called once for each button that changed state since the last frame
  144542. * @param buttonIdx Which button index changed
  144543. * @param state New state of the button
  144544. * @param changes Which properties on the state changed since last frame
  144545. */
  144546. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  144547. }
  144548. }
  144549. declare module BABYLON {
  144550. /**
  144551. * Generic Controller
  144552. */
  144553. export class GenericController extends WebVRController {
  144554. /**
  144555. * Base Url for the controller model.
  144556. */
  144557. static readonly MODEL_BASE_URL: string;
  144558. /**
  144559. * File name for the controller model.
  144560. */
  144561. static readonly MODEL_FILENAME: string;
  144562. /**
  144563. * Creates a new GenericController from a gamepad
  144564. * @param vrGamepad the gamepad that the controller should be created from
  144565. */
  144566. constructor(vrGamepad: any);
  144567. /**
  144568. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  144569. * @param scene scene in which to add meshes
  144570. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  144571. */
  144572. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  144573. /**
  144574. * Called once for each button that changed state since the last frame
  144575. * @param buttonIdx Which button index changed
  144576. * @param state New state of the button
  144577. * @param changes Which properties on the state changed since last frame
  144578. */
  144579. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  144580. }
  144581. }
  144582. declare module BABYLON {
  144583. /**
  144584. * Oculus Touch Controller
  144585. */
  144586. export class OculusTouchController extends WebVRController {
  144587. /**
  144588. * Base Url for the controller model.
  144589. */
  144590. static MODEL_BASE_URL: string;
  144591. /**
  144592. * File name for the left controller model.
  144593. */
  144594. static MODEL_LEFT_FILENAME: string;
  144595. /**
  144596. * File name for the right controller model.
  144597. */
  144598. static MODEL_RIGHT_FILENAME: string;
  144599. /**
  144600. * Base Url for the Quest controller model.
  144601. */
  144602. static QUEST_MODEL_BASE_URL: string;
  144603. /**
  144604. * @hidden
  144605. * If the controllers are running on a device that needs the updated Quest controller models
  144606. */
  144607. static _IsQuest: boolean;
  144608. /**
  144609. * Fired when the secondary trigger on this controller is modified
  144610. */
  144611. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  144612. /**
  144613. * Fired when the thumb rest on this controller is modified
  144614. */
  144615. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  144616. /**
  144617. * Creates a new OculusTouchController from a gamepad
  144618. * @param vrGamepad the gamepad that the controller should be created from
  144619. */
  144620. constructor(vrGamepad: any);
  144621. /**
  144622. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  144623. * @param scene scene in which to add meshes
  144624. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  144625. */
  144626. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  144627. /**
  144628. * Fired when the A button on this controller is modified
  144629. */
  144630. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  144631. /**
  144632. * Fired when the B button on this controller is modified
  144633. */
  144634. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  144635. /**
  144636. * Fired when the X button on this controller is modified
  144637. */
  144638. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  144639. /**
  144640. * Fired when the Y button on this controller is modified
  144641. */
  144642. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  144643. /**
  144644. * Called once for each button that changed state since the last frame
  144645. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  144646. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  144647. * 2) secondary trigger (same)
  144648. * 3) A (right) X (left), touch, pressed = value
  144649. * 4) B / Y
  144650. * 5) thumb rest
  144651. * @param buttonIdx Which button index changed
  144652. * @param state New state of the button
  144653. * @param changes Which properties on the state changed since last frame
  144654. */
  144655. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  144656. }
  144657. }
  144658. declare module BABYLON {
  144659. /**
  144660. * Vive Controller
  144661. */
  144662. export class ViveController extends WebVRController {
  144663. /**
  144664. * Base Url for the controller model.
  144665. */
  144666. static MODEL_BASE_URL: string;
  144667. /**
  144668. * File name for the controller model.
  144669. */
  144670. static MODEL_FILENAME: string;
  144671. /**
  144672. * Creates a new ViveController from a gamepad
  144673. * @param vrGamepad the gamepad that the controller should be created from
  144674. */
  144675. constructor(vrGamepad: any);
  144676. /**
  144677. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  144678. * @param scene scene in which to add meshes
  144679. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  144680. */
  144681. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  144682. /**
  144683. * Fired when the left button on this controller is modified
  144684. */
  144685. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  144686. /**
  144687. * Fired when the right button on this controller is modified
  144688. */
  144689. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  144690. /**
  144691. * Fired when the menu button on this controller is modified
  144692. */
  144693. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  144694. /**
  144695. * Called once for each button that changed state since the last frame
  144696. * Vive mapping:
  144697. * 0: touchpad
  144698. * 1: trigger
  144699. * 2: left AND right buttons
  144700. * 3: menu button
  144701. * @param buttonIdx Which button index changed
  144702. * @param state New state of the button
  144703. * @param changes Which properties on the state changed since last frame
  144704. */
  144705. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  144706. }
  144707. }
  144708. declare module BABYLON {
  144709. /**
  144710. * Defines the WindowsMotionController object that the state of the windows motion controller
  144711. */
  144712. export class WindowsMotionController extends WebVRController {
  144713. /**
  144714. * The base url used to load the left and right controller models
  144715. */
  144716. static MODEL_BASE_URL: string;
  144717. /**
  144718. * The name of the left controller model file
  144719. */
  144720. static MODEL_LEFT_FILENAME: string;
  144721. /**
  144722. * The name of the right controller model file
  144723. */
  144724. static MODEL_RIGHT_FILENAME: string;
  144725. /**
  144726. * The controller name prefix for this controller type
  144727. */
  144728. static readonly GAMEPAD_ID_PREFIX: string;
  144729. /**
  144730. * The controller id pattern for this controller type
  144731. */
  144732. private static readonly GAMEPAD_ID_PATTERN;
  144733. private _loadedMeshInfo;
  144734. protected readonly _mapping: {
  144735. buttons: string[];
  144736. buttonMeshNames: {
  144737. trigger: string;
  144738. menu: string;
  144739. grip: string;
  144740. thumbstick: string;
  144741. trackpad: string;
  144742. };
  144743. buttonObservableNames: {
  144744. trigger: string;
  144745. menu: string;
  144746. grip: string;
  144747. thumbstick: string;
  144748. trackpad: string;
  144749. };
  144750. axisMeshNames: string[];
  144751. pointingPoseMeshName: string;
  144752. };
  144753. /**
  144754. * Fired when the trackpad on this controller is clicked
  144755. */
  144756. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  144757. /**
  144758. * Fired when the trackpad on this controller is modified
  144759. */
  144760. onTrackpadValuesChangedObservable: Observable<StickValues>;
  144761. /**
  144762. * The current x and y values of this controller's trackpad
  144763. */
  144764. trackpad: StickValues;
  144765. /**
  144766. * Creates a new WindowsMotionController from a gamepad
  144767. * @param vrGamepad the gamepad that the controller should be created from
  144768. */
  144769. constructor(vrGamepad: any);
  144770. /**
  144771. * Fired when the trigger on this controller is modified
  144772. */
  144773. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  144774. /**
  144775. * Fired when the menu button on this controller is modified
  144776. */
  144777. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  144778. /**
  144779. * Fired when the grip button on this controller is modified
  144780. */
  144781. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  144782. /**
  144783. * Fired when the thumbstick button on this controller is modified
  144784. */
  144785. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  144786. /**
  144787. * Fired when the touchpad button on this controller is modified
  144788. */
  144789. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  144790. /**
  144791. * Fired when the touchpad values on this controller are modified
  144792. */
  144793. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  144794. protected _updateTrackpad(): void;
  144795. /**
  144796. * Called once per frame by the engine.
  144797. */
  144798. update(): void;
  144799. /**
  144800. * Called once for each button that changed state since the last frame
  144801. * @param buttonIdx Which button index changed
  144802. * @param state New state of the button
  144803. * @param changes Which properties on the state changed since last frame
  144804. */
  144805. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  144806. /**
  144807. * Moves the buttons on the controller mesh based on their current state
  144808. * @param buttonName the name of the button to move
  144809. * @param buttonValue the value of the button which determines the buttons new position
  144810. */
  144811. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  144812. /**
  144813. * Moves the axis on the controller mesh based on its current state
  144814. * @param axis the index of the axis
  144815. * @param axisValue the value of the axis which determines the meshes new position
  144816. * @hidden
  144817. */
  144818. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  144819. /**
  144820. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  144821. * @param scene scene in which to add meshes
  144822. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  144823. */
  144824. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  144825. /**
  144826. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  144827. * can be transformed by button presses and axes values, based on this._mapping.
  144828. *
  144829. * @param scene scene in which the meshes exist
  144830. * @param meshes list of meshes that make up the controller model to process
  144831. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  144832. */
  144833. private processModel;
  144834. private createMeshInfo;
  144835. /**
  144836. * Gets the ray of the controller in the direction the controller is pointing
  144837. * @param length the length the resulting ray should be
  144838. * @returns a ray in the direction the controller is pointing
  144839. */
  144840. getForwardRay(length?: number): Ray;
  144841. /**
  144842. * Disposes of the controller
  144843. */
  144844. dispose(): void;
  144845. }
  144846. /**
  144847. * This class represents a new windows motion controller in XR.
  144848. */
  144849. export class XRWindowsMotionController extends WindowsMotionController {
  144850. /**
  144851. * Changing the original WIndowsMotionController mapping to fir the new mapping
  144852. */
  144853. protected readonly _mapping: {
  144854. buttons: string[];
  144855. buttonMeshNames: {
  144856. trigger: string;
  144857. menu: string;
  144858. grip: string;
  144859. thumbstick: string;
  144860. trackpad: string;
  144861. };
  144862. buttonObservableNames: {
  144863. trigger: string;
  144864. menu: string;
  144865. grip: string;
  144866. thumbstick: string;
  144867. trackpad: string;
  144868. };
  144869. axisMeshNames: string[];
  144870. pointingPoseMeshName: string;
  144871. };
  144872. /**
  144873. * Construct a new XR-Based windows motion controller
  144874. *
  144875. * @param gamepadInfo the gamepad object from the browser
  144876. */
  144877. constructor(gamepadInfo: any);
  144878. /**
  144879. * holds the thumbstick values (X,Y)
  144880. */
  144881. thumbstickValues: StickValues;
  144882. /**
  144883. * Fired when the thumbstick on this controller is clicked
  144884. */
  144885. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  144886. /**
  144887. * Fired when the thumbstick on this controller is modified
  144888. */
  144889. onThumbstickValuesChangedObservable: Observable<StickValues>;
  144890. /**
  144891. * Fired when the touchpad button on this controller is modified
  144892. */
  144893. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  144894. /**
  144895. * Fired when the touchpad values on this controller are modified
  144896. */
  144897. onTrackpadValuesChangedObservable: Observable<StickValues>;
  144898. /**
  144899. * Fired when the thumbstick button on this controller is modified
  144900. * here to prevent breaking changes
  144901. */
  144902. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  144903. /**
  144904. * updating the thumbstick(!) and not the trackpad.
  144905. * This is named this way due to the difference between WebVR and XR and to avoid
  144906. * changing the parent class.
  144907. */
  144908. protected _updateTrackpad(): void;
  144909. /**
  144910. * Disposes the class with joy
  144911. */
  144912. dispose(): void;
  144913. }
  144914. }
  144915. declare module BABYLON {
  144916. /**
  144917. * A directional light is defined by a direction (what a surprise!).
  144918. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  144919. * 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.
  144920. * Documentation: https://doc.babylonjs.com/babylon101/lights
  144921. */
  144922. export class DirectionalLight extends ShadowLight {
  144923. private _shadowFrustumSize;
  144924. /**
  144925. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  144926. */
  144927. get shadowFrustumSize(): number;
  144928. /**
  144929. * Specifies a fix frustum size for the shadow generation.
  144930. */
  144931. set shadowFrustumSize(value: number);
  144932. private _shadowOrthoScale;
  144933. /**
  144934. * Gets the shadow projection scale against the optimal computed one.
  144935. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  144936. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  144937. */
  144938. get shadowOrthoScale(): number;
  144939. /**
  144940. * Sets the shadow projection scale against the optimal computed one.
  144941. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  144942. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  144943. */
  144944. set shadowOrthoScale(value: number);
  144945. /**
  144946. * Automatically compute the projection matrix to best fit (including all the casters)
  144947. * on each frame.
  144948. */
  144949. autoUpdateExtends: boolean;
  144950. /**
  144951. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  144952. * on each frame. autoUpdateExtends must be set to true for this to work
  144953. */
  144954. autoCalcShadowZBounds: boolean;
  144955. private _orthoLeft;
  144956. private _orthoRight;
  144957. private _orthoTop;
  144958. private _orthoBottom;
  144959. /**
  144960. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  144961. * The directional light is emitted from everywhere in the given direction.
  144962. * It can cast shadows.
  144963. * Documentation : https://doc.babylonjs.com/babylon101/lights
  144964. * @param name The friendly name of the light
  144965. * @param direction The direction of the light
  144966. * @param scene The scene the light belongs to
  144967. */
  144968. constructor(name: string, direction: Vector3, scene: Scene);
  144969. /**
  144970. * Returns the string "DirectionalLight".
  144971. * @return The class name
  144972. */
  144973. getClassName(): string;
  144974. /**
  144975. * Returns the integer 1.
  144976. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  144977. */
  144978. getTypeID(): number;
  144979. /**
  144980. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  144981. * Returns the DirectionalLight Shadow projection matrix.
  144982. */
  144983. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  144984. /**
  144985. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  144986. * Returns the DirectionalLight Shadow projection matrix.
  144987. */
  144988. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  144989. /**
  144990. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  144991. * Returns the DirectionalLight Shadow projection matrix.
  144992. */
  144993. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  144994. protected _buildUniformLayout(): void;
  144995. /**
  144996. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  144997. * @param effect The effect to update
  144998. * @param lightIndex The index of the light in the effect to update
  144999. * @returns The directional light
  145000. */
  145001. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  145002. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  145003. /**
  145004. * Gets the minZ used for shadow according to both the scene and the light.
  145005. *
  145006. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  145007. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  145008. * @param activeCamera The camera we are returning the min for
  145009. * @returns the depth min z
  145010. */
  145011. getDepthMinZ(activeCamera: Camera): number;
  145012. /**
  145013. * Gets the maxZ used for shadow according to both the scene and the light.
  145014. *
  145015. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  145016. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  145017. * @param activeCamera The camera we are returning the max for
  145018. * @returns the depth max z
  145019. */
  145020. getDepthMaxZ(activeCamera: Camera): number;
  145021. /**
  145022. * Prepares the list of defines specific to the light type.
  145023. * @param defines the list of defines
  145024. * @param lightIndex defines the index of the light for the effect
  145025. */
  145026. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  145027. }
  145028. }
  145029. declare module BABYLON {
  145030. /**
  145031. * Class containing static functions to help procedurally build meshes
  145032. */
  145033. export class HemisphereBuilder {
  145034. /**
  145035. * Creates a hemisphere mesh
  145036. * @param name defines the name of the mesh
  145037. * @param options defines the options used to create the mesh
  145038. * @param scene defines the hosting scene
  145039. * @returns the hemisphere mesh
  145040. */
  145041. static CreateHemisphere(name: string, options: {
  145042. segments?: number;
  145043. diameter?: number;
  145044. sideOrientation?: number;
  145045. }, scene: any): Mesh;
  145046. }
  145047. }
  145048. declare module BABYLON {
  145049. /**
  145050. * A spot light is defined by a position, a direction, an angle, and an exponent.
  145051. * These values define a cone of light starting from the position, emitting toward the direction.
  145052. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  145053. * and the exponent defines the speed of the decay of the light with distance (reach).
  145054. * Documentation: https://doc.babylonjs.com/babylon101/lights
  145055. */
  145056. export class SpotLight extends ShadowLight {
  145057. private _angle;
  145058. private _innerAngle;
  145059. private _cosHalfAngle;
  145060. private _lightAngleScale;
  145061. private _lightAngleOffset;
  145062. /**
  145063. * Gets the cone angle of the spot light in Radians.
  145064. */
  145065. get angle(): number;
  145066. /**
  145067. * Sets the cone angle of the spot light in Radians.
  145068. */
  145069. set angle(value: number);
  145070. /**
  145071. * Only used in gltf falloff mode, this defines the angle where
  145072. * the directional falloff will start before cutting at angle which could be seen
  145073. * as outer angle.
  145074. */
  145075. get innerAngle(): number;
  145076. /**
  145077. * Only used in gltf falloff mode, this defines the angle where
  145078. * the directional falloff will start before cutting at angle which could be seen
  145079. * as outer angle.
  145080. */
  145081. set innerAngle(value: number);
  145082. private _shadowAngleScale;
  145083. /**
  145084. * Allows scaling the angle of the light for shadow generation only.
  145085. */
  145086. get shadowAngleScale(): number;
  145087. /**
  145088. * Allows scaling the angle of the light for shadow generation only.
  145089. */
  145090. set shadowAngleScale(value: number);
  145091. /**
  145092. * The light decay speed with the distance from the emission spot.
  145093. */
  145094. exponent: number;
  145095. private _projectionTextureMatrix;
  145096. /**
  145097. * Allows reading the projecton texture
  145098. */
  145099. get projectionTextureMatrix(): Matrix;
  145100. protected _projectionTextureLightNear: number;
  145101. /**
  145102. * Gets the near clip of the Spotlight for texture projection.
  145103. */
  145104. get projectionTextureLightNear(): number;
  145105. /**
  145106. * Sets the near clip of the Spotlight for texture projection.
  145107. */
  145108. set projectionTextureLightNear(value: number);
  145109. protected _projectionTextureLightFar: number;
  145110. /**
  145111. * Gets the far clip of the Spotlight for texture projection.
  145112. */
  145113. get projectionTextureLightFar(): number;
  145114. /**
  145115. * Sets the far clip of the Spotlight for texture projection.
  145116. */
  145117. set projectionTextureLightFar(value: number);
  145118. protected _projectionTextureUpDirection: Vector3;
  145119. /**
  145120. * Gets the Up vector of the Spotlight for texture projection.
  145121. */
  145122. get projectionTextureUpDirection(): Vector3;
  145123. /**
  145124. * Sets the Up vector of the Spotlight for texture projection.
  145125. */
  145126. set projectionTextureUpDirection(value: Vector3);
  145127. private _projectionTexture;
  145128. /**
  145129. * Gets the projection texture of the light.
  145130. */
  145131. get projectionTexture(): Nullable<BaseTexture>;
  145132. /**
  145133. * Sets the projection texture of the light.
  145134. */
  145135. set projectionTexture(value: Nullable<BaseTexture>);
  145136. private static _IsProceduralTexture;
  145137. private static _IsTexture;
  145138. private _projectionTextureViewLightDirty;
  145139. private _projectionTextureProjectionLightDirty;
  145140. private _projectionTextureDirty;
  145141. private _projectionTextureViewTargetVector;
  145142. private _projectionTextureViewLightMatrix;
  145143. private _projectionTextureProjectionLightMatrix;
  145144. private _projectionTextureScalingMatrix;
  145145. /**
  145146. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  145147. * It can cast shadows.
  145148. * Documentation : https://doc.babylonjs.com/babylon101/lights
  145149. * @param name The light friendly name
  145150. * @param position The position of the spot light in the scene
  145151. * @param direction The direction of the light in the scene
  145152. * @param angle The cone angle of the light in Radians
  145153. * @param exponent The light decay speed with the distance from the emission spot
  145154. * @param scene The scene the lights belongs to
  145155. */
  145156. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  145157. /**
  145158. * Returns the string "SpotLight".
  145159. * @returns the class name
  145160. */
  145161. getClassName(): string;
  145162. /**
  145163. * Returns the integer 2.
  145164. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  145165. */
  145166. getTypeID(): number;
  145167. /**
  145168. * Overrides the direction setter to recompute the projection texture view light Matrix.
  145169. */
  145170. protected _setDirection(value: Vector3): void;
  145171. /**
  145172. * Overrides the position setter to recompute the projection texture view light Matrix.
  145173. */
  145174. protected _setPosition(value: Vector3): void;
  145175. /**
  145176. * 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.
  145177. * Returns the SpotLight.
  145178. */
  145179. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  145180. protected _computeProjectionTextureViewLightMatrix(): void;
  145181. protected _computeProjectionTextureProjectionLightMatrix(): void;
  145182. /**
  145183. * Main function for light texture projection matrix computing.
  145184. */
  145185. protected _computeProjectionTextureMatrix(): void;
  145186. protected _buildUniformLayout(): void;
  145187. private _computeAngleValues;
  145188. /**
  145189. * Sets the passed Effect "effect" with the Light textures.
  145190. * @param effect The effect to update
  145191. * @param lightIndex The index of the light in the effect to update
  145192. * @returns The light
  145193. */
  145194. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  145195. /**
  145196. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  145197. * @param effect The effect to update
  145198. * @param lightIndex The index of the light in the effect to update
  145199. * @returns The spot light
  145200. */
  145201. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  145202. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  145203. /**
  145204. * Disposes the light and the associated resources.
  145205. */
  145206. dispose(): void;
  145207. /**
  145208. * Prepares the list of defines specific to the light type.
  145209. * @param defines the list of defines
  145210. * @param lightIndex defines the index of the light for the effect
  145211. */
  145212. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  145213. }
  145214. }
  145215. declare module BABYLON {
  145216. /**
  145217. * Gizmo that enables viewing a light
  145218. */
  145219. export class LightGizmo extends Gizmo {
  145220. private _lightMesh;
  145221. private _material;
  145222. private _cachedPosition;
  145223. private _cachedForward;
  145224. private _attachedMeshParent;
  145225. private _pointerObserver;
  145226. /**
  145227. * Event that fires each time the gizmo is clicked
  145228. */
  145229. onClickedObservable: Observable<Light>;
  145230. /**
  145231. * Creates a LightGizmo
  145232. * @param gizmoLayer The utility layer the gizmo will be added to
  145233. */
  145234. constructor(gizmoLayer?: UtilityLayerRenderer);
  145235. private _light;
  145236. /**
  145237. * The light that the gizmo is attached to
  145238. */
  145239. set light(light: Nullable<Light>);
  145240. get light(): Nullable<Light>;
  145241. /**
  145242. * Gets the material used to render the light gizmo
  145243. */
  145244. get material(): StandardMaterial;
  145245. /**
  145246. * @hidden
  145247. * Updates the gizmo to match the attached mesh's position/rotation
  145248. */
  145249. protected _update(): void;
  145250. private static _Scale;
  145251. /**
  145252. * Creates the lines for a light mesh
  145253. */
  145254. private static _CreateLightLines;
  145255. /**
  145256. * Disposes of the light gizmo
  145257. */
  145258. dispose(): void;
  145259. private static _CreateHemisphericLightMesh;
  145260. private static _CreatePointLightMesh;
  145261. private static _CreateSpotLightMesh;
  145262. private static _CreateDirectionalLightMesh;
  145263. }
  145264. }
  145265. declare module BABYLON {
  145266. /**
  145267. * Gizmo that enables viewing a camera
  145268. */
  145269. export class CameraGizmo extends Gizmo {
  145270. private _cameraMesh;
  145271. private _cameraLinesMesh;
  145272. private _material;
  145273. private _pointerObserver;
  145274. /**
  145275. * Event that fires each time the gizmo is clicked
  145276. */
  145277. onClickedObservable: Observable<Camera>;
  145278. /**
  145279. * Creates a CameraGizmo
  145280. * @param gizmoLayer The utility layer the gizmo will be added to
  145281. */
  145282. constructor(gizmoLayer?: UtilityLayerRenderer);
  145283. private _camera;
  145284. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  145285. get displayFrustum(): boolean;
  145286. set displayFrustum(value: boolean);
  145287. /**
  145288. * The camera that the gizmo is attached to
  145289. */
  145290. set camera(camera: Nullable<Camera>);
  145291. get camera(): Nullable<Camera>;
  145292. /**
  145293. * Gets the material used to render the camera gizmo
  145294. */
  145295. get material(): StandardMaterial;
  145296. /**
  145297. * @hidden
  145298. * Updates the gizmo to match the attached mesh's position/rotation
  145299. */
  145300. protected _update(): void;
  145301. private static _Scale;
  145302. private _invProjection;
  145303. /**
  145304. * Disposes of the camera gizmo
  145305. */
  145306. dispose(): void;
  145307. private static _CreateCameraMesh;
  145308. private static _CreateCameraFrustum;
  145309. }
  145310. }
  145311. declare module BABYLON {
  145312. /** @hidden */
  145313. export var backgroundFragmentDeclaration: {
  145314. name: string;
  145315. shader: string;
  145316. };
  145317. }
  145318. declare module BABYLON {
  145319. /** @hidden */
  145320. export var backgroundUboDeclaration: {
  145321. name: string;
  145322. shader: string;
  145323. };
  145324. }
  145325. declare module BABYLON {
  145326. /** @hidden */
  145327. export var backgroundPixelShader: {
  145328. name: string;
  145329. shader: string;
  145330. };
  145331. }
  145332. declare module BABYLON {
  145333. /** @hidden */
  145334. export var backgroundVertexDeclaration: {
  145335. name: string;
  145336. shader: string;
  145337. };
  145338. }
  145339. declare module BABYLON {
  145340. /** @hidden */
  145341. export var backgroundVertexShader: {
  145342. name: string;
  145343. shader: string;
  145344. };
  145345. }
  145346. declare module BABYLON {
  145347. /**
  145348. * Background material used to create an efficient environement around your scene.
  145349. */
  145350. export class BackgroundMaterial extends PushMaterial {
  145351. /**
  145352. * Standard reflectance value at parallel view angle.
  145353. */
  145354. static StandardReflectance0: number;
  145355. /**
  145356. * Standard reflectance value at grazing angle.
  145357. */
  145358. static StandardReflectance90: number;
  145359. protected _primaryColor: Color3;
  145360. /**
  145361. * Key light Color (multiply against the environement texture)
  145362. */
  145363. primaryColor: Color3;
  145364. protected __perceptualColor: Nullable<Color3>;
  145365. /**
  145366. * Experimental Internal Use Only.
  145367. *
  145368. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  145369. * This acts as a helper to set the primary color to a more "human friendly" value.
  145370. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  145371. * output color as close as possible from the chosen value.
  145372. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  145373. * part of lighting setup.)
  145374. */
  145375. get _perceptualColor(): Nullable<Color3>;
  145376. set _perceptualColor(value: Nullable<Color3>);
  145377. protected _primaryColorShadowLevel: float;
  145378. /**
  145379. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  145380. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  145381. */
  145382. get primaryColorShadowLevel(): float;
  145383. set primaryColorShadowLevel(value: float);
  145384. protected _primaryColorHighlightLevel: float;
  145385. /**
  145386. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  145387. * The primary color is used at the level chosen to define what the white area would look.
  145388. */
  145389. get primaryColorHighlightLevel(): float;
  145390. set primaryColorHighlightLevel(value: float);
  145391. protected _reflectionTexture: Nullable<BaseTexture>;
  145392. /**
  145393. * Reflection Texture used in the material.
  145394. * Should be author in a specific way for the best result (refer to the documentation).
  145395. */
  145396. reflectionTexture: Nullable<BaseTexture>;
  145397. protected _reflectionBlur: float;
  145398. /**
  145399. * Reflection Texture level of blur.
  145400. *
  145401. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  145402. * texture twice.
  145403. */
  145404. reflectionBlur: float;
  145405. protected _diffuseTexture: Nullable<BaseTexture>;
  145406. /**
  145407. * Diffuse Texture used in the material.
  145408. * Should be author in a specific way for the best result (refer to the documentation).
  145409. */
  145410. diffuseTexture: Nullable<BaseTexture>;
  145411. protected _shadowLights: Nullable<IShadowLight[]>;
  145412. /**
  145413. * Specify the list of lights casting shadow on the material.
  145414. * All scene shadow lights will be included if null.
  145415. */
  145416. shadowLights: Nullable<IShadowLight[]>;
  145417. protected _shadowLevel: float;
  145418. /**
  145419. * Helps adjusting the shadow to a softer level if required.
  145420. * 0 means black shadows and 1 means no shadows.
  145421. */
  145422. shadowLevel: float;
  145423. protected _sceneCenter: Vector3;
  145424. /**
  145425. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  145426. * It is usually zero but might be interesting to modify according to your setup.
  145427. */
  145428. sceneCenter: Vector3;
  145429. protected _opacityFresnel: boolean;
  145430. /**
  145431. * This helps specifying that the material is falling off to the sky box at grazing angle.
  145432. * This helps ensuring a nice transition when the camera goes under the ground.
  145433. */
  145434. opacityFresnel: boolean;
  145435. protected _reflectionFresnel: boolean;
  145436. /**
  145437. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  145438. * This helps adding a mirror texture on the ground.
  145439. */
  145440. reflectionFresnel: boolean;
  145441. protected _reflectionFalloffDistance: number;
  145442. /**
  145443. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  145444. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  145445. */
  145446. reflectionFalloffDistance: number;
  145447. protected _reflectionAmount: number;
  145448. /**
  145449. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  145450. */
  145451. reflectionAmount: number;
  145452. protected _reflectionReflectance0: number;
  145453. /**
  145454. * This specifies the weight of the reflection at grazing angle.
  145455. */
  145456. reflectionReflectance0: number;
  145457. protected _reflectionReflectance90: number;
  145458. /**
  145459. * This specifies the weight of the reflection at a perpendicular point of view.
  145460. */
  145461. reflectionReflectance90: number;
  145462. /**
  145463. * Sets the reflection reflectance fresnel values according to the default standard
  145464. * empirically know to work well :-)
  145465. */
  145466. set reflectionStandardFresnelWeight(value: number);
  145467. protected _useRGBColor: boolean;
  145468. /**
  145469. * Helps to directly use the maps channels instead of their level.
  145470. */
  145471. useRGBColor: boolean;
  145472. protected _enableNoise: boolean;
  145473. /**
  145474. * This helps reducing the banding effect that could occur on the background.
  145475. */
  145476. enableNoise: boolean;
  145477. /**
  145478. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  145479. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  145480. * Recommended to be keep at 1.0 except for special cases.
  145481. */
  145482. get fovMultiplier(): number;
  145483. set fovMultiplier(value: number);
  145484. private _fovMultiplier;
  145485. /**
  145486. * Enable the FOV adjustment feature controlled by fovMultiplier.
  145487. */
  145488. useEquirectangularFOV: boolean;
  145489. private _maxSimultaneousLights;
  145490. /**
  145491. * Number of Simultaneous lights allowed on the material.
  145492. */
  145493. maxSimultaneousLights: int;
  145494. private _shadowOnly;
  145495. /**
  145496. * Make the material only render shadows
  145497. */
  145498. shadowOnly: boolean;
  145499. /**
  145500. * Default configuration related to image processing available in the Background Material.
  145501. */
  145502. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  145503. /**
  145504. * Keep track of the image processing observer to allow dispose and replace.
  145505. */
  145506. private _imageProcessingObserver;
  145507. /**
  145508. * Attaches a new image processing configuration to the PBR Material.
  145509. * @param configuration (if null the scene configuration will be use)
  145510. */
  145511. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  145512. /**
  145513. * Gets the image processing configuration used either in this material.
  145514. */
  145515. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  145516. /**
  145517. * Sets the Default image processing configuration used either in the this material.
  145518. *
  145519. * If sets to null, the scene one is in use.
  145520. */
  145521. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  145522. /**
  145523. * Gets wether the color curves effect is enabled.
  145524. */
  145525. get cameraColorCurvesEnabled(): boolean;
  145526. /**
  145527. * Sets wether the color curves effect is enabled.
  145528. */
  145529. set cameraColorCurvesEnabled(value: boolean);
  145530. /**
  145531. * Gets wether the color grading effect is enabled.
  145532. */
  145533. get cameraColorGradingEnabled(): boolean;
  145534. /**
  145535. * Gets wether the color grading effect is enabled.
  145536. */
  145537. set cameraColorGradingEnabled(value: boolean);
  145538. /**
  145539. * Gets wether tonemapping is enabled or not.
  145540. */
  145541. get cameraToneMappingEnabled(): boolean;
  145542. /**
  145543. * Sets wether tonemapping is enabled or not
  145544. */
  145545. set cameraToneMappingEnabled(value: boolean);
  145546. /**
  145547. * The camera exposure used on this material.
  145548. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  145549. * This corresponds to a photographic exposure.
  145550. */
  145551. get cameraExposure(): float;
  145552. /**
  145553. * The camera exposure used on this material.
  145554. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  145555. * This corresponds to a photographic exposure.
  145556. */
  145557. set cameraExposure(value: float);
  145558. /**
  145559. * Gets The camera contrast used on this material.
  145560. */
  145561. get cameraContrast(): float;
  145562. /**
  145563. * Sets The camera contrast used on this material.
  145564. */
  145565. set cameraContrast(value: float);
  145566. /**
  145567. * Gets the Color Grading 2D Lookup Texture.
  145568. */
  145569. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  145570. /**
  145571. * Sets the Color Grading 2D Lookup Texture.
  145572. */
  145573. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  145574. /**
  145575. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  145576. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  145577. * 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;
  145578. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  145579. */
  145580. get cameraColorCurves(): Nullable<ColorCurves>;
  145581. /**
  145582. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  145583. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  145584. * 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;
  145585. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  145586. */
  145587. set cameraColorCurves(value: Nullable<ColorCurves>);
  145588. /**
  145589. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  145590. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  145591. */
  145592. switchToBGR: boolean;
  145593. private _renderTargets;
  145594. private _reflectionControls;
  145595. private _white;
  145596. private _primaryShadowColor;
  145597. private _primaryHighlightColor;
  145598. /**
  145599. * Instantiates a Background Material in the given scene
  145600. * @param name The friendly name of the material
  145601. * @param scene The scene to add the material to
  145602. */
  145603. constructor(name: string, scene: Scene);
  145604. /**
  145605. * Gets a boolean indicating that current material needs to register RTT
  145606. */
  145607. get hasRenderTargetTextures(): boolean;
  145608. /**
  145609. * The entire material has been created in order to prevent overdraw.
  145610. * @returns false
  145611. */
  145612. needAlphaTesting(): boolean;
  145613. /**
  145614. * The entire material has been created in order to prevent overdraw.
  145615. * @returns true if blending is enable
  145616. */
  145617. needAlphaBlending(): boolean;
  145618. /**
  145619. * Checks wether the material is ready to be rendered for a given mesh.
  145620. * @param mesh The mesh to render
  145621. * @param subMesh The submesh to check against
  145622. * @param useInstances Specify wether or not the material is used with instances
  145623. * @returns true if all the dependencies are ready (Textures, Effects...)
  145624. */
  145625. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  145626. /**
  145627. * Compute the primary color according to the chosen perceptual color.
  145628. */
  145629. private _computePrimaryColorFromPerceptualColor;
  145630. /**
  145631. * Compute the highlights and shadow colors according to their chosen levels.
  145632. */
  145633. private _computePrimaryColors;
  145634. /**
  145635. * Build the uniform buffer used in the material.
  145636. */
  145637. buildUniformLayout(): void;
  145638. /**
  145639. * Unbind the material.
  145640. */
  145641. unbind(): void;
  145642. /**
  145643. * Bind only the world matrix to the material.
  145644. * @param world The world matrix to bind.
  145645. */
  145646. bindOnlyWorldMatrix(world: Matrix): void;
  145647. /**
  145648. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  145649. * @param world The world matrix to bind.
  145650. * @param subMesh The submesh to bind for.
  145651. */
  145652. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  145653. /**
  145654. * Checks to see if a texture is used in the material.
  145655. * @param texture - Base texture to use.
  145656. * @returns - Boolean specifying if a texture is used in the material.
  145657. */
  145658. hasTexture(texture: BaseTexture): boolean;
  145659. /**
  145660. * Dispose the material.
  145661. * @param forceDisposeEffect Force disposal of the associated effect.
  145662. * @param forceDisposeTextures Force disposal of the associated textures.
  145663. */
  145664. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  145665. /**
  145666. * Clones the material.
  145667. * @param name The cloned name.
  145668. * @returns The cloned material.
  145669. */
  145670. clone(name: string): BackgroundMaterial;
  145671. /**
  145672. * Serializes the current material to its JSON representation.
  145673. * @returns The JSON representation.
  145674. */
  145675. serialize(): any;
  145676. /**
  145677. * Gets the class name of the material
  145678. * @returns "BackgroundMaterial"
  145679. */
  145680. getClassName(): string;
  145681. /**
  145682. * Parse a JSON input to create back a background material.
  145683. * @param source The JSON data to parse
  145684. * @param scene The scene to create the parsed material in
  145685. * @param rootUrl The root url of the assets the material depends upon
  145686. * @returns the instantiated BackgroundMaterial.
  145687. */
  145688. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  145689. }
  145690. }
  145691. declare module BABYLON {
  145692. /**
  145693. * Represents the different options available during the creation of
  145694. * a Environment helper.
  145695. *
  145696. * This can control the default ground, skybox and image processing setup of your scene.
  145697. */
  145698. export interface IEnvironmentHelperOptions {
  145699. /**
  145700. * Specifies whether or not to create a ground.
  145701. * True by default.
  145702. */
  145703. createGround: boolean;
  145704. /**
  145705. * Specifies the ground size.
  145706. * 15 by default.
  145707. */
  145708. groundSize: number;
  145709. /**
  145710. * The texture used on the ground for the main color.
  145711. * Comes from the BabylonJS CDN by default.
  145712. *
  145713. * Remarks: Can be either a texture or a url.
  145714. */
  145715. groundTexture: string | BaseTexture;
  145716. /**
  145717. * The color mixed in the ground texture by default.
  145718. * BabylonJS clearColor by default.
  145719. */
  145720. groundColor: Color3;
  145721. /**
  145722. * Specifies the ground opacity.
  145723. * 1 by default.
  145724. */
  145725. groundOpacity: number;
  145726. /**
  145727. * Enables the ground to receive shadows.
  145728. * True by default.
  145729. */
  145730. enableGroundShadow: boolean;
  145731. /**
  145732. * Helps preventing the shadow to be fully black on the ground.
  145733. * 0.5 by default.
  145734. */
  145735. groundShadowLevel: number;
  145736. /**
  145737. * Creates a mirror texture attach to the ground.
  145738. * false by default.
  145739. */
  145740. enableGroundMirror: boolean;
  145741. /**
  145742. * Specifies the ground mirror size ratio.
  145743. * 0.3 by default as the default kernel is 64.
  145744. */
  145745. groundMirrorSizeRatio: number;
  145746. /**
  145747. * Specifies the ground mirror blur kernel size.
  145748. * 64 by default.
  145749. */
  145750. groundMirrorBlurKernel: number;
  145751. /**
  145752. * Specifies the ground mirror visibility amount.
  145753. * 1 by default
  145754. */
  145755. groundMirrorAmount: number;
  145756. /**
  145757. * Specifies the ground mirror reflectance weight.
  145758. * This uses the standard weight of the background material to setup the fresnel effect
  145759. * of the mirror.
  145760. * 1 by default.
  145761. */
  145762. groundMirrorFresnelWeight: number;
  145763. /**
  145764. * Specifies the ground mirror Falloff distance.
  145765. * This can helps reducing the size of the reflection.
  145766. * 0 by Default.
  145767. */
  145768. groundMirrorFallOffDistance: number;
  145769. /**
  145770. * Specifies the ground mirror texture type.
  145771. * Unsigned Int by Default.
  145772. */
  145773. groundMirrorTextureType: number;
  145774. /**
  145775. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  145776. * the shown objects.
  145777. */
  145778. groundYBias: number;
  145779. /**
  145780. * Specifies whether or not to create a skybox.
  145781. * True by default.
  145782. */
  145783. createSkybox: boolean;
  145784. /**
  145785. * Specifies the skybox size.
  145786. * 20 by default.
  145787. */
  145788. skyboxSize: number;
  145789. /**
  145790. * The texture used on the skybox for the main color.
  145791. * Comes from the BabylonJS CDN by default.
  145792. *
  145793. * Remarks: Can be either a texture or a url.
  145794. */
  145795. skyboxTexture: string | BaseTexture;
  145796. /**
  145797. * The color mixed in the skybox texture by default.
  145798. * BabylonJS clearColor by default.
  145799. */
  145800. skyboxColor: Color3;
  145801. /**
  145802. * The background rotation around the Y axis of the scene.
  145803. * This helps aligning the key lights of your scene with the background.
  145804. * 0 by default.
  145805. */
  145806. backgroundYRotation: number;
  145807. /**
  145808. * Compute automatically the size of the elements to best fit with the scene.
  145809. */
  145810. sizeAuto: boolean;
  145811. /**
  145812. * Default position of the rootMesh if autoSize is not true.
  145813. */
  145814. rootPosition: Vector3;
  145815. /**
  145816. * Sets up the image processing in the scene.
  145817. * true by default.
  145818. */
  145819. setupImageProcessing: boolean;
  145820. /**
  145821. * The texture used as your environment texture in the scene.
  145822. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  145823. *
  145824. * Remarks: Can be either a texture or a url.
  145825. */
  145826. environmentTexture: string | BaseTexture;
  145827. /**
  145828. * The value of the exposure to apply to the scene.
  145829. * 0.6 by default if setupImageProcessing is true.
  145830. */
  145831. cameraExposure: number;
  145832. /**
  145833. * The value of the contrast to apply to the scene.
  145834. * 1.6 by default if setupImageProcessing is true.
  145835. */
  145836. cameraContrast: number;
  145837. /**
  145838. * Specifies whether or not tonemapping should be enabled in the scene.
  145839. * true by default if setupImageProcessing is true.
  145840. */
  145841. toneMappingEnabled: boolean;
  145842. }
  145843. /**
  145844. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  145845. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  145846. * It also helps with the default setup of your imageProcessing configuration.
  145847. */
  145848. export class EnvironmentHelper {
  145849. /**
  145850. * Default ground texture URL.
  145851. */
  145852. private static _groundTextureCDNUrl;
  145853. /**
  145854. * Default skybox texture URL.
  145855. */
  145856. private static _skyboxTextureCDNUrl;
  145857. /**
  145858. * Default environment texture URL.
  145859. */
  145860. private static _environmentTextureCDNUrl;
  145861. /**
  145862. * Creates the default options for the helper.
  145863. */
  145864. private static _getDefaultOptions;
  145865. private _rootMesh;
  145866. /**
  145867. * Gets the root mesh created by the helper.
  145868. */
  145869. get rootMesh(): Mesh;
  145870. private _skybox;
  145871. /**
  145872. * Gets the skybox created by the helper.
  145873. */
  145874. get skybox(): Nullable<Mesh>;
  145875. private _skyboxTexture;
  145876. /**
  145877. * Gets the skybox texture created by the helper.
  145878. */
  145879. get skyboxTexture(): Nullable<BaseTexture>;
  145880. private _skyboxMaterial;
  145881. /**
  145882. * Gets the skybox material created by the helper.
  145883. */
  145884. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  145885. private _ground;
  145886. /**
  145887. * Gets the ground mesh created by the helper.
  145888. */
  145889. get ground(): Nullable<Mesh>;
  145890. private _groundTexture;
  145891. /**
  145892. * Gets the ground texture created by the helper.
  145893. */
  145894. get groundTexture(): Nullable<BaseTexture>;
  145895. private _groundMirror;
  145896. /**
  145897. * Gets the ground mirror created by the helper.
  145898. */
  145899. get groundMirror(): Nullable<MirrorTexture>;
  145900. /**
  145901. * Gets the ground mirror render list to helps pushing the meshes
  145902. * you wish in the ground reflection.
  145903. */
  145904. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  145905. private _groundMaterial;
  145906. /**
  145907. * Gets the ground material created by the helper.
  145908. */
  145909. get groundMaterial(): Nullable<BackgroundMaterial>;
  145910. /**
  145911. * Stores the creation options.
  145912. */
  145913. private readonly _scene;
  145914. private _options;
  145915. /**
  145916. * This observable will be notified with any error during the creation of the environment,
  145917. * mainly texture creation errors.
  145918. */
  145919. onErrorObservable: Observable<{
  145920. message?: string;
  145921. exception?: any;
  145922. }>;
  145923. /**
  145924. * constructor
  145925. * @param options Defines the options we want to customize the helper
  145926. * @param scene The scene to add the material to
  145927. */
  145928. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  145929. /**
  145930. * Updates the background according to the new options
  145931. * @param options
  145932. */
  145933. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  145934. /**
  145935. * Sets the primary color of all the available elements.
  145936. * @param color the main color to affect to the ground and the background
  145937. */
  145938. setMainColor(color: Color3): void;
  145939. /**
  145940. * Setup the image processing according to the specified options.
  145941. */
  145942. private _setupImageProcessing;
  145943. /**
  145944. * Setup the environment texture according to the specified options.
  145945. */
  145946. private _setupEnvironmentTexture;
  145947. /**
  145948. * Setup the background according to the specified options.
  145949. */
  145950. private _setupBackground;
  145951. /**
  145952. * Get the scene sizes according to the setup.
  145953. */
  145954. private _getSceneSize;
  145955. /**
  145956. * Setup the ground according to the specified options.
  145957. */
  145958. private _setupGround;
  145959. /**
  145960. * Setup the ground material according to the specified options.
  145961. */
  145962. private _setupGroundMaterial;
  145963. /**
  145964. * Setup the ground diffuse texture according to the specified options.
  145965. */
  145966. private _setupGroundDiffuseTexture;
  145967. /**
  145968. * Setup the ground mirror texture according to the specified options.
  145969. */
  145970. private _setupGroundMirrorTexture;
  145971. /**
  145972. * Setup the ground to receive the mirror texture.
  145973. */
  145974. private _setupMirrorInGroundMaterial;
  145975. /**
  145976. * Setup the skybox according to the specified options.
  145977. */
  145978. private _setupSkybox;
  145979. /**
  145980. * Setup the skybox material according to the specified options.
  145981. */
  145982. private _setupSkyboxMaterial;
  145983. /**
  145984. * Setup the skybox reflection texture according to the specified options.
  145985. */
  145986. private _setupSkyboxReflectionTexture;
  145987. private _errorHandler;
  145988. /**
  145989. * Dispose all the elements created by the Helper.
  145990. */
  145991. dispose(): void;
  145992. }
  145993. }
  145994. declare module BABYLON {
  145995. /**
  145996. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  145997. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  145998. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  145999. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  146000. */
  146001. export abstract class TextureDome<T extends Texture> extends TransformNode {
  146002. protected onError: Nullable<(message?: string, exception?: any) => void>;
  146003. /**
  146004. * Define the source as a Monoscopic panoramic 360/180.
  146005. */
  146006. static readonly MODE_MONOSCOPIC: number;
  146007. /**
  146008. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  146009. */
  146010. static readonly MODE_TOPBOTTOM: number;
  146011. /**
  146012. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  146013. */
  146014. static readonly MODE_SIDEBYSIDE: number;
  146015. private _halfDome;
  146016. private _crossEye;
  146017. protected _useDirectMapping: boolean;
  146018. /**
  146019. * The texture being displayed on the sphere
  146020. */
  146021. protected _texture: T;
  146022. /**
  146023. * Gets the texture being displayed on the sphere
  146024. */
  146025. get texture(): T;
  146026. /**
  146027. * Sets the texture being displayed on the sphere
  146028. */
  146029. set texture(newTexture: T);
  146030. /**
  146031. * The skybox material
  146032. */
  146033. protected _material: BackgroundMaterial;
  146034. /**
  146035. * The surface used for the dome
  146036. */
  146037. protected _mesh: Mesh;
  146038. /**
  146039. * Gets the mesh used for the dome.
  146040. */
  146041. get mesh(): Mesh;
  146042. /**
  146043. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  146044. */
  146045. private _halfDomeMask;
  146046. /**
  146047. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  146048. * Also see the options.resolution property.
  146049. */
  146050. get fovMultiplier(): number;
  146051. set fovMultiplier(value: number);
  146052. protected _textureMode: number;
  146053. /**
  146054. * Gets or set the current texture mode for the texture. It can be:
  146055. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  146056. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  146057. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  146058. */
  146059. get textureMode(): number;
  146060. /**
  146061. * Sets the current texture mode for the texture. It can be:
  146062. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  146063. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  146064. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  146065. */
  146066. set textureMode(value: number);
  146067. /**
  146068. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  146069. */
  146070. get halfDome(): boolean;
  146071. /**
  146072. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  146073. */
  146074. set halfDome(enabled: boolean);
  146075. /**
  146076. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  146077. */
  146078. set crossEye(enabled: boolean);
  146079. /**
  146080. * Is it a cross-eye texture?
  146081. */
  146082. get crossEye(): boolean;
  146083. /**
  146084. * The background material of this dome.
  146085. */
  146086. get material(): BackgroundMaterial;
  146087. /**
  146088. * Oberserver used in Stereoscopic VR Mode.
  146089. */
  146090. private _onBeforeCameraRenderObserver;
  146091. /**
  146092. * Observable raised when an error occured while loading the 360 image
  146093. */
  146094. onLoadErrorObservable: Observable<string>;
  146095. /**
  146096. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  146097. * @param name Element's name, child elements will append suffixes for their own names.
  146098. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  146099. * @param options An object containing optional or exposed sub element properties
  146100. */
  146101. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  146102. resolution?: number;
  146103. clickToPlay?: boolean;
  146104. autoPlay?: boolean;
  146105. loop?: boolean;
  146106. size?: number;
  146107. poster?: string;
  146108. faceForward?: boolean;
  146109. useDirectMapping?: boolean;
  146110. halfDomeMode?: boolean;
  146111. crossEyeMode?: boolean;
  146112. generateMipMaps?: boolean;
  146113. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  146114. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  146115. protected _changeTextureMode(value: number): void;
  146116. /**
  146117. * Releases resources associated with this node.
  146118. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  146119. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  146120. */
  146121. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  146122. }
  146123. }
  146124. declare module BABYLON {
  146125. /**
  146126. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  146127. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  146128. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  146129. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  146130. */
  146131. export class PhotoDome extends TextureDome<Texture> {
  146132. /**
  146133. * Define the image as a Monoscopic panoramic 360 image.
  146134. */
  146135. static readonly MODE_MONOSCOPIC: number;
  146136. /**
  146137. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  146138. */
  146139. static readonly MODE_TOPBOTTOM: number;
  146140. /**
  146141. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  146142. */
  146143. static readonly MODE_SIDEBYSIDE: number;
  146144. /**
  146145. * Gets or sets the texture being displayed on the sphere
  146146. */
  146147. get photoTexture(): Texture;
  146148. /**
  146149. * sets the texture being displayed on the sphere
  146150. */
  146151. set photoTexture(value: Texture);
  146152. /**
  146153. * Gets the current video mode for the video. It can be:
  146154. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  146155. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  146156. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  146157. */
  146158. get imageMode(): number;
  146159. /**
  146160. * Sets the current video mode for the video. It can be:
  146161. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  146162. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  146163. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  146164. */
  146165. set imageMode(value: number);
  146166. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  146167. }
  146168. }
  146169. declare module BABYLON {
  146170. /**
  146171. * Direct draw surface info
  146172. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  146173. */
  146174. export interface DDSInfo {
  146175. /**
  146176. * Width of the texture
  146177. */
  146178. width: number;
  146179. /**
  146180. * Width of the texture
  146181. */
  146182. height: number;
  146183. /**
  146184. * Number of Mipmaps for the texture
  146185. * @see https://en.wikipedia.org/wiki/Mipmap
  146186. */
  146187. mipmapCount: number;
  146188. /**
  146189. * If the textures format is a known fourCC format
  146190. * @see https://www.fourcc.org/
  146191. */
  146192. isFourCC: boolean;
  146193. /**
  146194. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  146195. */
  146196. isRGB: boolean;
  146197. /**
  146198. * If the texture is a lumincance format
  146199. */
  146200. isLuminance: boolean;
  146201. /**
  146202. * If this is a cube texture
  146203. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  146204. */
  146205. isCube: boolean;
  146206. /**
  146207. * If the texture is a compressed format eg. FOURCC_DXT1
  146208. */
  146209. isCompressed: boolean;
  146210. /**
  146211. * The dxgiFormat of the texture
  146212. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  146213. */
  146214. dxgiFormat: number;
  146215. /**
  146216. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  146217. */
  146218. textureType: number;
  146219. /**
  146220. * Sphericle polynomial created for the dds texture
  146221. */
  146222. sphericalPolynomial?: SphericalPolynomial;
  146223. }
  146224. /**
  146225. * Class used to provide DDS decompression tools
  146226. */
  146227. export class DDSTools {
  146228. /**
  146229. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  146230. */
  146231. static StoreLODInAlphaChannel: boolean;
  146232. /**
  146233. * Gets DDS information from an array buffer
  146234. * @param data defines the array buffer view to read data from
  146235. * @returns the DDS information
  146236. */
  146237. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  146238. private static _FloatView;
  146239. private static _Int32View;
  146240. private static _ToHalfFloat;
  146241. private static _FromHalfFloat;
  146242. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  146243. private static _GetHalfFloatRGBAArrayBuffer;
  146244. private static _GetFloatRGBAArrayBuffer;
  146245. private static _GetFloatAsUIntRGBAArrayBuffer;
  146246. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  146247. private static _GetRGBAArrayBuffer;
  146248. private static _ExtractLongWordOrder;
  146249. private static _GetRGBArrayBuffer;
  146250. private static _GetLuminanceArrayBuffer;
  146251. /**
  146252. * Uploads DDS Levels to a Babylon Texture
  146253. * @hidden
  146254. */
  146255. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  146256. }
  146257. interface ThinEngine {
  146258. /**
  146259. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  146260. * @param rootUrl defines the url where the file to load is located
  146261. * @param scene defines the current scene
  146262. * @param lodScale defines scale to apply to the mip map selection
  146263. * @param lodOffset defines offset to apply to the mip map selection
  146264. * @param onLoad defines an optional callback raised when the texture is loaded
  146265. * @param onError defines an optional callback raised if there is an issue to load the texture
  146266. * @param format defines the format of the data
  146267. * @param forcedExtension defines the extension to use to pick the right loader
  146268. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  146269. * @returns the cube texture as an InternalTexture
  146270. */
  146271. 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;
  146272. }
  146273. }
  146274. declare module BABYLON {
  146275. /**
  146276. * Implementation of the DDS Texture Loader.
  146277. * @hidden
  146278. */
  146279. export class _DDSTextureLoader implements IInternalTextureLoader {
  146280. /**
  146281. * Defines wether the loader supports cascade loading the different faces.
  146282. */
  146283. readonly supportCascades: boolean;
  146284. /**
  146285. * This returns if the loader support the current file information.
  146286. * @param extension defines the file extension of the file being loaded
  146287. * @returns true if the loader can load the specified file
  146288. */
  146289. canLoad(extension: string): boolean;
  146290. /**
  146291. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  146292. * @param data contains the texture data
  146293. * @param texture defines the BabylonJS internal texture
  146294. * @param createPolynomials will be true if polynomials have been requested
  146295. * @param onLoad defines the callback to trigger once the texture is ready
  146296. * @param onError defines the callback to trigger in case of error
  146297. */
  146298. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  146299. /**
  146300. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  146301. * @param data contains the texture data
  146302. * @param texture defines the BabylonJS internal texture
  146303. * @param callback defines the method to call once ready to upload
  146304. */
  146305. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  146306. }
  146307. }
  146308. declare module BABYLON {
  146309. /**
  146310. * Implementation of the ENV Texture Loader.
  146311. * @hidden
  146312. */
  146313. export class _ENVTextureLoader implements IInternalTextureLoader {
  146314. /**
  146315. * Defines wether the loader supports cascade loading the different faces.
  146316. */
  146317. readonly supportCascades: boolean;
  146318. /**
  146319. * This returns if the loader support the current file information.
  146320. * @param extension defines the file extension of the file being loaded
  146321. * @returns true if the loader can load the specified file
  146322. */
  146323. canLoad(extension: string): boolean;
  146324. /**
  146325. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  146326. * @param data contains the texture data
  146327. * @param texture defines the BabylonJS internal texture
  146328. * @param createPolynomials will be true if polynomials have been requested
  146329. * @param onLoad defines the callback to trigger once the texture is ready
  146330. * @param onError defines the callback to trigger in case of error
  146331. */
  146332. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  146333. /**
  146334. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  146335. * @param data contains the texture data
  146336. * @param texture defines the BabylonJS internal texture
  146337. * @param callback defines the method to call once ready to upload
  146338. */
  146339. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  146340. }
  146341. }
  146342. declare module BABYLON {
  146343. /**
  146344. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  146345. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  146346. */
  146347. export class KhronosTextureContainer {
  146348. /** contents of the KTX container file */
  146349. data: ArrayBufferView;
  146350. private static HEADER_LEN;
  146351. private static COMPRESSED_2D;
  146352. private static COMPRESSED_3D;
  146353. private static TEX_2D;
  146354. private static TEX_3D;
  146355. /**
  146356. * Gets the openGL type
  146357. */
  146358. glType: number;
  146359. /**
  146360. * Gets the openGL type size
  146361. */
  146362. glTypeSize: number;
  146363. /**
  146364. * Gets the openGL format
  146365. */
  146366. glFormat: number;
  146367. /**
  146368. * Gets the openGL internal format
  146369. */
  146370. glInternalFormat: number;
  146371. /**
  146372. * Gets the base internal format
  146373. */
  146374. glBaseInternalFormat: number;
  146375. /**
  146376. * Gets image width in pixel
  146377. */
  146378. pixelWidth: number;
  146379. /**
  146380. * Gets image height in pixel
  146381. */
  146382. pixelHeight: number;
  146383. /**
  146384. * Gets image depth in pixels
  146385. */
  146386. pixelDepth: number;
  146387. /**
  146388. * Gets the number of array elements
  146389. */
  146390. numberOfArrayElements: number;
  146391. /**
  146392. * Gets the number of faces
  146393. */
  146394. numberOfFaces: number;
  146395. /**
  146396. * Gets the number of mipmap levels
  146397. */
  146398. numberOfMipmapLevels: number;
  146399. /**
  146400. * Gets the bytes of key value data
  146401. */
  146402. bytesOfKeyValueData: number;
  146403. /**
  146404. * Gets the load type
  146405. */
  146406. loadType: number;
  146407. /**
  146408. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  146409. */
  146410. isInvalid: boolean;
  146411. /**
  146412. * Creates a new KhronosTextureContainer
  146413. * @param data contents of the KTX container file
  146414. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  146415. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  146416. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  146417. */
  146418. constructor(
  146419. /** contents of the KTX container file */
  146420. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  146421. /**
  146422. * Uploads KTX content to a Babylon Texture.
  146423. * It is assumed that the texture has already been created & is currently bound
  146424. * @hidden
  146425. */
  146426. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  146427. private _upload2DCompressedLevels;
  146428. /**
  146429. * Checks if the given data starts with a KTX file identifier.
  146430. * @param data the data to check
  146431. * @returns true if the data is a KTX file or false otherwise
  146432. */
  146433. static IsValid(data: ArrayBufferView): boolean;
  146434. }
  146435. }
  146436. declare module BABYLON {
  146437. /**
  146438. * Helper class to push actions to a pool of workers.
  146439. */
  146440. export class WorkerPool implements IDisposable {
  146441. private _workerInfos;
  146442. private _pendingActions;
  146443. /**
  146444. * Constructor
  146445. * @param workers Array of workers to use for actions
  146446. */
  146447. constructor(workers: Array<Worker>);
  146448. /**
  146449. * Terminates all workers and clears any pending actions.
  146450. */
  146451. dispose(): void;
  146452. /**
  146453. * Pushes an action to the worker pool. If all the workers are active, the action will be
  146454. * pended until a worker has completed its action.
  146455. * @param action The action to perform. Call onComplete when the action is complete.
  146456. */
  146457. push(action: (worker: Worker, onComplete: () => void) => void): void;
  146458. private _execute;
  146459. }
  146460. }
  146461. declare module BABYLON {
  146462. /**
  146463. * Class for loading KTX2 files
  146464. */
  146465. export class KhronosTextureContainer2 {
  146466. private static _WorkerPoolPromise?;
  146467. private static _Initialized;
  146468. private static _Ktx2Decoder;
  146469. /**
  146470. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  146471. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  146472. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  146473. * Urls you can change:
  146474. * URLConfig.jsDecoderModule
  146475. * URLConfig.wasmUASTCToASTC
  146476. * URLConfig.wasmUASTCToBC7
  146477. * URLConfig.wasmUASTCToRGBA_UNORM
  146478. * URLConfig.wasmUASTCToRGBA_SRGB
  146479. * URLConfig.jsMSCTranscoder
  146480. * URLConfig.wasmMSCTranscoder
  146481. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#22
  146482. */
  146483. static URLConfig: {
  146484. jsDecoderModule: string;
  146485. wasmUASTCToASTC: null;
  146486. wasmUASTCToBC7: null;
  146487. wasmUASTCToRGBA_UNORM: null;
  146488. wasmUASTCToRGBA_SRGB: null;
  146489. jsMSCTranscoder: null;
  146490. wasmMSCTranscoder: null;
  146491. };
  146492. /**
  146493. * Default number of workers used to handle data decoding
  146494. */
  146495. static DefaultNumWorkers: number;
  146496. private static GetDefaultNumWorkers;
  146497. private _engine;
  146498. private static _CreateWorkerPool;
  146499. /**
  146500. * Constructor
  146501. * @param engine The engine to use
  146502. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  146503. */
  146504. constructor(engine: ThinEngine, numWorkers?: number);
  146505. /** @hidden */
  146506. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  146507. /**
  146508. * Stop all async operations and release resources.
  146509. */
  146510. dispose(): void;
  146511. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  146512. /**
  146513. * Checks if the given data starts with a KTX2 file identifier.
  146514. * @param data the data to check
  146515. * @returns true if the data is a KTX2 file or false otherwise
  146516. */
  146517. static IsValid(data: ArrayBufferView): boolean;
  146518. }
  146519. }
  146520. declare module BABYLON {
  146521. /**
  146522. * Implementation of the KTX Texture Loader.
  146523. * @hidden
  146524. */
  146525. export class _KTXTextureLoader implements IInternalTextureLoader {
  146526. /**
  146527. * Defines wether the loader supports cascade loading the different faces.
  146528. */
  146529. readonly supportCascades: boolean;
  146530. /**
  146531. * This returns if the loader support the current file information.
  146532. * @param extension defines the file extension of the file being loaded
  146533. * @param mimeType defines the optional mime type of the file being loaded
  146534. * @returns true if the loader can load the specified file
  146535. */
  146536. canLoad(extension: string, mimeType?: string): boolean;
  146537. /**
  146538. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  146539. * @param data contains the texture data
  146540. * @param texture defines the BabylonJS internal texture
  146541. * @param createPolynomials will be true if polynomials have been requested
  146542. * @param onLoad defines the callback to trigger once the texture is ready
  146543. * @param onError defines the callback to trigger in case of error
  146544. */
  146545. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  146546. /**
  146547. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  146548. * @param data contains the texture data
  146549. * @param texture defines the BabylonJS internal texture
  146550. * @param callback defines the method to call once ready to upload
  146551. */
  146552. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  146553. }
  146554. }
  146555. declare module BABYLON {
  146556. /** @hidden */
  146557. export var _forceSceneHelpersToBundle: boolean;
  146558. interface Scene {
  146559. /**
  146560. * Creates a default light for the scene.
  146561. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  146562. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  146563. */
  146564. createDefaultLight(replace?: boolean): void;
  146565. /**
  146566. * Creates a default camera for the scene.
  146567. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  146568. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  146569. * @param replace has default false, when true replaces the active camera in the scene
  146570. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  146571. */
  146572. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  146573. /**
  146574. * Creates a default camera and a default light.
  146575. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  146576. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  146577. * @param replace has the default false, when true replaces the active camera/light in the scene
  146578. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  146579. */
  146580. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  146581. /**
  146582. * Creates a new sky box
  146583. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  146584. * @param environmentTexture defines the texture to use as environment texture
  146585. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  146586. * @param scale defines the overall scale of the skybox
  146587. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  146588. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  146589. * @returns a new mesh holding the sky box
  146590. */
  146591. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  146592. /**
  146593. * Creates a new environment
  146594. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  146595. * @param options defines the options you can use to configure the environment
  146596. * @returns the new EnvironmentHelper
  146597. */
  146598. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  146599. /**
  146600. * Creates a new VREXperienceHelper
  146601. * @see https://doc.babylonjs.com/how_to/webvr_helper
  146602. * @param webVROptions defines the options used to create the new VREXperienceHelper
  146603. * @returns a new VREXperienceHelper
  146604. */
  146605. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  146606. /**
  146607. * Creates a new WebXRDefaultExperience
  146608. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  146609. * @param options experience options
  146610. * @returns a promise for a new WebXRDefaultExperience
  146611. */
  146612. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  146613. }
  146614. }
  146615. declare module BABYLON {
  146616. /**
  146617. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  146618. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  146619. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  146620. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  146621. */
  146622. export class VideoDome extends TextureDome<VideoTexture> {
  146623. /**
  146624. * Define the video source as a Monoscopic panoramic 360 video.
  146625. */
  146626. static readonly MODE_MONOSCOPIC: number;
  146627. /**
  146628. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  146629. */
  146630. static readonly MODE_TOPBOTTOM: number;
  146631. /**
  146632. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  146633. */
  146634. static readonly MODE_SIDEBYSIDE: number;
  146635. /**
  146636. * Get the video texture associated with this video dome
  146637. */
  146638. get videoTexture(): VideoTexture;
  146639. /**
  146640. * Get the video mode of this dome
  146641. */
  146642. get videoMode(): number;
  146643. /**
  146644. * Set the video mode of this dome.
  146645. * @see textureMode
  146646. */
  146647. set videoMode(value: number);
  146648. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  146649. }
  146650. }
  146651. declare module BABYLON {
  146652. /**
  146653. * This class can be used to get instrumentation data from a Babylon engine
  146654. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  146655. */
  146656. export class EngineInstrumentation implements IDisposable {
  146657. /**
  146658. * Define the instrumented engine.
  146659. */
  146660. engine: Engine;
  146661. private _captureGPUFrameTime;
  146662. private _gpuFrameTimeToken;
  146663. private _gpuFrameTime;
  146664. private _captureShaderCompilationTime;
  146665. private _shaderCompilationTime;
  146666. private _onBeginFrameObserver;
  146667. private _onEndFrameObserver;
  146668. private _onBeforeShaderCompilationObserver;
  146669. private _onAfterShaderCompilationObserver;
  146670. /**
  146671. * Gets the perf counter used for GPU frame time
  146672. */
  146673. get gpuFrameTimeCounter(): PerfCounter;
  146674. /**
  146675. * Gets the GPU frame time capture status
  146676. */
  146677. get captureGPUFrameTime(): boolean;
  146678. /**
  146679. * Enable or disable the GPU frame time capture
  146680. */
  146681. set captureGPUFrameTime(value: boolean);
  146682. /**
  146683. * Gets the perf counter used for shader compilation time
  146684. */
  146685. get shaderCompilationTimeCounter(): PerfCounter;
  146686. /**
  146687. * Gets the shader compilation time capture status
  146688. */
  146689. get captureShaderCompilationTime(): boolean;
  146690. /**
  146691. * Enable or disable the shader compilation time capture
  146692. */
  146693. set captureShaderCompilationTime(value: boolean);
  146694. /**
  146695. * Instantiates a new engine instrumentation.
  146696. * This class can be used to get instrumentation data from a Babylon engine
  146697. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  146698. * @param engine Defines the engine to instrument
  146699. */
  146700. constructor(
  146701. /**
  146702. * Define the instrumented engine.
  146703. */
  146704. engine: Engine);
  146705. /**
  146706. * Dispose and release associated resources.
  146707. */
  146708. dispose(): void;
  146709. }
  146710. }
  146711. declare module BABYLON {
  146712. /**
  146713. * This class can be used to get instrumentation data from a Babylon engine
  146714. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  146715. */
  146716. export class SceneInstrumentation implements IDisposable {
  146717. /**
  146718. * Defines the scene to instrument
  146719. */
  146720. scene: Scene;
  146721. private _captureActiveMeshesEvaluationTime;
  146722. private _activeMeshesEvaluationTime;
  146723. private _captureRenderTargetsRenderTime;
  146724. private _renderTargetsRenderTime;
  146725. private _captureFrameTime;
  146726. private _frameTime;
  146727. private _captureRenderTime;
  146728. private _renderTime;
  146729. private _captureInterFrameTime;
  146730. private _interFrameTime;
  146731. private _captureParticlesRenderTime;
  146732. private _particlesRenderTime;
  146733. private _captureSpritesRenderTime;
  146734. private _spritesRenderTime;
  146735. private _capturePhysicsTime;
  146736. private _physicsTime;
  146737. private _captureAnimationsTime;
  146738. private _animationsTime;
  146739. private _captureCameraRenderTime;
  146740. private _cameraRenderTime;
  146741. private _onBeforeActiveMeshesEvaluationObserver;
  146742. private _onAfterActiveMeshesEvaluationObserver;
  146743. private _onBeforeRenderTargetsRenderObserver;
  146744. private _onAfterRenderTargetsRenderObserver;
  146745. private _onAfterRenderObserver;
  146746. private _onBeforeDrawPhaseObserver;
  146747. private _onAfterDrawPhaseObserver;
  146748. private _onBeforeAnimationsObserver;
  146749. private _onBeforeParticlesRenderingObserver;
  146750. private _onAfterParticlesRenderingObserver;
  146751. private _onBeforeSpritesRenderingObserver;
  146752. private _onAfterSpritesRenderingObserver;
  146753. private _onBeforePhysicsObserver;
  146754. private _onAfterPhysicsObserver;
  146755. private _onAfterAnimationsObserver;
  146756. private _onBeforeCameraRenderObserver;
  146757. private _onAfterCameraRenderObserver;
  146758. /**
  146759. * Gets the perf counter used for active meshes evaluation time
  146760. */
  146761. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  146762. /**
  146763. * Gets the active meshes evaluation time capture status
  146764. */
  146765. get captureActiveMeshesEvaluationTime(): boolean;
  146766. /**
  146767. * Enable or disable the active meshes evaluation time capture
  146768. */
  146769. set captureActiveMeshesEvaluationTime(value: boolean);
  146770. /**
  146771. * Gets the perf counter used for render targets render time
  146772. */
  146773. get renderTargetsRenderTimeCounter(): PerfCounter;
  146774. /**
  146775. * Gets the render targets render time capture status
  146776. */
  146777. get captureRenderTargetsRenderTime(): boolean;
  146778. /**
  146779. * Enable or disable the render targets render time capture
  146780. */
  146781. set captureRenderTargetsRenderTime(value: boolean);
  146782. /**
  146783. * Gets the perf counter used for particles render time
  146784. */
  146785. get particlesRenderTimeCounter(): PerfCounter;
  146786. /**
  146787. * Gets the particles render time capture status
  146788. */
  146789. get captureParticlesRenderTime(): boolean;
  146790. /**
  146791. * Enable or disable the particles render time capture
  146792. */
  146793. set captureParticlesRenderTime(value: boolean);
  146794. /**
  146795. * Gets the perf counter used for sprites render time
  146796. */
  146797. get spritesRenderTimeCounter(): PerfCounter;
  146798. /**
  146799. * Gets the sprites render time capture status
  146800. */
  146801. get captureSpritesRenderTime(): boolean;
  146802. /**
  146803. * Enable or disable the sprites render time capture
  146804. */
  146805. set captureSpritesRenderTime(value: boolean);
  146806. /**
  146807. * Gets the perf counter used for physics time
  146808. */
  146809. get physicsTimeCounter(): PerfCounter;
  146810. /**
  146811. * Gets the physics time capture status
  146812. */
  146813. get capturePhysicsTime(): boolean;
  146814. /**
  146815. * Enable or disable the physics time capture
  146816. */
  146817. set capturePhysicsTime(value: boolean);
  146818. /**
  146819. * Gets the perf counter used for animations time
  146820. */
  146821. get animationsTimeCounter(): PerfCounter;
  146822. /**
  146823. * Gets the animations time capture status
  146824. */
  146825. get captureAnimationsTime(): boolean;
  146826. /**
  146827. * Enable or disable the animations time capture
  146828. */
  146829. set captureAnimationsTime(value: boolean);
  146830. /**
  146831. * Gets the perf counter used for frame time capture
  146832. */
  146833. get frameTimeCounter(): PerfCounter;
  146834. /**
  146835. * Gets the frame time capture status
  146836. */
  146837. get captureFrameTime(): boolean;
  146838. /**
  146839. * Enable or disable the frame time capture
  146840. */
  146841. set captureFrameTime(value: boolean);
  146842. /**
  146843. * Gets the perf counter used for inter-frames time capture
  146844. */
  146845. get interFrameTimeCounter(): PerfCounter;
  146846. /**
  146847. * Gets the inter-frames time capture status
  146848. */
  146849. get captureInterFrameTime(): boolean;
  146850. /**
  146851. * Enable or disable the inter-frames time capture
  146852. */
  146853. set captureInterFrameTime(value: boolean);
  146854. /**
  146855. * Gets the perf counter used for render time capture
  146856. */
  146857. get renderTimeCounter(): PerfCounter;
  146858. /**
  146859. * Gets the render time capture status
  146860. */
  146861. get captureRenderTime(): boolean;
  146862. /**
  146863. * Enable or disable the render time capture
  146864. */
  146865. set captureRenderTime(value: boolean);
  146866. /**
  146867. * Gets the perf counter used for camera render time capture
  146868. */
  146869. get cameraRenderTimeCounter(): PerfCounter;
  146870. /**
  146871. * Gets the camera render time capture status
  146872. */
  146873. get captureCameraRenderTime(): boolean;
  146874. /**
  146875. * Enable or disable the camera render time capture
  146876. */
  146877. set captureCameraRenderTime(value: boolean);
  146878. /**
  146879. * Gets the perf counter used for draw calls
  146880. */
  146881. get drawCallsCounter(): PerfCounter;
  146882. /**
  146883. * Instantiates a new scene instrumentation.
  146884. * This class can be used to get instrumentation data from a Babylon engine
  146885. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  146886. * @param scene Defines the scene to instrument
  146887. */
  146888. constructor(
  146889. /**
  146890. * Defines the scene to instrument
  146891. */
  146892. scene: Scene);
  146893. /**
  146894. * Dispose and release associated resources.
  146895. */
  146896. dispose(): void;
  146897. }
  146898. }
  146899. declare module BABYLON {
  146900. /** @hidden */
  146901. export var glowMapGenerationPixelShader: {
  146902. name: string;
  146903. shader: string;
  146904. };
  146905. }
  146906. declare module BABYLON {
  146907. /** @hidden */
  146908. export var glowMapGenerationVertexShader: {
  146909. name: string;
  146910. shader: string;
  146911. };
  146912. }
  146913. declare module BABYLON {
  146914. /**
  146915. * Effect layer options. This helps customizing the behaviour
  146916. * of the effect layer.
  146917. */
  146918. export interface IEffectLayerOptions {
  146919. /**
  146920. * Multiplication factor apply to the canvas size to compute the render target size
  146921. * used to generated the objects (the smaller the faster).
  146922. */
  146923. mainTextureRatio: number;
  146924. /**
  146925. * Enforces a fixed size texture to ensure effect stability across devices.
  146926. */
  146927. mainTextureFixedSize?: number;
  146928. /**
  146929. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  146930. */
  146931. alphaBlendingMode: number;
  146932. /**
  146933. * The camera attached to the layer.
  146934. */
  146935. camera: Nullable<Camera>;
  146936. /**
  146937. * The rendering group to draw the layer in.
  146938. */
  146939. renderingGroupId: number;
  146940. }
  146941. /**
  146942. * The effect layer Helps adding post process effect blended with the main pass.
  146943. *
  146944. * This can be for instance use to generate glow or higlight effects on the scene.
  146945. *
  146946. * The effect layer class can not be used directly and is intented to inherited from to be
  146947. * customized per effects.
  146948. */
  146949. export abstract class EffectLayer {
  146950. private _vertexBuffers;
  146951. private _indexBuffer;
  146952. private _cachedDefines;
  146953. private _effectLayerMapGenerationEffect;
  146954. private _effectLayerOptions;
  146955. private _mergeEffect;
  146956. protected _scene: Scene;
  146957. protected _engine: Engine;
  146958. protected _maxSize: number;
  146959. protected _mainTextureDesiredSize: ISize;
  146960. protected _mainTexture: RenderTargetTexture;
  146961. protected _shouldRender: boolean;
  146962. protected _postProcesses: PostProcess[];
  146963. protected _textures: BaseTexture[];
  146964. protected _emissiveTextureAndColor: {
  146965. texture: Nullable<BaseTexture>;
  146966. color: Color4;
  146967. };
  146968. /**
  146969. * The name of the layer
  146970. */
  146971. name: string;
  146972. /**
  146973. * The clear color of the texture used to generate the glow map.
  146974. */
  146975. neutralColor: Color4;
  146976. /**
  146977. * Specifies whether the highlight layer is enabled or not.
  146978. */
  146979. isEnabled: boolean;
  146980. /**
  146981. * Gets the camera attached to the layer.
  146982. */
  146983. get camera(): Nullable<Camera>;
  146984. /**
  146985. * Gets the rendering group id the layer should render in.
  146986. */
  146987. get renderingGroupId(): number;
  146988. set renderingGroupId(renderingGroupId: number);
  146989. /**
  146990. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  146991. */
  146992. disableBoundingBoxesFromEffectLayer: boolean;
  146993. /**
  146994. * An event triggered when the effect layer has been disposed.
  146995. */
  146996. onDisposeObservable: Observable<EffectLayer>;
  146997. /**
  146998. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  146999. */
  147000. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  147001. /**
  147002. * An event triggered when the generated texture is being merged in the scene.
  147003. */
  147004. onBeforeComposeObservable: Observable<EffectLayer>;
  147005. /**
  147006. * An event triggered when the mesh is rendered into the effect render target.
  147007. */
  147008. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  147009. /**
  147010. * An event triggered after the mesh has been rendered into the effect render target.
  147011. */
  147012. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  147013. /**
  147014. * An event triggered when the generated texture has been merged in the scene.
  147015. */
  147016. onAfterComposeObservable: Observable<EffectLayer>;
  147017. /**
  147018. * An event triggered when the efffect layer changes its size.
  147019. */
  147020. onSizeChangedObservable: Observable<EffectLayer>;
  147021. /** @hidden */
  147022. static _SceneComponentInitialization: (scene: Scene) => void;
  147023. /**
  147024. * Instantiates a new effect Layer and references it in the scene.
  147025. * @param name The name of the layer
  147026. * @param scene The scene to use the layer in
  147027. */
  147028. constructor(
  147029. /** The Friendly of the effect in the scene */
  147030. name: string, scene: Scene);
  147031. /**
  147032. * Get the effect name of the layer.
  147033. * @return The effect name
  147034. */
  147035. abstract getEffectName(): string;
  147036. /**
  147037. * Checks for the readiness of the element composing the layer.
  147038. * @param subMesh the mesh to check for
  147039. * @param useInstances specify whether or not to use instances to render the mesh
  147040. * @return true if ready otherwise, false
  147041. */
  147042. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  147043. /**
  147044. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  147045. * @returns true if the effect requires stencil during the main canvas render pass.
  147046. */
  147047. abstract needStencil(): boolean;
  147048. /**
  147049. * Create the merge effect. This is the shader use to blit the information back
  147050. * to the main canvas at the end of the scene rendering.
  147051. * @returns The effect containing the shader used to merge the effect on the main canvas
  147052. */
  147053. protected abstract _createMergeEffect(): Effect;
  147054. /**
  147055. * Creates the render target textures and post processes used in the effect layer.
  147056. */
  147057. protected abstract _createTextureAndPostProcesses(): void;
  147058. /**
  147059. * Implementation specific of rendering the generating effect on the main canvas.
  147060. * @param effect The effect used to render through
  147061. */
  147062. protected abstract _internalRender(effect: Effect): void;
  147063. /**
  147064. * Sets the required values for both the emissive texture and and the main color.
  147065. */
  147066. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  147067. /**
  147068. * Free any resources and references associated to a mesh.
  147069. * Internal use
  147070. * @param mesh The mesh to free.
  147071. */
  147072. abstract _disposeMesh(mesh: Mesh): void;
  147073. /**
  147074. * Serializes this layer (Glow or Highlight for example)
  147075. * @returns a serialized layer object
  147076. */
  147077. abstract serialize?(): any;
  147078. /**
  147079. * Initializes the effect layer with the required options.
  147080. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  147081. */
  147082. protected _init(options: Partial<IEffectLayerOptions>): void;
  147083. /**
  147084. * Generates the index buffer of the full screen quad blending to the main canvas.
  147085. */
  147086. private _generateIndexBuffer;
  147087. /**
  147088. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  147089. */
  147090. private _generateVertexBuffer;
  147091. /**
  147092. * Sets the main texture desired size which is the closest power of two
  147093. * of the engine canvas size.
  147094. */
  147095. private _setMainTextureSize;
  147096. /**
  147097. * Creates the main texture for the effect layer.
  147098. */
  147099. protected _createMainTexture(): void;
  147100. /**
  147101. * Adds specific effects defines.
  147102. * @param defines The defines to add specifics to.
  147103. */
  147104. protected _addCustomEffectDefines(defines: string[]): void;
  147105. /**
  147106. * Checks for the readiness of the element composing the layer.
  147107. * @param subMesh the mesh to check for
  147108. * @param useInstances specify whether or not to use instances to render the mesh
  147109. * @param emissiveTexture the associated emissive texture used to generate the glow
  147110. * @return true if ready otherwise, false
  147111. */
  147112. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  147113. /**
  147114. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  147115. */
  147116. render(): void;
  147117. /**
  147118. * Determine if a given mesh will be used in the current effect.
  147119. * @param mesh mesh to test
  147120. * @returns true if the mesh will be used
  147121. */
  147122. hasMesh(mesh: AbstractMesh): boolean;
  147123. /**
  147124. * Returns true if the layer contains information to display, otherwise false.
  147125. * @returns true if the glow layer should be rendered
  147126. */
  147127. shouldRender(): boolean;
  147128. /**
  147129. * Returns true if the mesh should render, otherwise false.
  147130. * @param mesh The mesh to render
  147131. * @returns true if it should render otherwise false
  147132. */
  147133. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  147134. /**
  147135. * Returns true if the mesh can be rendered, otherwise false.
  147136. * @param mesh The mesh to render
  147137. * @param material The material used on the mesh
  147138. * @returns true if it can be rendered otherwise false
  147139. */
  147140. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  147141. /**
  147142. * Returns true if the mesh should render, otherwise false.
  147143. * @param mesh The mesh to render
  147144. * @returns true if it should render otherwise false
  147145. */
  147146. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  147147. /**
  147148. * Renders the submesh passed in parameter to the generation map.
  147149. */
  147150. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  147151. /**
  147152. * Defines whether the current material of the mesh should be use to render the effect.
  147153. * @param mesh defines the current mesh to render
  147154. */
  147155. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  147156. /**
  147157. * Rebuild the required buffers.
  147158. * @hidden Internal use only.
  147159. */
  147160. _rebuild(): void;
  147161. /**
  147162. * Dispose only the render target textures and post process.
  147163. */
  147164. private _disposeTextureAndPostProcesses;
  147165. /**
  147166. * Dispose the highlight layer and free resources.
  147167. */
  147168. dispose(): void;
  147169. /**
  147170. * Gets the class name of the effect layer
  147171. * @returns the string with the class name of the effect layer
  147172. */
  147173. getClassName(): string;
  147174. /**
  147175. * Creates an effect layer from parsed effect layer data
  147176. * @param parsedEffectLayer defines effect layer data
  147177. * @param scene defines the current scene
  147178. * @param rootUrl defines the root URL containing the effect layer information
  147179. * @returns a parsed effect Layer
  147180. */
  147181. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  147182. }
  147183. }
  147184. declare module BABYLON {
  147185. interface AbstractScene {
  147186. /**
  147187. * The list of effect layers (highlights/glow) added to the scene
  147188. * @see https://doc.babylonjs.com/how_to/highlight_layer
  147189. * @see https://doc.babylonjs.com/how_to/glow_layer
  147190. */
  147191. effectLayers: Array<EffectLayer>;
  147192. /**
  147193. * Removes the given effect layer from this scene.
  147194. * @param toRemove defines the effect layer to remove
  147195. * @returns the index of the removed effect layer
  147196. */
  147197. removeEffectLayer(toRemove: EffectLayer): number;
  147198. /**
  147199. * Adds the given effect layer to this scene
  147200. * @param newEffectLayer defines the effect layer to add
  147201. */
  147202. addEffectLayer(newEffectLayer: EffectLayer): void;
  147203. }
  147204. /**
  147205. * Defines the layer scene component responsible to manage any effect layers
  147206. * in a given scene.
  147207. */
  147208. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  147209. /**
  147210. * The component name helpfull to identify the component in the list of scene components.
  147211. */
  147212. readonly name: string;
  147213. /**
  147214. * The scene the component belongs to.
  147215. */
  147216. scene: Scene;
  147217. private _engine;
  147218. private _renderEffects;
  147219. private _needStencil;
  147220. private _previousStencilState;
  147221. /**
  147222. * Creates a new instance of the component for the given scene
  147223. * @param scene Defines the scene to register the component in
  147224. */
  147225. constructor(scene: Scene);
  147226. /**
  147227. * Registers the component in a given scene
  147228. */
  147229. register(): void;
  147230. /**
  147231. * Rebuilds the elements related to this component in case of
  147232. * context lost for instance.
  147233. */
  147234. rebuild(): void;
  147235. /**
  147236. * Serializes the component data to the specified json object
  147237. * @param serializationObject The object to serialize to
  147238. */
  147239. serialize(serializationObject: any): void;
  147240. /**
  147241. * Adds all the elements from the container to the scene
  147242. * @param container the container holding the elements
  147243. */
  147244. addFromContainer(container: AbstractScene): void;
  147245. /**
  147246. * Removes all the elements in the container from the scene
  147247. * @param container contains the elements to remove
  147248. * @param dispose if the removed element should be disposed (default: false)
  147249. */
  147250. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  147251. /**
  147252. * Disposes the component and the associated ressources.
  147253. */
  147254. dispose(): void;
  147255. private _isReadyForMesh;
  147256. private _renderMainTexture;
  147257. private _setStencil;
  147258. private _setStencilBack;
  147259. private _draw;
  147260. private _drawCamera;
  147261. private _drawRenderingGroup;
  147262. }
  147263. }
  147264. declare module BABYLON {
  147265. /** @hidden */
  147266. export var glowMapMergePixelShader: {
  147267. name: string;
  147268. shader: string;
  147269. };
  147270. }
  147271. declare module BABYLON {
  147272. /** @hidden */
  147273. export var glowMapMergeVertexShader: {
  147274. name: string;
  147275. shader: string;
  147276. };
  147277. }
  147278. declare module BABYLON {
  147279. interface AbstractScene {
  147280. /**
  147281. * Return a the first highlight layer of the scene with a given name.
  147282. * @param name The name of the highlight layer to look for.
  147283. * @return The highlight layer if found otherwise null.
  147284. */
  147285. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  147286. }
  147287. /**
  147288. * Glow layer options. This helps customizing the behaviour
  147289. * of the glow layer.
  147290. */
  147291. export interface IGlowLayerOptions {
  147292. /**
  147293. * Multiplication factor apply to the canvas size to compute the render target size
  147294. * used to generated the glowing objects (the smaller the faster).
  147295. */
  147296. mainTextureRatio: number;
  147297. /**
  147298. * Enforces a fixed size texture to ensure resize independant blur.
  147299. */
  147300. mainTextureFixedSize?: number;
  147301. /**
  147302. * How big is the kernel of the blur texture.
  147303. */
  147304. blurKernelSize: number;
  147305. /**
  147306. * The camera attached to the layer.
  147307. */
  147308. camera: Nullable<Camera>;
  147309. /**
  147310. * Enable MSAA by chosing the number of samples.
  147311. */
  147312. mainTextureSamples?: number;
  147313. /**
  147314. * The rendering group to draw the layer in.
  147315. */
  147316. renderingGroupId: number;
  147317. }
  147318. /**
  147319. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  147320. *
  147321. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  147322. *
  147323. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  147324. */
  147325. export class GlowLayer extends EffectLayer {
  147326. /**
  147327. * Effect Name of the layer.
  147328. */
  147329. static readonly EffectName: string;
  147330. /**
  147331. * The default blur kernel size used for the glow.
  147332. */
  147333. static DefaultBlurKernelSize: number;
  147334. /**
  147335. * The default texture size ratio used for the glow.
  147336. */
  147337. static DefaultTextureRatio: number;
  147338. /**
  147339. * Sets the kernel size of the blur.
  147340. */
  147341. set blurKernelSize(value: number);
  147342. /**
  147343. * Gets the kernel size of the blur.
  147344. */
  147345. get blurKernelSize(): number;
  147346. /**
  147347. * Sets the glow intensity.
  147348. */
  147349. set intensity(value: number);
  147350. /**
  147351. * Gets the glow intensity.
  147352. */
  147353. get intensity(): number;
  147354. private _options;
  147355. private _intensity;
  147356. private _horizontalBlurPostprocess1;
  147357. private _verticalBlurPostprocess1;
  147358. private _horizontalBlurPostprocess2;
  147359. private _verticalBlurPostprocess2;
  147360. private _blurTexture1;
  147361. private _blurTexture2;
  147362. private _postProcesses1;
  147363. private _postProcesses2;
  147364. private _includedOnlyMeshes;
  147365. private _excludedMeshes;
  147366. private _meshesUsingTheirOwnMaterials;
  147367. /**
  147368. * Callback used to let the user override the color selection on a per mesh basis
  147369. */
  147370. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  147371. /**
  147372. * Callback used to let the user override the texture selection on a per mesh basis
  147373. */
  147374. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  147375. /**
  147376. * Instantiates a new glow Layer and references it to the scene.
  147377. * @param name The name of the layer
  147378. * @param scene The scene to use the layer in
  147379. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  147380. */
  147381. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  147382. /**
  147383. * Get the effect name of the layer.
  147384. * @return The effect name
  147385. */
  147386. getEffectName(): string;
  147387. /**
  147388. * Create the merge effect. This is the shader use to blit the information back
  147389. * to the main canvas at the end of the scene rendering.
  147390. */
  147391. protected _createMergeEffect(): Effect;
  147392. /**
  147393. * Creates the render target textures and post processes used in the glow layer.
  147394. */
  147395. protected _createTextureAndPostProcesses(): void;
  147396. /**
  147397. * Checks for the readiness of the element composing the layer.
  147398. * @param subMesh the mesh to check for
  147399. * @param useInstances specify wether or not to use instances to render the mesh
  147400. * @param emissiveTexture the associated emissive texture used to generate the glow
  147401. * @return true if ready otherwise, false
  147402. */
  147403. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  147404. /**
  147405. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  147406. */
  147407. needStencil(): boolean;
  147408. /**
  147409. * Returns true if the mesh can be rendered, otherwise false.
  147410. * @param mesh The mesh to render
  147411. * @param material The material used on the mesh
  147412. * @returns true if it can be rendered otherwise false
  147413. */
  147414. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  147415. /**
  147416. * Implementation specific of rendering the generating effect on the main canvas.
  147417. * @param effect The effect used to render through
  147418. */
  147419. protected _internalRender(effect: Effect): void;
  147420. /**
  147421. * Sets the required values for both the emissive texture and and the main color.
  147422. */
  147423. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  147424. /**
  147425. * Returns true if the mesh should render, otherwise false.
  147426. * @param mesh The mesh to render
  147427. * @returns true if it should render otherwise false
  147428. */
  147429. protected _shouldRenderMesh(mesh: Mesh): boolean;
  147430. /**
  147431. * Adds specific effects defines.
  147432. * @param defines The defines to add specifics to.
  147433. */
  147434. protected _addCustomEffectDefines(defines: string[]): void;
  147435. /**
  147436. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  147437. * @param mesh The mesh to exclude from the glow layer
  147438. */
  147439. addExcludedMesh(mesh: Mesh): void;
  147440. /**
  147441. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  147442. * @param mesh The mesh to remove
  147443. */
  147444. removeExcludedMesh(mesh: Mesh): void;
  147445. /**
  147446. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  147447. * @param mesh The mesh to include in the glow layer
  147448. */
  147449. addIncludedOnlyMesh(mesh: Mesh): void;
  147450. /**
  147451. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  147452. * @param mesh The mesh to remove
  147453. */
  147454. removeIncludedOnlyMesh(mesh: Mesh): void;
  147455. /**
  147456. * Determine if a given mesh will be used in the glow layer
  147457. * @param mesh The mesh to test
  147458. * @returns true if the mesh will be highlighted by the current glow layer
  147459. */
  147460. hasMesh(mesh: AbstractMesh): boolean;
  147461. /**
  147462. * Defines whether the current material of the mesh should be use to render the effect.
  147463. * @param mesh defines the current mesh to render
  147464. */
  147465. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  147466. /**
  147467. * Add a mesh to be rendered through its own material and not with emissive only.
  147468. * @param mesh The mesh for which we need to use its material
  147469. */
  147470. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  147471. /**
  147472. * Remove a mesh from being rendered through its own material and not with emissive only.
  147473. * @param mesh The mesh for which we need to not use its material
  147474. */
  147475. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  147476. /**
  147477. * Free any resources and references associated to a mesh.
  147478. * Internal use
  147479. * @param mesh The mesh to free.
  147480. * @hidden
  147481. */
  147482. _disposeMesh(mesh: Mesh): void;
  147483. /**
  147484. * Gets the class name of the effect layer
  147485. * @returns the string with the class name of the effect layer
  147486. */
  147487. getClassName(): string;
  147488. /**
  147489. * Serializes this glow layer
  147490. * @returns a serialized glow layer object
  147491. */
  147492. serialize(): any;
  147493. /**
  147494. * Creates a Glow Layer from parsed glow layer data
  147495. * @param parsedGlowLayer defines glow layer data
  147496. * @param scene defines the current scene
  147497. * @param rootUrl defines the root URL containing the glow layer information
  147498. * @returns a parsed Glow Layer
  147499. */
  147500. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  147501. }
  147502. }
  147503. declare module BABYLON {
  147504. /** @hidden */
  147505. export var glowBlurPostProcessPixelShader: {
  147506. name: string;
  147507. shader: string;
  147508. };
  147509. }
  147510. declare module BABYLON {
  147511. interface AbstractScene {
  147512. /**
  147513. * Return a the first highlight layer of the scene with a given name.
  147514. * @param name The name of the highlight layer to look for.
  147515. * @return The highlight layer if found otherwise null.
  147516. */
  147517. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  147518. }
  147519. /**
  147520. * Highlight layer options. This helps customizing the behaviour
  147521. * of the highlight layer.
  147522. */
  147523. export interface IHighlightLayerOptions {
  147524. /**
  147525. * Multiplication factor apply to the canvas size to compute the render target size
  147526. * used to generated the glowing objects (the smaller the faster).
  147527. */
  147528. mainTextureRatio: number;
  147529. /**
  147530. * Enforces a fixed size texture to ensure resize independant blur.
  147531. */
  147532. mainTextureFixedSize?: number;
  147533. /**
  147534. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  147535. * of the picture to blur (the smaller the faster).
  147536. */
  147537. blurTextureSizeRatio: number;
  147538. /**
  147539. * How big in texel of the blur texture is the vertical blur.
  147540. */
  147541. blurVerticalSize: number;
  147542. /**
  147543. * How big in texel of the blur texture is the horizontal blur.
  147544. */
  147545. blurHorizontalSize: number;
  147546. /**
  147547. * Alpha blending mode used to apply the blur. Default is combine.
  147548. */
  147549. alphaBlendingMode: number;
  147550. /**
  147551. * The camera attached to the layer.
  147552. */
  147553. camera: Nullable<Camera>;
  147554. /**
  147555. * Should we display highlight as a solid stroke?
  147556. */
  147557. isStroke?: boolean;
  147558. /**
  147559. * The rendering group to draw the layer in.
  147560. */
  147561. renderingGroupId: number;
  147562. }
  147563. /**
  147564. * The highlight layer Helps adding a glow effect around a mesh.
  147565. *
  147566. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  147567. * glowy meshes to your scene.
  147568. *
  147569. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  147570. */
  147571. export class HighlightLayer extends EffectLayer {
  147572. name: string;
  147573. /**
  147574. * Effect Name of the highlight layer.
  147575. */
  147576. static readonly EffectName: string;
  147577. /**
  147578. * The neutral color used during the preparation of the glow effect.
  147579. * This is black by default as the blend operation is a blend operation.
  147580. */
  147581. static NeutralColor: Color4;
  147582. /**
  147583. * Stencil value used for glowing meshes.
  147584. */
  147585. static GlowingMeshStencilReference: number;
  147586. /**
  147587. * Stencil value used for the other meshes in the scene.
  147588. */
  147589. static NormalMeshStencilReference: number;
  147590. /**
  147591. * Specifies whether or not the inner glow is ACTIVE in the layer.
  147592. */
  147593. innerGlow: boolean;
  147594. /**
  147595. * Specifies whether or not the outer glow is ACTIVE in the layer.
  147596. */
  147597. outerGlow: boolean;
  147598. /**
  147599. * Specifies the horizontal size of the blur.
  147600. */
  147601. set blurHorizontalSize(value: number);
  147602. /**
  147603. * Specifies the vertical size of the blur.
  147604. */
  147605. set blurVerticalSize(value: number);
  147606. /**
  147607. * Gets the horizontal size of the blur.
  147608. */
  147609. get blurHorizontalSize(): number;
  147610. /**
  147611. * Gets the vertical size of the blur.
  147612. */
  147613. get blurVerticalSize(): number;
  147614. /**
  147615. * An event triggered when the highlight layer is being blurred.
  147616. */
  147617. onBeforeBlurObservable: Observable<HighlightLayer>;
  147618. /**
  147619. * An event triggered when the highlight layer has been blurred.
  147620. */
  147621. onAfterBlurObservable: Observable<HighlightLayer>;
  147622. private _instanceGlowingMeshStencilReference;
  147623. private _options;
  147624. private _downSamplePostprocess;
  147625. private _horizontalBlurPostprocess;
  147626. private _verticalBlurPostprocess;
  147627. private _blurTexture;
  147628. private _meshes;
  147629. private _excludedMeshes;
  147630. /**
  147631. * Instantiates a new highlight Layer and references it to the scene..
  147632. * @param name The name of the layer
  147633. * @param scene The scene to use the layer in
  147634. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  147635. */
  147636. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  147637. /**
  147638. * Get the effect name of the layer.
  147639. * @return The effect name
  147640. */
  147641. getEffectName(): string;
  147642. /**
  147643. * Create the merge effect. This is the shader use to blit the information back
  147644. * to the main canvas at the end of the scene rendering.
  147645. */
  147646. protected _createMergeEffect(): Effect;
  147647. /**
  147648. * Creates the render target textures and post processes used in the highlight layer.
  147649. */
  147650. protected _createTextureAndPostProcesses(): void;
  147651. /**
  147652. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  147653. */
  147654. needStencil(): boolean;
  147655. /**
  147656. * Checks for the readiness of the element composing the layer.
  147657. * @param subMesh the mesh to check for
  147658. * @param useInstances specify wether or not to use instances to render the mesh
  147659. * @param emissiveTexture the associated emissive texture used to generate the glow
  147660. * @return true if ready otherwise, false
  147661. */
  147662. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  147663. /**
  147664. * Implementation specific of rendering the generating effect on the main canvas.
  147665. * @param effect The effect used to render through
  147666. */
  147667. protected _internalRender(effect: Effect): void;
  147668. /**
  147669. * Returns true if the layer contains information to display, otherwise false.
  147670. */
  147671. shouldRender(): boolean;
  147672. /**
  147673. * Returns true if the mesh should render, otherwise false.
  147674. * @param mesh The mesh to render
  147675. * @returns true if it should render otherwise false
  147676. */
  147677. protected _shouldRenderMesh(mesh: Mesh): boolean;
  147678. /**
  147679. * Returns true if the mesh can be rendered, otherwise false.
  147680. * @param mesh The mesh to render
  147681. * @param material The material used on the mesh
  147682. * @returns true if it can be rendered otherwise false
  147683. */
  147684. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  147685. /**
  147686. * Adds specific effects defines.
  147687. * @param defines The defines to add specifics to.
  147688. */
  147689. protected _addCustomEffectDefines(defines: string[]): void;
  147690. /**
  147691. * Sets the required values for both the emissive texture and and the main color.
  147692. */
  147693. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  147694. /**
  147695. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  147696. * @param mesh The mesh to exclude from the highlight layer
  147697. */
  147698. addExcludedMesh(mesh: Mesh): void;
  147699. /**
  147700. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  147701. * @param mesh The mesh to highlight
  147702. */
  147703. removeExcludedMesh(mesh: Mesh): void;
  147704. /**
  147705. * Determine if a given mesh will be highlighted by the current HighlightLayer
  147706. * @param mesh mesh to test
  147707. * @returns true if the mesh will be highlighted by the current HighlightLayer
  147708. */
  147709. hasMesh(mesh: AbstractMesh): boolean;
  147710. /**
  147711. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  147712. * @param mesh The mesh to highlight
  147713. * @param color The color of the highlight
  147714. * @param glowEmissiveOnly Extract the glow from the emissive texture
  147715. */
  147716. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  147717. /**
  147718. * Remove a mesh from the highlight layer in order to make it stop glowing.
  147719. * @param mesh The mesh to highlight
  147720. */
  147721. removeMesh(mesh: Mesh): void;
  147722. /**
  147723. * Remove all the meshes currently referenced in the highlight layer
  147724. */
  147725. removeAllMeshes(): void;
  147726. /**
  147727. * Force the stencil to the normal expected value for none glowing parts
  147728. */
  147729. private _defaultStencilReference;
  147730. /**
  147731. * Free any resources and references associated to a mesh.
  147732. * Internal use
  147733. * @param mesh The mesh to free.
  147734. * @hidden
  147735. */
  147736. _disposeMesh(mesh: Mesh): void;
  147737. /**
  147738. * Dispose the highlight layer and free resources.
  147739. */
  147740. dispose(): void;
  147741. /**
  147742. * Gets the class name of the effect layer
  147743. * @returns the string with the class name of the effect layer
  147744. */
  147745. getClassName(): string;
  147746. /**
  147747. * Serializes this Highlight layer
  147748. * @returns a serialized Highlight layer object
  147749. */
  147750. serialize(): any;
  147751. /**
  147752. * Creates a Highlight layer from parsed Highlight layer data
  147753. * @param parsedHightlightLayer defines the Highlight layer data
  147754. * @param scene defines the current scene
  147755. * @param rootUrl defines the root URL containing the Highlight layer information
  147756. * @returns a parsed Highlight layer
  147757. */
  147758. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  147759. }
  147760. }
  147761. declare module BABYLON {
  147762. interface AbstractScene {
  147763. /**
  147764. * The list of layers (background and foreground) of the scene
  147765. */
  147766. layers: Array<Layer>;
  147767. }
  147768. /**
  147769. * Defines the layer scene component responsible to manage any layers
  147770. * in a given scene.
  147771. */
  147772. export class LayerSceneComponent implements ISceneComponent {
  147773. /**
  147774. * The component name helpfull to identify the component in the list of scene components.
  147775. */
  147776. readonly name: string;
  147777. /**
  147778. * The scene the component belongs to.
  147779. */
  147780. scene: Scene;
  147781. private _engine;
  147782. /**
  147783. * Creates a new instance of the component for the given scene
  147784. * @param scene Defines the scene to register the component in
  147785. */
  147786. constructor(scene: Scene);
  147787. /**
  147788. * Registers the component in a given scene
  147789. */
  147790. register(): void;
  147791. /**
  147792. * Rebuilds the elements related to this component in case of
  147793. * context lost for instance.
  147794. */
  147795. rebuild(): void;
  147796. /**
  147797. * Disposes the component and the associated ressources.
  147798. */
  147799. dispose(): void;
  147800. private _draw;
  147801. private _drawCameraPredicate;
  147802. private _drawCameraBackground;
  147803. private _drawCameraForeground;
  147804. private _drawRenderTargetPredicate;
  147805. private _drawRenderTargetBackground;
  147806. private _drawRenderTargetForeground;
  147807. /**
  147808. * Adds all the elements from the container to the scene
  147809. * @param container the container holding the elements
  147810. */
  147811. addFromContainer(container: AbstractScene): void;
  147812. /**
  147813. * Removes all the elements in the container from the scene
  147814. * @param container contains the elements to remove
  147815. * @param dispose if the removed element should be disposed (default: false)
  147816. */
  147817. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  147818. }
  147819. }
  147820. declare module BABYLON {
  147821. /** @hidden */
  147822. export var layerPixelShader: {
  147823. name: string;
  147824. shader: string;
  147825. };
  147826. }
  147827. declare module BABYLON {
  147828. /** @hidden */
  147829. export var layerVertexShader: {
  147830. name: string;
  147831. shader: string;
  147832. };
  147833. }
  147834. declare module BABYLON {
  147835. /**
  147836. * This represents a full screen 2d layer.
  147837. * This can be useful to display a picture in the background of your scene for instance.
  147838. * @see https://www.babylonjs-playground.com/#08A2BS#1
  147839. */
  147840. export class Layer {
  147841. /**
  147842. * Define the name of the layer.
  147843. */
  147844. name: string;
  147845. /**
  147846. * Define the texture the layer should display.
  147847. */
  147848. texture: Nullable<Texture>;
  147849. /**
  147850. * Is the layer in background or foreground.
  147851. */
  147852. isBackground: boolean;
  147853. /**
  147854. * Define the color of the layer (instead of texture).
  147855. */
  147856. color: Color4;
  147857. /**
  147858. * Define the scale of the layer in order to zoom in out of the texture.
  147859. */
  147860. scale: Vector2;
  147861. /**
  147862. * Define an offset for the layer in order to shift the texture.
  147863. */
  147864. offset: Vector2;
  147865. /**
  147866. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  147867. */
  147868. alphaBlendingMode: number;
  147869. /**
  147870. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  147871. * Alpha test will not mix with the background color in case of transparency.
  147872. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  147873. */
  147874. alphaTest: boolean;
  147875. /**
  147876. * Define a mask to restrict the layer to only some of the scene cameras.
  147877. */
  147878. layerMask: number;
  147879. /**
  147880. * Define the list of render target the layer is visible into.
  147881. */
  147882. renderTargetTextures: RenderTargetTexture[];
  147883. /**
  147884. * Define if the layer is only used in renderTarget or if it also
  147885. * renders in the main frame buffer of the canvas.
  147886. */
  147887. renderOnlyInRenderTargetTextures: boolean;
  147888. private _scene;
  147889. private _vertexBuffers;
  147890. private _indexBuffer;
  147891. private _effect;
  147892. private _previousDefines;
  147893. /**
  147894. * An event triggered when the layer is disposed.
  147895. */
  147896. onDisposeObservable: Observable<Layer>;
  147897. private _onDisposeObserver;
  147898. /**
  147899. * Back compatibility with callback before the onDisposeObservable existed.
  147900. * The set callback will be triggered when the layer has been disposed.
  147901. */
  147902. set onDispose(callback: () => void);
  147903. /**
  147904. * An event triggered before rendering the scene
  147905. */
  147906. onBeforeRenderObservable: Observable<Layer>;
  147907. private _onBeforeRenderObserver;
  147908. /**
  147909. * Back compatibility with callback before the onBeforeRenderObservable existed.
  147910. * The set callback will be triggered just before rendering the layer.
  147911. */
  147912. set onBeforeRender(callback: () => void);
  147913. /**
  147914. * An event triggered after rendering the scene
  147915. */
  147916. onAfterRenderObservable: Observable<Layer>;
  147917. private _onAfterRenderObserver;
  147918. /**
  147919. * Back compatibility with callback before the onAfterRenderObservable existed.
  147920. * The set callback will be triggered just after rendering the layer.
  147921. */
  147922. set onAfterRender(callback: () => void);
  147923. /**
  147924. * Instantiates a new layer.
  147925. * This represents a full screen 2d layer.
  147926. * This can be useful to display a picture in the background of your scene for instance.
  147927. * @see https://www.babylonjs-playground.com/#08A2BS#1
  147928. * @param name Define the name of the layer in the scene
  147929. * @param imgUrl Define the url of the texture to display in the layer
  147930. * @param scene Define the scene the layer belongs to
  147931. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  147932. * @param color Defines a color for the layer
  147933. */
  147934. constructor(
  147935. /**
  147936. * Define the name of the layer.
  147937. */
  147938. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  147939. private _createIndexBuffer;
  147940. /** @hidden */
  147941. _rebuild(): void;
  147942. /**
  147943. * Renders the layer in the scene.
  147944. */
  147945. render(): void;
  147946. /**
  147947. * Disposes and releases the associated ressources.
  147948. */
  147949. dispose(): void;
  147950. }
  147951. }
  147952. declare module BABYLON {
  147953. /** @hidden */
  147954. export var lensFlarePixelShader: {
  147955. name: string;
  147956. shader: string;
  147957. };
  147958. }
  147959. declare module BABYLON {
  147960. /** @hidden */
  147961. export var lensFlareVertexShader: {
  147962. name: string;
  147963. shader: string;
  147964. };
  147965. }
  147966. declare module BABYLON {
  147967. /**
  147968. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  147969. * It is usually composed of several `lensFlare`.
  147970. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  147971. */
  147972. export class LensFlareSystem {
  147973. /**
  147974. * Define the name of the lens flare system
  147975. */
  147976. name: string;
  147977. /**
  147978. * List of lens flares used in this system.
  147979. */
  147980. lensFlares: LensFlare[];
  147981. /**
  147982. * Define a limit from the border the lens flare can be visible.
  147983. */
  147984. borderLimit: number;
  147985. /**
  147986. * Define a viewport border we do not want to see the lens flare in.
  147987. */
  147988. viewportBorder: number;
  147989. /**
  147990. * Define a predicate which could limit the list of meshes able to occlude the effect.
  147991. */
  147992. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  147993. /**
  147994. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  147995. */
  147996. layerMask: number;
  147997. /**
  147998. * Define the id of the lens flare system in the scene.
  147999. * (equal to name by default)
  148000. */
  148001. id: string;
  148002. private _scene;
  148003. private _emitter;
  148004. private _vertexBuffers;
  148005. private _indexBuffer;
  148006. private _effect;
  148007. private _positionX;
  148008. private _positionY;
  148009. private _isEnabled;
  148010. /** @hidden */
  148011. static _SceneComponentInitialization: (scene: Scene) => void;
  148012. /**
  148013. * Instantiates a lens flare system.
  148014. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  148015. * It is usually composed of several `lensFlare`.
  148016. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  148017. * @param name Define the name of the lens flare system in the scene
  148018. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  148019. * @param scene Define the scene the lens flare system belongs to
  148020. */
  148021. constructor(
  148022. /**
  148023. * Define the name of the lens flare system
  148024. */
  148025. name: string, emitter: any, scene: Scene);
  148026. /**
  148027. * Define if the lens flare system is enabled.
  148028. */
  148029. get isEnabled(): boolean;
  148030. set isEnabled(value: boolean);
  148031. /**
  148032. * Get the scene the effects belongs to.
  148033. * @returns the scene holding the lens flare system
  148034. */
  148035. getScene(): Scene;
  148036. /**
  148037. * Get the emitter of the lens flare system.
  148038. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  148039. * @returns the emitter of the lens flare system
  148040. */
  148041. getEmitter(): any;
  148042. /**
  148043. * Set the emitter of the lens flare system.
  148044. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  148045. * @param newEmitter Define the new emitter of the system
  148046. */
  148047. setEmitter(newEmitter: any): void;
  148048. /**
  148049. * Get the lens flare system emitter position.
  148050. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  148051. * @returns the position
  148052. */
  148053. getEmitterPosition(): Vector3;
  148054. /**
  148055. * @hidden
  148056. */
  148057. computeEffectivePosition(globalViewport: Viewport): boolean;
  148058. /** @hidden */
  148059. _isVisible(): boolean;
  148060. /**
  148061. * @hidden
  148062. */
  148063. render(): boolean;
  148064. /**
  148065. * Dispose and release the lens flare with its associated resources.
  148066. */
  148067. dispose(): void;
  148068. /**
  148069. * Parse a lens flare system from a JSON repressentation
  148070. * @param parsedLensFlareSystem Define the JSON to parse
  148071. * @param scene Define the scene the parsed system should be instantiated in
  148072. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  148073. * @returns the parsed system
  148074. */
  148075. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  148076. /**
  148077. * Serialize the current Lens Flare System into a JSON representation.
  148078. * @returns the serialized JSON
  148079. */
  148080. serialize(): any;
  148081. }
  148082. }
  148083. declare module BABYLON {
  148084. /**
  148085. * This represents one of the lens effect in a `lensFlareSystem`.
  148086. * It controls one of the indiviual texture used in the effect.
  148087. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  148088. */
  148089. export class LensFlare {
  148090. /**
  148091. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  148092. */
  148093. size: number;
  148094. /**
  148095. * 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.
  148096. */
  148097. position: number;
  148098. /**
  148099. * Define the lens color.
  148100. */
  148101. color: Color3;
  148102. /**
  148103. * Define the lens texture.
  148104. */
  148105. texture: Nullable<Texture>;
  148106. /**
  148107. * Define the alpha mode to render this particular lens.
  148108. */
  148109. alphaMode: number;
  148110. private _system;
  148111. /**
  148112. * Creates a new Lens Flare.
  148113. * This represents one of the lens effect in a `lensFlareSystem`.
  148114. * It controls one of the indiviual texture used in the effect.
  148115. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  148116. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  148117. * @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.
  148118. * @param color Define the lens color
  148119. * @param imgUrl Define the lens texture url
  148120. * @param system Define the `lensFlareSystem` this flare is part of
  148121. * @returns The newly created Lens Flare
  148122. */
  148123. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  148124. /**
  148125. * Instantiates a new Lens Flare.
  148126. * This represents one of the lens effect in a `lensFlareSystem`.
  148127. * It controls one of the indiviual texture used in the effect.
  148128. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  148129. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  148130. * @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.
  148131. * @param color Define the lens color
  148132. * @param imgUrl Define the lens texture url
  148133. * @param system Define the `lensFlareSystem` this flare is part of
  148134. */
  148135. constructor(
  148136. /**
  148137. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  148138. */
  148139. size: number,
  148140. /**
  148141. * 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.
  148142. */
  148143. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  148144. /**
  148145. * Dispose and release the lens flare with its associated resources.
  148146. */
  148147. dispose(): void;
  148148. }
  148149. }
  148150. declare module BABYLON {
  148151. interface AbstractScene {
  148152. /**
  148153. * The list of lens flare system added to the scene
  148154. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  148155. */
  148156. lensFlareSystems: Array<LensFlareSystem>;
  148157. /**
  148158. * Removes the given lens flare system from this scene.
  148159. * @param toRemove The lens flare system to remove
  148160. * @returns The index of the removed lens flare system
  148161. */
  148162. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  148163. /**
  148164. * Adds the given lens flare system to this scene
  148165. * @param newLensFlareSystem The lens flare system to add
  148166. */
  148167. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  148168. /**
  148169. * Gets a lens flare system using its name
  148170. * @param name defines the name to look for
  148171. * @returns the lens flare system or null if not found
  148172. */
  148173. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  148174. /**
  148175. * Gets a lens flare system using its id
  148176. * @param id defines the id to look for
  148177. * @returns the lens flare system or null if not found
  148178. */
  148179. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  148180. }
  148181. /**
  148182. * Defines the lens flare scene component responsible to manage any lens flares
  148183. * in a given scene.
  148184. */
  148185. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  148186. /**
  148187. * The component name helpfull to identify the component in the list of scene components.
  148188. */
  148189. readonly name: string;
  148190. /**
  148191. * The scene the component belongs to.
  148192. */
  148193. scene: Scene;
  148194. /**
  148195. * Creates a new instance of the component for the given scene
  148196. * @param scene Defines the scene to register the component in
  148197. */
  148198. constructor(scene: Scene);
  148199. /**
  148200. * Registers the component in a given scene
  148201. */
  148202. register(): void;
  148203. /**
  148204. * Rebuilds the elements related to this component in case of
  148205. * context lost for instance.
  148206. */
  148207. rebuild(): void;
  148208. /**
  148209. * Adds all the elements from the container to the scene
  148210. * @param container the container holding the elements
  148211. */
  148212. addFromContainer(container: AbstractScene): void;
  148213. /**
  148214. * Removes all the elements in the container from the scene
  148215. * @param container contains the elements to remove
  148216. * @param dispose if the removed element should be disposed (default: false)
  148217. */
  148218. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  148219. /**
  148220. * Serializes the component data to the specified json object
  148221. * @param serializationObject The object to serialize to
  148222. */
  148223. serialize(serializationObject: any): void;
  148224. /**
  148225. * Disposes the component and the associated ressources.
  148226. */
  148227. dispose(): void;
  148228. private _draw;
  148229. }
  148230. }
  148231. declare module BABYLON {
  148232. /** @hidden */
  148233. export var depthPixelShader: {
  148234. name: string;
  148235. shader: string;
  148236. };
  148237. }
  148238. declare module BABYLON {
  148239. /** @hidden */
  148240. export var depthVertexShader: {
  148241. name: string;
  148242. shader: string;
  148243. };
  148244. }
  148245. declare module BABYLON {
  148246. /**
  148247. * This represents a depth renderer in Babylon.
  148248. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  148249. */
  148250. export class DepthRenderer {
  148251. private _scene;
  148252. private _depthMap;
  148253. private _effect;
  148254. private readonly _storeNonLinearDepth;
  148255. private readonly _clearColor;
  148256. /** Get if the depth renderer is using packed depth or not */
  148257. readonly isPacked: boolean;
  148258. private _cachedDefines;
  148259. private _camera;
  148260. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  148261. enabled: boolean;
  148262. /**
  148263. * Specifiess that the depth renderer will only be used within
  148264. * the camera it is created for.
  148265. * This can help forcing its rendering during the camera processing.
  148266. */
  148267. useOnlyInActiveCamera: boolean;
  148268. /** @hidden */
  148269. static _SceneComponentInitialization: (scene: Scene) => void;
  148270. /**
  148271. * Instantiates a depth renderer
  148272. * @param scene The scene the renderer belongs to
  148273. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  148274. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  148275. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  148276. */
  148277. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  148278. /**
  148279. * Creates the depth rendering effect and checks if the effect is ready.
  148280. * @param subMesh The submesh to be used to render the depth map of
  148281. * @param useInstances If multiple world instances should be used
  148282. * @returns if the depth renderer is ready to render the depth map
  148283. */
  148284. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  148285. /**
  148286. * Gets the texture which the depth map will be written to.
  148287. * @returns The depth map texture
  148288. */
  148289. getDepthMap(): RenderTargetTexture;
  148290. /**
  148291. * Disposes of the depth renderer.
  148292. */
  148293. dispose(): void;
  148294. }
  148295. }
  148296. declare module BABYLON {
  148297. /** @hidden */
  148298. export var minmaxReduxPixelShader: {
  148299. name: string;
  148300. shader: string;
  148301. };
  148302. }
  148303. declare module BABYLON {
  148304. /**
  148305. * This class computes a min/max reduction from a texture: it means it computes the minimum
  148306. * and maximum values from all values of the texture.
  148307. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  148308. * The source values are read from the red channel of the texture.
  148309. */
  148310. export class MinMaxReducer {
  148311. /**
  148312. * Observable triggered when the computation has been performed
  148313. */
  148314. onAfterReductionPerformed: Observable<{
  148315. min: number;
  148316. max: number;
  148317. }>;
  148318. protected _camera: Camera;
  148319. protected _sourceTexture: Nullable<RenderTargetTexture>;
  148320. protected _reductionSteps: Nullable<Array<PostProcess>>;
  148321. protected _postProcessManager: PostProcessManager;
  148322. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  148323. protected _forceFullscreenViewport: boolean;
  148324. /**
  148325. * Creates a min/max reducer
  148326. * @param camera The camera to use for the post processes
  148327. */
  148328. constructor(camera: Camera);
  148329. /**
  148330. * Gets the texture used to read the values from.
  148331. */
  148332. get sourceTexture(): Nullable<RenderTargetTexture>;
  148333. /**
  148334. * Sets the source texture to read the values from.
  148335. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  148336. * because in such textures '1' value must not be taken into account to compute the maximum
  148337. * as this value is used to clear the texture.
  148338. * Note that the computation is not activated by calling this function, you must call activate() for that!
  148339. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  148340. * @param depthRedux Indicates if the texture is a depth texture or not
  148341. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  148342. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  148343. */
  148344. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  148345. /**
  148346. * Defines the refresh rate of the computation.
  148347. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  148348. */
  148349. get refreshRate(): number;
  148350. set refreshRate(value: number);
  148351. protected _activated: boolean;
  148352. /**
  148353. * Gets the activation status of the reducer
  148354. */
  148355. get activated(): boolean;
  148356. /**
  148357. * Activates the reduction computation.
  148358. * When activated, the observers registered in onAfterReductionPerformed are
  148359. * called after the compuation is performed
  148360. */
  148361. activate(): void;
  148362. /**
  148363. * Deactivates the reduction computation.
  148364. */
  148365. deactivate(): void;
  148366. /**
  148367. * Disposes the min/max reducer
  148368. * @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.
  148369. */
  148370. dispose(disposeAll?: boolean): void;
  148371. }
  148372. }
  148373. declare module BABYLON {
  148374. /**
  148375. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  148376. */
  148377. export class DepthReducer extends MinMaxReducer {
  148378. private _depthRenderer;
  148379. private _depthRendererId;
  148380. /**
  148381. * Gets the depth renderer used for the computation.
  148382. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  148383. */
  148384. get depthRenderer(): Nullable<DepthRenderer>;
  148385. /**
  148386. * Creates a depth reducer
  148387. * @param camera The camera used to render the depth texture
  148388. */
  148389. constructor(camera: Camera);
  148390. /**
  148391. * Sets the depth renderer to use to generate the depth map
  148392. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  148393. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  148394. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  148395. */
  148396. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  148397. /** @hidden */
  148398. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  148399. /**
  148400. * Activates the reduction computation.
  148401. * When activated, the observers registered in onAfterReductionPerformed are
  148402. * called after the compuation is performed
  148403. */
  148404. activate(): void;
  148405. /**
  148406. * Deactivates the reduction computation.
  148407. */
  148408. deactivate(): void;
  148409. /**
  148410. * Disposes the depth reducer
  148411. * @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.
  148412. */
  148413. dispose(disposeAll?: boolean): void;
  148414. }
  148415. }
  148416. declare module BABYLON {
  148417. /**
  148418. * A CSM implementation allowing casting shadows on large scenes.
  148419. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  148420. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  148421. */
  148422. export class CascadedShadowGenerator extends ShadowGenerator {
  148423. private static readonly frustumCornersNDCSpace;
  148424. /**
  148425. * Name of the CSM class
  148426. */
  148427. static CLASSNAME: string;
  148428. /**
  148429. * Defines the default number of cascades used by the CSM.
  148430. */
  148431. static readonly DEFAULT_CASCADES_COUNT: number;
  148432. /**
  148433. * Defines the minimum number of cascades used by the CSM.
  148434. */
  148435. static readonly MIN_CASCADES_COUNT: number;
  148436. /**
  148437. * Defines the maximum number of cascades used by the CSM.
  148438. */
  148439. static readonly MAX_CASCADES_COUNT: number;
  148440. protected _validateFilter(filter: number): number;
  148441. /**
  148442. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  148443. */
  148444. penumbraDarkness: number;
  148445. private _numCascades;
  148446. /**
  148447. * Gets or set the number of cascades used by the CSM.
  148448. */
  148449. get numCascades(): number;
  148450. set numCascades(value: number);
  148451. /**
  148452. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  148453. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  148454. */
  148455. stabilizeCascades: boolean;
  148456. private _freezeShadowCastersBoundingInfo;
  148457. private _freezeShadowCastersBoundingInfoObservable;
  148458. /**
  148459. * Enables or disables the shadow casters bounding info computation.
  148460. * If your shadow casters don't move, you can disable this feature.
  148461. * If it is enabled, the bounding box computation is done every frame.
  148462. */
  148463. get freezeShadowCastersBoundingInfo(): boolean;
  148464. set freezeShadowCastersBoundingInfo(freeze: boolean);
  148465. private _scbiMin;
  148466. private _scbiMax;
  148467. protected _computeShadowCastersBoundingInfo(): void;
  148468. protected _shadowCastersBoundingInfo: BoundingInfo;
  148469. /**
  148470. * Gets or sets the shadow casters bounding info.
  148471. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  148472. * so that the system won't overwrite the bounds you provide
  148473. */
  148474. get shadowCastersBoundingInfo(): BoundingInfo;
  148475. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  148476. protected _breaksAreDirty: boolean;
  148477. protected _minDistance: number;
  148478. protected _maxDistance: number;
  148479. /**
  148480. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  148481. *
  148482. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  148483. * If you don't know these values, simply leave them to their defaults and don't call this function.
  148484. * @param min minimal distance for the breaks (default to 0.)
  148485. * @param max maximal distance for the breaks (default to 1.)
  148486. */
  148487. setMinMaxDistance(min: number, max: number): void;
  148488. /** Gets the minimal distance used in the cascade break computation */
  148489. get minDistance(): number;
  148490. /** Gets the maximal distance used in the cascade break computation */
  148491. get maxDistance(): number;
  148492. /**
  148493. * Gets the class name of that object
  148494. * @returns "CascadedShadowGenerator"
  148495. */
  148496. getClassName(): string;
  148497. private _cascadeMinExtents;
  148498. private _cascadeMaxExtents;
  148499. /**
  148500. * Gets a cascade minimum extents
  148501. * @param cascadeIndex index of the cascade
  148502. * @returns the minimum cascade extents
  148503. */
  148504. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  148505. /**
  148506. * Gets a cascade maximum extents
  148507. * @param cascadeIndex index of the cascade
  148508. * @returns the maximum cascade extents
  148509. */
  148510. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  148511. private _cascades;
  148512. private _currentLayer;
  148513. private _viewSpaceFrustumsZ;
  148514. private _viewMatrices;
  148515. private _projectionMatrices;
  148516. private _transformMatrices;
  148517. private _transformMatricesAsArray;
  148518. private _frustumLengths;
  148519. private _lightSizeUVCorrection;
  148520. private _depthCorrection;
  148521. private _frustumCornersWorldSpace;
  148522. private _frustumCenter;
  148523. private _shadowCameraPos;
  148524. private _shadowMaxZ;
  148525. /**
  148526. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  148527. * It defaults to camera.maxZ
  148528. */
  148529. get shadowMaxZ(): number;
  148530. /**
  148531. * Sets the shadow max z distance.
  148532. */
  148533. set shadowMaxZ(value: number);
  148534. protected _debug: boolean;
  148535. /**
  148536. * Gets or sets the debug flag.
  148537. * When enabled, the cascades are materialized by different colors on the screen.
  148538. */
  148539. get debug(): boolean;
  148540. set debug(dbg: boolean);
  148541. private _depthClamp;
  148542. /**
  148543. * Gets or sets the depth clamping value.
  148544. *
  148545. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  148546. * to account for the shadow casters far away.
  148547. *
  148548. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  148549. */
  148550. get depthClamp(): boolean;
  148551. set depthClamp(value: boolean);
  148552. private _cascadeBlendPercentage;
  148553. /**
  148554. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  148555. * It defaults to 0.1 (10% blending).
  148556. */
  148557. get cascadeBlendPercentage(): number;
  148558. set cascadeBlendPercentage(value: number);
  148559. private _lambda;
  148560. /**
  148561. * Gets or set the lambda parameter.
  148562. * This parameter is used to split the camera frustum and create the cascades.
  148563. * 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.
  148564. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  148565. */
  148566. get lambda(): number;
  148567. set lambda(value: number);
  148568. /**
  148569. * Gets the view matrix corresponding to a given cascade
  148570. * @param cascadeNum cascade to retrieve the view matrix from
  148571. * @returns the cascade view matrix
  148572. */
  148573. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  148574. /**
  148575. * Gets the projection matrix corresponding to a given cascade
  148576. * @param cascadeNum cascade to retrieve the projection matrix from
  148577. * @returns the cascade projection matrix
  148578. */
  148579. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  148580. /**
  148581. * Gets the transformation matrix corresponding to a given cascade
  148582. * @param cascadeNum cascade to retrieve the transformation matrix from
  148583. * @returns the cascade transformation matrix
  148584. */
  148585. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  148586. private _depthRenderer;
  148587. /**
  148588. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  148589. *
  148590. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  148591. *
  148592. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  148593. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  148594. * @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
  148595. */
  148596. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  148597. private _depthReducer;
  148598. private _autoCalcDepthBounds;
  148599. /**
  148600. * Gets or sets the autoCalcDepthBounds property.
  148601. *
  148602. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  148603. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  148604. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  148605. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  148606. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  148607. */
  148608. get autoCalcDepthBounds(): boolean;
  148609. set autoCalcDepthBounds(value: boolean);
  148610. /**
  148611. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  148612. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  148613. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  148614. * for setting the refresh rate on the renderer yourself!
  148615. */
  148616. get autoCalcDepthBoundsRefreshRate(): number;
  148617. set autoCalcDepthBoundsRefreshRate(value: number);
  148618. /**
  148619. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  148620. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  148621. * you change the camera near/far planes!
  148622. */
  148623. splitFrustum(): void;
  148624. private _splitFrustum;
  148625. private _computeMatrices;
  148626. private _computeFrustumInWorldSpace;
  148627. private _computeCascadeFrustum;
  148628. /**
  148629. * Support test.
  148630. */
  148631. static get IsSupported(): boolean;
  148632. /** @hidden */
  148633. static _SceneComponentInitialization: (scene: Scene) => void;
  148634. /**
  148635. * Creates a Cascaded Shadow Generator object.
  148636. * A ShadowGenerator is the required tool to use the shadows.
  148637. * Each directional light casting shadows needs to use its own ShadowGenerator.
  148638. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  148639. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  148640. * @param light The directional light object generating the shadows.
  148641. * @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.
  148642. */
  148643. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  148644. protected _initializeGenerator(): void;
  148645. protected _createTargetRenderTexture(): void;
  148646. protected _initializeShadowMap(): void;
  148647. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  148648. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  148649. /**
  148650. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  148651. * @param defines Defines of the material we want to update
  148652. * @param lightIndex Index of the light in the enabled light list of the material
  148653. */
  148654. prepareDefines(defines: any, lightIndex: number): void;
  148655. /**
  148656. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  148657. * defined in the generator but impacting the effect).
  148658. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  148659. * @param effect The effect we are binfing the information for
  148660. */
  148661. bindShadowLight(lightIndex: string, effect: Effect): void;
  148662. /**
  148663. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  148664. * (eq to view projection * shadow projection matrices)
  148665. * @returns The transform matrix used to create the shadow map
  148666. */
  148667. getTransformMatrix(): Matrix;
  148668. /**
  148669. * Disposes the ShadowGenerator.
  148670. * Returns nothing.
  148671. */
  148672. dispose(): void;
  148673. /**
  148674. * Serializes the shadow generator setup to a json object.
  148675. * @returns The serialized JSON object
  148676. */
  148677. serialize(): any;
  148678. /**
  148679. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  148680. * @param parsedShadowGenerator The JSON object to parse
  148681. * @param scene The scene to create the shadow map for
  148682. * @returns The parsed shadow generator
  148683. */
  148684. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  148685. }
  148686. }
  148687. declare module BABYLON {
  148688. /**
  148689. * Defines the shadow generator component responsible to manage any shadow generators
  148690. * in a given scene.
  148691. */
  148692. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  148693. /**
  148694. * The component name helpfull to identify the component in the list of scene components.
  148695. */
  148696. readonly name: string;
  148697. /**
  148698. * The scene the component belongs to.
  148699. */
  148700. scene: Scene;
  148701. /**
  148702. * Creates a new instance of the component for the given scene
  148703. * @param scene Defines the scene to register the component in
  148704. */
  148705. constructor(scene: Scene);
  148706. /**
  148707. * Registers the component in a given scene
  148708. */
  148709. register(): void;
  148710. /**
  148711. * Rebuilds the elements related to this component in case of
  148712. * context lost for instance.
  148713. */
  148714. rebuild(): void;
  148715. /**
  148716. * Serializes the component data to the specified json object
  148717. * @param serializationObject The object to serialize to
  148718. */
  148719. serialize(serializationObject: any): void;
  148720. /**
  148721. * Adds all the elements from the container to the scene
  148722. * @param container the container holding the elements
  148723. */
  148724. addFromContainer(container: AbstractScene): void;
  148725. /**
  148726. * Removes all the elements in the container from the scene
  148727. * @param container contains the elements to remove
  148728. * @param dispose if the removed element should be disposed (default: false)
  148729. */
  148730. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  148731. /**
  148732. * Rebuilds the elements related to this component in case of
  148733. * context lost for instance.
  148734. */
  148735. dispose(): void;
  148736. private _gatherRenderTargets;
  148737. }
  148738. }
  148739. declare module BABYLON {
  148740. /**
  148741. * A point light is a light defined by an unique point in world space.
  148742. * The light is emitted in every direction from this point.
  148743. * A good example of a point light is a standard light bulb.
  148744. * Documentation: https://doc.babylonjs.com/babylon101/lights
  148745. */
  148746. export class PointLight extends ShadowLight {
  148747. private _shadowAngle;
  148748. /**
  148749. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  148750. * This specifies what angle the shadow will use to be created.
  148751. *
  148752. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  148753. */
  148754. get shadowAngle(): number;
  148755. /**
  148756. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  148757. * This specifies what angle the shadow will use to be created.
  148758. *
  148759. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  148760. */
  148761. set shadowAngle(value: number);
  148762. /**
  148763. * Gets the direction if it has been set.
  148764. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  148765. */
  148766. get direction(): Vector3;
  148767. /**
  148768. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  148769. */
  148770. set direction(value: Vector3);
  148771. /**
  148772. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  148773. * A PointLight emits the light in every direction.
  148774. * It can cast shadows.
  148775. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  148776. * ```javascript
  148777. * var pointLight = new PointLight("pl", camera.position, scene);
  148778. * ```
  148779. * Documentation : https://doc.babylonjs.com/babylon101/lights
  148780. * @param name The light friendly name
  148781. * @param position The position of the point light in the scene
  148782. * @param scene The scene the lights belongs to
  148783. */
  148784. constructor(name: string, position: Vector3, scene: Scene);
  148785. /**
  148786. * Returns the string "PointLight"
  148787. * @returns the class name
  148788. */
  148789. getClassName(): string;
  148790. /**
  148791. * Returns the integer 0.
  148792. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  148793. */
  148794. getTypeID(): number;
  148795. /**
  148796. * Specifies wether or not the shadowmap should be a cube texture.
  148797. * @returns true if the shadowmap needs to be a cube texture.
  148798. */
  148799. needCube(): boolean;
  148800. /**
  148801. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  148802. * @param faceIndex The index of the face we are computed the direction to generate shadow
  148803. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  148804. */
  148805. getShadowDirection(faceIndex?: number): Vector3;
  148806. /**
  148807. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  148808. * - fov = PI / 2
  148809. * - aspect ratio : 1.0
  148810. * - z-near and far equal to the active camera minZ and maxZ.
  148811. * Returns the PointLight.
  148812. */
  148813. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  148814. protected _buildUniformLayout(): void;
  148815. /**
  148816. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  148817. * @param effect The effect to update
  148818. * @param lightIndex The index of the light in the effect to update
  148819. * @returns The point light
  148820. */
  148821. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  148822. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  148823. /**
  148824. * Prepares the list of defines specific to the light type.
  148825. * @param defines the list of defines
  148826. * @param lightIndex defines the index of the light for the effect
  148827. */
  148828. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  148829. }
  148830. }
  148831. declare module BABYLON {
  148832. /**
  148833. * Header information of HDR texture files.
  148834. */
  148835. export interface HDRInfo {
  148836. /**
  148837. * The height of the texture in pixels.
  148838. */
  148839. height: number;
  148840. /**
  148841. * The width of the texture in pixels.
  148842. */
  148843. width: number;
  148844. /**
  148845. * The index of the beginning of the data in the binary file.
  148846. */
  148847. dataPosition: number;
  148848. }
  148849. /**
  148850. * This groups tools to convert HDR texture to native colors array.
  148851. */
  148852. export class HDRTools {
  148853. private static Ldexp;
  148854. private static Rgbe2float;
  148855. private static readStringLine;
  148856. /**
  148857. * Reads header information from an RGBE texture stored in a native array.
  148858. * More information on this format are available here:
  148859. * https://en.wikipedia.org/wiki/RGBE_image_format
  148860. *
  148861. * @param uint8array The binary file stored in native array.
  148862. * @return The header information.
  148863. */
  148864. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  148865. /**
  148866. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  148867. * This RGBE texture needs to store the information as a panorama.
  148868. *
  148869. * More information on this format are available here:
  148870. * https://en.wikipedia.org/wiki/RGBE_image_format
  148871. *
  148872. * @param buffer The binary file stored in an array buffer.
  148873. * @param size The expected size of the extracted cubemap.
  148874. * @return The Cube Map information.
  148875. */
  148876. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  148877. /**
  148878. * Returns the pixels data extracted from an RGBE texture.
  148879. * This pixels will be stored left to right up to down in the R G B order in one array.
  148880. *
  148881. * More information on this format are available here:
  148882. * https://en.wikipedia.org/wiki/RGBE_image_format
  148883. *
  148884. * @param uint8array The binary file stored in an array buffer.
  148885. * @param hdrInfo The header information of the file.
  148886. * @return The pixels data in RGB right to left up to down order.
  148887. */
  148888. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  148889. private static RGBE_ReadPixels_RLE;
  148890. private static RGBE_ReadPixels_NOT_RLE;
  148891. }
  148892. }
  148893. declare module BABYLON {
  148894. /**
  148895. * Effect Render Options
  148896. */
  148897. export interface IEffectRendererOptions {
  148898. /**
  148899. * Defines the vertices positions.
  148900. */
  148901. positions?: number[];
  148902. /**
  148903. * Defines the indices.
  148904. */
  148905. indices?: number[];
  148906. }
  148907. /**
  148908. * Helper class to render one or more effects.
  148909. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  148910. */
  148911. export class EffectRenderer {
  148912. private engine;
  148913. private static _DefaultOptions;
  148914. private _vertexBuffers;
  148915. private _indexBuffer;
  148916. private _fullscreenViewport;
  148917. /**
  148918. * Creates an effect renderer
  148919. * @param engine the engine to use for rendering
  148920. * @param options defines the options of the effect renderer
  148921. */
  148922. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  148923. /**
  148924. * Sets the current viewport in normalized coordinates 0-1
  148925. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  148926. */
  148927. setViewport(viewport?: Viewport): void;
  148928. /**
  148929. * Binds the embedded attributes buffer to the effect.
  148930. * @param effect Defines the effect to bind the attributes for
  148931. */
  148932. bindBuffers(effect: Effect): void;
  148933. /**
  148934. * Sets the current effect wrapper to use during draw.
  148935. * The effect needs to be ready before calling this api.
  148936. * This also sets the default full screen position attribute.
  148937. * @param effectWrapper Defines the effect to draw with
  148938. */
  148939. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  148940. /**
  148941. * Restores engine states
  148942. */
  148943. restoreStates(): void;
  148944. /**
  148945. * Draws a full screen quad.
  148946. */
  148947. draw(): void;
  148948. private isRenderTargetTexture;
  148949. /**
  148950. * renders one or more effects to a specified texture
  148951. * @param effectWrapper the effect to renderer
  148952. * @param outputTexture texture to draw to, if null it will render to the screen.
  148953. */
  148954. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  148955. /**
  148956. * Disposes of the effect renderer
  148957. */
  148958. dispose(): void;
  148959. }
  148960. /**
  148961. * Options to create an EffectWrapper
  148962. */
  148963. interface EffectWrapperCreationOptions {
  148964. /**
  148965. * Engine to use to create the effect
  148966. */
  148967. engine: ThinEngine;
  148968. /**
  148969. * Fragment shader for the effect
  148970. */
  148971. fragmentShader: string;
  148972. /**
  148973. * Use the shader store instead of direct source code
  148974. */
  148975. useShaderStore?: boolean;
  148976. /**
  148977. * Vertex shader for the effect
  148978. */
  148979. vertexShader?: string;
  148980. /**
  148981. * Attributes to use in the shader
  148982. */
  148983. attributeNames?: Array<string>;
  148984. /**
  148985. * Uniforms to use in the shader
  148986. */
  148987. uniformNames?: Array<string>;
  148988. /**
  148989. * Texture sampler names to use in the shader
  148990. */
  148991. samplerNames?: Array<string>;
  148992. /**
  148993. * Defines to use in the shader
  148994. */
  148995. defines?: Array<string>;
  148996. /**
  148997. * Callback when effect is compiled
  148998. */
  148999. onCompiled?: Nullable<(effect: Effect) => void>;
  149000. /**
  149001. * The friendly name of the effect displayed in Spector.
  149002. */
  149003. name?: string;
  149004. }
  149005. /**
  149006. * Wraps an effect to be used for rendering
  149007. */
  149008. export class EffectWrapper {
  149009. /**
  149010. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  149011. */
  149012. onApplyObservable: Observable<{}>;
  149013. /**
  149014. * The underlying effect
  149015. */
  149016. effect: Effect;
  149017. /**
  149018. * Creates an effect to be renderer
  149019. * @param creationOptions options to create the effect
  149020. */
  149021. constructor(creationOptions: EffectWrapperCreationOptions);
  149022. /**
  149023. * Disposes of the effect wrapper
  149024. */
  149025. dispose(): void;
  149026. }
  149027. }
  149028. declare module BABYLON {
  149029. /** @hidden */
  149030. export var hdrFilteringVertexShader: {
  149031. name: string;
  149032. shader: string;
  149033. };
  149034. }
  149035. declare module BABYLON {
  149036. /** @hidden */
  149037. export var hdrFilteringPixelShader: {
  149038. name: string;
  149039. shader: string;
  149040. };
  149041. }
  149042. declare module BABYLON {
  149043. /**
  149044. * Options for texture filtering
  149045. */
  149046. interface IHDRFilteringOptions {
  149047. /**
  149048. * Scales pixel intensity for the input HDR map.
  149049. */
  149050. hdrScale?: number;
  149051. /**
  149052. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  149053. */
  149054. quality?: number;
  149055. }
  149056. /**
  149057. * Filters HDR maps to get correct renderings of PBR reflections
  149058. */
  149059. export class HDRFiltering {
  149060. private _engine;
  149061. private _effectRenderer;
  149062. private _effectWrapper;
  149063. private _lodGenerationOffset;
  149064. private _lodGenerationScale;
  149065. /**
  149066. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  149067. * you care about baking speed.
  149068. */
  149069. quality: number;
  149070. /**
  149071. * Scales pixel intensity for the input HDR map.
  149072. */
  149073. hdrScale: number;
  149074. /**
  149075. * Instantiates HDR filter for reflection maps
  149076. *
  149077. * @param engine Thin engine
  149078. * @param options Options
  149079. */
  149080. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  149081. private _createRenderTarget;
  149082. private _prefilterInternal;
  149083. private _createEffect;
  149084. /**
  149085. * Get a value indicating if the filter is ready to be used
  149086. * @param texture Texture to filter
  149087. * @returns true if the filter is ready
  149088. */
  149089. isReady(texture: BaseTexture): boolean;
  149090. /**
  149091. * Prefilters a cube texture to have mipmap levels representing roughness values.
  149092. * Prefiltering will be invoked at the end of next rendering pass.
  149093. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  149094. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  149095. * @param texture Texture to filter
  149096. * @param onFinished Callback when filtering is done
  149097. * @return Promise called when prefiltering is done
  149098. */
  149099. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<void>;
  149100. }
  149101. }
  149102. declare module BABYLON {
  149103. /**
  149104. * This represents a texture coming from an HDR input.
  149105. *
  149106. * The only supported format is currently panorama picture stored in RGBE format.
  149107. * Example of such files can be found on HDRLib: http://hdrlib.com/
  149108. */
  149109. export class HDRCubeTexture extends BaseTexture {
  149110. private static _facesMapping;
  149111. private _generateHarmonics;
  149112. private _noMipmap;
  149113. private _prefilterOnLoad;
  149114. private _textureMatrix;
  149115. private _size;
  149116. private _onLoad;
  149117. private _onError;
  149118. /**
  149119. * The texture URL.
  149120. */
  149121. url: string;
  149122. protected _isBlocking: boolean;
  149123. /**
  149124. * Sets wether or not the texture is blocking during loading.
  149125. */
  149126. set isBlocking(value: boolean);
  149127. /**
  149128. * Gets wether or not the texture is blocking during loading.
  149129. */
  149130. get isBlocking(): boolean;
  149131. protected _rotationY: number;
  149132. /**
  149133. * Sets texture matrix rotation angle around Y axis in radians.
  149134. */
  149135. set rotationY(value: number);
  149136. /**
  149137. * Gets texture matrix rotation angle around Y axis radians.
  149138. */
  149139. get rotationY(): number;
  149140. /**
  149141. * Gets or sets the center of the bounding box associated with the cube texture
  149142. * It must define where the camera used to render the texture was set
  149143. */
  149144. boundingBoxPosition: Vector3;
  149145. private _boundingBoxSize;
  149146. /**
  149147. * Gets or sets the size of the bounding box associated with the cube texture
  149148. * When defined, the cubemap will switch to local mode
  149149. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  149150. * @example https://www.babylonjs-playground.com/#RNASML
  149151. */
  149152. set boundingBoxSize(value: Vector3);
  149153. get boundingBoxSize(): Vector3;
  149154. /**
  149155. * Instantiates an HDRTexture from the following parameters.
  149156. *
  149157. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  149158. * @param sceneOrEngine The scene or engine the texture will be used in
  149159. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  149160. * @param noMipmap Forces to not generate the mipmap if true
  149161. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  149162. * @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)
  149163. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  149164. */
  149165. 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>);
  149166. /**
  149167. * Get the current class name of the texture useful for serialization or dynamic coding.
  149168. * @returns "HDRCubeTexture"
  149169. */
  149170. getClassName(): string;
  149171. /**
  149172. * Occurs when the file is raw .hdr file.
  149173. */
  149174. private loadTexture;
  149175. clone(): HDRCubeTexture;
  149176. delayLoad(): void;
  149177. /**
  149178. * Get the texture reflection matrix used to rotate/transform the reflection.
  149179. * @returns the reflection matrix
  149180. */
  149181. getReflectionTextureMatrix(): Matrix;
  149182. /**
  149183. * Set the texture reflection matrix used to rotate/transform the reflection.
  149184. * @param value Define the reflection matrix to set
  149185. */
  149186. setReflectionTextureMatrix(value: Matrix): void;
  149187. /**
  149188. * Parses a JSON representation of an HDR Texture in order to create the texture
  149189. * @param parsedTexture Define the JSON representation
  149190. * @param scene Define the scene the texture should be created in
  149191. * @param rootUrl Define the root url in case we need to load relative dependencies
  149192. * @returns the newly created texture after parsing
  149193. */
  149194. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  149195. serialize(): any;
  149196. }
  149197. }
  149198. declare module BABYLON {
  149199. /**
  149200. * Class used to control physics engine
  149201. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  149202. */
  149203. export class PhysicsEngine implements IPhysicsEngine {
  149204. private _physicsPlugin;
  149205. /**
  149206. * Global value used to control the smallest number supported by the simulation
  149207. */
  149208. static Epsilon: number;
  149209. private _impostors;
  149210. private _joints;
  149211. private _subTimeStep;
  149212. /**
  149213. * Gets the gravity vector used by the simulation
  149214. */
  149215. gravity: Vector3;
  149216. /**
  149217. * Factory used to create the default physics plugin.
  149218. * @returns The default physics plugin
  149219. */
  149220. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  149221. /**
  149222. * Creates a new Physics Engine
  149223. * @param gravity defines the gravity vector used by the simulation
  149224. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  149225. */
  149226. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  149227. /**
  149228. * Sets the gravity vector used by the simulation
  149229. * @param gravity defines the gravity vector to use
  149230. */
  149231. setGravity(gravity: Vector3): void;
  149232. /**
  149233. * Set the time step of the physics engine.
  149234. * Default is 1/60.
  149235. * To slow it down, enter 1/600 for example.
  149236. * To speed it up, 1/30
  149237. * @param newTimeStep defines the new timestep to apply to this world.
  149238. */
  149239. setTimeStep(newTimeStep?: number): void;
  149240. /**
  149241. * Get the time step of the physics engine.
  149242. * @returns the current time step
  149243. */
  149244. getTimeStep(): number;
  149245. /**
  149246. * Set the sub time step of the physics engine.
  149247. * Default is 0 meaning there is no sub steps
  149248. * To increase physics resolution precision, set a small value (like 1 ms)
  149249. * @param subTimeStep defines the new sub timestep used for physics resolution.
  149250. */
  149251. setSubTimeStep(subTimeStep?: number): void;
  149252. /**
  149253. * Get the sub time step of the physics engine.
  149254. * @returns the current sub time step
  149255. */
  149256. getSubTimeStep(): number;
  149257. /**
  149258. * Release all resources
  149259. */
  149260. dispose(): void;
  149261. /**
  149262. * Gets the name of the current physics plugin
  149263. * @returns the name of the plugin
  149264. */
  149265. getPhysicsPluginName(): string;
  149266. /**
  149267. * Adding a new impostor for the impostor tracking.
  149268. * This will be done by the impostor itself.
  149269. * @param impostor the impostor to add
  149270. */
  149271. addImpostor(impostor: PhysicsImpostor): void;
  149272. /**
  149273. * Remove an impostor from the engine.
  149274. * This impostor and its mesh will not longer be updated by the physics engine.
  149275. * @param impostor the impostor to remove
  149276. */
  149277. removeImpostor(impostor: PhysicsImpostor): void;
  149278. /**
  149279. * Add a joint to the physics engine
  149280. * @param mainImpostor defines the main impostor to which the joint is added.
  149281. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  149282. * @param joint defines the joint that will connect both impostors.
  149283. */
  149284. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  149285. /**
  149286. * Removes a joint from the simulation
  149287. * @param mainImpostor defines the impostor used with the joint
  149288. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  149289. * @param joint defines the joint to remove
  149290. */
  149291. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  149292. /**
  149293. * Called by the scene. No need to call it.
  149294. * @param delta defines the timespam between frames
  149295. */
  149296. _step(delta: number): void;
  149297. /**
  149298. * Gets the current plugin used to run the simulation
  149299. * @returns current plugin
  149300. */
  149301. getPhysicsPlugin(): IPhysicsEnginePlugin;
  149302. /**
  149303. * Gets the list of physic impostors
  149304. * @returns an array of PhysicsImpostor
  149305. */
  149306. getImpostors(): Array<PhysicsImpostor>;
  149307. /**
  149308. * Gets the impostor for a physics enabled object
  149309. * @param object defines the object impersonated by the impostor
  149310. * @returns the PhysicsImpostor or null if not found
  149311. */
  149312. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  149313. /**
  149314. * Gets the impostor for a physics body object
  149315. * @param body defines physics body used by the impostor
  149316. * @returns the PhysicsImpostor or null if not found
  149317. */
  149318. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  149319. /**
  149320. * Does a raycast in the physics world
  149321. * @param from when should the ray start?
  149322. * @param to when should the ray end?
  149323. * @returns PhysicsRaycastResult
  149324. */
  149325. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  149326. }
  149327. }
  149328. declare module BABYLON {
  149329. /** @hidden */
  149330. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  149331. private _useDeltaForWorldStep;
  149332. world: any;
  149333. name: string;
  149334. private _physicsMaterials;
  149335. private _fixedTimeStep;
  149336. private _cannonRaycastResult;
  149337. private _raycastResult;
  149338. private _physicsBodysToRemoveAfterStep;
  149339. private _firstFrame;
  149340. BJSCANNON: any;
  149341. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  149342. setGravity(gravity: Vector3): void;
  149343. setTimeStep(timeStep: number): void;
  149344. getTimeStep(): number;
  149345. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  149346. private _removeMarkedPhysicsBodiesFromWorld;
  149347. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  149348. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  149349. generatePhysicsBody(impostor: PhysicsImpostor): void;
  149350. private _processChildMeshes;
  149351. removePhysicsBody(impostor: PhysicsImpostor): void;
  149352. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  149353. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  149354. private _addMaterial;
  149355. private _checkWithEpsilon;
  149356. private _createShape;
  149357. private _createHeightmap;
  149358. private _minus90X;
  149359. private _plus90X;
  149360. private _tmpPosition;
  149361. private _tmpDeltaPosition;
  149362. private _tmpUnityRotation;
  149363. private _updatePhysicsBodyTransformation;
  149364. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  149365. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  149366. isSupported(): boolean;
  149367. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  149368. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  149369. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  149370. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  149371. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  149372. getBodyMass(impostor: PhysicsImpostor): number;
  149373. getBodyFriction(impostor: PhysicsImpostor): number;
  149374. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  149375. getBodyRestitution(impostor: PhysicsImpostor): number;
  149376. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  149377. sleepBody(impostor: PhysicsImpostor): void;
  149378. wakeUpBody(impostor: PhysicsImpostor): void;
  149379. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  149380. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  149381. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  149382. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  149383. getRadius(impostor: PhysicsImpostor): number;
  149384. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  149385. dispose(): void;
  149386. private _extendNamespace;
  149387. /**
  149388. * Does a raycast in the physics world
  149389. * @param from when should the ray start?
  149390. * @param to when should the ray end?
  149391. * @returns PhysicsRaycastResult
  149392. */
  149393. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  149394. }
  149395. }
  149396. declare module BABYLON {
  149397. /** @hidden */
  149398. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  149399. private _useDeltaForWorldStep;
  149400. world: any;
  149401. name: string;
  149402. BJSOIMO: any;
  149403. private _raycastResult;
  149404. private _fixedTimeStep;
  149405. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  149406. setGravity(gravity: Vector3): void;
  149407. setTimeStep(timeStep: number): void;
  149408. getTimeStep(): number;
  149409. private _tmpImpostorsArray;
  149410. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  149411. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  149412. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  149413. generatePhysicsBody(impostor: PhysicsImpostor): void;
  149414. private _tmpPositionVector;
  149415. removePhysicsBody(impostor: PhysicsImpostor): void;
  149416. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  149417. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  149418. isSupported(): boolean;
  149419. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  149420. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  149421. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  149422. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  149423. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  149424. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  149425. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  149426. getBodyMass(impostor: PhysicsImpostor): number;
  149427. getBodyFriction(impostor: PhysicsImpostor): number;
  149428. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  149429. getBodyRestitution(impostor: PhysicsImpostor): number;
  149430. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  149431. sleepBody(impostor: PhysicsImpostor): void;
  149432. wakeUpBody(impostor: PhysicsImpostor): void;
  149433. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  149434. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  149435. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  149436. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  149437. getRadius(impostor: PhysicsImpostor): number;
  149438. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  149439. dispose(): void;
  149440. /**
  149441. * Does a raycast in the physics world
  149442. * @param from when should the ray start?
  149443. * @param to when should the ray end?
  149444. * @returns PhysicsRaycastResult
  149445. */
  149446. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  149447. }
  149448. }
  149449. declare module BABYLON {
  149450. /**
  149451. * AmmoJS Physics plugin
  149452. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  149453. * @see https://github.com/kripken/ammo.js/
  149454. */
  149455. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  149456. private _useDeltaForWorldStep;
  149457. /**
  149458. * Reference to the Ammo library
  149459. */
  149460. bjsAMMO: any;
  149461. /**
  149462. * Created ammoJS world which physics bodies are added to
  149463. */
  149464. world: any;
  149465. /**
  149466. * Name of the plugin
  149467. */
  149468. name: string;
  149469. private _timeStep;
  149470. private _fixedTimeStep;
  149471. private _maxSteps;
  149472. private _tmpQuaternion;
  149473. private _tmpAmmoTransform;
  149474. private _tmpAmmoQuaternion;
  149475. private _tmpAmmoConcreteContactResultCallback;
  149476. private _collisionConfiguration;
  149477. private _dispatcher;
  149478. private _overlappingPairCache;
  149479. private _solver;
  149480. private _softBodySolver;
  149481. private _tmpAmmoVectorA;
  149482. private _tmpAmmoVectorB;
  149483. private _tmpAmmoVectorC;
  149484. private _tmpAmmoVectorD;
  149485. private _tmpContactCallbackResult;
  149486. private _tmpAmmoVectorRCA;
  149487. private _tmpAmmoVectorRCB;
  149488. private _raycastResult;
  149489. private _tmpContactPoint;
  149490. private static readonly DISABLE_COLLISION_FLAG;
  149491. private static readonly KINEMATIC_FLAG;
  149492. private static readonly DISABLE_DEACTIVATION_FLAG;
  149493. /**
  149494. * Initializes the ammoJS plugin
  149495. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  149496. * @param ammoInjection can be used to inject your own ammo reference
  149497. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  149498. */
  149499. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  149500. /**
  149501. * Sets the gravity of the physics world (m/(s^2))
  149502. * @param gravity Gravity to set
  149503. */
  149504. setGravity(gravity: Vector3): void;
  149505. /**
  149506. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  149507. * @param timeStep timestep to use in seconds
  149508. */
  149509. setTimeStep(timeStep: number): void;
  149510. /**
  149511. * 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)
  149512. * @param fixedTimeStep fixedTimeStep to use in seconds
  149513. */
  149514. setFixedTimeStep(fixedTimeStep: number): void;
  149515. /**
  149516. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  149517. * @param maxSteps the maximum number of steps by the physics engine per frame
  149518. */
  149519. setMaxSteps(maxSteps: number): void;
  149520. /**
  149521. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  149522. * @returns the current timestep in seconds
  149523. */
  149524. getTimeStep(): number;
  149525. /**
  149526. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  149527. */
  149528. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  149529. private _isImpostorInContact;
  149530. private _isImpostorPairInContact;
  149531. private _stepSimulation;
  149532. /**
  149533. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  149534. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  149535. * After the step the babylon meshes are set to the position of the physics imposters
  149536. * @param delta amount of time to step forward
  149537. * @param impostors array of imposters to update before/after the step
  149538. */
  149539. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  149540. /**
  149541. * Update babylon mesh to match physics world object
  149542. * @param impostor imposter to match
  149543. */
  149544. private _afterSoftStep;
  149545. /**
  149546. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  149547. * @param impostor imposter to match
  149548. */
  149549. private _ropeStep;
  149550. /**
  149551. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  149552. * @param impostor imposter to match
  149553. */
  149554. private _softbodyOrClothStep;
  149555. private _tmpMatrix;
  149556. /**
  149557. * Applies an impulse on the imposter
  149558. * @param impostor imposter to apply impulse to
  149559. * @param force amount of force to be applied to the imposter
  149560. * @param contactPoint the location to apply the impulse on the imposter
  149561. */
  149562. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  149563. /**
  149564. * Applies a force on the imposter
  149565. * @param impostor imposter to apply force
  149566. * @param force amount of force to be applied to the imposter
  149567. * @param contactPoint the location to apply the force on the imposter
  149568. */
  149569. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  149570. /**
  149571. * Creates a physics body using the plugin
  149572. * @param impostor the imposter to create the physics body on
  149573. */
  149574. generatePhysicsBody(impostor: PhysicsImpostor): void;
  149575. /**
  149576. * Removes the physics body from the imposter and disposes of the body's memory
  149577. * @param impostor imposter to remove the physics body from
  149578. */
  149579. removePhysicsBody(impostor: PhysicsImpostor): void;
  149580. /**
  149581. * Generates a joint
  149582. * @param impostorJoint the imposter joint to create the joint with
  149583. */
  149584. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  149585. /**
  149586. * Removes a joint
  149587. * @param impostorJoint the imposter joint to remove the joint from
  149588. */
  149589. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  149590. private _addMeshVerts;
  149591. /**
  149592. * Initialise the soft body vertices to match its object's (mesh) vertices
  149593. * Softbody vertices (nodes) are in world space and to match this
  149594. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  149595. * @param impostor to create the softbody for
  149596. */
  149597. private _softVertexData;
  149598. /**
  149599. * Create an impostor's soft body
  149600. * @param impostor to create the softbody for
  149601. */
  149602. private _createSoftbody;
  149603. /**
  149604. * Create cloth for an impostor
  149605. * @param impostor to create the softbody for
  149606. */
  149607. private _createCloth;
  149608. /**
  149609. * Create rope for an impostor
  149610. * @param impostor to create the softbody for
  149611. */
  149612. private _createRope;
  149613. /**
  149614. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  149615. * @param impostor to create the custom physics shape for
  149616. */
  149617. private _createCustom;
  149618. private _addHullVerts;
  149619. private _createShape;
  149620. /**
  149621. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  149622. * @param impostor imposter containing the physics body and babylon object
  149623. */
  149624. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  149625. /**
  149626. * Sets the babylon object's position/rotation from the physics body's position/rotation
  149627. * @param impostor imposter containing the physics body and babylon object
  149628. * @param newPosition new position
  149629. * @param newRotation new rotation
  149630. */
  149631. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  149632. /**
  149633. * If this plugin is supported
  149634. * @returns true if its supported
  149635. */
  149636. isSupported(): boolean;
  149637. /**
  149638. * Sets the linear velocity of the physics body
  149639. * @param impostor imposter to set the velocity on
  149640. * @param velocity velocity to set
  149641. */
  149642. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  149643. /**
  149644. * Sets the angular velocity of the physics body
  149645. * @param impostor imposter to set the velocity on
  149646. * @param velocity velocity to set
  149647. */
  149648. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  149649. /**
  149650. * gets the linear velocity
  149651. * @param impostor imposter to get linear velocity from
  149652. * @returns linear velocity
  149653. */
  149654. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  149655. /**
  149656. * gets the angular velocity
  149657. * @param impostor imposter to get angular velocity from
  149658. * @returns angular velocity
  149659. */
  149660. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  149661. /**
  149662. * Sets the mass of physics body
  149663. * @param impostor imposter to set the mass on
  149664. * @param mass mass to set
  149665. */
  149666. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  149667. /**
  149668. * Gets the mass of the physics body
  149669. * @param impostor imposter to get the mass from
  149670. * @returns mass
  149671. */
  149672. getBodyMass(impostor: PhysicsImpostor): number;
  149673. /**
  149674. * Gets friction of the impostor
  149675. * @param impostor impostor to get friction from
  149676. * @returns friction value
  149677. */
  149678. getBodyFriction(impostor: PhysicsImpostor): number;
  149679. /**
  149680. * Sets friction of the impostor
  149681. * @param impostor impostor to set friction on
  149682. * @param friction friction value
  149683. */
  149684. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  149685. /**
  149686. * Gets restitution of the impostor
  149687. * @param impostor impostor to get restitution from
  149688. * @returns restitution value
  149689. */
  149690. getBodyRestitution(impostor: PhysicsImpostor): number;
  149691. /**
  149692. * Sets resitution of the impostor
  149693. * @param impostor impostor to set resitution on
  149694. * @param restitution resitution value
  149695. */
  149696. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  149697. /**
  149698. * Gets pressure inside the impostor
  149699. * @param impostor impostor to get pressure from
  149700. * @returns pressure value
  149701. */
  149702. getBodyPressure(impostor: PhysicsImpostor): number;
  149703. /**
  149704. * Sets pressure inside a soft body impostor
  149705. * Cloth and rope must remain 0 pressure
  149706. * @param impostor impostor to set pressure on
  149707. * @param pressure pressure value
  149708. */
  149709. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  149710. /**
  149711. * Gets stiffness of the impostor
  149712. * @param impostor impostor to get stiffness from
  149713. * @returns pressure value
  149714. */
  149715. getBodyStiffness(impostor: PhysicsImpostor): number;
  149716. /**
  149717. * Sets stiffness of the impostor
  149718. * @param impostor impostor to set stiffness on
  149719. * @param stiffness stiffness value from 0 to 1
  149720. */
  149721. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  149722. /**
  149723. * Gets velocityIterations of the impostor
  149724. * @param impostor impostor to get velocity iterations from
  149725. * @returns velocityIterations value
  149726. */
  149727. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  149728. /**
  149729. * Sets velocityIterations of the impostor
  149730. * @param impostor impostor to set velocity iterations on
  149731. * @param velocityIterations velocityIterations value
  149732. */
  149733. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  149734. /**
  149735. * Gets positionIterations of the impostor
  149736. * @param impostor impostor to get position iterations from
  149737. * @returns positionIterations value
  149738. */
  149739. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  149740. /**
  149741. * Sets positionIterations of the impostor
  149742. * @param impostor impostor to set position on
  149743. * @param positionIterations positionIterations value
  149744. */
  149745. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  149746. /**
  149747. * Append an anchor to a cloth object
  149748. * @param impostor is the cloth impostor to add anchor to
  149749. * @param otherImpostor is the rigid impostor to anchor to
  149750. * @param width ratio across width from 0 to 1
  149751. * @param height ratio up height from 0 to 1
  149752. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  149753. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  149754. */
  149755. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  149756. /**
  149757. * Append an hook to a rope object
  149758. * @param impostor is the rope impostor to add hook to
  149759. * @param otherImpostor is the rigid impostor to hook to
  149760. * @param length ratio along the rope from 0 to 1
  149761. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  149762. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  149763. */
  149764. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  149765. /**
  149766. * Sleeps the physics body and stops it from being active
  149767. * @param impostor impostor to sleep
  149768. */
  149769. sleepBody(impostor: PhysicsImpostor): void;
  149770. /**
  149771. * Activates the physics body
  149772. * @param impostor impostor to activate
  149773. */
  149774. wakeUpBody(impostor: PhysicsImpostor): void;
  149775. /**
  149776. * Updates the distance parameters of the joint
  149777. * @param joint joint to update
  149778. * @param maxDistance maximum distance of the joint
  149779. * @param minDistance minimum distance of the joint
  149780. */
  149781. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  149782. /**
  149783. * Sets a motor on the joint
  149784. * @param joint joint to set motor on
  149785. * @param speed speed of the motor
  149786. * @param maxForce maximum force of the motor
  149787. * @param motorIndex index of the motor
  149788. */
  149789. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  149790. /**
  149791. * Sets the motors limit
  149792. * @param joint joint to set limit on
  149793. * @param upperLimit upper limit
  149794. * @param lowerLimit lower limit
  149795. */
  149796. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  149797. /**
  149798. * Syncs the position and rotation of a mesh with the impostor
  149799. * @param mesh mesh to sync
  149800. * @param impostor impostor to update the mesh with
  149801. */
  149802. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  149803. /**
  149804. * Gets the radius of the impostor
  149805. * @param impostor impostor to get radius from
  149806. * @returns the radius
  149807. */
  149808. getRadius(impostor: PhysicsImpostor): number;
  149809. /**
  149810. * Gets the box size of the impostor
  149811. * @param impostor impostor to get box size from
  149812. * @param result the resulting box size
  149813. */
  149814. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  149815. /**
  149816. * Disposes of the impostor
  149817. */
  149818. dispose(): void;
  149819. /**
  149820. * Does a raycast in the physics world
  149821. * @param from when should the ray start?
  149822. * @param to when should the ray end?
  149823. * @returns PhysicsRaycastResult
  149824. */
  149825. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  149826. }
  149827. }
  149828. declare module BABYLON {
  149829. interface AbstractScene {
  149830. /**
  149831. * The list of reflection probes added to the scene
  149832. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  149833. */
  149834. reflectionProbes: Array<ReflectionProbe>;
  149835. /**
  149836. * Removes the given reflection probe from this scene.
  149837. * @param toRemove The reflection probe to remove
  149838. * @returns The index of the removed reflection probe
  149839. */
  149840. removeReflectionProbe(toRemove: ReflectionProbe): number;
  149841. /**
  149842. * Adds the given reflection probe to this scene.
  149843. * @param newReflectionProbe The reflection probe to add
  149844. */
  149845. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  149846. }
  149847. /**
  149848. * Class used to generate realtime reflection / refraction cube textures
  149849. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  149850. */
  149851. export class ReflectionProbe {
  149852. /** defines the name of the probe */
  149853. name: string;
  149854. private _scene;
  149855. private _renderTargetTexture;
  149856. private _projectionMatrix;
  149857. private _viewMatrix;
  149858. private _target;
  149859. private _add;
  149860. private _attachedMesh;
  149861. private _invertYAxis;
  149862. /** Gets or sets probe position (center of the cube map) */
  149863. position: Vector3;
  149864. /**
  149865. * Creates a new reflection probe
  149866. * @param name defines the name of the probe
  149867. * @param size defines the texture resolution (for each face)
  149868. * @param scene defines the hosting scene
  149869. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  149870. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  149871. */
  149872. constructor(
  149873. /** defines the name of the probe */
  149874. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  149875. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  149876. get samples(): number;
  149877. set samples(value: number);
  149878. /** Gets or sets the refresh rate to use (on every frame by default) */
  149879. get refreshRate(): number;
  149880. set refreshRate(value: number);
  149881. /**
  149882. * Gets the hosting scene
  149883. * @returns a Scene
  149884. */
  149885. getScene(): Scene;
  149886. /** Gets the internal CubeTexture used to render to */
  149887. get cubeTexture(): RenderTargetTexture;
  149888. /** Gets the list of meshes to render */
  149889. get renderList(): Nullable<AbstractMesh[]>;
  149890. /**
  149891. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  149892. * @param mesh defines the mesh to attach to
  149893. */
  149894. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  149895. /**
  149896. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  149897. * @param renderingGroupId The rendering group id corresponding to its index
  149898. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  149899. */
  149900. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  149901. /**
  149902. * Clean all associated resources
  149903. */
  149904. dispose(): void;
  149905. /**
  149906. * Converts the reflection probe information to a readable string for debug purpose.
  149907. * @param fullDetails Supports for multiple levels of logging within scene loading
  149908. * @returns the human readable reflection probe info
  149909. */
  149910. toString(fullDetails?: boolean): string;
  149911. /**
  149912. * Get the class name of the relfection probe.
  149913. * @returns "ReflectionProbe"
  149914. */
  149915. getClassName(): string;
  149916. /**
  149917. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  149918. * @returns The JSON representation of the texture
  149919. */
  149920. serialize(): any;
  149921. /**
  149922. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  149923. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  149924. * @param scene Define the scene the parsed reflection probe should be instantiated in
  149925. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  149926. * @returns The parsed reflection probe if successful
  149927. */
  149928. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  149929. }
  149930. }
  149931. declare module BABYLON {
  149932. /** @hidden */
  149933. export var _BabylonLoaderRegistered: boolean;
  149934. /**
  149935. * Helps setting up some configuration for the babylon file loader.
  149936. */
  149937. export class BabylonFileLoaderConfiguration {
  149938. /**
  149939. * The loader does not allow injecting custom physix engine into the plugins.
  149940. * Unfortunately in ES6, we need to manually inject them into the plugin.
  149941. * So you could set this variable to your engine import to make it work.
  149942. */
  149943. static LoaderInjectedPhysicsEngine: any;
  149944. }
  149945. }
  149946. declare module BABYLON {
  149947. /**
  149948. * A material to use for fast depth-only rendering.
  149949. */
  149950. export class OcclusionMaterial extends ShaderMaterial {
  149951. constructor(name: string, scene: Scene);
  149952. }
  149953. }
  149954. declare module BABYLON {
  149955. /**
  149956. * The Physically based simple base material of BJS.
  149957. *
  149958. * This enables better naming and convention enforcements on top of the pbrMaterial.
  149959. * It is used as the base class for both the specGloss and metalRough conventions.
  149960. */
  149961. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  149962. /**
  149963. * Number of Simultaneous lights allowed on the material.
  149964. */
  149965. maxSimultaneousLights: number;
  149966. /**
  149967. * If sets to true, disables all the lights affecting the material.
  149968. */
  149969. disableLighting: boolean;
  149970. /**
  149971. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  149972. */
  149973. environmentTexture: BaseTexture;
  149974. /**
  149975. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  149976. */
  149977. invertNormalMapX: boolean;
  149978. /**
  149979. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  149980. */
  149981. invertNormalMapY: boolean;
  149982. /**
  149983. * Normal map used in the model.
  149984. */
  149985. normalTexture: BaseTexture;
  149986. /**
  149987. * Emissivie color used to self-illuminate the model.
  149988. */
  149989. emissiveColor: Color3;
  149990. /**
  149991. * Emissivie texture used to self-illuminate the model.
  149992. */
  149993. emissiveTexture: BaseTexture;
  149994. /**
  149995. * Occlusion Channel Strenght.
  149996. */
  149997. occlusionStrength: number;
  149998. /**
  149999. * Occlusion Texture of the material (adding extra occlusion effects).
  150000. */
  150001. occlusionTexture: BaseTexture;
  150002. /**
  150003. * Defines the alpha limits in alpha test mode.
  150004. */
  150005. alphaCutOff: number;
  150006. /**
  150007. * Gets the current double sided mode.
  150008. */
  150009. get doubleSided(): boolean;
  150010. /**
  150011. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  150012. */
  150013. set doubleSided(value: boolean);
  150014. /**
  150015. * Stores the pre-calculated light information of a mesh in a texture.
  150016. */
  150017. lightmapTexture: BaseTexture;
  150018. /**
  150019. * If true, the light map contains occlusion information instead of lighting info.
  150020. */
  150021. useLightmapAsShadowmap: boolean;
  150022. /**
  150023. * Instantiates a new PBRMaterial instance.
  150024. *
  150025. * @param name The material name
  150026. * @param scene The scene the material will be use in.
  150027. */
  150028. constructor(name: string, scene: Scene);
  150029. getClassName(): string;
  150030. }
  150031. }
  150032. declare module BABYLON {
  150033. /**
  150034. * The PBR material of BJS following the metal roughness convention.
  150035. *
  150036. * This fits to the PBR convention in the GLTF definition:
  150037. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  150038. */
  150039. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  150040. /**
  150041. * The base color has two different interpretations depending on the value of metalness.
  150042. * When the material is a metal, the base color is the specific measured reflectance value
  150043. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  150044. * of the material.
  150045. */
  150046. baseColor: Color3;
  150047. /**
  150048. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  150049. * well as opacity information in the alpha channel.
  150050. */
  150051. baseTexture: BaseTexture;
  150052. /**
  150053. * Specifies the metallic scalar value of the material.
  150054. * Can also be used to scale the metalness values of the metallic texture.
  150055. */
  150056. metallic: number;
  150057. /**
  150058. * Specifies the roughness scalar value of the material.
  150059. * Can also be used to scale the roughness values of the metallic texture.
  150060. */
  150061. roughness: number;
  150062. /**
  150063. * Texture containing both the metallic value in the B channel and the
  150064. * roughness value in the G channel to keep better precision.
  150065. */
  150066. metallicRoughnessTexture: BaseTexture;
  150067. /**
  150068. * Instantiates a new PBRMetalRoughnessMaterial instance.
  150069. *
  150070. * @param name The material name
  150071. * @param scene The scene the material will be use in.
  150072. */
  150073. constructor(name: string, scene: Scene);
  150074. /**
  150075. * Return the currrent class name of the material.
  150076. */
  150077. getClassName(): string;
  150078. /**
  150079. * Makes a duplicate of the current material.
  150080. * @param name - name to use for the new material.
  150081. */
  150082. clone(name: string): PBRMetallicRoughnessMaterial;
  150083. /**
  150084. * Serialize the material to a parsable JSON object.
  150085. */
  150086. serialize(): any;
  150087. /**
  150088. * Parses a JSON object correponding to the serialize function.
  150089. */
  150090. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  150091. }
  150092. }
  150093. declare module BABYLON {
  150094. /**
  150095. * The PBR material of BJS following the specular glossiness convention.
  150096. *
  150097. * This fits to the PBR convention in the GLTF definition:
  150098. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  150099. */
  150100. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  150101. /**
  150102. * Specifies the diffuse color of the material.
  150103. */
  150104. diffuseColor: Color3;
  150105. /**
  150106. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  150107. * channel.
  150108. */
  150109. diffuseTexture: BaseTexture;
  150110. /**
  150111. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  150112. */
  150113. specularColor: Color3;
  150114. /**
  150115. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  150116. */
  150117. glossiness: number;
  150118. /**
  150119. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  150120. */
  150121. specularGlossinessTexture: BaseTexture;
  150122. /**
  150123. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  150124. */
  150125. get useMicroSurfaceFromReflectivityMapAlpha(): boolean;
  150126. /**
  150127. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  150128. *
  150129. * @param name The material name
  150130. * @param scene The scene the material will be use in.
  150131. */
  150132. constructor(name: string, scene: Scene);
  150133. /**
  150134. * Return the currrent class name of the material.
  150135. */
  150136. getClassName(): string;
  150137. /**
  150138. * Makes a duplicate of the current material.
  150139. * @param name - name to use for the new material.
  150140. */
  150141. clone(name: string): PBRSpecularGlossinessMaterial;
  150142. /**
  150143. * Serialize the material to a parsable JSON object.
  150144. */
  150145. serialize(): any;
  150146. /**
  150147. * Parses a JSON object correponding to the serialize function.
  150148. */
  150149. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  150150. }
  150151. }
  150152. declare module BABYLON {
  150153. /**
  150154. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  150155. * It can help converting any input color in a desired output one. This can then be used to create effects
  150156. * from sepia, black and white to sixties or futuristic rendering...
  150157. *
  150158. * The only supported format is currently 3dl.
  150159. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  150160. */
  150161. export class ColorGradingTexture extends BaseTexture {
  150162. /**
  150163. * The texture URL.
  150164. */
  150165. url: string;
  150166. /**
  150167. * Empty line regex stored for GC.
  150168. */
  150169. private static _noneEmptyLineRegex;
  150170. private _textureMatrix;
  150171. private _onLoad;
  150172. /**
  150173. * Instantiates a ColorGradingTexture from the following parameters.
  150174. *
  150175. * @param url The location of the color gradind data (currently only supporting 3dl)
  150176. * @param sceneOrEngine The scene or engine the texture will be used in
  150177. * @param onLoad defines a callback triggered when the texture has been loaded
  150178. */
  150179. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  150180. /**
  150181. * Fires the onload event from the constructor if requested.
  150182. */
  150183. private _triggerOnLoad;
  150184. /**
  150185. * Returns the texture matrix used in most of the material.
  150186. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  150187. */
  150188. getTextureMatrix(): Matrix;
  150189. /**
  150190. * Occurs when the file being loaded is a .3dl LUT file.
  150191. */
  150192. private load3dlTexture;
  150193. /**
  150194. * Starts the loading process of the texture.
  150195. */
  150196. private loadTexture;
  150197. /**
  150198. * Clones the color gradind texture.
  150199. */
  150200. clone(): ColorGradingTexture;
  150201. /**
  150202. * Called during delayed load for textures.
  150203. */
  150204. delayLoad(): void;
  150205. /**
  150206. * Parses a color grading texture serialized by Babylon.
  150207. * @param parsedTexture The texture information being parsedTexture
  150208. * @param scene The scene to load the texture in
  150209. * @param rootUrl The root url of the data assets to load
  150210. * @return A color gradind texture
  150211. */
  150212. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  150213. /**
  150214. * Serializes the LUT texture to json format.
  150215. */
  150216. serialize(): any;
  150217. }
  150218. }
  150219. declare module BABYLON {
  150220. /**
  150221. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  150222. */
  150223. export class EquiRectangularCubeTexture extends BaseTexture {
  150224. /** The six faces of the cube. */
  150225. private static _FacesMapping;
  150226. private _noMipmap;
  150227. private _onLoad;
  150228. private _onError;
  150229. /** The size of the cubemap. */
  150230. private _size;
  150231. /** The buffer of the image. */
  150232. private _buffer;
  150233. /** The width of the input image. */
  150234. private _width;
  150235. /** The height of the input image. */
  150236. private _height;
  150237. /** The URL to the image. */
  150238. url: string;
  150239. /**
  150240. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  150241. * @param url The location of the image
  150242. * @param scene The scene the texture will be used in
  150243. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  150244. * @param noMipmap Forces to not generate the mipmap if true
  150245. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  150246. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  150247. * @param onLoad — defines a callback called when texture is loaded
  150248. * @param onError — defines a callback called if there is an error
  150249. */
  150250. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  150251. /**
  150252. * Load the image data, by putting the image on a canvas and extracting its buffer.
  150253. */
  150254. private loadImage;
  150255. /**
  150256. * Convert the image buffer into a cubemap and create a CubeTexture.
  150257. */
  150258. private loadTexture;
  150259. /**
  150260. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  150261. * @param buffer The ArrayBuffer that should be converted.
  150262. * @returns The buffer as Float32Array.
  150263. */
  150264. private getFloat32ArrayFromArrayBuffer;
  150265. /**
  150266. * Get the current class name of the texture useful for serialization or dynamic coding.
  150267. * @returns "EquiRectangularCubeTexture"
  150268. */
  150269. getClassName(): string;
  150270. /**
  150271. * Create a clone of the current EquiRectangularCubeTexture and return it.
  150272. * @returns A clone of the current EquiRectangularCubeTexture.
  150273. */
  150274. clone(): EquiRectangularCubeTexture;
  150275. }
  150276. }
  150277. declare module BABYLON {
  150278. /**
  150279. * Defines the options related to the creation of an HtmlElementTexture
  150280. */
  150281. export interface IHtmlElementTextureOptions {
  150282. /**
  150283. * Defines wether mip maps should be created or not.
  150284. */
  150285. generateMipMaps?: boolean;
  150286. /**
  150287. * Defines the sampling mode of the texture.
  150288. */
  150289. samplingMode?: number;
  150290. /**
  150291. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  150292. */
  150293. engine: Nullable<ThinEngine>;
  150294. /**
  150295. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  150296. */
  150297. scene: Nullable<Scene>;
  150298. }
  150299. /**
  150300. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  150301. * To be as efficient as possible depending on your constraints nothing aside the first upload
  150302. * is automatically managed.
  150303. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  150304. * in your application.
  150305. *
  150306. * As the update is not automatic, you need to call them manually.
  150307. */
  150308. export class HtmlElementTexture extends BaseTexture {
  150309. /**
  150310. * The texture URL.
  150311. */
  150312. element: HTMLVideoElement | HTMLCanvasElement;
  150313. private static readonly DefaultOptions;
  150314. private _textureMatrix;
  150315. private _isVideo;
  150316. private _generateMipMaps;
  150317. private _samplingMode;
  150318. /**
  150319. * Instantiates a HtmlElementTexture from the following parameters.
  150320. *
  150321. * @param name Defines the name of the texture
  150322. * @param element Defines the video or canvas the texture is filled with
  150323. * @param options Defines the other none mandatory texture creation options
  150324. */
  150325. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  150326. private _createInternalTexture;
  150327. /**
  150328. * Returns the texture matrix used in most of the material.
  150329. */
  150330. getTextureMatrix(): Matrix;
  150331. /**
  150332. * Updates the content of the texture.
  150333. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  150334. */
  150335. update(invertY?: Nullable<boolean>): void;
  150336. }
  150337. }
  150338. declare module BABYLON {
  150339. /**
  150340. * Based on jsTGALoader - Javascript loader for TGA file
  150341. * By Vincent Thibault
  150342. * @see http://blog.robrowser.com/javascript-tga-loader.html
  150343. */
  150344. export class TGATools {
  150345. private static _TYPE_INDEXED;
  150346. private static _TYPE_RGB;
  150347. private static _TYPE_GREY;
  150348. private static _TYPE_RLE_INDEXED;
  150349. private static _TYPE_RLE_RGB;
  150350. private static _TYPE_RLE_GREY;
  150351. private static _ORIGIN_MASK;
  150352. private static _ORIGIN_SHIFT;
  150353. private static _ORIGIN_BL;
  150354. private static _ORIGIN_BR;
  150355. private static _ORIGIN_UL;
  150356. private static _ORIGIN_UR;
  150357. /**
  150358. * Gets the header of a TGA file
  150359. * @param data defines the TGA data
  150360. * @returns the header
  150361. */
  150362. static GetTGAHeader(data: Uint8Array): any;
  150363. /**
  150364. * Uploads TGA content to a Babylon Texture
  150365. * @hidden
  150366. */
  150367. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  150368. /** @hidden */
  150369. 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;
  150370. /** @hidden */
  150371. 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;
  150372. /** @hidden */
  150373. 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;
  150374. /** @hidden */
  150375. 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;
  150376. /** @hidden */
  150377. 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;
  150378. /** @hidden */
  150379. 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;
  150380. }
  150381. }
  150382. declare module BABYLON {
  150383. /**
  150384. * Implementation of the TGA Texture Loader.
  150385. * @hidden
  150386. */
  150387. export class _TGATextureLoader implements IInternalTextureLoader {
  150388. /**
  150389. * Defines wether the loader supports cascade loading the different faces.
  150390. */
  150391. readonly supportCascades: boolean;
  150392. /**
  150393. * This returns if the loader support the current file information.
  150394. * @param extension defines the file extension of the file being loaded
  150395. * @returns true if the loader can load the specified file
  150396. */
  150397. canLoad(extension: string): boolean;
  150398. /**
  150399. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  150400. * @param data contains the texture data
  150401. * @param texture defines the BabylonJS internal texture
  150402. * @param createPolynomials will be true if polynomials have been requested
  150403. * @param onLoad defines the callback to trigger once the texture is ready
  150404. * @param onError defines the callback to trigger in case of error
  150405. */
  150406. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  150407. /**
  150408. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  150409. * @param data contains the texture data
  150410. * @param texture defines the BabylonJS internal texture
  150411. * @param callback defines the method to call once ready to upload
  150412. */
  150413. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  150414. }
  150415. }
  150416. declare module BABYLON {
  150417. /**
  150418. * Info about the .basis files
  150419. */
  150420. class BasisFileInfo {
  150421. /**
  150422. * If the file has alpha
  150423. */
  150424. hasAlpha: boolean;
  150425. /**
  150426. * Info about each image of the basis file
  150427. */
  150428. images: Array<{
  150429. levels: Array<{
  150430. width: number;
  150431. height: number;
  150432. transcodedPixels: ArrayBufferView;
  150433. }>;
  150434. }>;
  150435. }
  150436. /**
  150437. * Result of transcoding a basis file
  150438. */
  150439. class TranscodeResult {
  150440. /**
  150441. * Info about the .basis file
  150442. */
  150443. fileInfo: BasisFileInfo;
  150444. /**
  150445. * Format to use when loading the file
  150446. */
  150447. format: number;
  150448. }
  150449. /**
  150450. * Configuration options for the Basis transcoder
  150451. */
  150452. export class BasisTranscodeConfiguration {
  150453. /**
  150454. * Supported compression formats used to determine the supported output format of the transcoder
  150455. */
  150456. supportedCompressionFormats?: {
  150457. /**
  150458. * etc1 compression format
  150459. */
  150460. etc1?: boolean;
  150461. /**
  150462. * s3tc compression format
  150463. */
  150464. s3tc?: boolean;
  150465. /**
  150466. * pvrtc compression format
  150467. */
  150468. pvrtc?: boolean;
  150469. /**
  150470. * etc2 compression format
  150471. */
  150472. etc2?: boolean;
  150473. };
  150474. /**
  150475. * If mipmap levels should be loaded for transcoded images (Default: true)
  150476. */
  150477. loadMipmapLevels?: boolean;
  150478. /**
  150479. * Index of a single image to load (Default: all images)
  150480. */
  150481. loadSingleImage?: number;
  150482. }
  150483. /**
  150484. * Used to load .Basis files
  150485. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  150486. */
  150487. export class BasisTools {
  150488. private static _IgnoreSupportedFormats;
  150489. /**
  150490. * URL to use when loading the basis transcoder
  150491. */
  150492. static JSModuleURL: string;
  150493. /**
  150494. * URL to use when loading the wasm module for the transcoder
  150495. */
  150496. static WasmModuleURL: string;
  150497. /**
  150498. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  150499. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  150500. * @returns internal format corresponding to the Basis format
  150501. */
  150502. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  150503. private static _WorkerPromise;
  150504. private static _Worker;
  150505. private static _actionId;
  150506. private static _CreateWorkerAsync;
  150507. /**
  150508. * Transcodes a loaded image file to compressed pixel data
  150509. * @param data image data to transcode
  150510. * @param config configuration options for the transcoding
  150511. * @returns a promise resulting in the transcoded image
  150512. */
  150513. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  150514. /**
  150515. * Loads a texture from the transcode result
  150516. * @param texture texture load to
  150517. * @param transcodeResult the result of transcoding the basis file to load from
  150518. */
  150519. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  150520. }
  150521. }
  150522. declare module BABYLON {
  150523. /**
  150524. * Loader for .basis file format
  150525. */
  150526. export class _BasisTextureLoader implements IInternalTextureLoader {
  150527. /**
  150528. * Defines whether the loader supports cascade loading the different faces.
  150529. */
  150530. readonly supportCascades: boolean;
  150531. /**
  150532. * This returns if the loader support the current file information.
  150533. * @param extension defines the file extension of the file being loaded
  150534. * @returns true if the loader can load the specified file
  150535. */
  150536. canLoad(extension: string): boolean;
  150537. /**
  150538. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  150539. * @param data contains the texture data
  150540. * @param texture defines the BabylonJS internal texture
  150541. * @param createPolynomials will be true if polynomials have been requested
  150542. * @param onLoad defines the callback to trigger once the texture is ready
  150543. * @param onError defines the callback to trigger in case of error
  150544. */
  150545. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  150546. /**
  150547. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  150548. * @param data contains the texture data
  150549. * @param texture defines the BabylonJS internal texture
  150550. * @param callback defines the method to call once ready to upload
  150551. */
  150552. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  150553. }
  150554. }
  150555. declare module BABYLON {
  150556. /**
  150557. * Defines the basic options interface of a TexturePacker Frame
  150558. */
  150559. export interface ITexturePackerFrame {
  150560. /**
  150561. * The frame ID
  150562. */
  150563. id: number;
  150564. /**
  150565. * The frames Scale
  150566. */
  150567. scale: Vector2;
  150568. /**
  150569. * The Frames offset
  150570. */
  150571. offset: Vector2;
  150572. }
  150573. /**
  150574. * This is a support class for frame Data on texture packer sets.
  150575. */
  150576. export class TexturePackerFrame implements ITexturePackerFrame {
  150577. /**
  150578. * The frame ID
  150579. */
  150580. id: number;
  150581. /**
  150582. * The frames Scale
  150583. */
  150584. scale: Vector2;
  150585. /**
  150586. * The Frames offset
  150587. */
  150588. offset: Vector2;
  150589. /**
  150590. * Initializes a texture package frame.
  150591. * @param id The numerical frame identifier
  150592. * @param scale Scalar Vector2 for UV frame
  150593. * @param offset Vector2 for the frame position in UV units.
  150594. * @returns TexturePackerFrame
  150595. */
  150596. constructor(id: number, scale: Vector2, offset: Vector2);
  150597. }
  150598. }
  150599. declare module BABYLON {
  150600. /**
  150601. * Defines the basic options interface of a TexturePacker
  150602. */
  150603. export interface ITexturePackerOptions {
  150604. /**
  150605. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  150606. */
  150607. map?: string[];
  150608. /**
  150609. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  150610. */
  150611. uvsIn?: string;
  150612. /**
  150613. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  150614. */
  150615. uvsOut?: string;
  150616. /**
  150617. * number representing the layout style. Defaults to LAYOUT_STRIP
  150618. */
  150619. layout?: number;
  150620. /**
  150621. * number of columns if using custom column count layout(2). This defaults to 4.
  150622. */
  150623. colnum?: number;
  150624. /**
  150625. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  150626. */
  150627. updateInputMeshes?: boolean;
  150628. /**
  150629. * boolean flag to dispose all the source textures. Defaults to true.
  150630. */
  150631. disposeSources?: boolean;
  150632. /**
  150633. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  150634. */
  150635. fillBlanks?: boolean;
  150636. /**
  150637. * string value representing the context fill style color. Defaults to 'black'.
  150638. */
  150639. customFillColor?: string;
  150640. /**
  150641. * Width and Height Value of each Frame in the TexturePacker Sets
  150642. */
  150643. frameSize?: number;
  150644. /**
  150645. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  150646. */
  150647. paddingRatio?: number;
  150648. /**
  150649. * Number that declares the fill method for the padding gutter.
  150650. */
  150651. paddingMode?: number;
  150652. /**
  150653. * If in SUBUV_COLOR padding mode what color to use.
  150654. */
  150655. paddingColor?: Color3 | Color4;
  150656. }
  150657. /**
  150658. * Defines the basic interface of a TexturePacker JSON File
  150659. */
  150660. export interface ITexturePackerJSON {
  150661. /**
  150662. * The frame ID
  150663. */
  150664. name: string;
  150665. /**
  150666. * The base64 channel data
  150667. */
  150668. sets: any;
  150669. /**
  150670. * The options of the Packer
  150671. */
  150672. options: ITexturePackerOptions;
  150673. /**
  150674. * The frame data of the Packer
  150675. */
  150676. frames: Array<number>;
  150677. }
  150678. /**
  150679. * This is a support class that generates a series of packed texture sets.
  150680. * @see https://doc.babylonjs.com/babylon101/materials
  150681. */
  150682. export class TexturePacker {
  150683. /** Packer Layout Constant 0 */
  150684. static readonly LAYOUT_STRIP: number;
  150685. /** Packer Layout Constant 1 */
  150686. static readonly LAYOUT_POWER2: number;
  150687. /** Packer Layout Constant 2 */
  150688. static readonly LAYOUT_COLNUM: number;
  150689. /** Packer Layout Constant 0 */
  150690. static readonly SUBUV_WRAP: number;
  150691. /** Packer Layout Constant 1 */
  150692. static readonly SUBUV_EXTEND: number;
  150693. /** Packer Layout Constant 2 */
  150694. static readonly SUBUV_COLOR: number;
  150695. /** The Name of the Texture Package */
  150696. name: string;
  150697. /** The scene scope of the TexturePacker */
  150698. scene: Scene;
  150699. /** The Meshes to target */
  150700. meshes: AbstractMesh[];
  150701. /** Arguments passed with the Constructor */
  150702. options: ITexturePackerOptions;
  150703. /** The promise that is started upon initialization */
  150704. promise: Nullable<Promise<TexturePacker | string>>;
  150705. /** The Container object for the channel sets that are generated */
  150706. sets: object;
  150707. /** The Container array for the frames that are generated */
  150708. frames: TexturePackerFrame[];
  150709. /** The expected number of textures the system is parsing. */
  150710. private _expecting;
  150711. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  150712. private _paddingValue;
  150713. /**
  150714. * Initializes a texture package series from an array of meshes or a single mesh.
  150715. * @param name The name of the package
  150716. * @param meshes The target meshes to compose the package from
  150717. * @param options The arguments that texture packer should follow while building.
  150718. * @param scene The scene which the textures are scoped to.
  150719. * @returns TexturePacker
  150720. */
  150721. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  150722. /**
  150723. * Starts the package process
  150724. * @param resolve The promises resolution function
  150725. * @returns TexturePacker
  150726. */
  150727. private _createFrames;
  150728. /**
  150729. * Calculates the Size of the Channel Sets
  150730. * @returns Vector2
  150731. */
  150732. private _calculateSize;
  150733. /**
  150734. * Calculates the UV data for the frames.
  150735. * @param baseSize the base frameSize
  150736. * @param padding the base frame padding
  150737. * @param dtSize size of the Dynamic Texture for that channel
  150738. * @param dtUnits is 1/dtSize
  150739. * @param update flag to update the input meshes
  150740. */
  150741. private _calculateMeshUVFrames;
  150742. /**
  150743. * Calculates the frames Offset.
  150744. * @param index of the frame
  150745. * @returns Vector2
  150746. */
  150747. private _getFrameOffset;
  150748. /**
  150749. * Updates a Mesh to the frame data
  150750. * @param mesh that is the target
  150751. * @param frameID or the frame index
  150752. */
  150753. private _updateMeshUV;
  150754. /**
  150755. * Updates a Meshes materials to use the texture packer channels
  150756. * @param m is the mesh to target
  150757. * @param force all channels on the packer to be set.
  150758. */
  150759. private _updateTextureReferences;
  150760. /**
  150761. * Public method to set a Mesh to a frame
  150762. * @param m that is the target
  150763. * @param frameID or the frame index
  150764. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  150765. */
  150766. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  150767. /**
  150768. * Starts the async promise to compile the texture packer.
  150769. * @returns Promise<void>
  150770. */
  150771. processAsync(): Promise<void>;
  150772. /**
  150773. * Disposes all textures associated with this packer
  150774. */
  150775. dispose(): void;
  150776. /**
  150777. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  150778. * @param imageType is the image type to use.
  150779. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  150780. */
  150781. download(imageType?: string, quality?: number): void;
  150782. /**
  150783. * Public method to load a texturePacker JSON file.
  150784. * @param data of the JSON file in string format.
  150785. */
  150786. updateFromJSON(data: string): void;
  150787. }
  150788. }
  150789. declare module BABYLON {
  150790. /**
  150791. * 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.
  150792. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  150793. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  150794. */
  150795. export class CustomProceduralTexture extends ProceduralTexture {
  150796. private _animate;
  150797. private _time;
  150798. private _config;
  150799. private _texturePath;
  150800. /**
  150801. * Instantiates a new Custom Procedural Texture.
  150802. * 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.
  150803. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  150804. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  150805. * @param name Define the name of the texture
  150806. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  150807. * @param size Define the size of the texture to create
  150808. * @param scene Define the scene the texture belongs to
  150809. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  150810. * @param generateMipMaps Define if the texture should creates mip maps or not
  150811. */
  150812. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  150813. private _loadJson;
  150814. /**
  150815. * Is the texture ready to be used ? (rendered at least once)
  150816. * @returns true if ready, otherwise, false.
  150817. */
  150818. isReady(): boolean;
  150819. /**
  150820. * Render the texture to its associated render target.
  150821. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  150822. */
  150823. render(useCameraPostProcess?: boolean): void;
  150824. /**
  150825. * Update the list of dependant textures samplers in the shader.
  150826. */
  150827. updateTextures(): void;
  150828. /**
  150829. * Update the uniform values of the procedural texture in the shader.
  150830. */
  150831. updateShaderUniforms(): void;
  150832. /**
  150833. * Define if the texture animates or not.
  150834. */
  150835. get animate(): boolean;
  150836. set animate(value: boolean);
  150837. }
  150838. }
  150839. declare module BABYLON {
  150840. /** @hidden */
  150841. export var noisePixelShader: {
  150842. name: string;
  150843. shader: string;
  150844. };
  150845. }
  150846. declare module BABYLON {
  150847. /**
  150848. * Class used to generate noise procedural textures
  150849. */
  150850. export class NoiseProceduralTexture extends ProceduralTexture {
  150851. /** Gets or sets the start time (default is 0) */
  150852. time: number;
  150853. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  150854. brightness: number;
  150855. /** Defines the number of octaves to process */
  150856. octaves: number;
  150857. /** Defines the level of persistence (0.8 by default) */
  150858. persistence: number;
  150859. /** Gets or sets animation speed factor (default is 1) */
  150860. animationSpeedFactor: number;
  150861. /**
  150862. * Creates a new NoiseProceduralTexture
  150863. * @param name defines the name fo the texture
  150864. * @param size defines the size of the texture (default is 256)
  150865. * @param scene defines the hosting scene
  150866. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  150867. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  150868. */
  150869. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  150870. private _updateShaderUniforms;
  150871. protected _getDefines(): string;
  150872. /** Generate the current state of the procedural texture */
  150873. render(useCameraPostProcess?: boolean): void;
  150874. /**
  150875. * Serializes this noise procedural texture
  150876. * @returns a serialized noise procedural texture object
  150877. */
  150878. serialize(): any;
  150879. /**
  150880. * Clone the texture.
  150881. * @returns the cloned texture
  150882. */
  150883. clone(): NoiseProceduralTexture;
  150884. /**
  150885. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  150886. * @param parsedTexture defines parsed texture data
  150887. * @param scene defines the current scene
  150888. * @param rootUrl defines the root URL containing noise procedural texture information
  150889. * @returns a parsed NoiseProceduralTexture
  150890. */
  150891. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  150892. }
  150893. }
  150894. declare module BABYLON {
  150895. /**
  150896. * Raw cube texture where the raw buffers are passed in
  150897. */
  150898. export class RawCubeTexture extends CubeTexture {
  150899. /**
  150900. * Creates a cube texture where the raw buffers are passed in.
  150901. * @param scene defines the scene the texture is attached to
  150902. * @param data defines the array of data to use to create each face
  150903. * @param size defines the size of the textures
  150904. * @param format defines the format of the data
  150905. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  150906. * @param generateMipMaps defines if the engine should generate the mip levels
  150907. * @param invertY defines if data must be stored with Y axis inverted
  150908. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  150909. * @param compression defines the compression used (null by default)
  150910. */
  150911. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  150912. /**
  150913. * Updates the raw cube texture.
  150914. * @param data defines the data to store
  150915. * @param format defines the data format
  150916. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  150917. * @param invertY defines if data must be stored with Y axis inverted
  150918. * @param compression defines the compression used (null by default)
  150919. * @param level defines which level of the texture to update
  150920. */
  150921. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  150922. /**
  150923. * Updates a raw cube texture with RGBD encoded data.
  150924. * @param data defines the array of data [mipmap][face] to use to create each face
  150925. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  150926. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  150927. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  150928. * @returns a promsie that resolves when the operation is complete
  150929. */
  150930. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  150931. /**
  150932. * Clones the raw cube texture.
  150933. * @return a new cube texture
  150934. */
  150935. clone(): CubeTexture;
  150936. /** @hidden */
  150937. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  150938. }
  150939. }
  150940. declare module BABYLON {
  150941. /**
  150942. * Class used to store 2D array textures containing user data
  150943. */
  150944. export class RawTexture2DArray extends Texture {
  150945. /** Gets or sets the texture format to use */
  150946. format: number;
  150947. /**
  150948. * Create a new RawTexture2DArray
  150949. * @param data defines the data of the texture
  150950. * @param width defines the width of the texture
  150951. * @param height defines the height of the texture
  150952. * @param depth defines the number of layers of the texture
  150953. * @param format defines the texture format to use
  150954. * @param scene defines the hosting scene
  150955. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  150956. * @param invertY defines if texture must be stored with Y axis inverted
  150957. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  150958. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  150959. */
  150960. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  150961. /** Gets or sets the texture format to use */
  150962. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  150963. /**
  150964. * Update the texture with new data
  150965. * @param data defines the data to store in the texture
  150966. */
  150967. update(data: ArrayBufferView): void;
  150968. }
  150969. }
  150970. declare module BABYLON {
  150971. /**
  150972. * Class used to store 3D textures containing user data
  150973. */
  150974. export class RawTexture3D extends Texture {
  150975. /** Gets or sets the texture format to use */
  150976. format: number;
  150977. /**
  150978. * Create a new RawTexture3D
  150979. * @param data defines the data of the texture
  150980. * @param width defines the width of the texture
  150981. * @param height defines the height of the texture
  150982. * @param depth defines the depth of the texture
  150983. * @param format defines the texture format to use
  150984. * @param scene defines the hosting scene
  150985. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  150986. * @param invertY defines if texture must be stored with Y axis inverted
  150987. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  150988. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  150989. */
  150990. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  150991. /** Gets or sets the texture format to use */
  150992. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  150993. /**
  150994. * Update the texture with new data
  150995. * @param data defines the data to store in the texture
  150996. */
  150997. update(data: ArrayBufferView): void;
  150998. }
  150999. }
  151000. declare module BABYLON {
  151001. /**
  151002. * Creates a refraction texture used by refraction channel of the standard material.
  151003. * It is like a mirror but to see through a material.
  151004. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  151005. */
  151006. export class RefractionTexture extends RenderTargetTexture {
  151007. /**
  151008. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  151009. * 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.
  151010. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  151011. */
  151012. refractionPlane: Plane;
  151013. /**
  151014. * Define how deep under the surface we should see.
  151015. */
  151016. depth: number;
  151017. /**
  151018. * Creates a refraction texture used by refraction channel of the standard material.
  151019. * It is like a mirror but to see through a material.
  151020. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  151021. * @param name Define the texture name
  151022. * @param size Define the size of the underlying texture
  151023. * @param scene Define the scene the refraction belongs to
  151024. * @param generateMipMaps Define if we need to generate mips level for the refraction
  151025. */
  151026. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  151027. /**
  151028. * Clone the refraction texture.
  151029. * @returns the cloned texture
  151030. */
  151031. clone(): RefractionTexture;
  151032. /**
  151033. * Serialize the texture to a JSON representation you could use in Parse later on
  151034. * @returns the serialized JSON representation
  151035. */
  151036. serialize(): any;
  151037. }
  151038. }
  151039. declare module BABYLON {
  151040. /**
  151041. * Block used to add support for vertex skinning (bones)
  151042. */
  151043. export class BonesBlock extends NodeMaterialBlock {
  151044. /**
  151045. * Creates a new BonesBlock
  151046. * @param name defines the block name
  151047. */
  151048. constructor(name: string);
  151049. /**
  151050. * Initialize the block and prepare the context for build
  151051. * @param state defines the state that will be used for the build
  151052. */
  151053. initialize(state: NodeMaterialBuildState): void;
  151054. /**
  151055. * Gets the current class name
  151056. * @returns the class name
  151057. */
  151058. getClassName(): string;
  151059. /**
  151060. * Gets the matrix indices input component
  151061. */
  151062. get matricesIndices(): NodeMaterialConnectionPoint;
  151063. /**
  151064. * Gets the matrix weights input component
  151065. */
  151066. get matricesWeights(): NodeMaterialConnectionPoint;
  151067. /**
  151068. * Gets the extra matrix indices input component
  151069. */
  151070. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  151071. /**
  151072. * Gets the extra matrix weights input component
  151073. */
  151074. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  151075. /**
  151076. * Gets the world input component
  151077. */
  151078. get world(): NodeMaterialConnectionPoint;
  151079. /**
  151080. * Gets the output component
  151081. */
  151082. get output(): NodeMaterialConnectionPoint;
  151083. autoConfigure(material: NodeMaterial): void;
  151084. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  151085. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  151086. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  151087. protected _buildBlock(state: NodeMaterialBuildState): this;
  151088. }
  151089. }
  151090. declare module BABYLON {
  151091. /**
  151092. * Block used to add support for instances
  151093. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  151094. */
  151095. export class InstancesBlock extends NodeMaterialBlock {
  151096. /**
  151097. * Creates a new InstancesBlock
  151098. * @param name defines the block name
  151099. */
  151100. constructor(name: string);
  151101. /**
  151102. * Gets the current class name
  151103. * @returns the class name
  151104. */
  151105. getClassName(): string;
  151106. /**
  151107. * Gets the first world row input component
  151108. */
  151109. get world0(): NodeMaterialConnectionPoint;
  151110. /**
  151111. * Gets the second world row input component
  151112. */
  151113. get world1(): NodeMaterialConnectionPoint;
  151114. /**
  151115. * Gets the third world row input component
  151116. */
  151117. get world2(): NodeMaterialConnectionPoint;
  151118. /**
  151119. * Gets the forth world row input component
  151120. */
  151121. get world3(): NodeMaterialConnectionPoint;
  151122. /**
  151123. * Gets the world input component
  151124. */
  151125. get world(): NodeMaterialConnectionPoint;
  151126. /**
  151127. * Gets the output component
  151128. */
  151129. get output(): NodeMaterialConnectionPoint;
  151130. /**
  151131. * Gets the isntanceID component
  151132. */
  151133. get instanceID(): NodeMaterialConnectionPoint;
  151134. autoConfigure(material: NodeMaterial): void;
  151135. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  151136. protected _buildBlock(state: NodeMaterialBuildState): this;
  151137. }
  151138. }
  151139. declare module BABYLON {
  151140. /**
  151141. * Block used to add morph targets support to vertex shader
  151142. */
  151143. export class MorphTargetsBlock extends NodeMaterialBlock {
  151144. private _repeatableContentAnchor;
  151145. /**
  151146. * Create a new MorphTargetsBlock
  151147. * @param name defines the block name
  151148. */
  151149. constructor(name: string);
  151150. /**
  151151. * Gets the current class name
  151152. * @returns the class name
  151153. */
  151154. getClassName(): string;
  151155. /**
  151156. * Gets the position input component
  151157. */
  151158. get position(): NodeMaterialConnectionPoint;
  151159. /**
  151160. * Gets the normal input component
  151161. */
  151162. get normal(): NodeMaterialConnectionPoint;
  151163. /**
  151164. * Gets the tangent input component
  151165. */
  151166. get tangent(): NodeMaterialConnectionPoint;
  151167. /**
  151168. * Gets the tangent input component
  151169. */
  151170. get uv(): NodeMaterialConnectionPoint;
  151171. /**
  151172. * Gets the position output component
  151173. */
  151174. get positionOutput(): NodeMaterialConnectionPoint;
  151175. /**
  151176. * Gets the normal output component
  151177. */
  151178. get normalOutput(): NodeMaterialConnectionPoint;
  151179. /**
  151180. * Gets the tangent output component
  151181. */
  151182. get tangentOutput(): NodeMaterialConnectionPoint;
  151183. /**
  151184. * Gets the tangent output component
  151185. */
  151186. get uvOutput(): NodeMaterialConnectionPoint;
  151187. initialize(state: NodeMaterialBuildState): void;
  151188. autoConfigure(material: NodeMaterial): void;
  151189. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  151190. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  151191. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  151192. protected _buildBlock(state: NodeMaterialBuildState): this;
  151193. }
  151194. }
  151195. declare module BABYLON {
  151196. /**
  151197. * Block used to get data information from a light
  151198. */
  151199. export class LightInformationBlock extends NodeMaterialBlock {
  151200. private _lightDataUniformName;
  151201. private _lightColorUniformName;
  151202. private _lightTypeDefineName;
  151203. /**
  151204. * Gets or sets the light associated with this block
  151205. */
  151206. light: Nullable<Light>;
  151207. /**
  151208. * Creates a new LightInformationBlock
  151209. * @param name defines the block name
  151210. */
  151211. constructor(name: string);
  151212. /**
  151213. * Gets the current class name
  151214. * @returns the class name
  151215. */
  151216. getClassName(): string;
  151217. /**
  151218. * Gets the world position input component
  151219. */
  151220. get worldPosition(): NodeMaterialConnectionPoint;
  151221. /**
  151222. * Gets the direction output component
  151223. */
  151224. get direction(): NodeMaterialConnectionPoint;
  151225. /**
  151226. * Gets the direction output component
  151227. */
  151228. get color(): NodeMaterialConnectionPoint;
  151229. /**
  151230. * Gets the direction output component
  151231. */
  151232. get intensity(): NodeMaterialConnectionPoint;
  151233. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  151234. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  151235. protected _buildBlock(state: NodeMaterialBuildState): this;
  151236. serialize(): any;
  151237. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  151238. }
  151239. }
  151240. declare module BABYLON {
  151241. /**
  151242. * Block used to add image processing support to fragment shader
  151243. */
  151244. export class ImageProcessingBlock extends NodeMaterialBlock {
  151245. /**
  151246. * Create a new ImageProcessingBlock
  151247. * @param name defines the block name
  151248. */
  151249. constructor(name: string);
  151250. /**
  151251. * Gets the current class name
  151252. * @returns the class name
  151253. */
  151254. getClassName(): string;
  151255. /**
  151256. * Gets the color input component
  151257. */
  151258. get color(): NodeMaterialConnectionPoint;
  151259. /**
  151260. * Gets the output component
  151261. */
  151262. get output(): NodeMaterialConnectionPoint;
  151263. /**
  151264. * Initialize the block and prepare the context for build
  151265. * @param state defines the state that will be used for the build
  151266. */
  151267. initialize(state: NodeMaterialBuildState): void;
  151268. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  151269. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  151270. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  151271. protected _buildBlock(state: NodeMaterialBuildState): this;
  151272. }
  151273. }
  151274. declare module BABYLON {
  151275. /**
  151276. * Block used to pertub normals based on a normal map
  151277. */
  151278. export class PerturbNormalBlock extends NodeMaterialBlock {
  151279. private _tangentSpaceParameterName;
  151280. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  151281. invertX: boolean;
  151282. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  151283. invertY: boolean;
  151284. /**
  151285. * Create a new PerturbNormalBlock
  151286. * @param name defines the block name
  151287. */
  151288. constructor(name: string);
  151289. /**
  151290. * Gets the current class name
  151291. * @returns the class name
  151292. */
  151293. getClassName(): string;
  151294. /**
  151295. * Gets the world position input component
  151296. */
  151297. get worldPosition(): NodeMaterialConnectionPoint;
  151298. /**
  151299. * Gets the world normal input component
  151300. */
  151301. get worldNormal(): NodeMaterialConnectionPoint;
  151302. /**
  151303. * Gets the world tangent input component
  151304. */
  151305. get worldTangent(): NodeMaterialConnectionPoint;
  151306. /**
  151307. * Gets the uv input component
  151308. */
  151309. get uv(): NodeMaterialConnectionPoint;
  151310. /**
  151311. * Gets the normal map color input component
  151312. */
  151313. get normalMapColor(): NodeMaterialConnectionPoint;
  151314. /**
  151315. * Gets the strength input component
  151316. */
  151317. get strength(): NodeMaterialConnectionPoint;
  151318. /**
  151319. * Gets the output component
  151320. */
  151321. get output(): NodeMaterialConnectionPoint;
  151322. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  151323. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  151324. autoConfigure(material: NodeMaterial): void;
  151325. protected _buildBlock(state: NodeMaterialBuildState): this;
  151326. protected _dumpPropertiesCode(): string;
  151327. serialize(): any;
  151328. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  151329. }
  151330. }
  151331. declare module BABYLON {
  151332. /**
  151333. * Block used to discard a pixel if a value is smaller than a cutoff
  151334. */
  151335. export class DiscardBlock extends NodeMaterialBlock {
  151336. /**
  151337. * Create a new DiscardBlock
  151338. * @param name defines the block name
  151339. */
  151340. constructor(name: string);
  151341. /**
  151342. * Gets the current class name
  151343. * @returns the class name
  151344. */
  151345. getClassName(): string;
  151346. /**
  151347. * Gets the color input component
  151348. */
  151349. get value(): NodeMaterialConnectionPoint;
  151350. /**
  151351. * Gets the cutoff input component
  151352. */
  151353. get cutoff(): NodeMaterialConnectionPoint;
  151354. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  151355. }
  151356. }
  151357. declare module BABYLON {
  151358. /**
  151359. * Block used to test if the fragment shader is front facing
  151360. */
  151361. export class FrontFacingBlock extends NodeMaterialBlock {
  151362. /**
  151363. * Creates a new FrontFacingBlock
  151364. * @param name defines the block name
  151365. */
  151366. constructor(name: string);
  151367. /**
  151368. * Gets the current class name
  151369. * @returns the class name
  151370. */
  151371. getClassName(): string;
  151372. /**
  151373. * Gets the output component
  151374. */
  151375. get output(): NodeMaterialConnectionPoint;
  151376. protected _buildBlock(state: NodeMaterialBuildState): this;
  151377. }
  151378. }
  151379. declare module BABYLON {
  151380. /**
  151381. * Block used to get the derivative value on x and y of a given input
  151382. */
  151383. export class DerivativeBlock extends NodeMaterialBlock {
  151384. /**
  151385. * Create a new DerivativeBlock
  151386. * @param name defines the block name
  151387. */
  151388. constructor(name: string);
  151389. /**
  151390. * Gets the current class name
  151391. * @returns the class name
  151392. */
  151393. getClassName(): string;
  151394. /**
  151395. * Gets the input component
  151396. */
  151397. get input(): NodeMaterialConnectionPoint;
  151398. /**
  151399. * Gets the derivative output on x
  151400. */
  151401. get dx(): NodeMaterialConnectionPoint;
  151402. /**
  151403. * Gets the derivative output on y
  151404. */
  151405. get dy(): NodeMaterialConnectionPoint;
  151406. protected _buildBlock(state: NodeMaterialBuildState): this;
  151407. }
  151408. }
  151409. declare module BABYLON {
  151410. /**
  151411. * Block used to make gl_FragCoord available
  151412. */
  151413. export class FragCoordBlock extends NodeMaterialBlock {
  151414. /**
  151415. * Creates a new FragCoordBlock
  151416. * @param name defines the block name
  151417. */
  151418. constructor(name: string);
  151419. /**
  151420. * Gets the current class name
  151421. * @returns the class name
  151422. */
  151423. getClassName(): string;
  151424. /**
  151425. * Gets the xy component
  151426. */
  151427. get xy(): NodeMaterialConnectionPoint;
  151428. /**
  151429. * Gets the xyz component
  151430. */
  151431. get xyz(): NodeMaterialConnectionPoint;
  151432. /**
  151433. * Gets the xyzw component
  151434. */
  151435. get xyzw(): NodeMaterialConnectionPoint;
  151436. /**
  151437. * Gets the x component
  151438. */
  151439. get x(): NodeMaterialConnectionPoint;
  151440. /**
  151441. * Gets the y component
  151442. */
  151443. get y(): NodeMaterialConnectionPoint;
  151444. /**
  151445. * Gets the z component
  151446. */
  151447. get z(): NodeMaterialConnectionPoint;
  151448. /**
  151449. * Gets the w component
  151450. */
  151451. get output(): NodeMaterialConnectionPoint;
  151452. protected writeOutputs(state: NodeMaterialBuildState): string;
  151453. protected _buildBlock(state: NodeMaterialBuildState): this;
  151454. }
  151455. }
  151456. declare module BABYLON {
  151457. /**
  151458. * Block used to get the screen sizes
  151459. */
  151460. export class ScreenSizeBlock extends NodeMaterialBlock {
  151461. private _varName;
  151462. private _scene;
  151463. /**
  151464. * Creates a new ScreenSizeBlock
  151465. * @param name defines the block name
  151466. */
  151467. constructor(name: string);
  151468. /**
  151469. * Gets the current class name
  151470. * @returns the class name
  151471. */
  151472. getClassName(): string;
  151473. /**
  151474. * Gets the xy component
  151475. */
  151476. get xy(): NodeMaterialConnectionPoint;
  151477. /**
  151478. * Gets the x component
  151479. */
  151480. get x(): NodeMaterialConnectionPoint;
  151481. /**
  151482. * Gets the y component
  151483. */
  151484. get y(): NodeMaterialConnectionPoint;
  151485. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  151486. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  151487. protected _buildBlock(state: NodeMaterialBuildState): this;
  151488. }
  151489. }
  151490. declare module BABYLON {
  151491. /**
  151492. * Block used to add support for scene fog
  151493. */
  151494. export class FogBlock extends NodeMaterialBlock {
  151495. private _fogDistanceName;
  151496. private _fogParameters;
  151497. /**
  151498. * Create a new FogBlock
  151499. * @param name defines the block name
  151500. */
  151501. constructor(name: string);
  151502. /**
  151503. * Gets the current class name
  151504. * @returns the class name
  151505. */
  151506. getClassName(): string;
  151507. /**
  151508. * Gets the world position input component
  151509. */
  151510. get worldPosition(): NodeMaterialConnectionPoint;
  151511. /**
  151512. * Gets the view input component
  151513. */
  151514. get view(): NodeMaterialConnectionPoint;
  151515. /**
  151516. * Gets the color input component
  151517. */
  151518. get input(): NodeMaterialConnectionPoint;
  151519. /**
  151520. * Gets the fog color input component
  151521. */
  151522. get fogColor(): NodeMaterialConnectionPoint;
  151523. /**
  151524. * Gets the output component
  151525. */
  151526. get output(): NodeMaterialConnectionPoint;
  151527. autoConfigure(material: NodeMaterial): void;
  151528. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  151529. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  151530. protected _buildBlock(state: NodeMaterialBuildState): this;
  151531. }
  151532. }
  151533. declare module BABYLON {
  151534. /**
  151535. * Block used to add light in the fragment shader
  151536. */
  151537. export class LightBlock extends NodeMaterialBlock {
  151538. private _lightId;
  151539. /**
  151540. * Gets or sets the light associated with this block
  151541. */
  151542. light: Nullable<Light>;
  151543. /**
  151544. * Create a new LightBlock
  151545. * @param name defines the block name
  151546. */
  151547. constructor(name: string);
  151548. /**
  151549. * Gets the current class name
  151550. * @returns the class name
  151551. */
  151552. getClassName(): string;
  151553. /**
  151554. * Gets the world position input component
  151555. */
  151556. get worldPosition(): NodeMaterialConnectionPoint;
  151557. /**
  151558. * Gets the world normal input component
  151559. */
  151560. get worldNormal(): NodeMaterialConnectionPoint;
  151561. /**
  151562. * Gets the camera (or eye) position component
  151563. */
  151564. get cameraPosition(): NodeMaterialConnectionPoint;
  151565. /**
  151566. * Gets the glossiness component
  151567. */
  151568. get glossiness(): NodeMaterialConnectionPoint;
  151569. /**
  151570. * Gets the glossinness power component
  151571. */
  151572. get glossPower(): NodeMaterialConnectionPoint;
  151573. /**
  151574. * Gets the diffuse color component
  151575. */
  151576. get diffuseColor(): NodeMaterialConnectionPoint;
  151577. /**
  151578. * Gets the specular color component
  151579. */
  151580. get specularColor(): NodeMaterialConnectionPoint;
  151581. /**
  151582. * Gets the view matrix component
  151583. */
  151584. get view(): NodeMaterialConnectionPoint;
  151585. /**
  151586. * Gets the diffuse output component
  151587. */
  151588. get diffuseOutput(): NodeMaterialConnectionPoint;
  151589. /**
  151590. * Gets the specular output component
  151591. */
  151592. get specularOutput(): NodeMaterialConnectionPoint;
  151593. /**
  151594. * Gets the shadow output component
  151595. */
  151596. get shadow(): NodeMaterialConnectionPoint;
  151597. autoConfigure(material: NodeMaterial): void;
  151598. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  151599. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  151600. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  151601. private _injectVertexCode;
  151602. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  151603. serialize(): any;
  151604. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  151605. }
  151606. }
  151607. declare module BABYLON {
  151608. /**
  151609. * Block used to read a reflection texture from a sampler
  151610. */
  151611. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  151612. /**
  151613. * Create a new ReflectionTextureBlock
  151614. * @param name defines the block name
  151615. */
  151616. constructor(name: string);
  151617. /**
  151618. * Gets the current class name
  151619. * @returns the class name
  151620. */
  151621. getClassName(): string;
  151622. /**
  151623. * Gets the world position input component
  151624. */
  151625. get position(): NodeMaterialConnectionPoint;
  151626. /**
  151627. * Gets the world position input component
  151628. */
  151629. get worldPosition(): NodeMaterialConnectionPoint;
  151630. /**
  151631. * Gets the world normal input component
  151632. */
  151633. get worldNormal(): NodeMaterialConnectionPoint;
  151634. /**
  151635. * Gets the world input component
  151636. */
  151637. get world(): NodeMaterialConnectionPoint;
  151638. /**
  151639. * Gets the camera (or eye) position component
  151640. */
  151641. get cameraPosition(): NodeMaterialConnectionPoint;
  151642. /**
  151643. * Gets the view input component
  151644. */
  151645. get view(): NodeMaterialConnectionPoint;
  151646. /**
  151647. * Gets the rgb output component
  151648. */
  151649. get rgb(): NodeMaterialConnectionPoint;
  151650. /**
  151651. * Gets the rgba output component
  151652. */
  151653. get rgba(): NodeMaterialConnectionPoint;
  151654. /**
  151655. * Gets the r output component
  151656. */
  151657. get r(): NodeMaterialConnectionPoint;
  151658. /**
  151659. * Gets the g output component
  151660. */
  151661. get g(): NodeMaterialConnectionPoint;
  151662. /**
  151663. * Gets the b output component
  151664. */
  151665. get b(): NodeMaterialConnectionPoint;
  151666. /**
  151667. * Gets the a output component
  151668. */
  151669. get a(): NodeMaterialConnectionPoint;
  151670. autoConfigure(material: NodeMaterial): void;
  151671. protected _buildBlock(state: NodeMaterialBuildState): this;
  151672. }
  151673. }
  151674. declare module BABYLON {
  151675. /**
  151676. * Block used to add 2 vectors
  151677. */
  151678. export class AddBlock extends NodeMaterialBlock {
  151679. /**
  151680. * Creates a new AddBlock
  151681. * @param name defines the block name
  151682. */
  151683. constructor(name: string);
  151684. /**
  151685. * Gets the current class name
  151686. * @returns the class name
  151687. */
  151688. getClassName(): string;
  151689. /**
  151690. * Gets the left operand input component
  151691. */
  151692. get left(): NodeMaterialConnectionPoint;
  151693. /**
  151694. * Gets the right operand input component
  151695. */
  151696. get right(): NodeMaterialConnectionPoint;
  151697. /**
  151698. * Gets the output component
  151699. */
  151700. get output(): NodeMaterialConnectionPoint;
  151701. protected _buildBlock(state: NodeMaterialBuildState): this;
  151702. }
  151703. }
  151704. declare module BABYLON {
  151705. /**
  151706. * Block used to scale a vector by a float
  151707. */
  151708. export class ScaleBlock extends NodeMaterialBlock {
  151709. /**
  151710. * Creates a new ScaleBlock
  151711. * @param name defines the block name
  151712. */
  151713. constructor(name: string);
  151714. /**
  151715. * Gets the current class name
  151716. * @returns the class name
  151717. */
  151718. getClassName(): string;
  151719. /**
  151720. * Gets the input component
  151721. */
  151722. get input(): NodeMaterialConnectionPoint;
  151723. /**
  151724. * Gets the factor input component
  151725. */
  151726. get factor(): NodeMaterialConnectionPoint;
  151727. /**
  151728. * Gets the output component
  151729. */
  151730. get output(): NodeMaterialConnectionPoint;
  151731. protected _buildBlock(state: NodeMaterialBuildState): this;
  151732. }
  151733. }
  151734. declare module BABYLON {
  151735. /**
  151736. * Block used to clamp a float
  151737. */
  151738. export class ClampBlock extends NodeMaterialBlock {
  151739. /** Gets or sets the minimum range */
  151740. minimum: number;
  151741. /** Gets or sets the maximum range */
  151742. maximum: number;
  151743. /**
  151744. * Creates a new ClampBlock
  151745. * @param name defines the block name
  151746. */
  151747. constructor(name: string);
  151748. /**
  151749. * Gets the current class name
  151750. * @returns the class name
  151751. */
  151752. getClassName(): string;
  151753. /**
  151754. * Gets the value input component
  151755. */
  151756. get value(): NodeMaterialConnectionPoint;
  151757. /**
  151758. * Gets the output component
  151759. */
  151760. get output(): NodeMaterialConnectionPoint;
  151761. protected _buildBlock(state: NodeMaterialBuildState): this;
  151762. protected _dumpPropertiesCode(): string;
  151763. serialize(): any;
  151764. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  151765. }
  151766. }
  151767. declare module BABYLON {
  151768. /**
  151769. * Block used to apply a cross product between 2 vectors
  151770. */
  151771. export class CrossBlock extends NodeMaterialBlock {
  151772. /**
  151773. * Creates a new CrossBlock
  151774. * @param name defines the block name
  151775. */
  151776. constructor(name: string);
  151777. /**
  151778. * Gets the current class name
  151779. * @returns the class name
  151780. */
  151781. getClassName(): string;
  151782. /**
  151783. * Gets the left operand input component
  151784. */
  151785. get left(): NodeMaterialConnectionPoint;
  151786. /**
  151787. * Gets the right operand input component
  151788. */
  151789. get right(): NodeMaterialConnectionPoint;
  151790. /**
  151791. * Gets the output component
  151792. */
  151793. get output(): NodeMaterialConnectionPoint;
  151794. protected _buildBlock(state: NodeMaterialBuildState): this;
  151795. }
  151796. }
  151797. declare module BABYLON {
  151798. /**
  151799. * Block used to apply a dot product between 2 vectors
  151800. */
  151801. export class DotBlock extends NodeMaterialBlock {
  151802. /**
  151803. * Creates a new DotBlock
  151804. * @param name defines the block name
  151805. */
  151806. constructor(name: string);
  151807. /**
  151808. * Gets the current class name
  151809. * @returns the class name
  151810. */
  151811. getClassName(): string;
  151812. /**
  151813. * Gets the left operand input component
  151814. */
  151815. get left(): NodeMaterialConnectionPoint;
  151816. /**
  151817. * Gets the right operand input component
  151818. */
  151819. get right(): NodeMaterialConnectionPoint;
  151820. /**
  151821. * Gets the output component
  151822. */
  151823. get output(): NodeMaterialConnectionPoint;
  151824. protected _buildBlock(state: NodeMaterialBuildState): this;
  151825. }
  151826. }
  151827. declare module BABYLON {
  151828. /**
  151829. * Block used to normalize a vector
  151830. */
  151831. export class NormalizeBlock extends NodeMaterialBlock {
  151832. /**
  151833. * Creates a new NormalizeBlock
  151834. * @param name defines the block name
  151835. */
  151836. constructor(name: string);
  151837. /**
  151838. * Gets the current class name
  151839. * @returns the class name
  151840. */
  151841. getClassName(): string;
  151842. /**
  151843. * Gets the input component
  151844. */
  151845. get input(): NodeMaterialConnectionPoint;
  151846. /**
  151847. * Gets the output component
  151848. */
  151849. get output(): NodeMaterialConnectionPoint;
  151850. protected _buildBlock(state: NodeMaterialBuildState): this;
  151851. }
  151852. }
  151853. declare module BABYLON {
  151854. /**
  151855. * Block used to create a Color3/4 out of individual inputs (one for each component)
  151856. */
  151857. export class ColorMergerBlock extends NodeMaterialBlock {
  151858. /**
  151859. * Create a new ColorMergerBlock
  151860. * @param name defines the block name
  151861. */
  151862. constructor(name: string);
  151863. /**
  151864. * Gets the current class name
  151865. * @returns the class name
  151866. */
  151867. getClassName(): string;
  151868. /**
  151869. * Gets the rgb component (input)
  151870. */
  151871. get rgbIn(): NodeMaterialConnectionPoint;
  151872. /**
  151873. * Gets the r component (input)
  151874. */
  151875. get r(): NodeMaterialConnectionPoint;
  151876. /**
  151877. * Gets the g component (input)
  151878. */
  151879. get g(): NodeMaterialConnectionPoint;
  151880. /**
  151881. * Gets the b component (input)
  151882. */
  151883. get b(): NodeMaterialConnectionPoint;
  151884. /**
  151885. * Gets the a component (input)
  151886. */
  151887. get a(): NodeMaterialConnectionPoint;
  151888. /**
  151889. * Gets the rgba component (output)
  151890. */
  151891. get rgba(): NodeMaterialConnectionPoint;
  151892. /**
  151893. * Gets the rgb component (output)
  151894. */
  151895. get rgbOut(): NodeMaterialConnectionPoint;
  151896. /**
  151897. * Gets the rgb component (output)
  151898. * @deprecated Please use rgbOut instead.
  151899. */
  151900. get rgb(): NodeMaterialConnectionPoint;
  151901. protected _buildBlock(state: NodeMaterialBuildState): this;
  151902. }
  151903. }
  151904. declare module BABYLON {
  151905. /**
  151906. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  151907. */
  151908. export class VectorSplitterBlock extends NodeMaterialBlock {
  151909. /**
  151910. * Create a new VectorSplitterBlock
  151911. * @param name defines the block name
  151912. */
  151913. constructor(name: string);
  151914. /**
  151915. * Gets the current class name
  151916. * @returns the class name
  151917. */
  151918. getClassName(): string;
  151919. /**
  151920. * Gets the xyzw component (input)
  151921. */
  151922. get xyzw(): NodeMaterialConnectionPoint;
  151923. /**
  151924. * Gets the xyz component (input)
  151925. */
  151926. get xyzIn(): NodeMaterialConnectionPoint;
  151927. /**
  151928. * Gets the xy component (input)
  151929. */
  151930. get xyIn(): NodeMaterialConnectionPoint;
  151931. /**
  151932. * Gets the xyz component (output)
  151933. */
  151934. get xyzOut(): NodeMaterialConnectionPoint;
  151935. /**
  151936. * Gets the xy component (output)
  151937. */
  151938. get xyOut(): NodeMaterialConnectionPoint;
  151939. /**
  151940. * Gets the x component (output)
  151941. */
  151942. get x(): NodeMaterialConnectionPoint;
  151943. /**
  151944. * Gets the y component (output)
  151945. */
  151946. get y(): NodeMaterialConnectionPoint;
  151947. /**
  151948. * Gets the z component (output)
  151949. */
  151950. get z(): NodeMaterialConnectionPoint;
  151951. /**
  151952. * Gets the w component (output)
  151953. */
  151954. get w(): NodeMaterialConnectionPoint;
  151955. protected _inputRename(name: string): string;
  151956. protected _outputRename(name: string): string;
  151957. protected _buildBlock(state: NodeMaterialBuildState): this;
  151958. }
  151959. }
  151960. declare module BABYLON {
  151961. /**
  151962. * Block used to lerp between 2 values
  151963. */
  151964. export class LerpBlock extends NodeMaterialBlock {
  151965. /**
  151966. * Creates a new LerpBlock
  151967. * @param name defines the block name
  151968. */
  151969. constructor(name: string);
  151970. /**
  151971. * Gets the current class name
  151972. * @returns the class name
  151973. */
  151974. getClassName(): string;
  151975. /**
  151976. * Gets the left operand input component
  151977. */
  151978. get left(): NodeMaterialConnectionPoint;
  151979. /**
  151980. * Gets the right operand input component
  151981. */
  151982. get right(): NodeMaterialConnectionPoint;
  151983. /**
  151984. * Gets the gradient operand input component
  151985. */
  151986. get gradient(): NodeMaterialConnectionPoint;
  151987. /**
  151988. * Gets the output component
  151989. */
  151990. get output(): NodeMaterialConnectionPoint;
  151991. protected _buildBlock(state: NodeMaterialBuildState): this;
  151992. }
  151993. }
  151994. declare module BABYLON {
  151995. /**
  151996. * Block used to divide 2 vectors
  151997. */
  151998. export class DivideBlock extends NodeMaterialBlock {
  151999. /**
  152000. * Creates a new DivideBlock
  152001. * @param name defines the block name
  152002. */
  152003. constructor(name: string);
  152004. /**
  152005. * Gets the current class name
  152006. * @returns the class name
  152007. */
  152008. getClassName(): string;
  152009. /**
  152010. * Gets the left operand input component
  152011. */
  152012. get left(): NodeMaterialConnectionPoint;
  152013. /**
  152014. * Gets the right operand input component
  152015. */
  152016. get right(): NodeMaterialConnectionPoint;
  152017. /**
  152018. * Gets the output component
  152019. */
  152020. get output(): NodeMaterialConnectionPoint;
  152021. protected _buildBlock(state: NodeMaterialBuildState): this;
  152022. }
  152023. }
  152024. declare module BABYLON {
  152025. /**
  152026. * Block used to subtract 2 vectors
  152027. */
  152028. export class SubtractBlock extends NodeMaterialBlock {
  152029. /**
  152030. * Creates a new SubtractBlock
  152031. * @param name defines the block name
  152032. */
  152033. constructor(name: string);
  152034. /**
  152035. * Gets the current class name
  152036. * @returns the class name
  152037. */
  152038. getClassName(): string;
  152039. /**
  152040. * Gets the left operand input component
  152041. */
  152042. get left(): NodeMaterialConnectionPoint;
  152043. /**
  152044. * Gets the right operand input component
  152045. */
  152046. get right(): NodeMaterialConnectionPoint;
  152047. /**
  152048. * Gets the output component
  152049. */
  152050. get output(): NodeMaterialConnectionPoint;
  152051. protected _buildBlock(state: NodeMaterialBuildState): this;
  152052. }
  152053. }
  152054. declare module BABYLON {
  152055. /**
  152056. * Block used to step a value
  152057. */
  152058. export class StepBlock extends NodeMaterialBlock {
  152059. /**
  152060. * Creates a new StepBlock
  152061. * @param name defines the block name
  152062. */
  152063. constructor(name: string);
  152064. /**
  152065. * Gets the current class name
  152066. * @returns the class name
  152067. */
  152068. getClassName(): string;
  152069. /**
  152070. * Gets the value operand input component
  152071. */
  152072. get value(): NodeMaterialConnectionPoint;
  152073. /**
  152074. * Gets the edge operand input component
  152075. */
  152076. get edge(): NodeMaterialConnectionPoint;
  152077. /**
  152078. * Gets the output component
  152079. */
  152080. get output(): NodeMaterialConnectionPoint;
  152081. protected _buildBlock(state: NodeMaterialBuildState): this;
  152082. }
  152083. }
  152084. declare module BABYLON {
  152085. /**
  152086. * Block used to get the opposite (1 - x) of a value
  152087. */
  152088. export class OneMinusBlock extends NodeMaterialBlock {
  152089. /**
  152090. * Creates a new OneMinusBlock
  152091. * @param name defines the block name
  152092. */
  152093. constructor(name: string);
  152094. /**
  152095. * Gets the current class name
  152096. * @returns the class name
  152097. */
  152098. getClassName(): string;
  152099. /**
  152100. * Gets the input component
  152101. */
  152102. get input(): NodeMaterialConnectionPoint;
  152103. /**
  152104. * Gets the output component
  152105. */
  152106. get output(): NodeMaterialConnectionPoint;
  152107. protected _buildBlock(state: NodeMaterialBuildState): this;
  152108. }
  152109. }
  152110. declare module BABYLON {
  152111. /**
  152112. * Block used to get the view direction
  152113. */
  152114. export class ViewDirectionBlock extends NodeMaterialBlock {
  152115. /**
  152116. * Creates a new ViewDirectionBlock
  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 position component
  152127. */
  152128. get worldPosition(): NodeMaterialConnectionPoint;
  152129. /**
  152130. * Gets the camera position component
  152131. */
  152132. get cameraPosition(): NodeMaterialConnectionPoint;
  152133. /**
  152134. * Gets the output component
  152135. */
  152136. get output(): NodeMaterialConnectionPoint;
  152137. autoConfigure(material: NodeMaterial): void;
  152138. protected _buildBlock(state: NodeMaterialBuildState): this;
  152139. }
  152140. }
  152141. declare module BABYLON {
  152142. /**
  152143. * Block used to compute fresnel value
  152144. */
  152145. export class FresnelBlock extends NodeMaterialBlock {
  152146. /**
  152147. * Create a new FresnelBlock
  152148. * @param name defines the block name
  152149. */
  152150. constructor(name: string);
  152151. /**
  152152. * Gets the current class name
  152153. * @returns the class name
  152154. */
  152155. getClassName(): string;
  152156. /**
  152157. * Gets the world normal input component
  152158. */
  152159. get worldNormal(): NodeMaterialConnectionPoint;
  152160. /**
  152161. * Gets the view direction input component
  152162. */
  152163. get viewDirection(): NodeMaterialConnectionPoint;
  152164. /**
  152165. * Gets the bias input component
  152166. */
  152167. get bias(): NodeMaterialConnectionPoint;
  152168. /**
  152169. * Gets the camera (or eye) position component
  152170. */
  152171. get power(): NodeMaterialConnectionPoint;
  152172. /**
  152173. * Gets the fresnel output component
  152174. */
  152175. get fresnel(): NodeMaterialConnectionPoint;
  152176. autoConfigure(material: NodeMaterial): void;
  152177. protected _buildBlock(state: NodeMaterialBuildState): this;
  152178. }
  152179. }
  152180. declare module BABYLON {
  152181. /**
  152182. * Block used to get the max of 2 values
  152183. */
  152184. export class MaxBlock extends NodeMaterialBlock {
  152185. /**
  152186. * Creates a new MaxBlock
  152187. * @param name defines the block name
  152188. */
  152189. constructor(name: string);
  152190. /**
  152191. * Gets the current class name
  152192. * @returns the class name
  152193. */
  152194. getClassName(): string;
  152195. /**
  152196. * Gets the left operand input component
  152197. */
  152198. get left(): NodeMaterialConnectionPoint;
  152199. /**
  152200. * Gets the right operand input component
  152201. */
  152202. get right(): NodeMaterialConnectionPoint;
  152203. /**
  152204. * Gets the output component
  152205. */
  152206. get output(): NodeMaterialConnectionPoint;
  152207. protected _buildBlock(state: NodeMaterialBuildState): this;
  152208. }
  152209. }
  152210. declare module BABYLON {
  152211. /**
  152212. * Block used to get the min of 2 values
  152213. */
  152214. export class MinBlock extends NodeMaterialBlock {
  152215. /**
  152216. * Creates a new MinBlock
  152217. * @param name defines the block name
  152218. */
  152219. constructor(name: string);
  152220. /**
  152221. * Gets the current class name
  152222. * @returns the class name
  152223. */
  152224. getClassName(): string;
  152225. /**
  152226. * Gets the left operand input component
  152227. */
  152228. get left(): NodeMaterialConnectionPoint;
  152229. /**
  152230. * Gets the right operand input component
  152231. */
  152232. get right(): NodeMaterialConnectionPoint;
  152233. /**
  152234. * Gets the output component
  152235. */
  152236. get output(): NodeMaterialConnectionPoint;
  152237. protected _buildBlock(state: NodeMaterialBuildState): this;
  152238. }
  152239. }
  152240. declare module BABYLON {
  152241. /**
  152242. * Block used to get the distance between 2 values
  152243. */
  152244. export class DistanceBlock extends NodeMaterialBlock {
  152245. /**
  152246. * Creates a new DistanceBlock
  152247. * @param name defines the block name
  152248. */
  152249. constructor(name: string);
  152250. /**
  152251. * Gets the current class name
  152252. * @returns the class name
  152253. */
  152254. getClassName(): string;
  152255. /**
  152256. * Gets the left operand input component
  152257. */
  152258. get left(): NodeMaterialConnectionPoint;
  152259. /**
  152260. * Gets the right operand input component
  152261. */
  152262. get right(): NodeMaterialConnectionPoint;
  152263. /**
  152264. * Gets the output component
  152265. */
  152266. get output(): NodeMaterialConnectionPoint;
  152267. protected _buildBlock(state: NodeMaterialBuildState): this;
  152268. }
  152269. }
  152270. declare module BABYLON {
  152271. /**
  152272. * Block used to get the length of a vector
  152273. */
  152274. export class LengthBlock extends NodeMaterialBlock {
  152275. /**
  152276. * Creates a new LengthBlock
  152277. * @param name defines the block name
  152278. */
  152279. constructor(name: string);
  152280. /**
  152281. * Gets the current class name
  152282. * @returns the class name
  152283. */
  152284. getClassName(): string;
  152285. /**
  152286. * Gets the value input component
  152287. */
  152288. get value(): NodeMaterialConnectionPoint;
  152289. /**
  152290. * Gets the output component
  152291. */
  152292. get output(): NodeMaterialConnectionPoint;
  152293. protected _buildBlock(state: NodeMaterialBuildState): this;
  152294. }
  152295. }
  152296. declare module BABYLON {
  152297. /**
  152298. * Block used to get negative version of a value (i.e. x * -1)
  152299. */
  152300. export class NegateBlock extends NodeMaterialBlock {
  152301. /**
  152302. * Creates a new NegateBlock
  152303. * @param name defines the block name
  152304. */
  152305. constructor(name: string);
  152306. /**
  152307. * Gets the current class name
  152308. * @returns the class name
  152309. */
  152310. getClassName(): string;
  152311. /**
  152312. * Gets the value input component
  152313. */
  152314. get value(): NodeMaterialConnectionPoint;
  152315. /**
  152316. * Gets the output component
  152317. */
  152318. get output(): NodeMaterialConnectionPoint;
  152319. protected _buildBlock(state: NodeMaterialBuildState): this;
  152320. }
  152321. }
  152322. declare module BABYLON {
  152323. /**
  152324. * Block used to get the value of the first parameter raised to the power of the second
  152325. */
  152326. export class PowBlock extends NodeMaterialBlock {
  152327. /**
  152328. * Creates a new PowBlock
  152329. * @param name defines the block name
  152330. */
  152331. constructor(name: string);
  152332. /**
  152333. * Gets the current class name
  152334. * @returns the class name
  152335. */
  152336. getClassName(): string;
  152337. /**
  152338. * Gets the value operand input component
  152339. */
  152340. get value(): NodeMaterialConnectionPoint;
  152341. /**
  152342. * Gets the power operand input component
  152343. */
  152344. get power(): NodeMaterialConnectionPoint;
  152345. /**
  152346. * Gets the output component
  152347. */
  152348. get output(): NodeMaterialConnectionPoint;
  152349. protected _buildBlock(state: NodeMaterialBuildState): this;
  152350. }
  152351. }
  152352. declare module BABYLON {
  152353. /**
  152354. * Block used to get a random number
  152355. */
  152356. export class RandomNumberBlock extends NodeMaterialBlock {
  152357. /**
  152358. * Creates a new RandomNumberBlock
  152359. * @param name defines the block name
  152360. */
  152361. constructor(name: string);
  152362. /**
  152363. * Gets the current class name
  152364. * @returns the class name
  152365. */
  152366. getClassName(): string;
  152367. /**
  152368. * Gets the seed input component
  152369. */
  152370. get seed(): NodeMaterialConnectionPoint;
  152371. /**
  152372. * Gets the output component
  152373. */
  152374. get output(): NodeMaterialConnectionPoint;
  152375. protected _buildBlock(state: NodeMaterialBuildState): this;
  152376. }
  152377. }
  152378. declare module BABYLON {
  152379. /**
  152380. * Block used to compute arc tangent of 2 values
  152381. */
  152382. export class ArcTan2Block extends NodeMaterialBlock {
  152383. /**
  152384. * Creates a new ArcTan2Block
  152385. * @param name defines the block name
  152386. */
  152387. constructor(name: string);
  152388. /**
  152389. * Gets the current class name
  152390. * @returns the class name
  152391. */
  152392. getClassName(): string;
  152393. /**
  152394. * Gets the x operand input component
  152395. */
  152396. get x(): NodeMaterialConnectionPoint;
  152397. /**
  152398. * Gets the y operand input component
  152399. */
  152400. get y(): NodeMaterialConnectionPoint;
  152401. /**
  152402. * Gets the output component
  152403. */
  152404. get output(): NodeMaterialConnectionPoint;
  152405. protected _buildBlock(state: NodeMaterialBuildState): this;
  152406. }
  152407. }
  152408. declare module BABYLON {
  152409. /**
  152410. * Block used to smooth step a value
  152411. */
  152412. export class SmoothStepBlock extends NodeMaterialBlock {
  152413. /**
  152414. * Creates a new SmoothStepBlock
  152415. * @param name defines the block name
  152416. */
  152417. constructor(name: string);
  152418. /**
  152419. * Gets the current class name
  152420. * @returns the class name
  152421. */
  152422. getClassName(): string;
  152423. /**
  152424. * Gets the value operand input component
  152425. */
  152426. get value(): NodeMaterialConnectionPoint;
  152427. /**
  152428. * Gets the first edge operand input component
  152429. */
  152430. get edge0(): NodeMaterialConnectionPoint;
  152431. /**
  152432. * Gets the second edge operand input component
  152433. */
  152434. get edge1(): NodeMaterialConnectionPoint;
  152435. /**
  152436. * Gets the output component
  152437. */
  152438. get output(): NodeMaterialConnectionPoint;
  152439. protected _buildBlock(state: NodeMaterialBuildState): this;
  152440. }
  152441. }
  152442. declare module BABYLON {
  152443. /**
  152444. * Block used to get the reciprocal (1 / x) of a value
  152445. */
  152446. export class ReciprocalBlock extends NodeMaterialBlock {
  152447. /**
  152448. * Creates a new ReciprocalBlock
  152449. * @param name defines the block name
  152450. */
  152451. constructor(name: string);
  152452. /**
  152453. * Gets the current class name
  152454. * @returns the class name
  152455. */
  152456. getClassName(): string;
  152457. /**
  152458. * Gets the input component
  152459. */
  152460. get input(): NodeMaterialConnectionPoint;
  152461. /**
  152462. * Gets the output component
  152463. */
  152464. get output(): NodeMaterialConnectionPoint;
  152465. protected _buildBlock(state: NodeMaterialBuildState): this;
  152466. }
  152467. }
  152468. declare module BABYLON {
  152469. /**
  152470. * Block used to replace a color by another one
  152471. */
  152472. export class ReplaceColorBlock extends NodeMaterialBlock {
  152473. /**
  152474. * Creates a new ReplaceColorBlock
  152475. * @param name defines the block name
  152476. */
  152477. constructor(name: string);
  152478. /**
  152479. * Gets the current class name
  152480. * @returns the class name
  152481. */
  152482. getClassName(): string;
  152483. /**
  152484. * Gets the value input component
  152485. */
  152486. get value(): NodeMaterialConnectionPoint;
  152487. /**
  152488. * Gets the reference input component
  152489. */
  152490. get reference(): NodeMaterialConnectionPoint;
  152491. /**
  152492. * Gets the distance input component
  152493. */
  152494. get distance(): NodeMaterialConnectionPoint;
  152495. /**
  152496. * Gets the replacement input component
  152497. */
  152498. get replacement(): 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. * Block used to posterize a value
  152509. * @see https://en.wikipedia.org/wiki/Posterization
  152510. */
  152511. export class PosterizeBlock extends NodeMaterialBlock {
  152512. /**
  152513. * Creates a new PosterizeBlock
  152514. * @param name defines the block name
  152515. */
  152516. constructor(name: string);
  152517. /**
  152518. * Gets the current class name
  152519. * @returns the class name
  152520. */
  152521. getClassName(): string;
  152522. /**
  152523. * Gets the value input component
  152524. */
  152525. get value(): NodeMaterialConnectionPoint;
  152526. /**
  152527. * Gets the steps input component
  152528. */
  152529. get steps(): NodeMaterialConnectionPoint;
  152530. /**
  152531. * Gets the output component
  152532. */
  152533. get output(): NodeMaterialConnectionPoint;
  152534. protected _buildBlock(state: NodeMaterialBuildState): this;
  152535. }
  152536. }
  152537. declare module BABYLON {
  152538. /**
  152539. * Operations supported by the Wave block
  152540. */
  152541. export enum WaveBlockKind {
  152542. /** SawTooth */
  152543. SawTooth = 0,
  152544. /** Square */
  152545. Square = 1,
  152546. /** Triangle */
  152547. Triangle = 2
  152548. }
  152549. /**
  152550. * Block used to apply wave operation to floats
  152551. */
  152552. export class WaveBlock extends NodeMaterialBlock {
  152553. /**
  152554. * Gets or sets the kibnd of wave to be applied by the block
  152555. */
  152556. kind: WaveBlockKind;
  152557. /**
  152558. * Creates a new WaveBlock
  152559. * @param name defines the block name
  152560. */
  152561. constructor(name: string);
  152562. /**
  152563. * Gets the current class name
  152564. * @returns the class name
  152565. */
  152566. getClassName(): string;
  152567. /**
  152568. * Gets the input component
  152569. */
  152570. get input(): NodeMaterialConnectionPoint;
  152571. /**
  152572. * Gets the output component
  152573. */
  152574. get output(): NodeMaterialConnectionPoint;
  152575. protected _buildBlock(state: NodeMaterialBuildState): this;
  152576. serialize(): any;
  152577. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  152578. }
  152579. }
  152580. declare module BABYLON {
  152581. /**
  152582. * Class used to store a color step for the GradientBlock
  152583. */
  152584. export class GradientBlockColorStep {
  152585. private _step;
  152586. /**
  152587. * Gets value indicating which step this color is associated with (between 0 and 1)
  152588. */
  152589. get step(): number;
  152590. /**
  152591. * Sets a value indicating which step this color is associated with (between 0 and 1)
  152592. */
  152593. set step(val: number);
  152594. private _color;
  152595. /**
  152596. * Gets the color associated with this step
  152597. */
  152598. get color(): Color3;
  152599. /**
  152600. * Sets the color associated with this step
  152601. */
  152602. set color(val: Color3);
  152603. /**
  152604. * Creates a new GradientBlockColorStep
  152605. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  152606. * @param color defines the color associated with this step
  152607. */
  152608. constructor(step: number, color: Color3);
  152609. }
  152610. /**
  152611. * Block used to return a color from a gradient based on an input value between 0 and 1
  152612. */
  152613. export class GradientBlock extends NodeMaterialBlock {
  152614. /**
  152615. * Gets or sets the list of color steps
  152616. */
  152617. colorSteps: GradientBlockColorStep[];
  152618. /** Gets an observable raised when the value is changed */
  152619. onValueChangedObservable: Observable<GradientBlock>;
  152620. /** calls observable when the value is changed*/
  152621. colorStepsUpdated(): void;
  152622. /**
  152623. * Creates a new GradientBlock
  152624. * @param name defines the block name
  152625. */
  152626. constructor(name: string);
  152627. /**
  152628. * Gets the current class name
  152629. * @returns the class name
  152630. */
  152631. getClassName(): string;
  152632. /**
  152633. * Gets the gradient input component
  152634. */
  152635. get gradient(): NodeMaterialConnectionPoint;
  152636. /**
  152637. * Gets the output component
  152638. */
  152639. get output(): NodeMaterialConnectionPoint;
  152640. private _writeColorConstant;
  152641. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  152642. serialize(): any;
  152643. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  152644. protected _dumpPropertiesCode(): string;
  152645. }
  152646. }
  152647. declare module BABYLON {
  152648. /**
  152649. * Block used to normalize lerp between 2 values
  152650. */
  152651. export class NLerpBlock extends NodeMaterialBlock {
  152652. /**
  152653. * Creates a new NLerpBlock
  152654. * @param name defines the block name
  152655. */
  152656. constructor(name: string);
  152657. /**
  152658. * Gets the current class name
  152659. * @returns the class name
  152660. */
  152661. getClassName(): string;
  152662. /**
  152663. * Gets the left operand input component
  152664. */
  152665. get left(): NodeMaterialConnectionPoint;
  152666. /**
  152667. * Gets the right operand input component
  152668. */
  152669. get right(): NodeMaterialConnectionPoint;
  152670. /**
  152671. * Gets the gradient operand input component
  152672. */
  152673. get gradient(): NodeMaterialConnectionPoint;
  152674. /**
  152675. * Gets the output component
  152676. */
  152677. get output(): NodeMaterialConnectionPoint;
  152678. protected _buildBlock(state: NodeMaterialBuildState): this;
  152679. }
  152680. }
  152681. declare module BABYLON {
  152682. /**
  152683. * block used to Generate a Worley Noise 3D Noise Pattern
  152684. */
  152685. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  152686. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  152687. manhattanDistance: boolean;
  152688. /**
  152689. * Creates a new WorleyNoise3DBlock
  152690. * @param name defines the block name
  152691. */
  152692. constructor(name: string);
  152693. /**
  152694. * Gets the current class name
  152695. * @returns the class name
  152696. */
  152697. getClassName(): string;
  152698. /**
  152699. * Gets the seed input component
  152700. */
  152701. get seed(): NodeMaterialConnectionPoint;
  152702. /**
  152703. * Gets the jitter input component
  152704. */
  152705. get jitter(): NodeMaterialConnectionPoint;
  152706. /**
  152707. * Gets the output component
  152708. */
  152709. get output(): NodeMaterialConnectionPoint;
  152710. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  152711. /**
  152712. * Exposes the properties to the UI?
  152713. */
  152714. protected _dumpPropertiesCode(): string;
  152715. /**
  152716. * Exposes the properties to the Seralize?
  152717. */
  152718. serialize(): any;
  152719. /**
  152720. * Exposes the properties to the deseralize?
  152721. */
  152722. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  152723. }
  152724. }
  152725. declare module BABYLON {
  152726. /**
  152727. * block used to Generate a Simplex Perlin 3d Noise Pattern
  152728. */
  152729. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  152730. /**
  152731. * Creates a new SimplexPerlin3DBlock
  152732. * @param name defines the block name
  152733. */
  152734. constructor(name: string);
  152735. /**
  152736. * Gets the current class name
  152737. * @returns the class name
  152738. */
  152739. getClassName(): string;
  152740. /**
  152741. * Gets the seed operand input component
  152742. */
  152743. get seed(): NodeMaterialConnectionPoint;
  152744. /**
  152745. * Gets the output component
  152746. */
  152747. get output(): NodeMaterialConnectionPoint;
  152748. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  152749. }
  152750. }
  152751. declare module BABYLON {
  152752. /**
  152753. * Block used to blend normals
  152754. */
  152755. export class NormalBlendBlock extends NodeMaterialBlock {
  152756. /**
  152757. * Creates a new NormalBlendBlock
  152758. * @param name defines the block name
  152759. */
  152760. constructor(name: string);
  152761. /**
  152762. * Gets the current class name
  152763. * @returns the class name
  152764. */
  152765. getClassName(): string;
  152766. /**
  152767. * Gets the first input component
  152768. */
  152769. get normalMap0(): NodeMaterialConnectionPoint;
  152770. /**
  152771. * Gets the second input component
  152772. */
  152773. get normalMap1(): NodeMaterialConnectionPoint;
  152774. /**
  152775. * Gets the output component
  152776. */
  152777. get output(): NodeMaterialConnectionPoint;
  152778. protected _buildBlock(state: NodeMaterialBuildState): this;
  152779. }
  152780. }
  152781. declare module BABYLON {
  152782. /**
  152783. * Block used to rotate a 2d vector by a given angle
  152784. */
  152785. export class Rotate2dBlock extends NodeMaterialBlock {
  152786. /**
  152787. * Creates a new Rotate2dBlock
  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 input vector
  152798. */
  152799. get input(): NodeMaterialConnectionPoint;
  152800. /**
  152801. * Gets the input angle
  152802. */
  152803. get angle(): NodeMaterialConnectionPoint;
  152804. /**
  152805. * Gets the output component
  152806. */
  152807. get output(): NodeMaterialConnectionPoint;
  152808. autoConfigure(material: NodeMaterial): void;
  152809. protected _buildBlock(state: NodeMaterialBuildState): this;
  152810. }
  152811. }
  152812. declare module BABYLON {
  152813. /**
  152814. * Block used to get the reflected vector from a direction and a normal
  152815. */
  152816. export class ReflectBlock extends NodeMaterialBlock {
  152817. /**
  152818. * Creates a new ReflectBlock
  152819. * @param name defines the block name
  152820. */
  152821. constructor(name: string);
  152822. /**
  152823. * Gets the current class name
  152824. * @returns the class name
  152825. */
  152826. getClassName(): string;
  152827. /**
  152828. * Gets the incident component
  152829. */
  152830. get incident(): NodeMaterialConnectionPoint;
  152831. /**
  152832. * Gets the normal component
  152833. */
  152834. get normal(): NodeMaterialConnectionPoint;
  152835. /**
  152836. * Gets the output component
  152837. */
  152838. get output(): NodeMaterialConnectionPoint;
  152839. protected _buildBlock(state: NodeMaterialBuildState): this;
  152840. }
  152841. }
  152842. declare module BABYLON {
  152843. /**
  152844. * Block used to get the refracted vector from a direction and a normal
  152845. */
  152846. export class RefractBlock extends NodeMaterialBlock {
  152847. /**
  152848. * Creates a new RefractBlock
  152849. * @param name defines the block name
  152850. */
  152851. constructor(name: string);
  152852. /**
  152853. * Gets the current class name
  152854. * @returns the class name
  152855. */
  152856. getClassName(): string;
  152857. /**
  152858. * Gets the incident component
  152859. */
  152860. get incident(): NodeMaterialConnectionPoint;
  152861. /**
  152862. * Gets the normal component
  152863. */
  152864. get normal(): NodeMaterialConnectionPoint;
  152865. /**
  152866. * Gets the index of refraction component
  152867. */
  152868. get ior(): NodeMaterialConnectionPoint;
  152869. /**
  152870. * Gets the output component
  152871. */
  152872. get output(): NodeMaterialConnectionPoint;
  152873. protected _buildBlock(state: NodeMaterialBuildState): this;
  152874. }
  152875. }
  152876. declare module BABYLON {
  152877. /**
  152878. * Block used to desaturate a color
  152879. */
  152880. export class DesaturateBlock extends NodeMaterialBlock {
  152881. /**
  152882. * Creates a new DesaturateBlock
  152883. * @param name defines the block name
  152884. */
  152885. constructor(name: string);
  152886. /**
  152887. * Gets the current class name
  152888. * @returns the class name
  152889. */
  152890. getClassName(): string;
  152891. /**
  152892. * Gets the color operand input component
  152893. */
  152894. get color(): NodeMaterialConnectionPoint;
  152895. /**
  152896. * Gets the level operand input component
  152897. */
  152898. get level(): NodeMaterialConnectionPoint;
  152899. /**
  152900. * Gets the output component
  152901. */
  152902. get output(): NodeMaterialConnectionPoint;
  152903. protected _buildBlock(state: NodeMaterialBuildState): this;
  152904. }
  152905. }
  152906. declare module BABYLON {
  152907. /**
  152908. * Block used to implement the reflection module of the PBR material
  152909. */
  152910. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  152911. /** @hidden */
  152912. _defineLODReflectionAlpha: string;
  152913. /** @hidden */
  152914. _defineLinearSpecularReflection: string;
  152915. private _vEnvironmentIrradianceName;
  152916. /** @hidden */
  152917. _vReflectionMicrosurfaceInfosName: string;
  152918. /** @hidden */
  152919. _vReflectionInfosName: string;
  152920. /** @hidden */
  152921. _vReflectionFilteringInfoName: string;
  152922. private _scene;
  152923. /**
  152924. * The properties below are set by the main PBR block prior to calling methods of this class.
  152925. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  152926. * It's less burden on the user side in the editor part.
  152927. */
  152928. /** @hidden */
  152929. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  152930. /** @hidden */
  152931. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  152932. /** @hidden */
  152933. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  152934. /** @hidden */
  152935. viewConnectionPoint: NodeMaterialConnectionPoint;
  152936. /**
  152937. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  152938. * diffuse part of the IBL.
  152939. */
  152940. useSphericalHarmonics: boolean;
  152941. /**
  152942. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  152943. */
  152944. forceIrradianceInFragment: boolean;
  152945. /**
  152946. * Create a new ReflectionBlock
  152947. * @param name defines the block name
  152948. */
  152949. constructor(name: string);
  152950. /**
  152951. * Gets the current class name
  152952. * @returns the class name
  152953. */
  152954. getClassName(): string;
  152955. /**
  152956. * Gets the position input component
  152957. */
  152958. get position(): NodeMaterialConnectionPoint;
  152959. /**
  152960. * Gets the world position input component
  152961. */
  152962. get worldPosition(): NodeMaterialConnectionPoint;
  152963. /**
  152964. * Gets the world normal input component
  152965. */
  152966. get worldNormal(): NodeMaterialConnectionPoint;
  152967. /**
  152968. * Gets the world input component
  152969. */
  152970. get world(): NodeMaterialConnectionPoint;
  152971. /**
  152972. * Gets the camera (or eye) position component
  152973. */
  152974. get cameraPosition(): NodeMaterialConnectionPoint;
  152975. /**
  152976. * Gets the view input component
  152977. */
  152978. get view(): NodeMaterialConnectionPoint;
  152979. /**
  152980. * Gets the color input component
  152981. */
  152982. get color(): NodeMaterialConnectionPoint;
  152983. /**
  152984. * Gets the reflection object output component
  152985. */
  152986. get reflection(): NodeMaterialConnectionPoint;
  152987. /**
  152988. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  152989. */
  152990. get hasTexture(): boolean;
  152991. /**
  152992. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  152993. */
  152994. get reflectionColor(): string;
  152995. protected _getTexture(): Nullable<BaseTexture>;
  152996. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  152997. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  152998. /**
  152999. * Gets the code to inject in the vertex shader
  153000. * @param state current state of the node material building
  153001. * @returns the shader code
  153002. */
  153003. handleVertexSide(state: NodeMaterialBuildState): string;
  153004. /**
  153005. * Gets the main code of the block (fragment side)
  153006. * @param state current state of the node material building
  153007. * @param normalVarName name of the existing variable corresponding to the normal
  153008. * @returns the shader code
  153009. */
  153010. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  153011. protected _buildBlock(state: NodeMaterialBuildState): this;
  153012. protected _dumpPropertiesCode(): string;
  153013. serialize(): any;
  153014. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  153015. }
  153016. }
  153017. declare module BABYLON {
  153018. /**
  153019. * Block used to implement the sheen module of the PBR material
  153020. */
  153021. export class SheenBlock extends NodeMaterialBlock {
  153022. /**
  153023. * Create a new SheenBlock
  153024. * @param name defines the block name
  153025. */
  153026. constructor(name: string);
  153027. /**
  153028. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  153029. * It allows the strength of the sheen effect to not depend on the base color of the material,
  153030. * making it easier to setup and tweak the effect
  153031. */
  153032. albedoScaling: boolean;
  153033. /**
  153034. * Defines if the sheen is linked to the sheen color.
  153035. */
  153036. linkSheenWithAlbedo: boolean;
  153037. /**
  153038. * Initialize the block and prepare the context for build
  153039. * @param state defines the state that will be used for the build
  153040. */
  153041. initialize(state: NodeMaterialBuildState): void;
  153042. /**
  153043. * Gets the current class name
  153044. * @returns the class name
  153045. */
  153046. getClassName(): string;
  153047. /**
  153048. * Gets the intensity input component
  153049. */
  153050. get intensity(): NodeMaterialConnectionPoint;
  153051. /**
  153052. * Gets the color input component
  153053. */
  153054. get color(): NodeMaterialConnectionPoint;
  153055. /**
  153056. * Gets the roughness input component
  153057. */
  153058. get roughness(): NodeMaterialConnectionPoint;
  153059. /**
  153060. * Gets the sheen object output component
  153061. */
  153062. get sheen(): NodeMaterialConnectionPoint;
  153063. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  153064. /**
  153065. * Gets the main code of the block (fragment side)
  153066. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  153067. * @returns the shader code
  153068. */
  153069. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  153070. protected _buildBlock(state: NodeMaterialBuildState): this;
  153071. protected _dumpPropertiesCode(): string;
  153072. serialize(): any;
  153073. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  153074. }
  153075. }
  153076. declare module BABYLON {
  153077. /**
  153078. * Block used to implement the anisotropy module of the PBR material
  153079. */
  153080. export class AnisotropyBlock extends NodeMaterialBlock {
  153081. /**
  153082. * The two properties below are set by the main PBR block prior to calling methods of this class.
  153083. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  153084. * It's less burden on the user side in the editor part.
  153085. */
  153086. /** @hidden */
  153087. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  153088. /** @hidden */
  153089. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  153090. /**
  153091. * Create a new AnisotropyBlock
  153092. * @param name defines the block name
  153093. */
  153094. constructor(name: string);
  153095. /**
  153096. * Initialize the block and prepare the context for build
  153097. * @param state defines the state that will be used for the build
  153098. */
  153099. initialize(state: NodeMaterialBuildState): void;
  153100. /**
  153101. * Gets the current class name
  153102. * @returns the class name
  153103. */
  153104. getClassName(): string;
  153105. /**
  153106. * Gets the intensity input component
  153107. */
  153108. get intensity(): NodeMaterialConnectionPoint;
  153109. /**
  153110. * Gets the direction input component
  153111. */
  153112. get direction(): NodeMaterialConnectionPoint;
  153113. /**
  153114. * Gets the uv input component
  153115. */
  153116. get uv(): NodeMaterialConnectionPoint;
  153117. /**
  153118. * Gets the worldTangent input component
  153119. */
  153120. get worldTangent(): NodeMaterialConnectionPoint;
  153121. /**
  153122. * Gets the anisotropy object output component
  153123. */
  153124. get anisotropy(): NodeMaterialConnectionPoint;
  153125. private _generateTBNSpace;
  153126. /**
  153127. * Gets the main code of the block (fragment side)
  153128. * @param state current state of the node material building
  153129. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  153130. * @returns the shader code
  153131. */
  153132. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  153133. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  153134. protected _buildBlock(state: NodeMaterialBuildState): this;
  153135. }
  153136. }
  153137. declare module BABYLON {
  153138. /**
  153139. * Block used to implement the clear coat module of the PBR material
  153140. */
  153141. export class ClearCoatBlock extends NodeMaterialBlock {
  153142. private _scene;
  153143. /**
  153144. * Create a new ClearCoatBlock
  153145. * @param name defines the block name
  153146. */
  153147. constructor(name: string);
  153148. /**
  153149. * Defines if the F0 value should be remapped to account for the interface change in the material.
  153150. */
  153151. remapF0OnInterfaceChange: boolean;
  153152. /**
  153153. * Initialize the block and prepare the context for build
  153154. * @param state defines the state that will be used for the build
  153155. */
  153156. initialize(state: NodeMaterialBuildState): void;
  153157. /**
  153158. * Gets the current class name
  153159. * @returns the class name
  153160. */
  153161. getClassName(): string;
  153162. /**
  153163. * Gets the intensity input component
  153164. */
  153165. get intensity(): NodeMaterialConnectionPoint;
  153166. /**
  153167. * Gets the roughness input component
  153168. */
  153169. get roughness(): NodeMaterialConnectionPoint;
  153170. /**
  153171. * Gets the ior input component
  153172. */
  153173. get indexOfRefraction(): NodeMaterialConnectionPoint;
  153174. /**
  153175. * Gets the bump texture input component
  153176. */
  153177. get normalMapColor(): NodeMaterialConnectionPoint;
  153178. /**
  153179. * Gets the uv input component
  153180. */
  153181. get uv(): NodeMaterialConnectionPoint;
  153182. /**
  153183. * Gets the tint color input component
  153184. */
  153185. get tintColor(): NodeMaterialConnectionPoint;
  153186. /**
  153187. * Gets the tint "at distance" input component
  153188. */
  153189. get tintAtDistance(): NodeMaterialConnectionPoint;
  153190. /**
  153191. * Gets the tint thickness input component
  153192. */
  153193. get tintThickness(): NodeMaterialConnectionPoint;
  153194. /**
  153195. * Gets the world tangent input component
  153196. */
  153197. get worldTangent(): NodeMaterialConnectionPoint;
  153198. /**
  153199. * Gets the clear coat object output component
  153200. */
  153201. get clearcoat(): NodeMaterialConnectionPoint;
  153202. autoConfigure(material: NodeMaterial): void;
  153203. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  153204. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  153205. private _generateTBNSpace;
  153206. /**
  153207. * Gets the main code of the block (fragment side)
  153208. * @param state current state of the node material building
  153209. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  153210. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  153211. * @param worldPosVarName name of the variable holding the world position
  153212. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  153213. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  153214. * @param worldNormalVarName name of the variable holding the world normal
  153215. * @returns the shader code
  153216. */
  153217. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  153218. protected _buildBlock(state: NodeMaterialBuildState): this;
  153219. protected _dumpPropertiesCode(): string;
  153220. serialize(): any;
  153221. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  153222. }
  153223. }
  153224. declare module BABYLON {
  153225. /**
  153226. * Block used to implement the sub surface module of the PBR material
  153227. */
  153228. export class SubSurfaceBlock extends NodeMaterialBlock {
  153229. /**
  153230. * Create a new SubSurfaceBlock
  153231. * @param name defines the block name
  153232. */
  153233. constructor(name: string);
  153234. /**
  153235. * Initialize the block and prepare the context for build
  153236. * @param state defines the state that will be used for the build
  153237. */
  153238. initialize(state: NodeMaterialBuildState): void;
  153239. /**
  153240. * Gets the current class name
  153241. * @returns the class name
  153242. */
  153243. getClassName(): string;
  153244. /**
  153245. * Gets the thickness component
  153246. */
  153247. get thickness(): NodeMaterialConnectionPoint;
  153248. /**
  153249. * Gets the tint color input component
  153250. */
  153251. get tintColor(): NodeMaterialConnectionPoint;
  153252. /**
  153253. * Gets the translucency intensity input component
  153254. */
  153255. get translucencyIntensity(): NodeMaterialConnectionPoint;
  153256. /**
  153257. * Gets the translucency diffusion distance input component
  153258. */
  153259. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  153260. /**
  153261. * Gets the refraction object parameters
  153262. */
  153263. get refraction(): NodeMaterialConnectionPoint;
  153264. /**
  153265. * Gets the sub surface object output component
  153266. */
  153267. get subsurface(): NodeMaterialConnectionPoint;
  153268. autoConfigure(material: NodeMaterial): void;
  153269. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  153270. /**
  153271. * Gets the main code of the block (fragment side)
  153272. * @param state current state of the node material building
  153273. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  153274. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  153275. * @param worldPosVarName name of the variable holding the world position
  153276. * @returns the shader code
  153277. */
  153278. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  153279. protected _buildBlock(state: NodeMaterialBuildState): this;
  153280. }
  153281. }
  153282. declare module BABYLON {
  153283. /**
  153284. * Block used to implement the PBR metallic/roughness model
  153285. */
  153286. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  153287. /**
  153288. * Gets or sets the light associated with this block
  153289. */
  153290. light: Nullable<Light>;
  153291. private _lightId;
  153292. private _scene;
  153293. private _environmentBRDFTexture;
  153294. private _environmentBrdfSamplerName;
  153295. private _vNormalWName;
  153296. private _invertNormalName;
  153297. private _metallicReflectanceColor;
  153298. private _metallicF0Factor;
  153299. private _vMetallicReflectanceFactorsName;
  153300. /**
  153301. * Create a new ReflectionBlock
  153302. * @param name defines the block name
  153303. */
  153304. constructor(name: string);
  153305. /**
  153306. * Intensity of the direct lights e.g. the four lights available in your scene.
  153307. * This impacts both the direct diffuse and specular highlights.
  153308. */
  153309. directIntensity: number;
  153310. /**
  153311. * Intensity of the environment e.g. how much the environment will light the object
  153312. * either through harmonics for rough material or through the refelction for shiny ones.
  153313. */
  153314. environmentIntensity: number;
  153315. /**
  153316. * This is a special control allowing the reduction of the specular highlights coming from the
  153317. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  153318. */
  153319. specularIntensity: number;
  153320. /**
  153321. * Defines the falloff type used in this material.
  153322. * It by default is Physical.
  153323. */
  153324. lightFalloff: number;
  153325. /**
  153326. * Specifies that alpha test should be used
  153327. */
  153328. useAlphaTest: boolean;
  153329. /**
  153330. * Defines the alpha limits in alpha test mode.
  153331. */
  153332. alphaTestCutoff: number;
  153333. /**
  153334. * Specifies that alpha blending should be used
  153335. */
  153336. useAlphaBlending: boolean;
  153337. /**
  153338. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  153339. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  153340. */
  153341. useRadianceOverAlpha: boolean;
  153342. /**
  153343. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  153344. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  153345. */
  153346. useSpecularOverAlpha: boolean;
  153347. /**
  153348. * Enables specular anti aliasing in the PBR shader.
  153349. * It will both interacts on the Geometry for analytical and IBL lighting.
  153350. * It also prefilter the roughness map based on the bump values.
  153351. */
  153352. enableSpecularAntiAliasing: boolean;
  153353. /**
  153354. * Enables realtime filtering on the texture.
  153355. */
  153356. realTimeFiltering: boolean;
  153357. /**
  153358. * Quality switch for realtime filtering
  153359. */
  153360. realTimeFilteringQuality: number;
  153361. /**
  153362. * Defines if the material uses energy conservation.
  153363. */
  153364. useEnergyConservation: boolean;
  153365. /**
  153366. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  153367. * too much the area relying on ambient texture to define their ambient occlusion.
  153368. */
  153369. useRadianceOcclusion: boolean;
  153370. /**
  153371. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  153372. * makes the reflect vector face the model (under horizon).
  153373. */
  153374. useHorizonOcclusion: boolean;
  153375. /**
  153376. * If set to true, no lighting calculations will be applied.
  153377. */
  153378. unlit: boolean;
  153379. /**
  153380. * Force normal to face away from face.
  153381. */
  153382. forceNormalForward: boolean;
  153383. /**
  153384. * Defines the material debug mode.
  153385. * It helps seeing only some components of the material while troubleshooting.
  153386. */
  153387. debugMode: number;
  153388. /**
  153389. * Specify from where on screen the debug mode should start.
  153390. * The value goes from -1 (full screen) to 1 (not visible)
  153391. * It helps with side by side comparison against the final render
  153392. * This defaults to 0
  153393. */
  153394. debugLimit: number;
  153395. /**
  153396. * As the default viewing range might not be enough (if the ambient is really small for instance)
  153397. * You can use the factor to better multiply the final value.
  153398. */
  153399. debugFactor: number;
  153400. /**
  153401. * Initialize the block and prepare the context for build
  153402. * @param state defines the state that will be used for the build
  153403. */
  153404. initialize(state: NodeMaterialBuildState): void;
  153405. /**
  153406. * Gets the current class name
  153407. * @returns the class name
  153408. */
  153409. getClassName(): string;
  153410. /**
  153411. * Gets the world position input component
  153412. */
  153413. get worldPosition(): NodeMaterialConnectionPoint;
  153414. /**
  153415. * Gets the world normal input component
  153416. */
  153417. get worldNormal(): NodeMaterialConnectionPoint;
  153418. /**
  153419. * Gets the view matrix parameter
  153420. */
  153421. get view(): NodeMaterialConnectionPoint;
  153422. /**
  153423. * Gets the camera position input component
  153424. */
  153425. get cameraPosition(): NodeMaterialConnectionPoint;
  153426. /**
  153427. * Gets the perturbed normal input component
  153428. */
  153429. get perturbedNormal(): NodeMaterialConnectionPoint;
  153430. /**
  153431. * Gets the base color input component
  153432. */
  153433. get baseColor(): NodeMaterialConnectionPoint;
  153434. /**
  153435. * Gets the metallic input component
  153436. */
  153437. get metallic(): NodeMaterialConnectionPoint;
  153438. /**
  153439. * Gets the roughness input component
  153440. */
  153441. get roughness(): NodeMaterialConnectionPoint;
  153442. /**
  153443. * Gets the ambient occlusion input component
  153444. */
  153445. get ambientOcc(): NodeMaterialConnectionPoint;
  153446. /**
  153447. * Gets the opacity input component
  153448. */
  153449. get opacity(): NodeMaterialConnectionPoint;
  153450. /**
  153451. * Gets the index of refraction input component
  153452. */
  153453. get indexOfRefraction(): NodeMaterialConnectionPoint;
  153454. /**
  153455. * Gets the ambient color input component
  153456. */
  153457. get ambientColor(): NodeMaterialConnectionPoint;
  153458. /**
  153459. * Gets the reflection object parameters
  153460. */
  153461. get reflection(): NodeMaterialConnectionPoint;
  153462. /**
  153463. * Gets the clear coat object parameters
  153464. */
  153465. get clearcoat(): NodeMaterialConnectionPoint;
  153466. /**
  153467. * Gets the sheen object parameters
  153468. */
  153469. get sheen(): NodeMaterialConnectionPoint;
  153470. /**
  153471. * Gets the sub surface object parameters
  153472. */
  153473. get subsurface(): NodeMaterialConnectionPoint;
  153474. /**
  153475. * Gets the anisotropy object parameters
  153476. */
  153477. get anisotropy(): NodeMaterialConnectionPoint;
  153478. /**
  153479. * Gets the ambient output component
  153480. */
  153481. get ambientClr(): NodeMaterialConnectionPoint;
  153482. /**
  153483. * Gets the diffuse output component
  153484. */
  153485. get diffuseDir(): NodeMaterialConnectionPoint;
  153486. /**
  153487. * Gets the specular output component
  153488. */
  153489. get specularDir(): NodeMaterialConnectionPoint;
  153490. /**
  153491. * Gets the clear coat output component
  153492. */
  153493. get clearcoatDir(): NodeMaterialConnectionPoint;
  153494. /**
  153495. * Gets the sheen output component
  153496. */
  153497. get sheenDir(): NodeMaterialConnectionPoint;
  153498. /**
  153499. * Gets the indirect diffuse output component
  153500. */
  153501. get diffuseIndirect(): NodeMaterialConnectionPoint;
  153502. /**
  153503. * Gets the indirect specular output component
  153504. */
  153505. get specularIndirect(): NodeMaterialConnectionPoint;
  153506. /**
  153507. * Gets the indirect clear coat output component
  153508. */
  153509. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  153510. /**
  153511. * Gets the indirect sheen output component
  153512. */
  153513. get sheenIndirect(): NodeMaterialConnectionPoint;
  153514. /**
  153515. * Gets the refraction output component
  153516. */
  153517. get refraction(): NodeMaterialConnectionPoint;
  153518. /**
  153519. * Gets the global lighting output component
  153520. */
  153521. get lighting(): NodeMaterialConnectionPoint;
  153522. /**
  153523. * Gets the shadow output component
  153524. */
  153525. get shadow(): NodeMaterialConnectionPoint;
  153526. /**
  153527. * Gets the alpha output component
  153528. */
  153529. get alpha(): NodeMaterialConnectionPoint;
  153530. autoConfigure(material: NodeMaterial): void;
  153531. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  153532. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  153533. isReady(): boolean;
  153534. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  153535. private _injectVertexCode;
  153536. private _getAlbedoOpacityCode;
  153537. private _getAmbientOcclusionCode;
  153538. private _getReflectivityCode;
  153539. protected _buildBlock(state: NodeMaterialBuildState): this;
  153540. protected _dumpPropertiesCode(): string;
  153541. serialize(): any;
  153542. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  153543. }
  153544. }
  153545. declare module BABYLON {
  153546. /**
  153547. * Block used to compute value of one parameter modulo another
  153548. */
  153549. export class ModBlock extends NodeMaterialBlock {
  153550. /**
  153551. * Creates a new ModBlock
  153552. * @param name defines the block name
  153553. */
  153554. constructor(name: string);
  153555. /**
  153556. * Gets the current class name
  153557. * @returns the class name
  153558. */
  153559. getClassName(): string;
  153560. /**
  153561. * Gets the left operand input component
  153562. */
  153563. get left(): NodeMaterialConnectionPoint;
  153564. /**
  153565. * Gets the right operand input component
  153566. */
  153567. get right(): NodeMaterialConnectionPoint;
  153568. /**
  153569. * Gets the output component
  153570. */
  153571. get output(): NodeMaterialConnectionPoint;
  153572. protected _buildBlock(state: NodeMaterialBuildState): this;
  153573. }
  153574. }
  153575. declare module BABYLON {
  153576. /**
  153577. * Configuration for Draco compression
  153578. */
  153579. export interface IDracoCompressionConfiguration {
  153580. /**
  153581. * Configuration for the decoder.
  153582. */
  153583. decoder: {
  153584. /**
  153585. * The url to the WebAssembly module.
  153586. */
  153587. wasmUrl?: string;
  153588. /**
  153589. * The url to the WebAssembly binary.
  153590. */
  153591. wasmBinaryUrl?: string;
  153592. /**
  153593. * The url to the fallback JavaScript module.
  153594. */
  153595. fallbackUrl?: string;
  153596. };
  153597. }
  153598. /**
  153599. * Draco compression (https://google.github.io/draco/)
  153600. *
  153601. * This class wraps the Draco module.
  153602. *
  153603. * **Encoder**
  153604. *
  153605. * The encoder is not currently implemented.
  153606. *
  153607. * **Decoder**
  153608. *
  153609. * 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.
  153610. *
  153611. * To update the configuration, use the following code:
  153612. * ```javascript
  153613. * DracoCompression.Configuration = {
  153614. * decoder: {
  153615. * wasmUrl: "<url to the WebAssembly library>",
  153616. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  153617. * fallbackUrl: "<url to the fallback JavaScript library>",
  153618. * }
  153619. * };
  153620. * ```
  153621. *
  153622. * 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.
  153623. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  153624. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  153625. *
  153626. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  153627. * ```javascript
  153628. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  153629. * ```
  153630. *
  153631. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  153632. */
  153633. export class DracoCompression implements IDisposable {
  153634. private _workerPoolPromise?;
  153635. private _decoderModulePromise?;
  153636. /**
  153637. * The configuration. Defaults to the following urls:
  153638. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  153639. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  153640. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  153641. */
  153642. static Configuration: IDracoCompressionConfiguration;
  153643. /**
  153644. * Returns true if the decoder configuration is available.
  153645. */
  153646. static get DecoderAvailable(): boolean;
  153647. /**
  153648. * Default number of workers to create when creating the draco compression object.
  153649. */
  153650. static DefaultNumWorkers: number;
  153651. private static GetDefaultNumWorkers;
  153652. private static _Default;
  153653. /**
  153654. * Default instance for the draco compression object.
  153655. */
  153656. static get Default(): DracoCompression;
  153657. /**
  153658. * Constructor
  153659. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  153660. */
  153661. constructor(numWorkers?: number);
  153662. /**
  153663. * Stop all async operations and release resources.
  153664. */
  153665. dispose(): void;
  153666. /**
  153667. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  153668. * @returns a promise that resolves when ready
  153669. */
  153670. whenReadyAsync(): Promise<void>;
  153671. /**
  153672. * Decode Draco compressed mesh data to vertex data.
  153673. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  153674. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  153675. * @returns A promise that resolves with the decoded vertex data
  153676. */
  153677. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  153678. [kind: string]: number;
  153679. }): Promise<VertexData>;
  153680. }
  153681. }
  153682. declare module BABYLON {
  153683. /**
  153684. * Class for building Constructive Solid Geometry
  153685. */
  153686. export class CSG {
  153687. private polygons;
  153688. /**
  153689. * The world matrix
  153690. */
  153691. matrix: Matrix;
  153692. /**
  153693. * Stores the position
  153694. */
  153695. position: Vector3;
  153696. /**
  153697. * Stores the rotation
  153698. */
  153699. rotation: Vector3;
  153700. /**
  153701. * Stores the rotation quaternion
  153702. */
  153703. rotationQuaternion: Nullable<Quaternion>;
  153704. /**
  153705. * Stores the scaling vector
  153706. */
  153707. scaling: Vector3;
  153708. /**
  153709. * Convert the Mesh to CSG
  153710. * @param mesh The Mesh to convert to CSG
  153711. * @returns A new CSG from the Mesh
  153712. */
  153713. static FromMesh(mesh: Mesh): CSG;
  153714. /**
  153715. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  153716. * @param polygons Polygons used to construct a CSG solid
  153717. */
  153718. private static FromPolygons;
  153719. /**
  153720. * Clones, or makes a deep copy, of the CSG
  153721. * @returns A new CSG
  153722. */
  153723. clone(): CSG;
  153724. /**
  153725. * Unions this CSG with another CSG
  153726. * @param csg The CSG to union against this CSG
  153727. * @returns The unioned CSG
  153728. */
  153729. union(csg: CSG): CSG;
  153730. /**
  153731. * Unions this CSG with another CSG in place
  153732. * @param csg The CSG to union against this CSG
  153733. */
  153734. unionInPlace(csg: CSG): void;
  153735. /**
  153736. * Subtracts this CSG with another CSG
  153737. * @param csg The CSG to subtract against this CSG
  153738. * @returns A new CSG
  153739. */
  153740. subtract(csg: CSG): CSG;
  153741. /**
  153742. * Subtracts this CSG with another CSG in place
  153743. * @param csg The CSG to subtact against this CSG
  153744. */
  153745. subtractInPlace(csg: CSG): void;
  153746. /**
  153747. * Intersect this CSG with another CSG
  153748. * @param csg The CSG to intersect against this CSG
  153749. * @returns A new CSG
  153750. */
  153751. intersect(csg: CSG): CSG;
  153752. /**
  153753. * Intersects this CSG with another CSG in place
  153754. * @param csg The CSG to intersect against this CSG
  153755. */
  153756. intersectInPlace(csg: CSG): void;
  153757. /**
  153758. * Return a new CSG solid with solid and empty space switched. This solid is
  153759. * not modified.
  153760. * @returns A new CSG solid with solid and empty space switched
  153761. */
  153762. inverse(): CSG;
  153763. /**
  153764. * Inverses the CSG in place
  153765. */
  153766. inverseInPlace(): void;
  153767. /**
  153768. * This is used to keep meshes transformations so they can be restored
  153769. * when we build back a Babylon Mesh
  153770. * NB : All CSG operations are performed in world coordinates
  153771. * @param csg The CSG to copy the transform attributes from
  153772. * @returns This CSG
  153773. */
  153774. copyTransformAttributes(csg: CSG): CSG;
  153775. /**
  153776. * Build Raw mesh from CSG
  153777. * Coordinates here are in world space
  153778. * @param name The name of the mesh geometry
  153779. * @param scene The Scene
  153780. * @param keepSubMeshes Specifies if the submeshes should be kept
  153781. * @returns A new Mesh
  153782. */
  153783. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  153784. /**
  153785. * Build Mesh from CSG taking material and transforms into account
  153786. * @param name The name of the Mesh
  153787. * @param material The material of the Mesh
  153788. * @param scene The Scene
  153789. * @param keepSubMeshes Specifies if submeshes should be kept
  153790. * @returns The new Mesh
  153791. */
  153792. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  153793. }
  153794. }
  153795. declare module BABYLON {
  153796. /**
  153797. * Class used to create a trail following a mesh
  153798. */
  153799. export class TrailMesh extends Mesh {
  153800. private _generator;
  153801. private _autoStart;
  153802. private _running;
  153803. private _diameter;
  153804. private _length;
  153805. private _sectionPolygonPointsCount;
  153806. private _sectionVectors;
  153807. private _sectionNormalVectors;
  153808. private _beforeRenderObserver;
  153809. /**
  153810. * @constructor
  153811. * @param name The value used by scene.getMeshByName() to do a lookup.
  153812. * @param generator The mesh or transform node to generate a trail.
  153813. * @param scene The scene to add this mesh to.
  153814. * @param diameter Diameter of trailing mesh. Default is 1.
  153815. * @param length Length of trailing mesh. Default is 60.
  153816. * @param autoStart Automatically start trailing mesh. Default true.
  153817. */
  153818. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  153819. /**
  153820. * "TrailMesh"
  153821. * @returns "TrailMesh"
  153822. */
  153823. getClassName(): string;
  153824. private _createMesh;
  153825. /**
  153826. * Start trailing mesh.
  153827. */
  153828. start(): void;
  153829. /**
  153830. * Stop trailing mesh.
  153831. */
  153832. stop(): void;
  153833. /**
  153834. * Update trailing mesh geometry.
  153835. */
  153836. update(): void;
  153837. /**
  153838. * Returns a new TrailMesh object.
  153839. * @param name is a string, the name given to the new mesh
  153840. * @param newGenerator use new generator object for cloned trail mesh
  153841. * @returns a new mesh
  153842. */
  153843. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  153844. /**
  153845. * Serializes this trail mesh
  153846. * @param serializationObject object to write serialization to
  153847. */
  153848. serialize(serializationObject: any): void;
  153849. /**
  153850. * Parses a serialized trail mesh
  153851. * @param parsedMesh the serialized mesh
  153852. * @param scene the scene to create the trail mesh in
  153853. * @returns the created trail mesh
  153854. */
  153855. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  153856. }
  153857. }
  153858. declare module BABYLON {
  153859. /**
  153860. * Class containing static functions to help procedurally build meshes
  153861. */
  153862. export class TiledBoxBuilder {
  153863. /**
  153864. * Creates a box mesh
  153865. * 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)
  153866. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  153867. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  153868. * * 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
  153869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  153870. * @param name defines the name of the mesh
  153871. * @param options defines the options used to create the mesh
  153872. * @param scene defines the hosting scene
  153873. * @returns the box mesh
  153874. */
  153875. static CreateTiledBox(name: string, options: {
  153876. pattern?: number;
  153877. width?: number;
  153878. height?: number;
  153879. depth?: number;
  153880. tileSize?: number;
  153881. tileWidth?: number;
  153882. tileHeight?: number;
  153883. alignHorizontal?: number;
  153884. alignVertical?: number;
  153885. faceUV?: Vector4[];
  153886. faceColors?: Color4[];
  153887. sideOrientation?: number;
  153888. updatable?: boolean;
  153889. }, scene?: Nullable<Scene>): Mesh;
  153890. }
  153891. }
  153892. declare module BABYLON {
  153893. /**
  153894. * Class containing static functions to help procedurally build meshes
  153895. */
  153896. export class TorusKnotBuilder {
  153897. /**
  153898. * Creates a torus knot mesh
  153899. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  153900. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  153901. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  153902. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  153903. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  153904. * * 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
  153905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  153906. * @param name defines the name of the mesh
  153907. * @param options defines the options used to create the mesh
  153908. * @param scene defines the hosting scene
  153909. * @returns the torus knot mesh
  153910. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  153911. */
  153912. static CreateTorusKnot(name: string, options: {
  153913. radius?: number;
  153914. tube?: number;
  153915. radialSegments?: number;
  153916. tubularSegments?: number;
  153917. p?: number;
  153918. q?: number;
  153919. updatable?: boolean;
  153920. sideOrientation?: number;
  153921. frontUVs?: Vector4;
  153922. backUVs?: Vector4;
  153923. }, scene: any): Mesh;
  153924. }
  153925. }
  153926. declare module BABYLON {
  153927. /**
  153928. * Polygon
  153929. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  153930. */
  153931. export class Polygon {
  153932. /**
  153933. * Creates a rectangle
  153934. * @param xmin bottom X coord
  153935. * @param ymin bottom Y coord
  153936. * @param xmax top X coord
  153937. * @param ymax top Y coord
  153938. * @returns points that make the resulting rectation
  153939. */
  153940. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  153941. /**
  153942. * Creates a circle
  153943. * @param radius radius of circle
  153944. * @param cx scale in x
  153945. * @param cy scale in y
  153946. * @param numberOfSides number of sides that make up the circle
  153947. * @returns points that make the resulting circle
  153948. */
  153949. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  153950. /**
  153951. * Creates a polygon from input string
  153952. * @param input Input polygon data
  153953. * @returns the parsed points
  153954. */
  153955. static Parse(input: string): Vector2[];
  153956. /**
  153957. * Starts building a polygon from x and y coordinates
  153958. * @param x x coordinate
  153959. * @param y y coordinate
  153960. * @returns the started path2
  153961. */
  153962. static StartingAt(x: number, y: number): Path2;
  153963. }
  153964. /**
  153965. * Builds a polygon
  153966. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  153967. */
  153968. export class PolygonMeshBuilder {
  153969. private _points;
  153970. private _outlinepoints;
  153971. private _holes;
  153972. private _name;
  153973. private _scene;
  153974. private _epoints;
  153975. private _eholes;
  153976. private _addToepoint;
  153977. /**
  153978. * Babylon reference to the earcut plugin.
  153979. */
  153980. bjsEarcut: any;
  153981. /**
  153982. * Creates a PolygonMeshBuilder
  153983. * @param name name of the builder
  153984. * @param contours Path of the polygon
  153985. * @param scene scene to add to when creating the mesh
  153986. * @param earcutInjection can be used to inject your own earcut reference
  153987. */
  153988. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  153989. /**
  153990. * Adds a whole within the polygon
  153991. * @param hole Array of points defining the hole
  153992. * @returns this
  153993. */
  153994. addHole(hole: Vector2[]): PolygonMeshBuilder;
  153995. /**
  153996. * Creates the polygon
  153997. * @param updatable If the mesh should be updatable
  153998. * @param depth The depth of the mesh created
  153999. * @returns the created mesh
  154000. */
  154001. build(updatable?: boolean, depth?: number): Mesh;
  154002. /**
  154003. * Creates the polygon
  154004. * @param depth The depth of the mesh created
  154005. * @returns the created VertexData
  154006. */
  154007. buildVertexData(depth?: number): VertexData;
  154008. /**
  154009. * Adds a side to the polygon
  154010. * @param positions points that make the polygon
  154011. * @param normals normals of the polygon
  154012. * @param uvs uvs of the polygon
  154013. * @param indices indices of the polygon
  154014. * @param bounds bounds of the polygon
  154015. * @param points points of the polygon
  154016. * @param depth depth of the polygon
  154017. * @param flip flip of the polygon
  154018. */
  154019. private addSide;
  154020. }
  154021. }
  154022. declare module BABYLON {
  154023. /**
  154024. * Class containing static functions to help procedurally build meshes
  154025. */
  154026. export class PolygonBuilder {
  154027. /**
  154028. * Creates a polygon mesh
  154029. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  154030. * * 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
  154031. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  154032. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154033. * * 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)
  154034. * * Remember you can only change the shape positions, not their number when updating a polygon
  154035. * @param name defines the name of the mesh
  154036. * @param options defines the options used to create the mesh
  154037. * @param scene defines the hosting scene
  154038. * @param earcutInjection can be used to inject your own earcut reference
  154039. * @returns the polygon mesh
  154040. */
  154041. static CreatePolygon(name: string, options: {
  154042. shape: Vector3[];
  154043. holes?: Vector3[][];
  154044. depth?: number;
  154045. faceUV?: Vector4[];
  154046. faceColors?: Color4[];
  154047. updatable?: boolean;
  154048. sideOrientation?: number;
  154049. frontUVs?: Vector4;
  154050. backUVs?: Vector4;
  154051. wrap?: boolean;
  154052. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  154053. /**
  154054. * Creates an extruded polygon mesh, with depth in the Y direction.
  154055. * * 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)
  154056. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  154057. * @param name defines the name of the mesh
  154058. * @param options defines the options used to create the mesh
  154059. * @param scene defines the hosting scene
  154060. * @param earcutInjection can be used to inject your own earcut reference
  154061. * @returns the polygon mesh
  154062. */
  154063. static ExtrudePolygon(name: string, options: {
  154064. shape: Vector3[];
  154065. holes?: Vector3[][];
  154066. depth?: number;
  154067. faceUV?: Vector4[];
  154068. faceColors?: Color4[];
  154069. updatable?: boolean;
  154070. sideOrientation?: number;
  154071. frontUVs?: Vector4;
  154072. backUVs?: Vector4;
  154073. wrap?: boolean;
  154074. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  154075. }
  154076. }
  154077. declare module BABYLON {
  154078. /**
  154079. * Class containing static functions to help procedurally build meshes
  154080. */
  154081. export class LatheBuilder {
  154082. /**
  154083. * Creates lathe mesh.
  154084. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  154085. * * 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
  154086. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  154087. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  154088. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  154089. * * 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
  154090. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  154091. * * 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
  154092. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154093. * * 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
  154094. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  154095. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154096. * @param name defines the name of the mesh
  154097. * @param options defines the options used to create the mesh
  154098. * @param scene defines the hosting scene
  154099. * @returns the lathe mesh
  154100. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  154101. */
  154102. static CreateLathe(name: string, options: {
  154103. shape: Vector3[];
  154104. radius?: number;
  154105. tessellation?: number;
  154106. clip?: number;
  154107. arc?: number;
  154108. closed?: boolean;
  154109. updatable?: boolean;
  154110. sideOrientation?: number;
  154111. frontUVs?: Vector4;
  154112. backUVs?: Vector4;
  154113. cap?: number;
  154114. invertUV?: boolean;
  154115. }, scene?: Nullable<Scene>): Mesh;
  154116. }
  154117. }
  154118. declare module BABYLON {
  154119. /**
  154120. * Class containing static functions to help procedurally build meshes
  154121. */
  154122. export class TiledPlaneBuilder {
  154123. /**
  154124. * Creates a tiled plane mesh
  154125. * * The parameter `pattern` will, depending on value, do nothing or
  154126. * * * flip (reflect about central vertical) alternate tiles across and up
  154127. * * * flip every tile on alternate rows
  154128. * * * rotate (180 degs) alternate tiles across and up
  154129. * * * rotate every tile on alternate rows
  154130. * * * flip and rotate alternate tiles across and up
  154131. * * * flip and rotate every tile on alternate rows
  154132. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  154133. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  154134. * * 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
  154135. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  154136. * * 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)
  154137. * * 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)
  154138. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  154139. * @param name defines the name of the mesh
  154140. * @param options defines the options used to create the mesh
  154141. * @param scene defines the hosting scene
  154142. * @returns the box mesh
  154143. */
  154144. static CreateTiledPlane(name: string, options: {
  154145. pattern?: number;
  154146. tileSize?: number;
  154147. tileWidth?: number;
  154148. tileHeight?: number;
  154149. size?: number;
  154150. width?: number;
  154151. height?: number;
  154152. alignHorizontal?: number;
  154153. alignVertical?: number;
  154154. sideOrientation?: number;
  154155. frontUVs?: Vector4;
  154156. backUVs?: Vector4;
  154157. updatable?: boolean;
  154158. }, scene?: Nullable<Scene>): Mesh;
  154159. }
  154160. }
  154161. declare module BABYLON {
  154162. /**
  154163. * Class containing static functions to help procedurally build meshes
  154164. */
  154165. export class TubeBuilder {
  154166. /**
  154167. * Creates a tube mesh.
  154168. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  154169. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  154170. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  154171. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  154172. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  154173. * * 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)
  154174. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  154175. * * 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
  154176. * * 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
  154177. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154178. * * 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
  154179. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  154180. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154181. * @param name defines the name of the mesh
  154182. * @param options defines the options used to create the mesh
  154183. * @param scene defines the hosting scene
  154184. * @returns the tube mesh
  154185. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  154186. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  154187. */
  154188. static CreateTube(name: string, options: {
  154189. path: Vector3[];
  154190. radius?: number;
  154191. tessellation?: number;
  154192. radiusFunction?: {
  154193. (i: number, distance: number): number;
  154194. };
  154195. cap?: number;
  154196. arc?: number;
  154197. updatable?: boolean;
  154198. sideOrientation?: number;
  154199. frontUVs?: Vector4;
  154200. backUVs?: Vector4;
  154201. instance?: Mesh;
  154202. invertUV?: boolean;
  154203. }, scene?: Nullable<Scene>): Mesh;
  154204. }
  154205. }
  154206. declare module BABYLON {
  154207. /**
  154208. * Class containing static functions to help procedurally build meshes
  154209. */
  154210. export class IcoSphereBuilder {
  154211. /**
  154212. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  154213. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  154214. * * 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`)
  154215. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  154216. * * 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
  154217. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154218. * * 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
  154219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154220. * @param name defines the name of the mesh
  154221. * @param options defines the options used to create the mesh
  154222. * @param scene defines the hosting scene
  154223. * @returns the icosahedron mesh
  154224. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  154225. */
  154226. static CreateIcoSphere(name: string, options: {
  154227. radius?: number;
  154228. radiusX?: number;
  154229. radiusY?: number;
  154230. radiusZ?: number;
  154231. flat?: boolean;
  154232. subdivisions?: number;
  154233. sideOrientation?: number;
  154234. frontUVs?: Vector4;
  154235. backUVs?: Vector4;
  154236. updatable?: boolean;
  154237. }, scene?: Nullable<Scene>): Mesh;
  154238. }
  154239. }
  154240. declare module BABYLON {
  154241. /**
  154242. * Class containing static functions to help procedurally build meshes
  154243. */
  154244. export class DecalBuilder {
  154245. /**
  154246. * Creates a decal mesh.
  154247. * 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
  154248. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  154249. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  154250. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  154251. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  154252. * @param name defines the name of the mesh
  154253. * @param sourceMesh defines the mesh where the decal must be applied
  154254. * @param options defines the options used to create the mesh
  154255. * @param scene defines the hosting scene
  154256. * @returns the decal mesh
  154257. * @see https://doc.babylonjs.com/how_to/decals
  154258. */
  154259. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  154260. position?: Vector3;
  154261. normal?: Vector3;
  154262. size?: Vector3;
  154263. angle?: number;
  154264. }): Mesh;
  154265. }
  154266. }
  154267. declare module BABYLON {
  154268. /**
  154269. * Class containing static functions to help procedurally build meshes
  154270. */
  154271. export class MeshBuilder {
  154272. /**
  154273. * Creates a box mesh
  154274. * * The parameter `size` sets the size (float) of each box side (default 1)
  154275. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  154276. * * 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)
  154277. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  154278. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154279. * * 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
  154280. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154281. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  154282. * @param name defines the name of the mesh
  154283. * @param options defines the options used to create the mesh
  154284. * @param scene defines the hosting scene
  154285. * @returns the box mesh
  154286. */
  154287. static CreateBox(name: string, options: {
  154288. size?: number;
  154289. width?: number;
  154290. height?: number;
  154291. depth?: number;
  154292. faceUV?: Vector4[];
  154293. faceColors?: Color4[];
  154294. sideOrientation?: number;
  154295. frontUVs?: Vector4;
  154296. backUVs?: Vector4;
  154297. wrap?: boolean;
  154298. topBaseAt?: number;
  154299. bottomBaseAt?: number;
  154300. updatable?: boolean;
  154301. }, scene?: Nullable<Scene>): Mesh;
  154302. /**
  154303. * Creates a tiled box mesh
  154304. * * faceTiles sets the pattern, tile size and number of tiles for a face
  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 tiled box mesh
  154310. */
  154311. static CreateTiledBox(name: string, options: {
  154312. pattern?: number;
  154313. size?: number;
  154314. width?: number;
  154315. height?: number;
  154316. depth: number;
  154317. tileSize?: number;
  154318. tileWidth?: number;
  154319. tileHeight?: number;
  154320. faceUV?: Vector4[];
  154321. faceColors?: Color4[];
  154322. alignHorizontal?: number;
  154323. alignVertical?: number;
  154324. sideOrientation?: number;
  154325. updatable?: boolean;
  154326. }, scene?: Nullable<Scene>): Mesh;
  154327. /**
  154328. * Creates a sphere mesh
  154329. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  154330. * * 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`)
  154331. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  154332. * * 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
  154333. * * 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)
  154334. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154335. * * 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
  154336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154337. * @param name defines the name of the mesh
  154338. * @param options defines the options used to create the mesh
  154339. * @param scene defines the hosting scene
  154340. * @returns the sphere mesh
  154341. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  154342. */
  154343. static CreateSphere(name: string, options: {
  154344. segments?: number;
  154345. diameter?: number;
  154346. diameterX?: number;
  154347. diameterY?: number;
  154348. diameterZ?: number;
  154349. arc?: number;
  154350. slice?: number;
  154351. sideOrientation?: number;
  154352. frontUVs?: Vector4;
  154353. backUVs?: Vector4;
  154354. updatable?: boolean;
  154355. }, scene?: Nullable<Scene>): Mesh;
  154356. /**
  154357. * Creates a plane polygonal mesh. By default, this is a disc
  154358. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  154359. * * 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
  154360. * * 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
  154361. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154362. * * 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
  154363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154364. * @param name defines the name of the mesh
  154365. * @param options defines the options used to create the mesh
  154366. * @param scene defines the hosting scene
  154367. * @returns the plane polygonal mesh
  154368. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  154369. */
  154370. static CreateDisc(name: string, options: {
  154371. radius?: number;
  154372. tessellation?: number;
  154373. arc?: number;
  154374. updatable?: boolean;
  154375. sideOrientation?: number;
  154376. frontUVs?: Vector4;
  154377. backUVs?: Vector4;
  154378. }, scene?: Nullable<Scene>): Mesh;
  154379. /**
  154380. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  154381. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  154382. * * 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`)
  154383. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  154384. * * 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
  154385. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154386. * * 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
  154387. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154388. * @param name defines the name of the mesh
  154389. * @param options defines the options used to create the mesh
  154390. * @param scene defines the hosting scene
  154391. * @returns the icosahedron mesh
  154392. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  154393. */
  154394. static CreateIcoSphere(name: string, options: {
  154395. radius?: number;
  154396. radiusX?: number;
  154397. radiusY?: number;
  154398. radiusZ?: number;
  154399. flat?: boolean;
  154400. subdivisions?: number;
  154401. sideOrientation?: number;
  154402. frontUVs?: Vector4;
  154403. backUVs?: Vector4;
  154404. updatable?: boolean;
  154405. }, scene?: Nullable<Scene>): Mesh;
  154406. /**
  154407. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  154408. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  154409. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  154410. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  154411. * * 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
  154412. * * 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
  154413. * * 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
  154414. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154415. * * 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
  154416. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  154417. * * 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
  154418. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  154419. * * 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
  154420. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  154421. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154422. * @param name defines the name of the mesh
  154423. * @param options defines the options used to create the mesh
  154424. * @param scene defines the hosting scene
  154425. * @returns the ribbon mesh
  154426. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  154427. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  154428. */
  154429. static CreateRibbon(name: string, options: {
  154430. pathArray: Vector3[][];
  154431. closeArray?: boolean;
  154432. closePath?: boolean;
  154433. offset?: number;
  154434. updatable?: boolean;
  154435. sideOrientation?: number;
  154436. frontUVs?: Vector4;
  154437. backUVs?: Vector4;
  154438. instance?: Mesh;
  154439. invertUV?: boolean;
  154440. uvs?: Vector2[];
  154441. colors?: Color4[];
  154442. }, scene?: Nullable<Scene>): Mesh;
  154443. /**
  154444. * Creates a cylinder or a cone mesh
  154445. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  154446. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  154447. * * 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.
  154448. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  154449. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  154450. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  154451. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  154452. * * 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).
  154453. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  154454. * * 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).
  154455. * * 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
  154456. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  154457. * * 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
  154458. * * 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.
  154459. * * If `enclose` is false, a ring surface is one element.
  154460. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  154461. * * 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
  154462. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154463. * * 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
  154464. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  154465. * @param name defines the name of the mesh
  154466. * @param options defines the options used to create the mesh
  154467. * @param scene defines the hosting scene
  154468. * @returns the cylinder mesh
  154469. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  154470. */
  154471. static CreateCylinder(name: string, options: {
  154472. height?: number;
  154473. diameterTop?: number;
  154474. diameterBottom?: number;
  154475. diameter?: number;
  154476. tessellation?: number;
  154477. subdivisions?: number;
  154478. arc?: number;
  154479. faceColors?: Color4[];
  154480. faceUV?: Vector4[];
  154481. updatable?: boolean;
  154482. hasRings?: boolean;
  154483. enclose?: boolean;
  154484. cap?: number;
  154485. sideOrientation?: number;
  154486. frontUVs?: Vector4;
  154487. backUVs?: Vector4;
  154488. }, scene?: Nullable<Scene>): Mesh;
  154489. /**
  154490. * Creates a torus mesh
  154491. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  154492. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  154493. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  154494. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154495. * * 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
  154496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  154497. * @param name defines the name of the mesh
  154498. * @param options defines the options used to create the mesh
  154499. * @param scene defines the hosting scene
  154500. * @returns the torus mesh
  154501. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  154502. */
  154503. static CreateTorus(name: string, options: {
  154504. diameter?: number;
  154505. thickness?: number;
  154506. tessellation?: number;
  154507. updatable?: boolean;
  154508. sideOrientation?: number;
  154509. frontUVs?: Vector4;
  154510. backUVs?: Vector4;
  154511. }, scene?: Nullable<Scene>): Mesh;
  154512. /**
  154513. * Creates a torus knot mesh
  154514. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  154515. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  154516. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  154517. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  154518. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154519. * * 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
  154520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  154521. * @param name defines the name of the mesh
  154522. * @param options defines the options used to create the mesh
  154523. * @param scene defines the hosting scene
  154524. * @returns the torus knot mesh
  154525. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  154526. */
  154527. static CreateTorusKnot(name: string, options: {
  154528. radius?: number;
  154529. tube?: number;
  154530. radialSegments?: number;
  154531. tubularSegments?: number;
  154532. p?: number;
  154533. q?: number;
  154534. updatable?: boolean;
  154535. sideOrientation?: number;
  154536. frontUVs?: Vector4;
  154537. backUVs?: Vector4;
  154538. }, scene?: Nullable<Scene>): Mesh;
  154539. /**
  154540. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  154541. * * 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
  154542. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  154543. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  154544. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  154545. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  154546. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  154547. * * 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
  154548. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  154549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154550. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  154551. * @param name defines the name of the new line system
  154552. * @param options defines the options used to create the line system
  154553. * @param scene defines the hosting scene
  154554. * @returns a new line system mesh
  154555. */
  154556. static CreateLineSystem(name: string, options: {
  154557. lines: Vector3[][];
  154558. updatable?: boolean;
  154559. instance?: Nullable<LinesMesh>;
  154560. colors?: Nullable<Color4[][]>;
  154561. useVertexAlpha?: boolean;
  154562. }, scene: Nullable<Scene>): LinesMesh;
  154563. /**
  154564. * Creates a line mesh
  154565. * 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
  154566. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  154567. * * The parameter `points` is an array successive Vector3
  154568. * * 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
  154569. * * The optional parameter `colors` is an array of successive Color4, one per line point
  154570. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  154571. * * When updating an instance, remember that only point positions can change, not the number of points
  154572. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154573. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  154574. * @param name defines the name of the new line system
  154575. * @param options defines the options used to create the line system
  154576. * @param scene defines the hosting scene
  154577. * @returns a new line mesh
  154578. */
  154579. static CreateLines(name: string, options: {
  154580. points: Vector3[];
  154581. updatable?: boolean;
  154582. instance?: Nullable<LinesMesh>;
  154583. colors?: Color4[];
  154584. useVertexAlpha?: boolean;
  154585. }, scene?: Nullable<Scene>): LinesMesh;
  154586. /**
  154587. * Creates a dashed line mesh
  154588. * * 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
  154589. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  154590. * * The parameter `points` is an array successive Vector3
  154591. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  154592. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  154593. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  154594. * * 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
  154595. * * When updating an instance, remember that only point positions can change, not the number of points
  154596. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154597. * @param name defines the name of the mesh
  154598. * @param options defines the options used to create the mesh
  154599. * @param scene defines the hosting scene
  154600. * @returns the dashed line mesh
  154601. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  154602. */
  154603. static CreateDashedLines(name: string, options: {
  154604. points: Vector3[];
  154605. dashSize?: number;
  154606. gapSize?: number;
  154607. dashNb?: number;
  154608. updatable?: boolean;
  154609. instance?: LinesMesh;
  154610. }, scene?: Nullable<Scene>): LinesMesh;
  154611. /**
  154612. * 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.
  154613. * * 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.
  154614. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  154615. * * 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.
  154616. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  154617. * * 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
  154618. * * 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
  154619. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  154620. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154621. * * 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
  154622. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  154623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  154624. * @param name defines the name of the mesh
  154625. * @param options defines the options used to create the mesh
  154626. * @param scene defines the hosting scene
  154627. * @returns the extruded shape mesh
  154628. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  154629. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  154630. */
  154631. static ExtrudeShape(name: string, options: {
  154632. shape: Vector3[];
  154633. path: Vector3[];
  154634. scale?: number;
  154635. rotation?: number;
  154636. cap?: number;
  154637. updatable?: boolean;
  154638. sideOrientation?: number;
  154639. frontUVs?: Vector4;
  154640. backUVs?: Vector4;
  154641. instance?: Mesh;
  154642. invertUV?: boolean;
  154643. }, scene?: Nullable<Scene>): Mesh;
  154644. /**
  154645. * Creates an custom extruded shape mesh.
  154646. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  154647. * * 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.
  154648. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  154649. * * 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
  154650. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  154651. * * 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
  154652. * * It must returns a float value that will be the scale value applied to the shape on each path point
  154653. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  154654. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  154655. * * 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
  154656. * * 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
  154657. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  154658. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154659. * * 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
  154660. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  154661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154662. * @param name defines the name of the mesh
  154663. * @param options defines the options used to create the mesh
  154664. * @param scene defines the hosting scene
  154665. * @returns the custom extruded shape mesh
  154666. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  154667. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  154668. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  154669. */
  154670. static ExtrudeShapeCustom(name: string, options: {
  154671. shape: Vector3[];
  154672. path: Vector3[];
  154673. scaleFunction?: any;
  154674. rotationFunction?: any;
  154675. ribbonCloseArray?: boolean;
  154676. ribbonClosePath?: boolean;
  154677. cap?: number;
  154678. updatable?: boolean;
  154679. sideOrientation?: number;
  154680. frontUVs?: Vector4;
  154681. backUVs?: Vector4;
  154682. instance?: Mesh;
  154683. invertUV?: boolean;
  154684. }, scene?: Nullable<Scene>): Mesh;
  154685. /**
  154686. * Creates lathe mesh.
  154687. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  154688. * * 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
  154689. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  154690. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  154691. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  154692. * * 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
  154693. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  154694. * * 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
  154695. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154696. * * 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
  154697. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  154698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154699. * @param name defines the name of the mesh
  154700. * @param options defines the options used to create the mesh
  154701. * @param scene defines the hosting scene
  154702. * @returns the lathe mesh
  154703. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  154704. */
  154705. static CreateLathe(name: string, options: {
  154706. shape: Vector3[];
  154707. radius?: number;
  154708. tessellation?: number;
  154709. clip?: number;
  154710. arc?: number;
  154711. closed?: boolean;
  154712. updatable?: boolean;
  154713. sideOrientation?: number;
  154714. frontUVs?: Vector4;
  154715. backUVs?: Vector4;
  154716. cap?: number;
  154717. invertUV?: boolean;
  154718. }, scene?: Nullable<Scene>): Mesh;
  154719. /**
  154720. * Creates a tiled plane mesh
  154721. * * You can set a limited pattern arrangement with the tiles
  154722. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154723. * * 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
  154724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154725. * @param name defines the name of the mesh
  154726. * @param options defines the options used to create the mesh
  154727. * @param scene defines the hosting scene
  154728. * @returns the plane mesh
  154729. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  154730. */
  154731. static CreateTiledPlane(name: string, options: {
  154732. pattern?: number;
  154733. tileSize?: number;
  154734. tileWidth?: number;
  154735. tileHeight?: number;
  154736. size?: number;
  154737. width?: number;
  154738. height?: number;
  154739. alignHorizontal?: number;
  154740. alignVertical?: number;
  154741. sideOrientation?: number;
  154742. frontUVs?: Vector4;
  154743. backUVs?: Vector4;
  154744. updatable?: boolean;
  154745. }, scene?: Nullable<Scene>): Mesh;
  154746. /**
  154747. * Creates a plane mesh
  154748. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  154749. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  154750. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  154751. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154752. * * 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
  154753. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154754. * @param name defines the name of the mesh
  154755. * @param options defines the options used to create the mesh
  154756. * @param scene defines the hosting scene
  154757. * @returns the plane mesh
  154758. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  154759. */
  154760. static CreatePlane(name: string, options: {
  154761. size?: number;
  154762. width?: number;
  154763. height?: number;
  154764. sideOrientation?: number;
  154765. frontUVs?: Vector4;
  154766. backUVs?: Vector4;
  154767. updatable?: boolean;
  154768. sourcePlane?: Plane;
  154769. }, scene?: Nullable<Scene>): Mesh;
  154770. /**
  154771. * Creates a ground mesh
  154772. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  154773. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  154774. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154775. * @param name defines the name of the mesh
  154776. * @param options defines the options used to create the mesh
  154777. * @param scene defines the hosting scene
  154778. * @returns the ground mesh
  154779. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  154780. */
  154781. static CreateGround(name: string, options: {
  154782. width?: number;
  154783. height?: number;
  154784. subdivisions?: number;
  154785. subdivisionsX?: number;
  154786. subdivisionsY?: number;
  154787. updatable?: boolean;
  154788. }, scene?: Nullable<Scene>): Mesh;
  154789. /**
  154790. * Creates a tiled ground mesh
  154791. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  154792. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  154793. * * 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
  154794. * * 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
  154795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  154796. * @param name defines the name of the mesh
  154797. * @param options defines the options used to create the mesh
  154798. * @param scene defines the hosting scene
  154799. * @returns the tiled ground mesh
  154800. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  154801. */
  154802. static CreateTiledGround(name: string, options: {
  154803. xmin: number;
  154804. zmin: number;
  154805. xmax: number;
  154806. zmax: number;
  154807. subdivisions?: {
  154808. w: number;
  154809. h: number;
  154810. };
  154811. precision?: {
  154812. w: number;
  154813. h: number;
  154814. };
  154815. updatable?: boolean;
  154816. }, scene?: Nullable<Scene>): Mesh;
  154817. /**
  154818. * Creates a ground mesh from a height map
  154819. * * The parameter `url` sets the URL of the height map image resource.
  154820. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  154821. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  154822. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  154823. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  154824. * * 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.
  154825. * * 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).
  154826. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  154827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  154828. * @param name defines the name of the mesh
  154829. * @param url defines the url to the height map
  154830. * @param options defines the options used to create the mesh
  154831. * @param scene defines the hosting scene
  154832. * @returns the ground mesh
  154833. * @see https://doc.babylonjs.com/babylon101/height_map
  154834. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  154835. */
  154836. static CreateGroundFromHeightMap(name: string, url: string, options: {
  154837. width?: number;
  154838. height?: number;
  154839. subdivisions?: number;
  154840. minHeight?: number;
  154841. maxHeight?: number;
  154842. colorFilter?: Color3;
  154843. alphaFilter?: number;
  154844. updatable?: boolean;
  154845. onReady?: (mesh: GroundMesh) => void;
  154846. }, scene?: Nullable<Scene>): GroundMesh;
  154847. /**
  154848. * Creates a polygon mesh
  154849. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  154850. * * 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
  154851. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  154852. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154853. * * 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)
  154854. * * Remember you can only change the shape positions, not their number when updating a polygon
  154855. * @param name defines the name of the mesh
  154856. * @param options defines the options used to create the mesh
  154857. * @param scene defines the hosting scene
  154858. * @param earcutInjection can be used to inject your own earcut reference
  154859. * @returns the polygon mesh
  154860. */
  154861. static CreatePolygon(name: string, options: {
  154862. shape: Vector3[];
  154863. holes?: Vector3[][];
  154864. depth?: number;
  154865. faceUV?: Vector4[];
  154866. faceColors?: Color4[];
  154867. updatable?: boolean;
  154868. sideOrientation?: number;
  154869. frontUVs?: Vector4;
  154870. backUVs?: Vector4;
  154871. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  154872. /**
  154873. * Creates an extruded polygon mesh, with depth in the Y direction.
  154874. * * 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)
  154875. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  154876. * @param name defines the name of the mesh
  154877. * @param options defines the options used to create the mesh
  154878. * @param scene defines the hosting scene
  154879. * @param earcutInjection can be used to inject your own earcut reference
  154880. * @returns the polygon mesh
  154881. */
  154882. static ExtrudePolygon(name: string, options: {
  154883. shape: Vector3[];
  154884. holes?: Vector3[][];
  154885. depth?: number;
  154886. faceUV?: Vector4[];
  154887. faceColors?: Color4[];
  154888. updatable?: boolean;
  154889. sideOrientation?: number;
  154890. frontUVs?: Vector4;
  154891. backUVs?: Vector4;
  154892. wrap?: boolean;
  154893. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  154894. /**
  154895. * Creates a tube mesh.
  154896. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  154897. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  154898. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  154899. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  154900. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  154901. * * 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)
  154902. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  154903. * * 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
  154904. * * 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
  154905. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154906. * * 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
  154907. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  154908. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154909. * @param name defines the name of the mesh
  154910. * @param options defines the options used to create the mesh
  154911. * @param scene defines the hosting scene
  154912. * @returns the tube mesh
  154913. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  154914. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  154915. */
  154916. static CreateTube(name: string, options: {
  154917. path: Vector3[];
  154918. radius?: number;
  154919. tessellation?: number;
  154920. radiusFunction?: {
  154921. (i: number, distance: number): number;
  154922. };
  154923. cap?: number;
  154924. arc?: number;
  154925. updatable?: boolean;
  154926. sideOrientation?: number;
  154927. frontUVs?: Vector4;
  154928. backUVs?: Vector4;
  154929. instance?: Mesh;
  154930. invertUV?: boolean;
  154931. }, scene?: Nullable<Scene>): Mesh;
  154932. /**
  154933. * Creates a polyhedron mesh
  154934. * * 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
  154935. * * The parameter `size` (positive float, default 1) sets the polygon size
  154936. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  154937. * * 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`
  154938. * * 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
  154939. * * 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)`)
  154940. * * 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
  154941. * * 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
  154942. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  154943. * * 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
  154944. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  154945. * @param name defines the name of the mesh
  154946. * @param options defines the options used to create the mesh
  154947. * @param scene defines the hosting scene
  154948. * @returns the polyhedron mesh
  154949. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  154950. */
  154951. static CreatePolyhedron(name: string, options: {
  154952. type?: number;
  154953. size?: number;
  154954. sizeX?: number;
  154955. sizeY?: number;
  154956. sizeZ?: number;
  154957. custom?: any;
  154958. faceUV?: Vector4[];
  154959. faceColors?: Color4[];
  154960. flat?: boolean;
  154961. updatable?: boolean;
  154962. sideOrientation?: number;
  154963. frontUVs?: Vector4;
  154964. backUVs?: Vector4;
  154965. }, scene?: Nullable<Scene>): Mesh;
  154966. /**
  154967. * Creates a decal mesh.
  154968. * 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
  154969. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  154970. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  154971. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  154972. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  154973. * @param name defines the name of the mesh
  154974. * @param sourceMesh defines the mesh where the decal must be applied
  154975. * @param options defines the options used to create the mesh
  154976. * @param scene defines the hosting scene
  154977. * @returns the decal mesh
  154978. * @see https://doc.babylonjs.com/how_to/decals
  154979. */
  154980. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  154981. position?: Vector3;
  154982. normal?: Vector3;
  154983. size?: Vector3;
  154984. angle?: number;
  154985. }): Mesh;
  154986. /**
  154987. * Creates a Capsule Mesh
  154988. * @param name defines the name of the mesh.
  154989. * @param options the constructors options used to shape the mesh.
  154990. * @param scene defines the scene the mesh is scoped to.
  154991. * @returns the capsule mesh
  154992. * @see https://doc.babylonjs.com/how_to/capsule_shape
  154993. */
  154994. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  154995. }
  154996. }
  154997. declare module BABYLON {
  154998. /**
  154999. * A simplifier interface for future simplification implementations
  155000. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  155001. */
  155002. export interface ISimplifier {
  155003. /**
  155004. * Simplification of a given mesh according to the given settings.
  155005. * Since this requires computation, it is assumed that the function runs async.
  155006. * @param settings The settings of the simplification, including quality and distance
  155007. * @param successCallback A callback that will be called after the mesh was simplified.
  155008. * @param errorCallback in case of an error, this callback will be called. optional.
  155009. */
  155010. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  155011. }
  155012. /**
  155013. * Expected simplification settings.
  155014. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  155015. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  155016. */
  155017. export interface ISimplificationSettings {
  155018. /**
  155019. * Gets or sets the expected quality
  155020. */
  155021. quality: number;
  155022. /**
  155023. * Gets or sets the distance when this optimized version should be used
  155024. */
  155025. distance: number;
  155026. /**
  155027. * Gets an already optimized mesh
  155028. */
  155029. optimizeMesh?: boolean;
  155030. }
  155031. /**
  155032. * Class used to specify simplification options
  155033. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  155034. */
  155035. export class SimplificationSettings implements ISimplificationSettings {
  155036. /** expected quality */
  155037. quality: number;
  155038. /** distance when this optimized version should be used */
  155039. distance: number;
  155040. /** already optimized mesh */
  155041. optimizeMesh?: boolean | undefined;
  155042. /**
  155043. * Creates a SimplificationSettings
  155044. * @param quality expected quality
  155045. * @param distance distance when this optimized version should be used
  155046. * @param optimizeMesh already optimized mesh
  155047. */
  155048. constructor(
  155049. /** expected quality */
  155050. quality: number,
  155051. /** distance when this optimized version should be used */
  155052. distance: number,
  155053. /** already optimized mesh */
  155054. optimizeMesh?: boolean | undefined);
  155055. }
  155056. /**
  155057. * Interface used to define a simplification task
  155058. */
  155059. export interface ISimplificationTask {
  155060. /**
  155061. * Array of settings
  155062. */
  155063. settings: Array<ISimplificationSettings>;
  155064. /**
  155065. * Simplification type
  155066. */
  155067. simplificationType: SimplificationType;
  155068. /**
  155069. * Mesh to simplify
  155070. */
  155071. mesh: Mesh;
  155072. /**
  155073. * Callback called on success
  155074. */
  155075. successCallback?: () => void;
  155076. /**
  155077. * Defines if parallel processing can be used
  155078. */
  155079. parallelProcessing: boolean;
  155080. }
  155081. /**
  155082. * Queue used to order the simplification tasks
  155083. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  155084. */
  155085. export class SimplificationQueue {
  155086. private _simplificationArray;
  155087. /**
  155088. * Gets a boolean indicating that the process is still running
  155089. */
  155090. running: boolean;
  155091. /**
  155092. * Creates a new queue
  155093. */
  155094. constructor();
  155095. /**
  155096. * Adds a new simplification task
  155097. * @param task defines a task to add
  155098. */
  155099. addTask(task: ISimplificationTask): void;
  155100. /**
  155101. * Execute next task
  155102. */
  155103. executeNext(): void;
  155104. /**
  155105. * Execute a simplification task
  155106. * @param task defines the task to run
  155107. */
  155108. runSimplification(task: ISimplificationTask): void;
  155109. private getSimplifier;
  155110. }
  155111. /**
  155112. * The implemented types of simplification
  155113. * At the moment only Quadratic Error Decimation is implemented
  155114. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  155115. */
  155116. export enum SimplificationType {
  155117. /** Quadratic error decimation */
  155118. QUADRATIC = 0
  155119. }
  155120. /**
  155121. * An implementation of the Quadratic Error simplification algorithm.
  155122. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  155123. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  155124. * @author RaananW
  155125. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  155126. */
  155127. export class QuadraticErrorSimplification implements ISimplifier {
  155128. private _mesh;
  155129. private triangles;
  155130. private vertices;
  155131. private references;
  155132. private _reconstructedMesh;
  155133. /** Gets or sets the number pf sync interations */
  155134. syncIterations: number;
  155135. /** Gets or sets the aggressiveness of the simplifier */
  155136. aggressiveness: number;
  155137. /** Gets or sets the number of allowed iterations for decimation */
  155138. decimationIterations: number;
  155139. /** Gets or sets the espilon to use for bounding box computation */
  155140. boundingBoxEpsilon: number;
  155141. /**
  155142. * Creates a new QuadraticErrorSimplification
  155143. * @param _mesh defines the target mesh
  155144. */
  155145. constructor(_mesh: Mesh);
  155146. /**
  155147. * Simplification of a given mesh according to the given settings.
  155148. * Since this requires computation, it is assumed that the function runs async.
  155149. * @param settings The settings of the simplification, including quality and distance
  155150. * @param successCallback A callback that will be called after the mesh was simplified.
  155151. */
  155152. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  155153. private runDecimation;
  155154. private initWithMesh;
  155155. private init;
  155156. private reconstructMesh;
  155157. private initDecimatedMesh;
  155158. private isFlipped;
  155159. private updateTriangles;
  155160. private identifyBorder;
  155161. private updateMesh;
  155162. private vertexError;
  155163. private calculateError;
  155164. }
  155165. }
  155166. declare module BABYLON {
  155167. interface Scene {
  155168. /** @hidden (Backing field) */
  155169. _simplificationQueue: SimplificationQueue;
  155170. /**
  155171. * Gets or sets the simplification queue attached to the scene
  155172. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  155173. */
  155174. simplificationQueue: SimplificationQueue;
  155175. }
  155176. interface Mesh {
  155177. /**
  155178. * Simplify the mesh according to the given array of settings.
  155179. * Function will return immediately and will simplify async
  155180. * @param settings a collection of simplification settings
  155181. * @param parallelProcessing should all levels calculate parallel or one after the other
  155182. * @param simplificationType the type of simplification to run
  155183. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  155184. * @returns the current mesh
  155185. */
  155186. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  155187. }
  155188. /**
  155189. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  155190. * created in a scene
  155191. */
  155192. export class SimplicationQueueSceneComponent implements ISceneComponent {
  155193. /**
  155194. * The component name helpfull to identify the component in the list of scene components.
  155195. */
  155196. readonly name: string;
  155197. /**
  155198. * The scene the component belongs to.
  155199. */
  155200. scene: Scene;
  155201. /**
  155202. * Creates a new instance of the component for the given scene
  155203. * @param scene Defines the scene to register the component in
  155204. */
  155205. constructor(scene: Scene);
  155206. /**
  155207. * Registers the component in a given scene
  155208. */
  155209. register(): void;
  155210. /**
  155211. * Rebuilds the elements related to this component in case of
  155212. * context lost for instance.
  155213. */
  155214. rebuild(): void;
  155215. /**
  155216. * Disposes the component and the associated ressources
  155217. */
  155218. dispose(): void;
  155219. private _beforeCameraUpdate;
  155220. }
  155221. }
  155222. declare module BABYLON {
  155223. interface Mesh {
  155224. /**
  155225. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  155226. */
  155227. thinInstanceEnablePicking: boolean;
  155228. /**
  155229. * Creates a new thin instance
  155230. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  155231. * @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
  155232. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  155233. */
  155234. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  155235. /**
  155236. * Adds the transformation (matrix) of the current mesh as a thin instance
  155237. * @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
  155238. * @returns the thin instance index number
  155239. */
  155240. thinInstanceAddSelf(refresh: boolean): number;
  155241. /**
  155242. * Registers a custom attribute to be used with thin instances
  155243. * @param kind name of the attribute
  155244. * @param stride size in floats of the attribute
  155245. */
  155246. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  155247. /**
  155248. * Sets the matrix of a thin instance
  155249. * @param index index of the thin instance
  155250. * @param matrix matrix to set
  155251. * @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
  155252. */
  155253. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  155254. /**
  155255. * Sets the value of a custom attribute for a thin instance
  155256. * @param kind name of the attribute
  155257. * @param index index of the thin instance
  155258. * @param value value to set
  155259. * @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
  155260. */
  155261. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  155262. /**
  155263. * 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.
  155264. */
  155265. thinInstanceCount: number;
  155266. /**
  155267. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  155268. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  155269. * @param buffer buffer to set
  155270. * @param stride size in floats of each value of the buffer
  155271. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  155272. */
  155273. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  155274. /**
  155275. * Gets the list of world matrices
  155276. * @return an array containing all the world matrices from the thin instances
  155277. */
  155278. thinInstanceGetWorldMatrices(): Matrix[];
  155279. /**
  155280. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  155281. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  155282. */
  155283. thinInstanceBufferUpdated(kind: string): void;
  155284. /**
  155285. * Applies a partial update to a buffer directly on the GPU
  155286. * 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
  155287. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  155288. * @param data the data to set in the GPU buffer
  155289. * @param offset the offset in the GPU buffer where to update the data
  155290. */
  155291. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  155292. /**
  155293. * Refreshes the bounding info, taking into account all the thin instances defined
  155294. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  155295. */
  155296. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  155297. /** @hidden */
  155298. _thinInstanceInitializeUserStorage(): void;
  155299. /** @hidden */
  155300. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  155301. /** @hidden */
  155302. _userThinInstanceBuffersStorage: {
  155303. data: {
  155304. [key: string]: Float32Array;
  155305. };
  155306. sizes: {
  155307. [key: string]: number;
  155308. };
  155309. vertexBuffers: {
  155310. [key: string]: Nullable<VertexBuffer>;
  155311. };
  155312. strides: {
  155313. [key: string]: number;
  155314. };
  155315. };
  155316. }
  155317. }
  155318. declare module BABYLON {
  155319. /**
  155320. * Navigation plugin interface to add navigation constrained by a navigation mesh
  155321. */
  155322. export interface INavigationEnginePlugin {
  155323. /**
  155324. * plugin name
  155325. */
  155326. name: string;
  155327. /**
  155328. * Creates a navigation mesh
  155329. * @param meshes array of all the geometry used to compute the navigatio mesh
  155330. * @param parameters bunch of parameters used to filter geometry
  155331. */
  155332. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  155333. /**
  155334. * Create a navigation mesh debug mesh
  155335. * @param scene is where the mesh will be added
  155336. * @returns debug display mesh
  155337. */
  155338. createDebugNavMesh(scene: Scene): Mesh;
  155339. /**
  155340. * Get a navigation mesh constrained position, closest to the parameter position
  155341. * @param position world position
  155342. * @returns the closest point to position constrained by the navigation mesh
  155343. */
  155344. getClosestPoint(position: Vector3): Vector3;
  155345. /**
  155346. * Get a navigation mesh constrained position, closest to the parameter position
  155347. * @param position world position
  155348. * @param result output the closest point to position constrained by the navigation mesh
  155349. */
  155350. getClosestPointToRef(position: Vector3, result: Vector3): void;
  155351. /**
  155352. * Get a navigation mesh constrained position, within a particular radius
  155353. * @param position world position
  155354. * @param maxRadius the maximum distance to the constrained world position
  155355. * @returns the closest point to position constrained by the navigation mesh
  155356. */
  155357. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  155358. /**
  155359. * Get a navigation mesh constrained position, within a particular radius
  155360. * @param position world position
  155361. * @param maxRadius the maximum distance to the constrained world position
  155362. * @param result output the closest point to position constrained by the navigation mesh
  155363. */
  155364. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  155365. /**
  155366. * Compute the final position from a segment made of destination-position
  155367. * @param position world position
  155368. * @param destination world position
  155369. * @returns the resulting point along the navmesh
  155370. */
  155371. moveAlong(position: Vector3, destination: Vector3): Vector3;
  155372. /**
  155373. * Compute the final position from a segment made of destination-position
  155374. * @param position world position
  155375. * @param destination world position
  155376. * @param result output the resulting point along the navmesh
  155377. */
  155378. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  155379. /**
  155380. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  155381. * @param start world position
  155382. * @param end world position
  155383. * @returns array containing world position composing the path
  155384. */
  155385. computePath(start: Vector3, end: Vector3): Vector3[];
  155386. /**
  155387. * If this plugin is supported
  155388. * @returns true if plugin is supported
  155389. */
  155390. isSupported(): boolean;
  155391. /**
  155392. * Create a new Crowd so you can add agents
  155393. * @param maxAgents the maximum agent count in the crowd
  155394. * @param maxAgentRadius the maximum radius an agent can have
  155395. * @param scene to attach the crowd to
  155396. * @returns the crowd you can add agents to
  155397. */
  155398. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  155399. /**
  155400. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  155401. * The queries will try to find a solution within those bounds
  155402. * default is (1,1,1)
  155403. * @param extent x,y,z value that define the extent around the queries point of reference
  155404. */
  155405. setDefaultQueryExtent(extent: Vector3): void;
  155406. /**
  155407. * Get the Bounding box extent specified by setDefaultQueryExtent
  155408. * @returns the box extent values
  155409. */
  155410. getDefaultQueryExtent(): Vector3;
  155411. /**
  155412. * build the navmesh from a previously saved state using getNavmeshData
  155413. * @param data the Uint8Array returned by getNavmeshData
  155414. */
  155415. buildFromNavmeshData(data: Uint8Array): void;
  155416. /**
  155417. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  155418. * @returns data the Uint8Array that can be saved and reused
  155419. */
  155420. getNavmeshData(): Uint8Array;
  155421. /**
  155422. * Get the Bounding box extent result specified by setDefaultQueryExtent
  155423. * @param result output the box extent values
  155424. */
  155425. getDefaultQueryExtentToRef(result: Vector3): void;
  155426. /**
  155427. * Set the time step of the navigation tick update.
  155428. * Default is 1/60.
  155429. * A value of 0 will disable fixed time update
  155430. * @param newTimeStep the new timestep to apply to this world.
  155431. */
  155432. setTimeStep(newTimeStep: number): void;
  155433. /**
  155434. * Get the time step of the navigation tick update.
  155435. * @returns the current time step
  155436. */
  155437. getTimeStep(): number;
  155438. /**
  155439. * If delta time in navigation tick update is greater than the time step
  155440. * a number of sub iterations are done. If more iterations are need to reach deltatime
  155441. * they will be discarded.
  155442. * A value of 0 will set to no maximum and update will use as many substeps as needed
  155443. * @param newStepCount the maximum number of iterations
  155444. */
  155445. setMaximumSubStepCount(newStepCount: number): void;
  155446. /**
  155447. * Get the maximum number of iterations per navigation tick update
  155448. * @returns the maximum number of iterations
  155449. */
  155450. getMaximumSubStepCount(): number;
  155451. /**
  155452. * Release all resources
  155453. */
  155454. dispose(): void;
  155455. }
  155456. /**
  155457. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  155458. */
  155459. export interface ICrowd {
  155460. /**
  155461. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  155462. * You can attach anything to that node. The node position is updated in the scene update tick.
  155463. * @param pos world position that will be constrained by the navigation mesh
  155464. * @param parameters agent parameters
  155465. * @param transform hooked to the agent that will be update by the scene
  155466. * @returns agent index
  155467. */
  155468. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  155469. /**
  155470. * Returns the agent position in world space
  155471. * @param index agent index returned by addAgent
  155472. * @returns world space position
  155473. */
  155474. getAgentPosition(index: number): Vector3;
  155475. /**
  155476. * Gets the agent position result in world space
  155477. * @param index agent index returned by addAgent
  155478. * @param result output world space position
  155479. */
  155480. getAgentPositionToRef(index: number, result: Vector3): void;
  155481. /**
  155482. * Gets the agent velocity in world space
  155483. * @param index agent index returned by addAgent
  155484. * @returns world space velocity
  155485. */
  155486. getAgentVelocity(index: number): Vector3;
  155487. /**
  155488. * Gets the agent velocity result in world space
  155489. * @param index agent index returned by addAgent
  155490. * @param result output world space velocity
  155491. */
  155492. getAgentVelocityToRef(index: number, result: Vector3): void;
  155493. /**
  155494. * Gets the agent next target point on the path
  155495. * @param index agent index returned by addAgent
  155496. * @returns world space position
  155497. */
  155498. getAgentNextTargetPath(index: number): Vector3;
  155499. /**
  155500. * Gets the agent state
  155501. * @param index agent index returned by addAgent
  155502. * @returns agent state
  155503. */
  155504. getAgentState(index: number): number;
  155505. /**
  155506. * returns true if the agent in over an off mesh link connection
  155507. * @param index agent index returned by addAgent
  155508. * @returns true if over an off mesh link connection
  155509. */
  155510. overOffmeshConnection(index: number): boolean;
  155511. /**
  155512. * Gets the agent next target point on the path
  155513. * @param index agent index returned by addAgent
  155514. * @param result output world space position
  155515. */
  155516. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  155517. /**
  155518. * remove a particular agent previously created
  155519. * @param index agent index returned by addAgent
  155520. */
  155521. removeAgent(index: number): void;
  155522. /**
  155523. * get the list of all agents attached to this crowd
  155524. * @returns list of agent indices
  155525. */
  155526. getAgents(): number[];
  155527. /**
  155528. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  155529. * @param deltaTime in seconds
  155530. */
  155531. update(deltaTime: number): void;
  155532. /**
  155533. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  155534. * @param index agent index returned by addAgent
  155535. * @param destination targeted world position
  155536. */
  155537. agentGoto(index: number, destination: Vector3): void;
  155538. /**
  155539. * Teleport the agent to a new position
  155540. * @param index agent index returned by addAgent
  155541. * @param destination targeted world position
  155542. */
  155543. agentTeleport(index: number, destination: Vector3): void;
  155544. /**
  155545. * Update agent parameters
  155546. * @param index agent index returned by addAgent
  155547. * @param parameters agent parameters
  155548. */
  155549. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  155550. /**
  155551. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  155552. * The queries will try to find a solution within those bounds
  155553. * default is (1,1,1)
  155554. * @param extent x,y,z value that define the extent around the queries point of reference
  155555. */
  155556. setDefaultQueryExtent(extent: Vector3): void;
  155557. /**
  155558. * Get the Bounding box extent specified by setDefaultQueryExtent
  155559. * @returns the box extent values
  155560. */
  155561. getDefaultQueryExtent(): Vector3;
  155562. /**
  155563. * Get the Bounding box extent result specified by setDefaultQueryExtent
  155564. * @param result output the box extent values
  155565. */
  155566. getDefaultQueryExtentToRef(result: Vector3): void;
  155567. /**
  155568. * Release all resources
  155569. */
  155570. dispose(): void;
  155571. }
  155572. /**
  155573. * Configures an agent
  155574. */
  155575. export interface IAgentParameters {
  155576. /**
  155577. * Agent radius. [Limit: >= 0]
  155578. */
  155579. radius: number;
  155580. /**
  155581. * Agent height. [Limit: > 0]
  155582. */
  155583. height: number;
  155584. /**
  155585. * Maximum allowed acceleration. [Limit: >= 0]
  155586. */
  155587. maxAcceleration: number;
  155588. /**
  155589. * Maximum allowed speed. [Limit: >= 0]
  155590. */
  155591. maxSpeed: number;
  155592. /**
  155593. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  155594. */
  155595. collisionQueryRange: number;
  155596. /**
  155597. * The path visibility optimization range. [Limit: > 0]
  155598. */
  155599. pathOptimizationRange: number;
  155600. /**
  155601. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  155602. */
  155603. separationWeight: number;
  155604. }
  155605. /**
  155606. * Configures the navigation mesh creation
  155607. */
  155608. export interface INavMeshParameters {
  155609. /**
  155610. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  155611. */
  155612. cs: number;
  155613. /**
  155614. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  155615. */
  155616. ch: number;
  155617. /**
  155618. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  155619. */
  155620. walkableSlopeAngle: number;
  155621. /**
  155622. * Minimum floor to 'ceiling' height that will still allow the floor area to
  155623. * be considered walkable. [Limit: >= 3] [Units: vx]
  155624. */
  155625. walkableHeight: number;
  155626. /**
  155627. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  155628. */
  155629. walkableClimb: number;
  155630. /**
  155631. * The distance to erode/shrink the walkable area of the heightfield away from
  155632. * obstructions. [Limit: >=0] [Units: vx]
  155633. */
  155634. walkableRadius: number;
  155635. /**
  155636. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  155637. */
  155638. maxEdgeLen: number;
  155639. /**
  155640. * The maximum distance a simplfied contour's border edges should deviate
  155641. * the original raw contour. [Limit: >=0] [Units: vx]
  155642. */
  155643. maxSimplificationError: number;
  155644. /**
  155645. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  155646. */
  155647. minRegionArea: number;
  155648. /**
  155649. * Any regions with a span count smaller than this value will, if possible,
  155650. * be merged with larger regions. [Limit: >=0] [Units: vx]
  155651. */
  155652. mergeRegionArea: number;
  155653. /**
  155654. * The maximum number of vertices allowed for polygons generated during the
  155655. * contour to polygon conversion process. [Limit: >= 3]
  155656. */
  155657. maxVertsPerPoly: number;
  155658. /**
  155659. * Sets the sampling distance to use when generating the detail mesh.
  155660. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  155661. */
  155662. detailSampleDist: number;
  155663. /**
  155664. * The maximum distance the detail mesh surface should deviate from heightfield
  155665. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  155666. */
  155667. detailSampleMaxError: number;
  155668. }
  155669. }
  155670. declare module BABYLON {
  155671. /**
  155672. * RecastJS navigation plugin
  155673. */
  155674. export class RecastJSPlugin implements INavigationEnginePlugin {
  155675. /**
  155676. * Reference to the Recast library
  155677. */
  155678. bjsRECAST: any;
  155679. /**
  155680. * plugin name
  155681. */
  155682. name: string;
  155683. /**
  155684. * the first navmesh created. We might extend this to support multiple navmeshes
  155685. */
  155686. navMesh: any;
  155687. private _maximumSubStepCount;
  155688. private _timeStep;
  155689. /**
  155690. * Initializes the recastJS plugin
  155691. * @param recastInjection can be used to inject your own recast reference
  155692. */
  155693. constructor(recastInjection?: any);
  155694. /**
  155695. * Set the time step of the navigation tick update.
  155696. * Default is 1/60.
  155697. * A value of 0 will disable fixed time update
  155698. * @param newTimeStep the new timestep to apply to this world.
  155699. */
  155700. setTimeStep(newTimeStep?: number): void;
  155701. /**
  155702. * Get the time step of the navigation tick update.
  155703. * @returns the current time step
  155704. */
  155705. getTimeStep(): number;
  155706. /**
  155707. * If delta time in navigation tick update is greater than the time step
  155708. * a number of sub iterations are done. If more iterations are need to reach deltatime
  155709. * they will be discarded.
  155710. * A value of 0 will set to no maximum and update will use as many substeps as needed
  155711. * @param newStepCount the maximum number of iterations
  155712. */
  155713. setMaximumSubStepCount(newStepCount?: number): void;
  155714. /**
  155715. * Get the maximum number of iterations per navigation tick update
  155716. * @returns the maximum number of iterations
  155717. */
  155718. getMaximumSubStepCount(): number;
  155719. /**
  155720. * Creates a navigation mesh
  155721. * @param meshes array of all the geometry used to compute the navigatio mesh
  155722. * @param parameters bunch of parameters used to filter geometry
  155723. */
  155724. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  155725. /**
  155726. * Create a navigation mesh debug mesh
  155727. * @param scene is where the mesh will be added
  155728. * @returns debug display mesh
  155729. */
  155730. createDebugNavMesh(scene: Scene): Mesh;
  155731. /**
  155732. * Get a navigation mesh constrained position, closest to the parameter position
  155733. * @param position world position
  155734. * @returns the closest point to position constrained by the navigation mesh
  155735. */
  155736. getClosestPoint(position: Vector3): Vector3;
  155737. /**
  155738. * Get a navigation mesh constrained position, closest to the parameter position
  155739. * @param position world position
  155740. * @param result output the closest point to position constrained by the navigation mesh
  155741. */
  155742. getClosestPointToRef(position: Vector3, result: Vector3): void;
  155743. /**
  155744. * Get a navigation mesh constrained position, within a particular radius
  155745. * @param position world position
  155746. * @param maxRadius the maximum distance to the constrained world position
  155747. * @returns the closest point to position constrained by the navigation mesh
  155748. */
  155749. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  155750. /**
  155751. * Get a navigation mesh constrained position, within a particular radius
  155752. * @param position world position
  155753. * @param maxRadius the maximum distance to the constrained world position
  155754. * @param result output the closest point to position constrained by the navigation mesh
  155755. */
  155756. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  155757. /**
  155758. * Compute the final position from a segment made of destination-position
  155759. * @param position world position
  155760. * @param destination world position
  155761. * @returns the resulting point along the navmesh
  155762. */
  155763. moveAlong(position: Vector3, destination: Vector3): Vector3;
  155764. /**
  155765. * Compute the final position from a segment made of destination-position
  155766. * @param position world position
  155767. * @param destination world position
  155768. * @param result output the resulting point along the navmesh
  155769. */
  155770. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  155771. /**
  155772. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  155773. * @param start world position
  155774. * @param end world position
  155775. * @returns array containing world position composing the path
  155776. */
  155777. computePath(start: Vector3, end: Vector3): Vector3[];
  155778. /**
  155779. * Create a new Crowd so you can add agents
  155780. * @param maxAgents the maximum agent count in the crowd
  155781. * @param maxAgentRadius the maximum radius an agent can have
  155782. * @param scene to attach the crowd to
  155783. * @returns the crowd you can add agents to
  155784. */
  155785. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  155786. /**
  155787. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  155788. * The queries will try to find a solution within those bounds
  155789. * default is (1,1,1)
  155790. * @param extent x,y,z value that define the extent around the queries point of reference
  155791. */
  155792. setDefaultQueryExtent(extent: Vector3): void;
  155793. /**
  155794. * Get the Bounding box extent specified by setDefaultQueryExtent
  155795. * @returns the box extent values
  155796. */
  155797. getDefaultQueryExtent(): Vector3;
  155798. /**
  155799. * build the navmesh from a previously saved state using getNavmeshData
  155800. * @param data the Uint8Array returned by getNavmeshData
  155801. */
  155802. buildFromNavmeshData(data: Uint8Array): void;
  155803. /**
  155804. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  155805. * @returns data the Uint8Array that can be saved and reused
  155806. */
  155807. getNavmeshData(): Uint8Array;
  155808. /**
  155809. * Get the Bounding box extent result specified by setDefaultQueryExtent
  155810. * @param result output the box extent values
  155811. */
  155812. getDefaultQueryExtentToRef(result: Vector3): void;
  155813. /**
  155814. * Disposes
  155815. */
  155816. dispose(): void;
  155817. /**
  155818. * If this plugin is supported
  155819. * @returns true if plugin is supported
  155820. */
  155821. isSupported(): boolean;
  155822. }
  155823. /**
  155824. * Recast detour crowd implementation
  155825. */
  155826. export class RecastJSCrowd implements ICrowd {
  155827. /**
  155828. * Recast/detour plugin
  155829. */
  155830. bjsRECASTPlugin: RecastJSPlugin;
  155831. /**
  155832. * Link to the detour crowd
  155833. */
  155834. recastCrowd: any;
  155835. /**
  155836. * One transform per agent
  155837. */
  155838. transforms: TransformNode[];
  155839. /**
  155840. * All agents created
  155841. */
  155842. agents: number[];
  155843. /**
  155844. * Link to the scene is kept to unregister the crowd from the scene
  155845. */
  155846. private _scene;
  155847. /**
  155848. * Observer for crowd updates
  155849. */
  155850. private _onBeforeAnimationsObserver;
  155851. /**
  155852. * Constructor
  155853. * @param plugin recastJS plugin
  155854. * @param maxAgents the maximum agent count in the crowd
  155855. * @param maxAgentRadius the maximum radius an agent can have
  155856. * @param scene to attach the crowd to
  155857. * @returns the crowd you can add agents to
  155858. */
  155859. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  155860. /**
  155861. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  155862. * You can attach anything to that node. The node position is updated in the scene update tick.
  155863. * @param pos world position that will be constrained by the navigation mesh
  155864. * @param parameters agent parameters
  155865. * @param transform hooked to the agent that will be update by the scene
  155866. * @returns agent index
  155867. */
  155868. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  155869. /**
  155870. * Returns the agent position in world space
  155871. * @param index agent index returned by addAgent
  155872. * @returns world space position
  155873. */
  155874. getAgentPosition(index: number): Vector3;
  155875. /**
  155876. * Returns the agent position result in world space
  155877. * @param index agent index returned by addAgent
  155878. * @param result output world space position
  155879. */
  155880. getAgentPositionToRef(index: number, result: Vector3): void;
  155881. /**
  155882. * Returns the agent velocity in world space
  155883. * @param index agent index returned by addAgent
  155884. * @returns world space velocity
  155885. */
  155886. getAgentVelocity(index: number): Vector3;
  155887. /**
  155888. * Returns the agent velocity result in world space
  155889. * @param index agent index returned by addAgent
  155890. * @param result output world space velocity
  155891. */
  155892. getAgentVelocityToRef(index: number, result: Vector3): void;
  155893. /**
  155894. * Returns the agent next target point on the path
  155895. * @param index agent index returned by addAgent
  155896. * @returns world space position
  155897. */
  155898. getAgentNextTargetPath(index: number): Vector3;
  155899. /**
  155900. * Returns the agent next target point on the path
  155901. * @param index agent index returned by addAgent
  155902. * @param result output world space position
  155903. */
  155904. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  155905. /**
  155906. * Gets the agent state
  155907. * @param index agent index returned by addAgent
  155908. * @returns agent state
  155909. */
  155910. getAgentState(index: number): number;
  155911. /**
  155912. * returns true if the agent in over an off mesh link connection
  155913. * @param index agent index returned by addAgent
  155914. * @returns true if over an off mesh link connection
  155915. */
  155916. overOffmeshConnection(index: number): boolean;
  155917. /**
  155918. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  155919. * @param index agent index returned by addAgent
  155920. * @param destination targeted world position
  155921. */
  155922. agentGoto(index: number, destination: Vector3): void;
  155923. /**
  155924. * Teleport the agent to a new position
  155925. * @param index agent index returned by addAgent
  155926. * @param destination targeted world position
  155927. */
  155928. agentTeleport(index: number, destination: Vector3): void;
  155929. /**
  155930. * Update agent parameters
  155931. * @param index agent index returned by addAgent
  155932. * @param parameters agent parameters
  155933. */
  155934. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  155935. /**
  155936. * remove a particular agent previously created
  155937. * @param index agent index returned by addAgent
  155938. */
  155939. removeAgent(index: number): void;
  155940. /**
  155941. * get the list of all agents attached to this crowd
  155942. * @returns list of agent indices
  155943. */
  155944. getAgents(): number[];
  155945. /**
  155946. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  155947. * @param deltaTime in seconds
  155948. */
  155949. update(deltaTime: number): void;
  155950. /**
  155951. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  155952. * The queries will try to find a solution within those bounds
  155953. * default is (1,1,1)
  155954. * @param extent x,y,z value that define the extent around the queries point of reference
  155955. */
  155956. setDefaultQueryExtent(extent: Vector3): void;
  155957. /**
  155958. * Get the Bounding box extent specified by setDefaultQueryExtent
  155959. * @returns the box extent values
  155960. */
  155961. getDefaultQueryExtent(): Vector3;
  155962. /**
  155963. * Get the Bounding box extent result specified by setDefaultQueryExtent
  155964. * @param result output the box extent values
  155965. */
  155966. getDefaultQueryExtentToRef(result: Vector3): void;
  155967. /**
  155968. * Release all resources
  155969. */
  155970. dispose(): void;
  155971. }
  155972. }
  155973. declare module BABYLON {
  155974. /**
  155975. * Class used to enable access to IndexedDB
  155976. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  155977. */
  155978. export class Database implements IOfflineProvider {
  155979. private _callbackManifestChecked;
  155980. private _currentSceneUrl;
  155981. private _db;
  155982. private _enableSceneOffline;
  155983. private _enableTexturesOffline;
  155984. private _manifestVersionFound;
  155985. private _mustUpdateRessources;
  155986. private _hasReachedQuota;
  155987. private _isSupported;
  155988. private _idbFactory;
  155989. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  155990. private static IsUASupportingBlobStorage;
  155991. /**
  155992. * Gets a boolean indicating if Database storate is enabled (off by default)
  155993. */
  155994. static IDBStorageEnabled: boolean;
  155995. /**
  155996. * Gets a boolean indicating if scene must be saved in the database
  155997. */
  155998. get enableSceneOffline(): boolean;
  155999. /**
  156000. * Gets a boolean indicating if textures must be saved in the database
  156001. */
  156002. get enableTexturesOffline(): boolean;
  156003. /**
  156004. * Creates a new Database
  156005. * @param urlToScene defines the url to load the scene
  156006. * @param callbackManifestChecked defines the callback to use when manifest is checked
  156007. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  156008. */
  156009. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  156010. private static _ParseURL;
  156011. private static _ReturnFullUrlLocation;
  156012. private _checkManifestFile;
  156013. /**
  156014. * Open the database and make it available
  156015. * @param successCallback defines the callback to call on success
  156016. * @param errorCallback defines the callback to call on error
  156017. */
  156018. open(successCallback: () => void, errorCallback: () => void): void;
  156019. /**
  156020. * Loads an image from the database
  156021. * @param url defines the url to load from
  156022. * @param image defines the target DOM image
  156023. */
  156024. loadImage(url: string, image: HTMLImageElement): void;
  156025. private _loadImageFromDBAsync;
  156026. private _saveImageIntoDBAsync;
  156027. private _checkVersionFromDB;
  156028. private _loadVersionFromDBAsync;
  156029. private _saveVersionIntoDBAsync;
  156030. /**
  156031. * Loads a file from database
  156032. * @param url defines the URL to load from
  156033. * @param sceneLoaded defines a callback to call on success
  156034. * @param progressCallBack defines a callback to call when progress changed
  156035. * @param errorCallback defines a callback to call on error
  156036. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  156037. */
  156038. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  156039. private _loadFileAsync;
  156040. private _saveFileAsync;
  156041. /**
  156042. * Validates if xhr data is correct
  156043. * @param xhr defines the request to validate
  156044. * @param dataType defines the expected data type
  156045. * @returns true if data is correct
  156046. */
  156047. private static _ValidateXHRData;
  156048. }
  156049. }
  156050. declare module BABYLON {
  156051. /** @hidden */
  156052. export var gpuUpdateParticlesPixelShader: {
  156053. name: string;
  156054. shader: string;
  156055. };
  156056. }
  156057. declare module BABYLON {
  156058. /** @hidden */
  156059. export var gpuUpdateParticlesVertexShader: {
  156060. name: string;
  156061. shader: string;
  156062. };
  156063. }
  156064. declare module BABYLON {
  156065. /** @hidden */
  156066. export var clipPlaneFragmentDeclaration2: {
  156067. name: string;
  156068. shader: string;
  156069. };
  156070. }
  156071. declare module BABYLON {
  156072. /** @hidden */
  156073. export var gpuRenderParticlesPixelShader: {
  156074. name: string;
  156075. shader: string;
  156076. };
  156077. }
  156078. declare module BABYLON {
  156079. /** @hidden */
  156080. export var clipPlaneVertexDeclaration2: {
  156081. name: string;
  156082. shader: string;
  156083. };
  156084. }
  156085. declare module BABYLON {
  156086. /** @hidden */
  156087. export var gpuRenderParticlesVertexShader: {
  156088. name: string;
  156089. shader: string;
  156090. };
  156091. }
  156092. declare module BABYLON {
  156093. /**
  156094. * This represents a GPU particle system in Babylon
  156095. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  156096. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  156097. */
  156098. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  156099. /**
  156100. * The layer mask we are rendering the particles through.
  156101. */
  156102. layerMask: number;
  156103. private _capacity;
  156104. private _activeCount;
  156105. private _currentActiveCount;
  156106. private _accumulatedCount;
  156107. private _renderEffect;
  156108. private _updateEffect;
  156109. private _buffer0;
  156110. private _buffer1;
  156111. private _spriteBuffer;
  156112. private _updateVAO;
  156113. private _renderVAO;
  156114. private _targetIndex;
  156115. private _sourceBuffer;
  156116. private _targetBuffer;
  156117. private _currentRenderId;
  156118. private _started;
  156119. private _stopped;
  156120. private _timeDelta;
  156121. private _randomTexture;
  156122. private _randomTexture2;
  156123. private _attributesStrideSize;
  156124. private _updateEffectOptions;
  156125. private _randomTextureSize;
  156126. private _actualFrame;
  156127. private _customEffect;
  156128. private readonly _rawTextureWidth;
  156129. /**
  156130. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  156131. */
  156132. static get IsSupported(): boolean;
  156133. /**
  156134. * An event triggered when the system is disposed.
  156135. */
  156136. onDisposeObservable: Observable<IParticleSystem>;
  156137. /**
  156138. * An event triggered when the system is stopped
  156139. */
  156140. onStoppedObservable: Observable<IParticleSystem>;
  156141. /**
  156142. * Gets the maximum number of particles active at the same time.
  156143. * @returns The max number of active particles.
  156144. */
  156145. getCapacity(): number;
  156146. /**
  156147. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  156148. * to override the particles.
  156149. */
  156150. forceDepthWrite: boolean;
  156151. /**
  156152. * Gets or set the number of active particles
  156153. */
  156154. get activeParticleCount(): number;
  156155. set activeParticleCount(value: number);
  156156. private _preWarmDone;
  156157. /**
  156158. * Specifies if the particles are updated in emitter local space or world space.
  156159. */
  156160. isLocal: boolean;
  156161. /** Gets or sets a matrix to use to compute projection */
  156162. defaultProjectionMatrix: Matrix;
  156163. /**
  156164. * Is this system ready to be used/rendered
  156165. * @return true if the system is ready
  156166. */
  156167. isReady(): boolean;
  156168. /**
  156169. * Gets if the system has been started. (Note: this will still be true after stop is called)
  156170. * @returns True if it has been started, otherwise false.
  156171. */
  156172. isStarted(): boolean;
  156173. /**
  156174. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  156175. * @returns True if it has been stopped, otherwise false.
  156176. */
  156177. isStopped(): boolean;
  156178. /**
  156179. * Gets a boolean indicating that the system is stopping
  156180. * @returns true if the system is currently stopping
  156181. */
  156182. isStopping(): boolean;
  156183. /**
  156184. * Gets the number of particles active at the same time.
  156185. * @returns The number of active particles.
  156186. */
  156187. getActiveCount(): number;
  156188. /**
  156189. * Starts the particle system and begins to emit
  156190. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  156191. */
  156192. start(delay?: number): void;
  156193. /**
  156194. * Stops the particle system.
  156195. */
  156196. stop(): void;
  156197. /**
  156198. * Remove all active particles
  156199. */
  156200. reset(): void;
  156201. /**
  156202. * Returns the string "GPUParticleSystem"
  156203. * @returns a string containing the class name
  156204. */
  156205. getClassName(): string;
  156206. /**
  156207. * Gets the custom effect used to render the particles
  156208. * @param blendMode Blend mode for which the effect should be retrieved
  156209. * @returns The effect
  156210. */
  156211. getCustomEffect(blendMode?: number): Nullable<Effect>;
  156212. /**
  156213. * Sets the custom effect used to render the particles
  156214. * @param effect The effect to set
  156215. * @param blendMode Blend mode for which the effect should be set
  156216. */
  156217. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  156218. /** @hidden */
  156219. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  156220. /**
  156221. * Observable that will be called just before the particles are drawn
  156222. */
  156223. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  156224. /**
  156225. * Gets the name of the particle vertex shader
  156226. */
  156227. get vertexShaderName(): string;
  156228. private _colorGradientsTexture;
  156229. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  156230. /**
  156231. * Adds a new color gradient
  156232. * @param gradient defines the gradient to use (between 0 and 1)
  156233. * @param color1 defines the color to affect to the specified gradient
  156234. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  156235. * @returns the current particle system
  156236. */
  156237. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  156238. private _refreshColorGradient;
  156239. /** Force the system to rebuild all gradients that need to be resync */
  156240. forceRefreshGradients(): void;
  156241. /**
  156242. * Remove a specific color gradient
  156243. * @param gradient defines the gradient to remove
  156244. * @returns the current particle system
  156245. */
  156246. removeColorGradient(gradient: number): GPUParticleSystem;
  156247. private _angularSpeedGradientsTexture;
  156248. private _sizeGradientsTexture;
  156249. private _velocityGradientsTexture;
  156250. private _limitVelocityGradientsTexture;
  156251. private _dragGradientsTexture;
  156252. private _addFactorGradient;
  156253. /**
  156254. * Adds a new size gradient
  156255. * @param gradient defines the gradient to use (between 0 and 1)
  156256. * @param factor defines the size factor to affect to the specified gradient
  156257. * @returns the current particle system
  156258. */
  156259. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  156260. /**
  156261. * Remove a specific size gradient
  156262. * @param gradient defines the gradient to remove
  156263. * @returns the current particle system
  156264. */
  156265. removeSizeGradient(gradient: number): GPUParticleSystem;
  156266. private _refreshFactorGradient;
  156267. /**
  156268. * Adds a new angular speed gradient
  156269. * @param gradient defines the gradient to use (between 0 and 1)
  156270. * @param factor defines the angular speed to affect to the specified gradient
  156271. * @returns the current particle system
  156272. */
  156273. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  156274. /**
  156275. * Remove a specific angular speed gradient
  156276. * @param gradient defines the gradient to remove
  156277. * @returns the current particle system
  156278. */
  156279. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  156280. /**
  156281. * Adds a new velocity gradient
  156282. * @param gradient defines the gradient to use (between 0 and 1)
  156283. * @param factor defines the velocity to affect to the specified gradient
  156284. * @returns the current particle system
  156285. */
  156286. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  156287. /**
  156288. * Remove a specific velocity gradient
  156289. * @param gradient defines the gradient to remove
  156290. * @returns the current particle system
  156291. */
  156292. removeVelocityGradient(gradient: number): GPUParticleSystem;
  156293. /**
  156294. * Adds a new limit velocity gradient
  156295. * @param gradient defines the gradient to use (between 0 and 1)
  156296. * @param factor defines the limit velocity value to affect to the specified gradient
  156297. * @returns the current particle system
  156298. */
  156299. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  156300. /**
  156301. * Remove a specific limit velocity gradient
  156302. * @param gradient defines the gradient to remove
  156303. * @returns the current particle system
  156304. */
  156305. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  156306. /**
  156307. * Adds a new drag gradient
  156308. * @param gradient defines the gradient to use (between 0 and 1)
  156309. * @param factor defines the drag value to affect to the specified gradient
  156310. * @returns the current particle system
  156311. */
  156312. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  156313. /**
  156314. * Remove a specific drag gradient
  156315. * @param gradient defines the gradient to remove
  156316. * @returns the current particle system
  156317. */
  156318. removeDragGradient(gradient: number): GPUParticleSystem;
  156319. /**
  156320. * Not supported by GPUParticleSystem
  156321. * @param gradient defines the gradient to use (between 0 and 1)
  156322. * @param factor defines the emit rate value to affect to the specified gradient
  156323. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  156324. * @returns the current particle system
  156325. */
  156326. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  156327. /**
  156328. * Not supported by GPUParticleSystem
  156329. * @param gradient defines the gradient to remove
  156330. * @returns the current particle system
  156331. */
  156332. removeEmitRateGradient(gradient: number): IParticleSystem;
  156333. /**
  156334. * Not supported by GPUParticleSystem
  156335. * @param gradient defines the gradient to use (between 0 and 1)
  156336. * @param factor defines the start size value to affect to the specified gradient
  156337. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  156338. * @returns the current particle system
  156339. */
  156340. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  156341. /**
  156342. * Not supported by GPUParticleSystem
  156343. * @param gradient defines the gradient to remove
  156344. * @returns the current particle system
  156345. */
  156346. removeStartSizeGradient(gradient: number): IParticleSystem;
  156347. /**
  156348. * Not supported by GPUParticleSystem
  156349. * @param gradient defines the gradient to use (between 0 and 1)
  156350. * @param min defines the color remap minimal range
  156351. * @param max defines the color remap maximal range
  156352. * @returns the current particle system
  156353. */
  156354. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  156355. /**
  156356. * Not supported by GPUParticleSystem
  156357. * @param gradient defines the gradient to remove
  156358. * @returns the current particle system
  156359. */
  156360. removeColorRemapGradient(): IParticleSystem;
  156361. /**
  156362. * Not supported by GPUParticleSystem
  156363. * @param gradient defines the gradient to use (between 0 and 1)
  156364. * @param min defines the alpha remap minimal range
  156365. * @param max defines the alpha remap maximal range
  156366. * @returns the current particle system
  156367. */
  156368. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  156369. /**
  156370. * Not supported by GPUParticleSystem
  156371. * @param gradient defines the gradient to remove
  156372. * @returns the current particle system
  156373. */
  156374. removeAlphaRemapGradient(): IParticleSystem;
  156375. /**
  156376. * Not supported by GPUParticleSystem
  156377. * @param gradient defines the gradient to use (between 0 and 1)
  156378. * @param color defines the color to affect to the specified gradient
  156379. * @returns the current particle system
  156380. */
  156381. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  156382. /**
  156383. * Not supported by GPUParticleSystem
  156384. * @param gradient defines the gradient to remove
  156385. * @returns the current particle system
  156386. */
  156387. removeRampGradient(): IParticleSystem;
  156388. /**
  156389. * Not supported by GPUParticleSystem
  156390. * @returns the list of ramp gradients
  156391. */
  156392. getRampGradients(): Nullable<Array<Color3Gradient>>;
  156393. /**
  156394. * Not supported by GPUParticleSystem
  156395. * Gets or sets a boolean indicating that ramp gradients must be used
  156396. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  156397. */
  156398. get useRampGradients(): boolean;
  156399. set useRampGradients(value: boolean);
  156400. /**
  156401. * Not supported by GPUParticleSystem
  156402. * @param gradient defines the gradient to use (between 0 and 1)
  156403. * @param factor defines the life time factor to affect to the specified gradient
  156404. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  156405. * @returns the current particle system
  156406. */
  156407. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  156408. /**
  156409. * Not supported by GPUParticleSystem
  156410. * @param gradient defines the gradient to remove
  156411. * @returns the current particle system
  156412. */
  156413. removeLifeTimeGradient(gradient: number): IParticleSystem;
  156414. /**
  156415. * Instantiates a GPU particle system.
  156416. * 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.
  156417. * @param name The name of the particle system
  156418. * @param options The options used to create the system
  156419. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  156420. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  156421. * @param customEffect a custom effect used to change the way particles are rendered by default
  156422. */
  156423. constructor(name: string, options: Partial<{
  156424. capacity: number;
  156425. randomTextureSize: number;
  156426. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  156427. protected _reset(): void;
  156428. private _createUpdateVAO;
  156429. private _createRenderVAO;
  156430. private _initialize;
  156431. /** @hidden */
  156432. _recreateUpdateEffect(): void;
  156433. private _getEffect;
  156434. /**
  156435. * Fill the defines array according to the current settings of the particle system
  156436. * @param defines Array to be updated
  156437. * @param blendMode blend mode to take into account when updating the array
  156438. */
  156439. fillDefines(defines: Array<string>, blendMode?: number): void;
  156440. /**
  156441. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  156442. * @param uniforms Uniforms array to fill
  156443. * @param attributes Attributes array to fill
  156444. * @param samplers Samplers array to fill
  156445. */
  156446. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  156447. /** @hidden */
  156448. _recreateRenderEffect(): Effect;
  156449. /**
  156450. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  156451. * @param preWarm defines if we are in the pre-warmimg phase
  156452. */
  156453. animate(preWarm?: boolean): void;
  156454. private _createFactorGradientTexture;
  156455. private _createSizeGradientTexture;
  156456. private _createAngularSpeedGradientTexture;
  156457. private _createVelocityGradientTexture;
  156458. private _createLimitVelocityGradientTexture;
  156459. private _createDragGradientTexture;
  156460. private _createColorGradientTexture;
  156461. /**
  156462. * Renders the particle system in its current state
  156463. * @param preWarm defines if the system should only update the particles but not render them
  156464. * @returns the current number of particles
  156465. */
  156466. render(preWarm?: boolean): number;
  156467. /**
  156468. * Rebuilds the particle system
  156469. */
  156470. rebuild(): void;
  156471. private _releaseBuffers;
  156472. private _releaseVAOs;
  156473. /**
  156474. * Disposes the particle system and free the associated resources
  156475. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  156476. */
  156477. dispose(disposeTexture?: boolean): void;
  156478. /**
  156479. * Clones the particle system.
  156480. * @param name The name of the cloned object
  156481. * @param newEmitter The new emitter to use
  156482. * @returns the cloned particle system
  156483. */
  156484. clone(name: string, newEmitter: any): GPUParticleSystem;
  156485. /**
  156486. * Serializes the particle system to a JSON object
  156487. * @param serializeTexture defines if the texture must be serialized as well
  156488. * @returns the JSON object
  156489. */
  156490. serialize(serializeTexture?: boolean): any;
  156491. /**
  156492. * Parses a JSON object to create a GPU particle system.
  156493. * @param parsedParticleSystem The JSON object to parse
  156494. * @param sceneOrEngine The scene or the engine to create the particle system in
  156495. * @param rootUrl The root url to use to load external dependencies like texture
  156496. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  156497. * @returns the parsed GPU particle system
  156498. */
  156499. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  156500. }
  156501. }
  156502. declare module BABYLON {
  156503. /**
  156504. * Represents a set of particle systems working together to create a specific effect
  156505. */
  156506. export class ParticleSystemSet implements IDisposable {
  156507. /**
  156508. * Gets or sets base Assets URL
  156509. */
  156510. static BaseAssetsUrl: string;
  156511. private _emitterCreationOptions;
  156512. private _emitterNode;
  156513. /**
  156514. * Gets the particle system list
  156515. */
  156516. systems: IParticleSystem[];
  156517. /**
  156518. * Gets the emitter node used with this set
  156519. */
  156520. get emitterNode(): Nullable<TransformNode>;
  156521. /**
  156522. * Creates a new emitter mesh as a sphere
  156523. * @param options defines the options used to create the sphere
  156524. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  156525. * @param scene defines the hosting scene
  156526. */
  156527. setEmitterAsSphere(options: {
  156528. diameter: number;
  156529. segments: number;
  156530. color: Color3;
  156531. }, renderingGroupId: number, scene: Scene): void;
  156532. /**
  156533. * Starts all particle systems of the set
  156534. * @param emitter defines an optional mesh to use as emitter for the particle systems
  156535. */
  156536. start(emitter?: AbstractMesh): void;
  156537. /**
  156538. * Release all associated resources
  156539. */
  156540. dispose(): void;
  156541. /**
  156542. * Serialize the set into a JSON compatible object
  156543. * @param serializeTexture defines if the texture must be serialized as well
  156544. * @returns a JSON compatible representation of the set
  156545. */
  156546. serialize(serializeTexture?: boolean): any;
  156547. /**
  156548. * Parse a new ParticleSystemSet from a serialized source
  156549. * @param data defines a JSON compatible representation of the set
  156550. * @param scene defines the hosting scene
  156551. * @param gpu defines if we want GPU particles or CPU particles
  156552. * @returns a new ParticleSystemSet
  156553. */
  156554. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  156555. }
  156556. }
  156557. declare module BABYLON {
  156558. /**
  156559. * This class is made for on one-liner static method to help creating particle system set.
  156560. */
  156561. export class ParticleHelper {
  156562. /**
  156563. * Gets or sets base Assets URL
  156564. */
  156565. static BaseAssetsUrl: string;
  156566. /** Define the Url to load snippets */
  156567. static SnippetUrl: string;
  156568. /**
  156569. * Create a default particle system that you can tweak
  156570. * @param emitter defines the emitter to use
  156571. * @param capacity defines the system capacity (default is 500 particles)
  156572. * @param scene defines the hosting scene
  156573. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  156574. * @returns the new Particle system
  156575. */
  156576. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  156577. /**
  156578. * This is the main static method (one-liner) of this helper to create different particle systems
  156579. * @param type This string represents the type to the particle system to create
  156580. * @param scene The scene where the particle system should live
  156581. * @param gpu If the system will use gpu
  156582. * @returns the ParticleSystemSet created
  156583. */
  156584. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  156585. /**
  156586. * Static function used to export a particle system to a ParticleSystemSet variable.
  156587. * Please note that the emitter shape is not exported
  156588. * @param systems defines the particle systems to export
  156589. * @returns the created particle system set
  156590. */
  156591. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  156592. /**
  156593. * Creates a particle system from a snippet saved in a remote file
  156594. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  156595. * @param url defines the url to load from
  156596. * @param scene defines the hosting scene
  156597. * @param gpu If the system will use gpu
  156598. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  156599. * @returns a promise that will resolve to the new particle system
  156600. */
  156601. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  156602. /**
  156603. * Creates a particle system from a snippet saved by the particle system editor
  156604. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  156605. * @param scene defines the hosting scene
  156606. * @param gpu If the system will use gpu
  156607. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  156608. * @returns a promise that will resolve to the new particle system
  156609. */
  156610. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  156611. }
  156612. }
  156613. declare module BABYLON {
  156614. interface Engine {
  156615. /**
  156616. * Create an effect to use with particle systems.
  156617. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  156618. * the particle system for which you want to create a custom effect in the last parameter
  156619. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  156620. * @param uniformsNames defines a list of attribute names
  156621. * @param samplers defines an array of string used to represent textures
  156622. * @param defines defines the string containing the defines to use to compile the shaders
  156623. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  156624. * @param onCompiled defines a function to call when the effect creation is successful
  156625. * @param onError defines a function to call when the effect creation has failed
  156626. * @param particleSystem the particle system you want to create the effect for
  156627. * @returns the new Effect
  156628. */
  156629. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  156630. }
  156631. interface Mesh {
  156632. /**
  156633. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  156634. * @returns an array of IParticleSystem
  156635. */
  156636. getEmittedParticleSystems(): IParticleSystem[];
  156637. /**
  156638. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  156639. * @returns an array of IParticleSystem
  156640. */
  156641. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  156642. }
  156643. }
  156644. declare module BABYLON {
  156645. /** Defines the 4 color options */
  156646. export enum PointColor {
  156647. /** color value */
  156648. Color = 2,
  156649. /** uv value */
  156650. UV = 1,
  156651. /** random value */
  156652. Random = 0,
  156653. /** stated value */
  156654. Stated = 3
  156655. }
  156656. /**
  156657. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  156658. * 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.
  156659. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  156660. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  156661. *
  156662. * Full documentation here : TO BE ENTERED
  156663. */
  156664. export class PointsCloudSystem implements IDisposable {
  156665. /**
  156666. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  156667. * Example : var p = SPS.particles[i];
  156668. */
  156669. particles: CloudPoint[];
  156670. /**
  156671. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  156672. */
  156673. nbParticles: number;
  156674. /**
  156675. * This a counter for your own usage. It's not set by any SPS functions.
  156676. */
  156677. counter: number;
  156678. /**
  156679. * The PCS name. This name is also given to the underlying mesh.
  156680. */
  156681. name: string;
  156682. /**
  156683. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  156684. */
  156685. mesh: Mesh;
  156686. /**
  156687. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  156688. * Please read :
  156689. */
  156690. vars: any;
  156691. /**
  156692. * @hidden
  156693. */
  156694. _size: number;
  156695. private _scene;
  156696. private _promises;
  156697. private _positions;
  156698. private _indices;
  156699. private _normals;
  156700. private _colors;
  156701. private _uvs;
  156702. private _indices32;
  156703. private _positions32;
  156704. private _colors32;
  156705. private _uvs32;
  156706. private _updatable;
  156707. private _isVisibilityBoxLocked;
  156708. private _alwaysVisible;
  156709. private _groups;
  156710. private _groupCounter;
  156711. private _computeParticleColor;
  156712. private _computeParticleTexture;
  156713. private _computeParticleRotation;
  156714. private _computeBoundingBox;
  156715. private _isReady;
  156716. /**
  156717. * Creates a PCS (Points Cloud System) object
  156718. * @param name (String) is the PCS name, this will be the underlying mesh name
  156719. * @param pointSize (number) is the size for each point
  156720. * @param scene (Scene) is the scene in which the PCS is added
  156721. * @param options defines the options of the PCS e.g.
  156722. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  156723. */
  156724. constructor(name: string, pointSize: number, scene: Scene, options?: {
  156725. updatable?: boolean;
  156726. });
  156727. /**
  156728. * Builds the PCS underlying mesh. Returns a standard Mesh.
  156729. * If no points were added to the PCS, the returned mesh is just a single point.
  156730. * @returns a promise for the created mesh
  156731. */
  156732. buildMeshAsync(): Promise<Mesh>;
  156733. /**
  156734. * @hidden
  156735. */
  156736. private _buildMesh;
  156737. private _addParticle;
  156738. private _randomUnitVector;
  156739. private _getColorIndicesForCoord;
  156740. private _setPointsColorOrUV;
  156741. private _colorFromTexture;
  156742. private _calculateDensity;
  156743. /**
  156744. * Adds points to the PCS in random positions within a unit sphere
  156745. * @param nb (positive integer) the number of particles to be created from this model
  156746. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  156747. * @returns the number of groups in the system
  156748. */
  156749. addPoints(nb: number, pointFunction?: any): number;
  156750. /**
  156751. * Adds points to the PCS from the surface of the model shape
  156752. * @param mesh is any Mesh object that will be used as a surface model for the points
  156753. * @param nb (positive integer) the number of particles to be created from this model
  156754. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  156755. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  156756. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  156757. * @returns the number of groups in the system
  156758. */
  156759. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  156760. /**
  156761. * Adds points to the PCS inside the model shape
  156762. * @param mesh is any Mesh object that will be used as a surface model for the points
  156763. * @param nb (positive integer) the number of particles to be created from this model
  156764. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  156765. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  156766. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  156767. * @returns the number of groups in the system
  156768. */
  156769. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  156770. /**
  156771. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  156772. * This method calls `updateParticle()` for each particle of the SPS.
  156773. * For an animated SPS, it is usually called within the render loop.
  156774. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  156775. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  156776. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  156777. * @returns the PCS.
  156778. */
  156779. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  156780. /**
  156781. * Disposes the PCS.
  156782. */
  156783. dispose(): void;
  156784. /**
  156785. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  156786. * doc :
  156787. * @returns the PCS.
  156788. */
  156789. refreshVisibleSize(): PointsCloudSystem;
  156790. /**
  156791. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  156792. * @param size the size (float) of the visibility box
  156793. * note : this doesn't lock the PCS mesh bounding box.
  156794. * doc :
  156795. */
  156796. setVisibilityBox(size: number): void;
  156797. /**
  156798. * Gets whether the PCS is always visible or not
  156799. * doc :
  156800. */
  156801. get isAlwaysVisible(): boolean;
  156802. /**
  156803. * Sets the PCS as always visible or not
  156804. * doc :
  156805. */
  156806. set isAlwaysVisible(val: boolean);
  156807. /**
  156808. * Tells to `setParticles()` to compute the particle rotations or not
  156809. * Default value : false. The PCS is faster when it's set to false
  156810. * Note : particle rotations are only applied to parent particles
  156811. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  156812. */
  156813. set computeParticleRotation(val: boolean);
  156814. /**
  156815. * Tells to `setParticles()` to compute the particle colors or not.
  156816. * Default value : true. The PCS is faster when it's set to false.
  156817. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  156818. */
  156819. set computeParticleColor(val: boolean);
  156820. set computeParticleTexture(val: boolean);
  156821. /**
  156822. * Gets if `setParticles()` computes the particle colors or not.
  156823. * Default value : false. The PCS is faster when it's set to false.
  156824. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  156825. */
  156826. get computeParticleColor(): boolean;
  156827. /**
  156828. * Gets if `setParticles()` computes the particle textures or not.
  156829. * Default value : false. The PCS is faster when it's set to false.
  156830. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  156831. */
  156832. get computeParticleTexture(): boolean;
  156833. /**
  156834. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  156835. */
  156836. set computeBoundingBox(val: boolean);
  156837. /**
  156838. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  156839. */
  156840. get computeBoundingBox(): boolean;
  156841. /**
  156842. * This function does nothing. It may be overwritten to set all the particle first values.
  156843. * The PCS doesn't call this function, you may have to call it by your own.
  156844. * doc :
  156845. */
  156846. initParticles(): void;
  156847. /**
  156848. * This function does nothing. It may be overwritten to recycle a particle
  156849. * The PCS doesn't call this function, you can to call it
  156850. * doc :
  156851. * @param particle The particle to recycle
  156852. * @returns the recycled particle
  156853. */
  156854. recycleParticle(particle: CloudPoint): CloudPoint;
  156855. /**
  156856. * Updates a particle : this function should be overwritten by the user.
  156857. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  156858. * doc :
  156859. * @example : just set a particle position or velocity and recycle conditions
  156860. * @param particle The particle to update
  156861. * @returns the updated particle
  156862. */
  156863. updateParticle(particle: CloudPoint): CloudPoint;
  156864. /**
  156865. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  156866. * This does nothing and may be overwritten by the user.
  156867. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  156868. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  156869. * @param update the boolean update value actually passed to setParticles()
  156870. */
  156871. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  156872. /**
  156873. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  156874. * This will be passed three parameters.
  156875. * This does nothing and may be overwritten by the user.
  156876. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  156877. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  156878. * @param update the boolean update value actually passed to setParticles()
  156879. */
  156880. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  156881. }
  156882. }
  156883. declare module BABYLON {
  156884. /**
  156885. * Represents one particle of a points cloud system.
  156886. */
  156887. export class CloudPoint {
  156888. /**
  156889. * particle global index
  156890. */
  156891. idx: number;
  156892. /**
  156893. * The color of the particle
  156894. */
  156895. color: Nullable<Color4>;
  156896. /**
  156897. * The world space position of the particle.
  156898. */
  156899. position: Vector3;
  156900. /**
  156901. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  156902. */
  156903. rotation: Vector3;
  156904. /**
  156905. * The world space rotation quaternion of the particle.
  156906. */
  156907. rotationQuaternion: Nullable<Quaternion>;
  156908. /**
  156909. * The uv of the particle.
  156910. */
  156911. uv: Nullable<Vector2>;
  156912. /**
  156913. * The current speed of the particle.
  156914. */
  156915. velocity: Vector3;
  156916. /**
  156917. * The pivot point in the particle local space.
  156918. */
  156919. pivot: Vector3;
  156920. /**
  156921. * Must the particle be translated from its pivot point in its local space ?
  156922. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  156923. * Default : false
  156924. */
  156925. translateFromPivot: boolean;
  156926. /**
  156927. * Index of this particle in the global "positions" array (Internal use)
  156928. * @hidden
  156929. */
  156930. _pos: number;
  156931. /**
  156932. * @hidden Index of this particle in the global "indices" array (Internal use)
  156933. */
  156934. _ind: number;
  156935. /**
  156936. * Group this particle belongs to
  156937. */
  156938. _group: PointsGroup;
  156939. /**
  156940. * Group id of this particle
  156941. */
  156942. groupId: number;
  156943. /**
  156944. * Index of the particle in its group id (Internal use)
  156945. */
  156946. idxInGroup: number;
  156947. /**
  156948. * @hidden Particle BoundingInfo object (Internal use)
  156949. */
  156950. _boundingInfo: BoundingInfo;
  156951. /**
  156952. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  156953. */
  156954. _pcs: PointsCloudSystem;
  156955. /**
  156956. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  156957. */
  156958. _stillInvisible: boolean;
  156959. /**
  156960. * @hidden Last computed particle rotation matrix
  156961. */
  156962. _rotationMatrix: number[];
  156963. /**
  156964. * Parent particle Id, if any.
  156965. * Default null.
  156966. */
  156967. parentId: Nullable<number>;
  156968. /**
  156969. * @hidden Internal global position in the PCS.
  156970. */
  156971. _globalPosition: Vector3;
  156972. /**
  156973. * Creates a Point Cloud object.
  156974. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  156975. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  156976. * @param group (PointsGroup) is the group the particle belongs to
  156977. * @param groupId (integer) is the group identifier in the PCS.
  156978. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  156979. * @param pcs defines the PCS it is associated to
  156980. */
  156981. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  156982. /**
  156983. * get point size
  156984. */
  156985. get size(): Vector3;
  156986. /**
  156987. * Set point size
  156988. */
  156989. set size(scale: Vector3);
  156990. /**
  156991. * Legacy support, changed quaternion to rotationQuaternion
  156992. */
  156993. get quaternion(): Nullable<Quaternion>;
  156994. /**
  156995. * Legacy support, changed quaternion to rotationQuaternion
  156996. */
  156997. set quaternion(q: Nullable<Quaternion>);
  156998. /**
  156999. * Returns a boolean. True if the particle intersects a mesh, else false
  157000. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  157001. * @param target is the object (point or mesh) what the intersection is computed against
  157002. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  157003. * @returns true if it intersects
  157004. */
  157005. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  157006. /**
  157007. * get the rotation matrix of the particle
  157008. * @hidden
  157009. */
  157010. getRotationMatrix(m: Matrix): void;
  157011. }
  157012. /**
  157013. * Represents a group of points in a points cloud system
  157014. * * PCS internal tool, don't use it manually.
  157015. */
  157016. export class PointsGroup {
  157017. /**
  157018. * The group id
  157019. * @hidden
  157020. */
  157021. groupID: number;
  157022. /**
  157023. * image data for group (internal use)
  157024. * @hidden
  157025. */
  157026. _groupImageData: Nullable<ArrayBufferView>;
  157027. /**
  157028. * Image Width (internal use)
  157029. * @hidden
  157030. */
  157031. _groupImgWidth: number;
  157032. /**
  157033. * Image Height (internal use)
  157034. * @hidden
  157035. */
  157036. _groupImgHeight: number;
  157037. /**
  157038. * Custom position function (internal use)
  157039. * @hidden
  157040. */
  157041. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  157042. /**
  157043. * density per facet for surface points
  157044. * @hidden
  157045. */
  157046. _groupDensity: number[];
  157047. /**
  157048. * Only when points are colored by texture carries pointer to texture list array
  157049. * @hidden
  157050. */
  157051. _textureNb: number;
  157052. /**
  157053. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  157054. * PCS internal tool, don't use it manually.
  157055. * @hidden
  157056. */
  157057. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  157058. }
  157059. }
  157060. declare module BABYLON {
  157061. interface Scene {
  157062. /** @hidden (Backing field) */
  157063. _physicsEngine: Nullable<IPhysicsEngine>;
  157064. /** @hidden */
  157065. _physicsTimeAccumulator: number;
  157066. /**
  157067. * Gets the current physics engine
  157068. * @returns a IPhysicsEngine or null if none attached
  157069. */
  157070. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  157071. /**
  157072. * Enables physics to the current scene
  157073. * @param gravity defines the scene's gravity for the physics engine
  157074. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  157075. * @return a boolean indicating if the physics engine was initialized
  157076. */
  157077. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  157078. /**
  157079. * Disables and disposes the physics engine associated with the scene
  157080. */
  157081. disablePhysicsEngine(): void;
  157082. /**
  157083. * Gets a boolean indicating if there is an active physics engine
  157084. * @returns a boolean indicating if there is an active physics engine
  157085. */
  157086. isPhysicsEnabled(): boolean;
  157087. /**
  157088. * Deletes a physics compound impostor
  157089. * @param compound defines the compound to delete
  157090. */
  157091. deleteCompoundImpostor(compound: any): void;
  157092. /**
  157093. * An event triggered when physic simulation is about to be run
  157094. */
  157095. onBeforePhysicsObservable: Observable<Scene>;
  157096. /**
  157097. * An event triggered when physic simulation has been done
  157098. */
  157099. onAfterPhysicsObservable: Observable<Scene>;
  157100. }
  157101. interface AbstractMesh {
  157102. /** @hidden */
  157103. _physicsImpostor: Nullable<PhysicsImpostor>;
  157104. /**
  157105. * Gets or sets impostor used for physic simulation
  157106. * @see https://doc.babylonjs.com/features/physics_engine
  157107. */
  157108. physicsImpostor: Nullable<PhysicsImpostor>;
  157109. /**
  157110. * Gets the current physics impostor
  157111. * @see https://doc.babylonjs.com/features/physics_engine
  157112. * @returns a physics impostor or null
  157113. */
  157114. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  157115. /** Apply a physic impulse to the mesh
  157116. * @param force defines the force to apply
  157117. * @param contactPoint defines where to apply the force
  157118. * @returns the current mesh
  157119. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  157120. */
  157121. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  157122. /**
  157123. * Creates a physic joint between two meshes
  157124. * @param otherMesh defines the other mesh to use
  157125. * @param pivot1 defines the pivot to use on this mesh
  157126. * @param pivot2 defines the pivot to use on the other mesh
  157127. * @param options defines additional options (can be plugin dependent)
  157128. * @returns the current mesh
  157129. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  157130. */
  157131. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  157132. /** @hidden */
  157133. _disposePhysicsObserver: Nullable<Observer<Node>>;
  157134. }
  157135. /**
  157136. * Defines the physics engine scene component responsible to manage a physics engine
  157137. */
  157138. export class PhysicsEngineSceneComponent implements ISceneComponent {
  157139. /**
  157140. * The component name helpful to identify the component in the list of scene components.
  157141. */
  157142. readonly name: string;
  157143. /**
  157144. * The scene the component belongs to.
  157145. */
  157146. scene: Scene;
  157147. /**
  157148. * Creates a new instance of the component for the given scene
  157149. * @param scene Defines the scene to register the component in
  157150. */
  157151. constructor(scene: Scene);
  157152. /**
  157153. * Registers the component in a given scene
  157154. */
  157155. register(): void;
  157156. /**
  157157. * Rebuilds the elements related to this component in case of
  157158. * context lost for instance.
  157159. */
  157160. rebuild(): void;
  157161. /**
  157162. * Disposes the component and the associated ressources
  157163. */
  157164. dispose(): void;
  157165. }
  157166. }
  157167. declare module BABYLON {
  157168. /**
  157169. * A helper for physics simulations
  157170. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  157171. */
  157172. export class PhysicsHelper {
  157173. private _scene;
  157174. private _physicsEngine;
  157175. /**
  157176. * Initializes the Physics helper
  157177. * @param scene Babylon.js scene
  157178. */
  157179. constructor(scene: Scene);
  157180. /**
  157181. * Applies a radial explosion impulse
  157182. * @param origin the origin of the explosion
  157183. * @param radiusOrEventOptions the radius or the options of radial explosion
  157184. * @param strength the explosion strength
  157185. * @param falloff possible options: Constant & Linear. Defaults to Constant
  157186. * @returns A physics radial explosion event, or null
  157187. */
  157188. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  157189. /**
  157190. * Applies a radial explosion force
  157191. * @param origin the origin of the explosion
  157192. * @param radiusOrEventOptions the radius or the options of radial explosion
  157193. * @param strength the explosion strength
  157194. * @param falloff possible options: Constant & Linear. Defaults to Constant
  157195. * @returns A physics radial explosion event, or null
  157196. */
  157197. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  157198. /**
  157199. * Creates a gravitational field
  157200. * @param origin the origin of the explosion
  157201. * @param radiusOrEventOptions the radius or the options of radial explosion
  157202. * @param strength the explosion strength
  157203. * @param falloff possible options: Constant & Linear. Defaults to Constant
  157204. * @returns A physics gravitational field event, or null
  157205. */
  157206. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  157207. /**
  157208. * Creates a physics updraft event
  157209. * @param origin the origin of the updraft
  157210. * @param radiusOrEventOptions the radius or the options of the updraft
  157211. * @param strength the strength of the updraft
  157212. * @param height the height of the updraft
  157213. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  157214. * @returns A physics updraft event, or null
  157215. */
  157216. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  157217. /**
  157218. * Creates a physics vortex event
  157219. * @param origin the of the vortex
  157220. * @param radiusOrEventOptions the radius or the options of the vortex
  157221. * @param strength the strength of the vortex
  157222. * @param height the height of the vortex
  157223. * @returns a Physics vortex event, or null
  157224. * A physics vortex event or null
  157225. */
  157226. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  157227. }
  157228. /**
  157229. * Represents a physics radial explosion event
  157230. */
  157231. class PhysicsRadialExplosionEvent {
  157232. private _scene;
  157233. private _options;
  157234. private _sphere;
  157235. private _dataFetched;
  157236. /**
  157237. * Initializes a radial explosioin event
  157238. * @param _scene BabylonJS scene
  157239. * @param _options The options for the vortex event
  157240. */
  157241. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  157242. /**
  157243. * Returns the data related to the radial explosion event (sphere).
  157244. * @returns The radial explosion event data
  157245. */
  157246. getData(): PhysicsRadialExplosionEventData;
  157247. /**
  157248. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  157249. * @param impostor A physics imposter
  157250. * @param origin the origin of the explosion
  157251. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  157252. */
  157253. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  157254. /**
  157255. * Triggers affecterd impostors callbacks
  157256. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  157257. */
  157258. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  157259. /**
  157260. * Disposes the sphere.
  157261. * @param force Specifies if the sphere should be disposed by force
  157262. */
  157263. dispose(force?: boolean): void;
  157264. /*** Helpers ***/
  157265. private _prepareSphere;
  157266. private _intersectsWithSphere;
  157267. }
  157268. /**
  157269. * Represents a gravitational field event
  157270. */
  157271. class PhysicsGravitationalFieldEvent {
  157272. private _physicsHelper;
  157273. private _scene;
  157274. private _origin;
  157275. private _options;
  157276. private _tickCallback;
  157277. private _sphere;
  157278. private _dataFetched;
  157279. /**
  157280. * Initializes the physics gravitational field event
  157281. * @param _physicsHelper A physics helper
  157282. * @param _scene BabylonJS scene
  157283. * @param _origin The origin position of the gravitational field event
  157284. * @param _options The options for the vortex event
  157285. */
  157286. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  157287. /**
  157288. * Returns the data related to the gravitational field event (sphere).
  157289. * @returns A gravitational field event
  157290. */
  157291. getData(): PhysicsGravitationalFieldEventData;
  157292. /**
  157293. * Enables the gravitational field.
  157294. */
  157295. enable(): void;
  157296. /**
  157297. * Disables the gravitational field.
  157298. */
  157299. disable(): void;
  157300. /**
  157301. * Disposes the sphere.
  157302. * @param force The force to dispose from the gravitational field event
  157303. */
  157304. dispose(force?: boolean): void;
  157305. private _tick;
  157306. }
  157307. /**
  157308. * Represents a physics updraft event
  157309. */
  157310. class PhysicsUpdraftEvent {
  157311. private _scene;
  157312. private _origin;
  157313. private _options;
  157314. private _physicsEngine;
  157315. private _originTop;
  157316. private _originDirection;
  157317. private _tickCallback;
  157318. private _cylinder;
  157319. private _cylinderPosition;
  157320. private _dataFetched;
  157321. /**
  157322. * Initializes the physics updraft event
  157323. * @param _scene BabylonJS scene
  157324. * @param _origin The origin position of the updraft
  157325. * @param _options The options for the updraft event
  157326. */
  157327. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  157328. /**
  157329. * Returns the data related to the updraft event (cylinder).
  157330. * @returns A physics updraft event
  157331. */
  157332. getData(): PhysicsUpdraftEventData;
  157333. /**
  157334. * Enables the updraft.
  157335. */
  157336. enable(): void;
  157337. /**
  157338. * Disables the updraft.
  157339. */
  157340. disable(): void;
  157341. /**
  157342. * Disposes the cylinder.
  157343. * @param force Specifies if the updraft should be disposed by force
  157344. */
  157345. dispose(force?: boolean): void;
  157346. private getImpostorHitData;
  157347. private _tick;
  157348. /*** Helpers ***/
  157349. private _prepareCylinder;
  157350. private _intersectsWithCylinder;
  157351. }
  157352. /**
  157353. * Represents a physics vortex event
  157354. */
  157355. class PhysicsVortexEvent {
  157356. private _scene;
  157357. private _origin;
  157358. private _options;
  157359. private _physicsEngine;
  157360. private _originTop;
  157361. private _tickCallback;
  157362. private _cylinder;
  157363. private _cylinderPosition;
  157364. private _dataFetched;
  157365. /**
  157366. * Initializes the physics vortex event
  157367. * @param _scene The BabylonJS scene
  157368. * @param _origin The origin position of the vortex
  157369. * @param _options The options for the vortex event
  157370. */
  157371. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  157372. /**
  157373. * Returns the data related to the vortex event (cylinder).
  157374. * @returns The physics vortex event data
  157375. */
  157376. getData(): PhysicsVortexEventData;
  157377. /**
  157378. * Enables the vortex.
  157379. */
  157380. enable(): void;
  157381. /**
  157382. * Disables the cortex.
  157383. */
  157384. disable(): void;
  157385. /**
  157386. * Disposes the sphere.
  157387. * @param force
  157388. */
  157389. dispose(force?: boolean): void;
  157390. private getImpostorHitData;
  157391. private _tick;
  157392. /*** Helpers ***/
  157393. private _prepareCylinder;
  157394. private _intersectsWithCylinder;
  157395. }
  157396. /**
  157397. * Options fot the radial explosion event
  157398. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  157399. */
  157400. export class PhysicsRadialExplosionEventOptions {
  157401. /**
  157402. * The radius of the sphere for the radial explosion.
  157403. */
  157404. radius: number;
  157405. /**
  157406. * The strenth of the explosion.
  157407. */
  157408. strength: number;
  157409. /**
  157410. * The strenght of the force in correspondence to the distance of the affected object
  157411. */
  157412. falloff: PhysicsRadialImpulseFalloff;
  157413. /**
  157414. * Sphere options for the radial explosion.
  157415. */
  157416. sphere: {
  157417. segments: number;
  157418. diameter: number;
  157419. };
  157420. /**
  157421. * Sphere options for the radial explosion.
  157422. */
  157423. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  157424. }
  157425. /**
  157426. * Options fot the updraft event
  157427. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  157428. */
  157429. export class PhysicsUpdraftEventOptions {
  157430. /**
  157431. * The radius of the cylinder for the vortex
  157432. */
  157433. radius: number;
  157434. /**
  157435. * The strenth of the updraft.
  157436. */
  157437. strength: number;
  157438. /**
  157439. * The height of the cylinder for the updraft.
  157440. */
  157441. height: number;
  157442. /**
  157443. * The mode for the the updraft.
  157444. */
  157445. updraftMode: PhysicsUpdraftMode;
  157446. }
  157447. /**
  157448. * Options fot the vortex event
  157449. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  157450. */
  157451. export class PhysicsVortexEventOptions {
  157452. /**
  157453. * The radius of the cylinder for the vortex
  157454. */
  157455. radius: number;
  157456. /**
  157457. * The strenth of the vortex.
  157458. */
  157459. strength: number;
  157460. /**
  157461. * The height of the cylinder for the vortex.
  157462. */
  157463. height: number;
  157464. /**
  157465. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  157466. */
  157467. centripetalForceThreshold: number;
  157468. /**
  157469. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  157470. */
  157471. centripetalForceMultiplier: number;
  157472. /**
  157473. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  157474. */
  157475. centrifugalForceMultiplier: number;
  157476. /**
  157477. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  157478. */
  157479. updraftForceMultiplier: number;
  157480. }
  157481. /**
  157482. * The strenght of the force in correspondence to the distance of the affected object
  157483. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  157484. */
  157485. export enum PhysicsRadialImpulseFalloff {
  157486. /** Defines that impulse is constant in strength across it's whole radius */
  157487. Constant = 0,
  157488. /** Defines that impulse gets weaker if it's further from the origin */
  157489. Linear = 1
  157490. }
  157491. /**
  157492. * The strength of the force in correspondence to the distance of the affected object
  157493. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  157494. */
  157495. export enum PhysicsUpdraftMode {
  157496. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  157497. Center = 0,
  157498. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  157499. Perpendicular = 1
  157500. }
  157501. /**
  157502. * Interface for a physics hit data
  157503. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  157504. */
  157505. export interface PhysicsHitData {
  157506. /**
  157507. * The force applied at the contact point
  157508. */
  157509. force: Vector3;
  157510. /**
  157511. * The contact point
  157512. */
  157513. contactPoint: Vector3;
  157514. /**
  157515. * The distance from the origin to the contact point
  157516. */
  157517. distanceFromOrigin: number;
  157518. }
  157519. /**
  157520. * Interface for radial explosion event data
  157521. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  157522. */
  157523. export interface PhysicsRadialExplosionEventData {
  157524. /**
  157525. * A sphere used for the radial explosion event
  157526. */
  157527. sphere: Mesh;
  157528. }
  157529. /**
  157530. * Interface for gravitational field event data
  157531. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  157532. */
  157533. export interface PhysicsGravitationalFieldEventData {
  157534. /**
  157535. * A sphere mesh used for the gravitational field event
  157536. */
  157537. sphere: Mesh;
  157538. }
  157539. /**
  157540. * Interface for updraft event data
  157541. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  157542. */
  157543. export interface PhysicsUpdraftEventData {
  157544. /**
  157545. * A cylinder used for the updraft event
  157546. */
  157547. cylinder: Mesh;
  157548. }
  157549. /**
  157550. * Interface for vortex event data
  157551. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  157552. */
  157553. export interface PhysicsVortexEventData {
  157554. /**
  157555. * A cylinder used for the vortex event
  157556. */
  157557. cylinder: Mesh;
  157558. }
  157559. /**
  157560. * Interface for an affected physics impostor
  157561. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  157562. */
  157563. export interface PhysicsAffectedImpostorWithData {
  157564. /**
  157565. * The impostor affected by the effect
  157566. */
  157567. impostor: PhysicsImpostor;
  157568. /**
  157569. * The data about the hit/horce from the explosion
  157570. */
  157571. hitData: PhysicsHitData;
  157572. }
  157573. }
  157574. declare module BABYLON {
  157575. /** @hidden */
  157576. export var blackAndWhitePixelShader: {
  157577. name: string;
  157578. shader: string;
  157579. };
  157580. }
  157581. declare module BABYLON {
  157582. /**
  157583. * Post process used to render in black and white
  157584. */
  157585. export class BlackAndWhitePostProcess extends PostProcess {
  157586. /**
  157587. * Linear about to convert he result to black and white (default: 1)
  157588. */
  157589. degree: number;
  157590. /**
  157591. * Gets a string identifying the name of the class
  157592. * @returns "BlackAndWhitePostProcess" string
  157593. */
  157594. getClassName(): string;
  157595. /**
  157596. * Creates a black and white post process
  157597. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  157598. * @param name The name of the effect.
  157599. * @param options The required width/height ratio to downsize to before computing the render pass.
  157600. * @param camera The camera to apply the render pass to.
  157601. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  157602. * @param engine The engine which the post process will be applied. (default: current engine)
  157603. * @param reusable If the post process can be reused on the same frame. (default: false)
  157604. */
  157605. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  157606. /** @hidden */
  157607. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  157608. }
  157609. }
  157610. declare module BABYLON {
  157611. /**
  157612. * This represents a set of one or more post processes in Babylon.
  157613. * A post process can be used to apply a shader to a texture after it is rendered.
  157614. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  157615. */
  157616. export class PostProcessRenderEffect {
  157617. private _postProcesses;
  157618. private _getPostProcesses;
  157619. private _singleInstance;
  157620. private _cameras;
  157621. private _indicesForCamera;
  157622. /**
  157623. * Name of the effect
  157624. * @hidden
  157625. */
  157626. _name: string;
  157627. /**
  157628. * Instantiates a post process render effect.
  157629. * A post process can be used to apply a shader to a texture after it is rendered.
  157630. * @param engine The engine the effect is tied to
  157631. * @param name The name of the effect
  157632. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  157633. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  157634. */
  157635. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  157636. /**
  157637. * Checks if all the post processes in the effect are supported.
  157638. */
  157639. get isSupported(): boolean;
  157640. /**
  157641. * Updates the current state of the effect
  157642. * @hidden
  157643. */
  157644. _update(): void;
  157645. /**
  157646. * Attaches the effect on cameras
  157647. * @param cameras The camera to attach to.
  157648. * @hidden
  157649. */
  157650. _attachCameras(cameras: Camera): void;
  157651. /**
  157652. * Attaches the effect on cameras
  157653. * @param cameras The camera to attach to.
  157654. * @hidden
  157655. */
  157656. _attachCameras(cameras: Camera[]): void;
  157657. /**
  157658. * Detaches the effect on cameras
  157659. * @param cameras The camera to detatch from.
  157660. * @hidden
  157661. */
  157662. _detachCameras(cameras: Camera): void;
  157663. /**
  157664. * Detatches the effect on cameras
  157665. * @param cameras The camera to detatch from.
  157666. * @hidden
  157667. */
  157668. _detachCameras(cameras: Camera[]): void;
  157669. /**
  157670. * Enables the effect on given cameras
  157671. * @param cameras The camera to enable.
  157672. * @hidden
  157673. */
  157674. _enable(cameras: Camera): void;
  157675. /**
  157676. * Enables the effect on given cameras
  157677. * @param cameras The camera to enable.
  157678. * @hidden
  157679. */
  157680. _enable(cameras: Nullable<Camera[]>): void;
  157681. /**
  157682. * Disables the effect on the given cameras
  157683. * @param cameras The camera to disable.
  157684. * @hidden
  157685. */
  157686. _disable(cameras: Camera): void;
  157687. /**
  157688. * Disables the effect on the given cameras
  157689. * @param cameras The camera to disable.
  157690. * @hidden
  157691. */
  157692. _disable(cameras: Nullable<Camera[]>): void;
  157693. /**
  157694. * Gets a list of the post processes contained in the effect.
  157695. * @param camera The camera to get the post processes on.
  157696. * @returns The list of the post processes in the effect.
  157697. */
  157698. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  157699. }
  157700. }
  157701. declare module BABYLON {
  157702. /** @hidden */
  157703. export var extractHighlightsPixelShader: {
  157704. name: string;
  157705. shader: string;
  157706. };
  157707. }
  157708. declare module BABYLON {
  157709. /**
  157710. * 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.
  157711. */
  157712. export class ExtractHighlightsPostProcess extends PostProcess {
  157713. /**
  157714. * The luminance threshold, pixels below this value will be set to black.
  157715. */
  157716. threshold: number;
  157717. /** @hidden */
  157718. _exposure: number;
  157719. /**
  157720. * Post process which has the input texture to be used when performing highlight extraction
  157721. * @hidden
  157722. */
  157723. _inputPostProcess: Nullable<PostProcess>;
  157724. /**
  157725. * Gets a string identifying the name of the class
  157726. * @returns "ExtractHighlightsPostProcess" string
  157727. */
  157728. getClassName(): string;
  157729. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  157730. }
  157731. }
  157732. declare module BABYLON {
  157733. /** @hidden */
  157734. export var bloomMergePixelShader: {
  157735. name: string;
  157736. shader: string;
  157737. };
  157738. }
  157739. declare module BABYLON {
  157740. /**
  157741. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  157742. */
  157743. export class BloomMergePostProcess extends PostProcess {
  157744. /** Weight of the bloom to be added to the original input. */
  157745. weight: number;
  157746. /**
  157747. * Gets a string identifying the name of the class
  157748. * @returns "BloomMergePostProcess" string
  157749. */
  157750. getClassName(): string;
  157751. /**
  157752. * Creates a new instance of @see BloomMergePostProcess
  157753. * @param name The name of the effect.
  157754. * @param originalFromInput Post process which's input will be used for the merge.
  157755. * @param blurred Blurred highlights post process which's output will be used.
  157756. * @param weight Weight of the bloom to be added to the original input.
  157757. * @param options The required width/height ratio to downsize to before computing the render pass.
  157758. * @param camera The camera to apply the render pass to.
  157759. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  157760. * @param engine The engine which the post process will be applied. (default: current engine)
  157761. * @param reusable If the post process can be reused on the same frame. (default: false)
  157762. * @param textureType Type of textures used when performing the post process. (default: 0)
  157763. * @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)
  157764. */
  157765. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  157766. /** Weight of the bloom to be added to the original input. */
  157767. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  157768. }
  157769. }
  157770. declare module BABYLON {
  157771. /**
  157772. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  157773. */
  157774. export class BloomEffect extends PostProcessRenderEffect {
  157775. private bloomScale;
  157776. /**
  157777. * @hidden Internal
  157778. */
  157779. _effects: Array<PostProcess>;
  157780. /**
  157781. * @hidden Internal
  157782. */
  157783. _downscale: ExtractHighlightsPostProcess;
  157784. private _blurX;
  157785. private _blurY;
  157786. private _merge;
  157787. /**
  157788. * The luminance threshold to find bright areas of the image to bloom.
  157789. */
  157790. get threshold(): number;
  157791. set threshold(value: number);
  157792. /**
  157793. * The strength of the bloom.
  157794. */
  157795. get weight(): number;
  157796. set weight(value: number);
  157797. /**
  157798. * Specifies the size of the bloom blur kernel, relative to the final output size
  157799. */
  157800. get kernel(): number;
  157801. set kernel(value: number);
  157802. /**
  157803. * Creates a new instance of @see BloomEffect
  157804. * @param scene The scene the effect belongs to.
  157805. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  157806. * @param bloomKernel The size of the kernel to be used when applying the blur.
  157807. * @param bloomWeight The the strength of bloom.
  157808. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  157809. * @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)
  157810. */
  157811. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  157812. /**
  157813. * Disposes each of the internal effects for a given camera.
  157814. * @param camera The camera to dispose the effect on.
  157815. */
  157816. disposeEffects(camera: Camera): void;
  157817. /**
  157818. * @hidden Internal
  157819. */
  157820. _updateEffects(): void;
  157821. /**
  157822. * Internal
  157823. * @returns if all the contained post processes are ready.
  157824. * @hidden
  157825. */
  157826. _isReady(): boolean;
  157827. }
  157828. }
  157829. declare module BABYLON {
  157830. /** @hidden */
  157831. export var chromaticAberrationPixelShader: {
  157832. name: string;
  157833. shader: string;
  157834. };
  157835. }
  157836. declare module BABYLON {
  157837. /**
  157838. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  157839. */
  157840. export class ChromaticAberrationPostProcess extends PostProcess {
  157841. /**
  157842. * The amount of seperation of rgb channels (default: 30)
  157843. */
  157844. aberrationAmount: number;
  157845. /**
  157846. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  157847. */
  157848. radialIntensity: number;
  157849. /**
  157850. * 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))
  157851. */
  157852. direction: Vector2;
  157853. /**
  157854. * 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))
  157855. */
  157856. centerPosition: Vector2;
  157857. /** The width of the screen to apply the effect on */
  157858. screenWidth: number;
  157859. /** The height of the screen to apply the effect on */
  157860. screenHeight: number;
  157861. /**
  157862. * Gets a string identifying the name of the class
  157863. * @returns "ChromaticAberrationPostProcess" string
  157864. */
  157865. getClassName(): string;
  157866. /**
  157867. * Creates a new instance ChromaticAberrationPostProcess
  157868. * @param name The name of the effect.
  157869. * @param screenWidth The width of the screen to apply the effect on.
  157870. * @param screenHeight The height of the screen to apply the effect on.
  157871. * @param options The required width/height ratio to downsize to before computing the render pass.
  157872. * @param camera The camera to apply the render pass to.
  157873. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  157874. * @param engine The engine which the post process will be applied. (default: current engine)
  157875. * @param reusable If the post process can be reused on the same frame. (default: false)
  157876. * @param textureType Type of textures used when performing the post process. (default: 0)
  157877. * @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)
  157878. */
  157879. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  157880. /** @hidden */
  157881. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  157882. }
  157883. }
  157884. declare module BABYLON {
  157885. /** @hidden */
  157886. export var circleOfConfusionPixelShader: {
  157887. name: string;
  157888. shader: string;
  157889. };
  157890. }
  157891. declare module BABYLON {
  157892. /**
  157893. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  157894. */
  157895. export class CircleOfConfusionPostProcess extends PostProcess {
  157896. /**
  157897. * 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.
  157898. */
  157899. lensSize: number;
  157900. /**
  157901. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  157902. */
  157903. fStop: number;
  157904. /**
  157905. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  157906. */
  157907. focusDistance: number;
  157908. /**
  157909. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  157910. */
  157911. focalLength: number;
  157912. /**
  157913. * Gets a string identifying the name of the class
  157914. * @returns "CircleOfConfusionPostProcess" string
  157915. */
  157916. getClassName(): string;
  157917. private _depthTexture;
  157918. /**
  157919. * Creates a new instance CircleOfConfusionPostProcess
  157920. * @param name The name of the effect.
  157921. * @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.
  157922. * @param options The required width/height ratio to downsize to before computing the render pass.
  157923. * @param camera The camera to apply the render pass to.
  157924. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  157925. * @param engine The engine which the post process will be applied. (default: current engine)
  157926. * @param reusable If the post process can be reused on the same frame. (default: false)
  157927. * @param textureType Type of textures used when performing the post process. (default: 0)
  157928. * @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)
  157929. */
  157930. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  157931. /**
  157932. * 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.
  157933. */
  157934. set depthTexture(value: RenderTargetTexture);
  157935. }
  157936. }
  157937. declare module BABYLON {
  157938. /** @hidden */
  157939. export var colorCorrectionPixelShader: {
  157940. name: string;
  157941. shader: string;
  157942. };
  157943. }
  157944. declare module BABYLON {
  157945. /**
  157946. *
  157947. * This post-process allows the modification of rendered colors by using
  157948. * a 'look-up table' (LUT). This effect is also called Color Grading.
  157949. *
  157950. * The object needs to be provided an url to a texture containing the color
  157951. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  157952. * Use an image editing software to tweak the LUT to match your needs.
  157953. *
  157954. * For an example of a color LUT, see here:
  157955. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  157956. * For explanations on color grading, see here:
  157957. * @see http://udn.epicgames.com/Three/ColorGrading.html
  157958. *
  157959. */
  157960. export class ColorCorrectionPostProcess extends PostProcess {
  157961. private _colorTableTexture;
  157962. /**
  157963. * Gets the color table url used to create the LUT texture
  157964. */
  157965. colorTableUrl: string;
  157966. /**
  157967. * Gets a string identifying the name of the class
  157968. * @returns "ColorCorrectionPostProcess" string
  157969. */
  157970. getClassName(): string;
  157971. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  157972. /** @hidden */
  157973. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  157974. }
  157975. }
  157976. declare module BABYLON {
  157977. /** @hidden */
  157978. export var convolutionPixelShader: {
  157979. name: string;
  157980. shader: string;
  157981. };
  157982. }
  157983. declare module BABYLON {
  157984. /**
  157985. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  157986. * input texture to perform effects such as edge detection or sharpening
  157987. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  157988. */
  157989. export class ConvolutionPostProcess extends PostProcess {
  157990. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  157991. kernel: number[];
  157992. /**
  157993. * Gets a string identifying the name of the class
  157994. * @returns "ConvolutionPostProcess" string
  157995. */
  157996. getClassName(): string;
  157997. /**
  157998. * Creates a new instance ConvolutionPostProcess
  157999. * @param name The name of the effect.
  158000. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  158001. * @param options The required width/height ratio to downsize to before computing the render pass.
  158002. * @param camera The camera to apply the render pass to.
  158003. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  158004. * @param engine The engine which the post process will be applied. (default: current engine)
  158005. * @param reusable If the post process can be reused on the same frame. (default: false)
  158006. * @param textureType Type of textures used when performing the post process. (default: 0)
  158007. */
  158008. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  158009. /** @hidden */
  158010. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  158011. /**
  158012. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  158013. */
  158014. static EdgeDetect0Kernel: number[];
  158015. /**
  158016. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  158017. */
  158018. static EdgeDetect1Kernel: number[];
  158019. /**
  158020. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  158021. */
  158022. static EdgeDetect2Kernel: number[];
  158023. /**
  158024. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  158025. */
  158026. static SharpenKernel: number[];
  158027. /**
  158028. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  158029. */
  158030. static EmbossKernel: number[];
  158031. /**
  158032. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  158033. */
  158034. static GaussianKernel: number[];
  158035. }
  158036. }
  158037. declare module BABYLON {
  158038. /**
  158039. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  158040. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  158041. * based on samples that have a large difference in distance than the center pixel.
  158042. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  158043. */
  158044. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  158045. /**
  158046. * The direction the blur should be applied
  158047. */
  158048. direction: Vector2;
  158049. /**
  158050. * Gets a string identifying the name of the class
  158051. * @returns "DepthOfFieldBlurPostProcess" string
  158052. */
  158053. getClassName(): string;
  158054. /**
  158055. * Creates a new instance CircleOfConfusionPostProcess
  158056. * @param name The name of the effect.
  158057. * @param scene The scene the effect belongs to.
  158058. * @param direction The direction the blur should be applied.
  158059. * @param kernel The size of the kernel used to blur.
  158060. * @param options The required width/height ratio to downsize to before computing the render pass.
  158061. * @param camera The camera to apply the render pass to.
  158062. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  158063. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  158064. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  158065. * @param engine The engine which the post process will be applied. (default: current engine)
  158066. * @param reusable If the post process can be reused on the same frame. (default: false)
  158067. * @param textureType Type of textures used when performing the post process. (default: 0)
  158068. * @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)
  158069. */
  158070. 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);
  158071. }
  158072. }
  158073. declare module BABYLON {
  158074. /** @hidden */
  158075. export var depthOfFieldMergePixelShader: {
  158076. name: string;
  158077. shader: string;
  158078. };
  158079. }
  158080. declare module BABYLON {
  158081. /**
  158082. * Options to be set when merging outputs from the default pipeline.
  158083. */
  158084. export class DepthOfFieldMergePostProcessOptions {
  158085. /**
  158086. * The original image to merge on top of
  158087. */
  158088. originalFromInput: PostProcess;
  158089. /**
  158090. * Parameters to perform the merge of the depth of field effect
  158091. */
  158092. depthOfField?: {
  158093. circleOfConfusion: PostProcess;
  158094. blurSteps: Array<PostProcess>;
  158095. };
  158096. /**
  158097. * Parameters to perform the merge of bloom effect
  158098. */
  158099. bloom?: {
  158100. blurred: PostProcess;
  158101. weight: number;
  158102. };
  158103. }
  158104. /**
  158105. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  158106. */
  158107. export class DepthOfFieldMergePostProcess extends PostProcess {
  158108. private blurSteps;
  158109. /**
  158110. * Gets a string identifying the name of the class
  158111. * @returns "DepthOfFieldMergePostProcess" string
  158112. */
  158113. getClassName(): string;
  158114. /**
  158115. * Creates a new instance of DepthOfFieldMergePostProcess
  158116. * @param name The name of the effect.
  158117. * @param originalFromInput Post process which's input will be used for the merge.
  158118. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  158119. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  158120. * @param options The required width/height ratio to downsize to before computing the render pass.
  158121. * @param camera The camera to apply the render pass to.
  158122. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  158123. * @param engine The engine which the post process will be applied. (default: current engine)
  158124. * @param reusable If the post process can be reused on the same frame. (default: false)
  158125. * @param textureType Type of textures used when performing the post process. (default: 0)
  158126. * @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)
  158127. */
  158128. 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);
  158129. /**
  158130. * Updates the effect with the current post process compile time values and recompiles the shader.
  158131. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  158132. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  158133. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  158134. * @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
  158135. * @param onCompiled Called when the shader has been compiled.
  158136. * @param onError Called if there is an error when compiling a shader.
  158137. */
  158138. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  158139. }
  158140. }
  158141. declare module BABYLON {
  158142. /**
  158143. * Specifies the level of max blur that should be applied when using the depth of field effect
  158144. */
  158145. export enum DepthOfFieldEffectBlurLevel {
  158146. /**
  158147. * Subtle blur
  158148. */
  158149. Low = 0,
  158150. /**
  158151. * Medium blur
  158152. */
  158153. Medium = 1,
  158154. /**
  158155. * Large blur
  158156. */
  158157. High = 2
  158158. }
  158159. /**
  158160. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  158161. */
  158162. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  158163. private _circleOfConfusion;
  158164. /**
  158165. * @hidden Internal, blurs from high to low
  158166. */
  158167. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  158168. private _depthOfFieldBlurY;
  158169. private _dofMerge;
  158170. /**
  158171. * @hidden Internal post processes in depth of field effect
  158172. */
  158173. _effects: Array<PostProcess>;
  158174. /**
  158175. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  158176. */
  158177. set focalLength(value: number);
  158178. get focalLength(): number;
  158179. /**
  158180. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  158181. */
  158182. set fStop(value: number);
  158183. get fStop(): number;
  158184. /**
  158185. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  158186. */
  158187. set focusDistance(value: number);
  158188. get focusDistance(): number;
  158189. /**
  158190. * 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.
  158191. */
  158192. set lensSize(value: number);
  158193. get lensSize(): number;
  158194. /**
  158195. * Creates a new instance DepthOfFieldEffect
  158196. * @param scene The scene the effect belongs to.
  158197. * @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.
  158198. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  158199. * @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)
  158200. */
  158201. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  158202. /**
  158203. * Get the current class name of the current effet
  158204. * @returns "DepthOfFieldEffect"
  158205. */
  158206. getClassName(): string;
  158207. /**
  158208. * 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.
  158209. */
  158210. set depthTexture(value: RenderTargetTexture);
  158211. /**
  158212. * Disposes each of the internal effects for a given camera.
  158213. * @param camera The camera to dispose the effect on.
  158214. */
  158215. disposeEffects(camera: Camera): void;
  158216. /**
  158217. * @hidden Internal
  158218. */
  158219. _updateEffects(): void;
  158220. /**
  158221. * Internal
  158222. * @returns if all the contained post processes are ready.
  158223. * @hidden
  158224. */
  158225. _isReady(): boolean;
  158226. }
  158227. }
  158228. declare module BABYLON {
  158229. /** @hidden */
  158230. export var displayPassPixelShader: {
  158231. name: string;
  158232. shader: string;
  158233. };
  158234. }
  158235. declare module BABYLON {
  158236. /**
  158237. * DisplayPassPostProcess which produces an output the same as it's input
  158238. */
  158239. export class DisplayPassPostProcess extends PostProcess {
  158240. /**
  158241. * Gets a string identifying the name of the class
  158242. * @returns "DisplayPassPostProcess" string
  158243. */
  158244. getClassName(): string;
  158245. /**
  158246. * Creates the DisplayPassPostProcess
  158247. * @param name The name of the effect.
  158248. * @param options The required width/height ratio to downsize to before computing the render pass.
  158249. * @param camera The camera to apply the render pass to.
  158250. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  158251. * @param engine The engine which the post process will be applied. (default: current engine)
  158252. * @param reusable If the post process can be reused on the same frame. (default: false)
  158253. */
  158254. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  158255. /** @hidden */
  158256. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  158257. }
  158258. }
  158259. declare module BABYLON {
  158260. /** @hidden */
  158261. export var filterPixelShader: {
  158262. name: string;
  158263. shader: string;
  158264. };
  158265. }
  158266. declare module BABYLON {
  158267. /**
  158268. * Applies a kernel filter to the image
  158269. */
  158270. export class FilterPostProcess extends PostProcess {
  158271. /** The matrix to be applied to the image */
  158272. kernelMatrix: Matrix;
  158273. /**
  158274. * Gets a string identifying the name of the class
  158275. * @returns "FilterPostProcess" string
  158276. */
  158277. getClassName(): string;
  158278. /**
  158279. *
  158280. * @param name The name of the effect.
  158281. * @param kernelMatrix The matrix to be applied to the image
  158282. * @param options The required width/height ratio to downsize to before computing the render pass.
  158283. * @param camera The camera to apply the render pass to.
  158284. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  158285. * @param engine The engine which the post process will be applied. (default: current engine)
  158286. * @param reusable If the post process can be reused on the same frame. (default: false)
  158287. */
  158288. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  158289. /** @hidden */
  158290. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  158291. }
  158292. }
  158293. declare module BABYLON {
  158294. /** @hidden */
  158295. export var fxaaPixelShader: {
  158296. name: string;
  158297. shader: string;
  158298. };
  158299. }
  158300. declare module BABYLON {
  158301. /** @hidden */
  158302. export var fxaaVertexShader: {
  158303. name: string;
  158304. shader: string;
  158305. };
  158306. }
  158307. declare module BABYLON {
  158308. /**
  158309. * Fxaa post process
  158310. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  158311. */
  158312. export class FxaaPostProcess extends PostProcess {
  158313. /**
  158314. * Gets a string identifying the name of the class
  158315. * @returns "FxaaPostProcess" string
  158316. */
  158317. getClassName(): string;
  158318. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  158319. private _getDefines;
  158320. /** @hidden */
  158321. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  158322. }
  158323. }
  158324. declare module BABYLON {
  158325. /** @hidden */
  158326. export var grainPixelShader: {
  158327. name: string;
  158328. shader: string;
  158329. };
  158330. }
  158331. declare module BABYLON {
  158332. /**
  158333. * The GrainPostProcess adds noise to the image at mid luminance levels
  158334. */
  158335. export class GrainPostProcess extends PostProcess {
  158336. /**
  158337. * The intensity of the grain added (default: 30)
  158338. */
  158339. intensity: number;
  158340. /**
  158341. * If the grain should be randomized on every frame
  158342. */
  158343. animated: boolean;
  158344. /**
  158345. * Gets a string identifying the name of the class
  158346. * @returns "GrainPostProcess" string
  158347. */
  158348. getClassName(): string;
  158349. /**
  158350. * Creates a new instance of @see GrainPostProcess
  158351. * @param name The name of the effect.
  158352. * @param options The required width/height ratio to downsize to before computing the render pass.
  158353. * @param camera The camera to apply the render pass to.
  158354. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  158355. * @param engine The engine which the post process will be applied. (default: current engine)
  158356. * @param reusable If the post process can be reused on the same frame. (default: false)
  158357. * @param textureType Type of textures used when performing the post process. (default: 0)
  158358. * @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)
  158359. */
  158360. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  158361. /** @hidden */
  158362. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  158363. }
  158364. }
  158365. declare module BABYLON {
  158366. /** @hidden */
  158367. export var highlightsPixelShader: {
  158368. name: string;
  158369. shader: string;
  158370. };
  158371. }
  158372. declare module BABYLON {
  158373. /**
  158374. * Extracts highlights from the image
  158375. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  158376. */
  158377. export class HighlightsPostProcess extends PostProcess {
  158378. /**
  158379. * Gets a string identifying the name of the class
  158380. * @returns "HighlightsPostProcess" string
  158381. */
  158382. getClassName(): string;
  158383. /**
  158384. * Extracts highlights from the image
  158385. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  158386. * @param name The name of the effect.
  158387. * @param options The required width/height ratio to downsize to before computing the render pass.
  158388. * @param camera The camera to apply the render pass to.
  158389. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  158390. * @param engine The engine which the post process will be applied. (default: current engine)
  158391. * @param reusable If the post process can be reused on the same frame. (default: false)
  158392. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  158393. */
  158394. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  158395. }
  158396. }
  158397. declare module BABYLON {
  158398. /**
  158399. * Contains all parameters needed for the prepass to perform
  158400. * motion blur
  158401. */
  158402. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  158403. /**
  158404. * Is motion blur enabled
  158405. */
  158406. enabled: boolean;
  158407. /**
  158408. * Name of the configuration
  158409. */
  158410. name: string;
  158411. /**
  158412. * Textures that should be present in the MRT for this effect to work
  158413. */
  158414. readonly texturesRequired: number[];
  158415. }
  158416. }
  158417. declare module BABYLON {
  158418. interface Scene {
  158419. /** @hidden (Backing field) */
  158420. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  158421. /**
  158422. * Gets or Sets the current geometry buffer associated to the scene.
  158423. */
  158424. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  158425. /**
  158426. * Enables a GeometryBufferRender and associates it with the scene
  158427. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  158428. * @returns the GeometryBufferRenderer
  158429. */
  158430. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  158431. /**
  158432. * Disables the GeometryBufferRender associated with the scene
  158433. */
  158434. disableGeometryBufferRenderer(): void;
  158435. }
  158436. /**
  158437. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  158438. * in several rendering techniques.
  158439. */
  158440. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  158441. /**
  158442. * The component name helpful to identify the component in the list of scene components.
  158443. */
  158444. readonly name: string;
  158445. /**
  158446. * The scene the component belongs to.
  158447. */
  158448. scene: Scene;
  158449. /**
  158450. * Creates a new instance of the component for the given scene
  158451. * @param scene Defines the scene to register the component in
  158452. */
  158453. constructor(scene: Scene);
  158454. /**
  158455. * Registers the component in a given scene
  158456. */
  158457. register(): void;
  158458. /**
  158459. * Rebuilds the elements related to this component in case of
  158460. * context lost for instance.
  158461. */
  158462. rebuild(): void;
  158463. /**
  158464. * Disposes the component and the associated ressources
  158465. */
  158466. dispose(): void;
  158467. private _gatherRenderTargets;
  158468. }
  158469. }
  158470. declare module BABYLON {
  158471. /** @hidden */
  158472. export var motionBlurPixelShader: {
  158473. name: string;
  158474. shader: string;
  158475. };
  158476. }
  158477. declare module BABYLON {
  158478. /**
  158479. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  158480. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  158481. * As an example, all you have to do is to create the post-process:
  158482. * var mb = new BABYLON.MotionBlurPostProcess(
  158483. * 'mb', // The name of the effect.
  158484. * scene, // The scene containing the objects to blur according to their velocity.
  158485. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  158486. * camera // The camera to apply the render pass to.
  158487. * );
  158488. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  158489. */
  158490. export class MotionBlurPostProcess extends PostProcess {
  158491. /**
  158492. * Defines how much the image is blurred by the movement. Default value is equal to 1
  158493. */
  158494. motionStrength: number;
  158495. /**
  158496. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  158497. */
  158498. get motionBlurSamples(): number;
  158499. /**
  158500. * Sets the number of iterations to be used for motion blur quality
  158501. */
  158502. set motionBlurSamples(samples: number);
  158503. private _motionBlurSamples;
  158504. /**
  158505. * Gets wether or not the motion blur post-process is in object based mode.
  158506. */
  158507. get isObjectBased(): boolean;
  158508. /**
  158509. * Sets wether or not the motion blur post-process is in object based mode.
  158510. */
  158511. set isObjectBased(value: boolean);
  158512. private _isObjectBased;
  158513. private _forceGeometryBuffer;
  158514. private _geometryBufferRenderer;
  158515. private _prePassRenderer;
  158516. private _invViewProjection;
  158517. private _previousViewProjection;
  158518. /**
  158519. * Gets a string identifying the name of the class
  158520. * @returns "MotionBlurPostProcess" string
  158521. */
  158522. getClassName(): string;
  158523. /**
  158524. * Creates a new instance MotionBlurPostProcess
  158525. * @param name The name of the effect.
  158526. * @param scene The scene containing the objects to blur according to their velocity.
  158527. * @param options The required width/height ratio to downsize to before computing the render pass.
  158528. * @param camera The camera to apply the render pass to.
  158529. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  158530. * @param engine The engine which the post process will be applied. (default: current engine)
  158531. * @param reusable If the post process can be reused on the same frame. (default: false)
  158532. * @param textureType Type of textures used when performing the post process. (default: 0)
  158533. * @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)
  158534. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  158535. */
  158536. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  158537. /**
  158538. * Excludes the given skinned mesh from computing bones velocities.
  158539. * 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.
  158540. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  158541. */
  158542. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  158543. /**
  158544. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  158545. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  158546. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  158547. */
  158548. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  158549. /**
  158550. * Disposes the post process.
  158551. * @param camera The camera to dispose the post process on.
  158552. */
  158553. dispose(camera?: Camera): void;
  158554. /**
  158555. * Called on the mode changed (object based or screen based).
  158556. */
  158557. private _applyMode;
  158558. /**
  158559. * Called on the effect is applied when the motion blur post-process is in object based mode.
  158560. */
  158561. private _onApplyObjectBased;
  158562. /**
  158563. * Called on the effect is applied when the motion blur post-process is in screen based mode.
  158564. */
  158565. private _onApplyScreenBased;
  158566. /**
  158567. * Called on the effect must be updated (changed mode, samples count, etc.).
  158568. */
  158569. private _updateEffect;
  158570. /** @hidden */
  158571. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  158572. }
  158573. }
  158574. declare module BABYLON {
  158575. /** @hidden */
  158576. export var refractionPixelShader: {
  158577. name: string;
  158578. shader: string;
  158579. };
  158580. }
  158581. declare module BABYLON {
  158582. /**
  158583. * Post process which applies a refractin texture
  158584. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  158585. */
  158586. export class RefractionPostProcess extends PostProcess {
  158587. private _refTexture;
  158588. private _ownRefractionTexture;
  158589. /** the base color of the refraction (used to taint the rendering) */
  158590. color: Color3;
  158591. /** simulated refraction depth */
  158592. depth: number;
  158593. /** the coefficient of the base color (0 to remove base color tainting) */
  158594. colorLevel: number;
  158595. /** Gets the url used to load the refraction texture */
  158596. refractionTextureUrl: string;
  158597. /**
  158598. * Gets or sets the refraction texture
  158599. * Please note that you are responsible for disposing the texture if you set it manually
  158600. */
  158601. get refractionTexture(): Texture;
  158602. set refractionTexture(value: Texture);
  158603. /**
  158604. * Gets a string identifying the name of the class
  158605. * @returns "RefractionPostProcess" string
  158606. */
  158607. getClassName(): string;
  158608. /**
  158609. * Initializes the RefractionPostProcess
  158610. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  158611. * @param name The name of the effect.
  158612. * @param refractionTextureUrl Url of the refraction texture to use
  158613. * @param color the base color of the refraction (used to taint the rendering)
  158614. * @param depth simulated refraction depth
  158615. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  158616. * @param camera The camera to apply the render pass to.
  158617. * @param options The required width/height ratio to downsize to before computing the render pass.
  158618. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  158619. * @param engine The engine which the post process will be applied. (default: current engine)
  158620. * @param reusable If the post process can be reused on the same frame. (default: false)
  158621. */
  158622. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  158623. /**
  158624. * Disposes of the post process
  158625. * @param camera Camera to dispose post process on
  158626. */
  158627. dispose(camera: Camera): void;
  158628. /** @hidden */
  158629. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  158630. }
  158631. }
  158632. declare module BABYLON {
  158633. /** @hidden */
  158634. export var sharpenPixelShader: {
  158635. name: string;
  158636. shader: string;
  158637. };
  158638. }
  158639. declare module BABYLON {
  158640. /**
  158641. * The SharpenPostProcess applies a sharpen kernel to every pixel
  158642. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  158643. */
  158644. export class SharpenPostProcess extends PostProcess {
  158645. /**
  158646. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  158647. */
  158648. colorAmount: number;
  158649. /**
  158650. * How much sharpness should be applied (default: 0.3)
  158651. */
  158652. edgeAmount: number;
  158653. /**
  158654. * Gets a string identifying the name of the class
  158655. * @returns "SharpenPostProcess" string
  158656. */
  158657. getClassName(): string;
  158658. /**
  158659. * Creates a new instance ConvolutionPostProcess
  158660. * @param name The name of the effect.
  158661. * @param options The required width/height ratio to downsize to before computing the render pass.
  158662. * @param camera The camera to apply the render pass to.
  158663. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  158664. * @param engine The engine which the post process will be applied. (default: current engine)
  158665. * @param reusable If the post process can be reused on the same frame. (default: false)
  158666. * @param textureType Type of textures used when performing the post process. (default: 0)
  158667. * @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)
  158668. */
  158669. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  158670. /** @hidden */
  158671. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  158672. }
  158673. }
  158674. declare module BABYLON {
  158675. /**
  158676. * PostProcessRenderPipeline
  158677. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  158678. */
  158679. export class PostProcessRenderPipeline {
  158680. private engine;
  158681. private _renderEffects;
  158682. private _renderEffectsForIsolatedPass;
  158683. /**
  158684. * List of inspectable custom properties (used by the Inspector)
  158685. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  158686. */
  158687. inspectableCustomProperties: IInspectable[];
  158688. /**
  158689. * @hidden
  158690. */
  158691. protected _cameras: Camera[];
  158692. /** @hidden */
  158693. _name: string;
  158694. /**
  158695. * Gets pipeline name
  158696. */
  158697. get name(): string;
  158698. /** Gets the list of attached cameras */
  158699. get cameras(): Camera[];
  158700. /**
  158701. * Initializes a PostProcessRenderPipeline
  158702. * @param engine engine to add the pipeline to
  158703. * @param name name of the pipeline
  158704. */
  158705. constructor(engine: Engine, name: string);
  158706. /**
  158707. * Gets the class name
  158708. * @returns "PostProcessRenderPipeline"
  158709. */
  158710. getClassName(): string;
  158711. /**
  158712. * If all the render effects in the pipeline are supported
  158713. */
  158714. get isSupported(): boolean;
  158715. /**
  158716. * Adds an effect to the pipeline
  158717. * @param renderEffect the effect to add
  158718. */
  158719. addEffect(renderEffect: PostProcessRenderEffect): void;
  158720. /** @hidden */
  158721. _rebuild(): void;
  158722. /** @hidden */
  158723. _enableEffect(renderEffectName: string, cameras: Camera): void;
  158724. /** @hidden */
  158725. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  158726. /** @hidden */
  158727. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  158728. /** @hidden */
  158729. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  158730. /** @hidden */
  158731. _attachCameras(cameras: Camera, unique: boolean): void;
  158732. /** @hidden */
  158733. _attachCameras(cameras: Camera[], unique: boolean): void;
  158734. /** @hidden */
  158735. _detachCameras(cameras: Camera): void;
  158736. /** @hidden */
  158737. _detachCameras(cameras: Nullable<Camera[]>): void;
  158738. /** @hidden */
  158739. _update(): void;
  158740. /** @hidden */
  158741. _reset(): void;
  158742. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  158743. /**
  158744. * Sets the required values to the prepass renderer.
  158745. * @param prePassRenderer defines the prepass renderer to setup.
  158746. * @returns true if the pre pass is needed.
  158747. */
  158748. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  158749. /**
  158750. * Disposes of the pipeline
  158751. */
  158752. dispose(): void;
  158753. }
  158754. }
  158755. declare module BABYLON {
  158756. /**
  158757. * PostProcessRenderPipelineManager class
  158758. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  158759. */
  158760. export class PostProcessRenderPipelineManager {
  158761. private _renderPipelines;
  158762. /**
  158763. * Initializes a PostProcessRenderPipelineManager
  158764. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  158765. */
  158766. constructor();
  158767. /**
  158768. * Gets the list of supported render pipelines
  158769. */
  158770. get supportedPipelines(): PostProcessRenderPipeline[];
  158771. /**
  158772. * Adds a pipeline to the manager
  158773. * @param renderPipeline The pipeline to add
  158774. */
  158775. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  158776. /**
  158777. * Attaches a camera to the pipeline
  158778. * @param renderPipelineName The name of the pipeline to attach to
  158779. * @param cameras the camera to attach
  158780. * @param unique if the camera can be attached multiple times to the pipeline
  158781. */
  158782. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  158783. /**
  158784. * Detaches a camera from the pipeline
  158785. * @param renderPipelineName The name of the pipeline to detach from
  158786. * @param cameras the camera to detach
  158787. */
  158788. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  158789. /**
  158790. * Enables an effect by name on a pipeline
  158791. * @param renderPipelineName the name of the pipeline to enable the effect in
  158792. * @param renderEffectName the name of the effect to enable
  158793. * @param cameras the cameras that the effect should be enabled on
  158794. */
  158795. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  158796. /**
  158797. * Disables an effect by name on a pipeline
  158798. * @param renderPipelineName the name of the pipeline to disable the effect in
  158799. * @param renderEffectName the name of the effect to disable
  158800. * @param cameras the cameras that the effect should be disabled on
  158801. */
  158802. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  158803. /**
  158804. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  158805. */
  158806. update(): void;
  158807. /** @hidden */
  158808. _rebuild(): void;
  158809. /**
  158810. * Disposes of the manager and pipelines
  158811. */
  158812. dispose(): void;
  158813. }
  158814. }
  158815. declare module BABYLON {
  158816. interface Scene {
  158817. /** @hidden (Backing field) */
  158818. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  158819. /**
  158820. * Gets the postprocess render pipeline manager
  158821. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  158822. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  158823. */
  158824. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  158825. }
  158826. /**
  158827. * Defines the Render Pipeline scene component responsible to rendering pipelines
  158828. */
  158829. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  158830. /**
  158831. * The component name helpfull to identify the component in the list of scene components.
  158832. */
  158833. readonly name: string;
  158834. /**
  158835. * The scene the component belongs to.
  158836. */
  158837. scene: Scene;
  158838. /**
  158839. * Creates a new instance of the component for the given scene
  158840. * @param scene Defines the scene to register the component in
  158841. */
  158842. constructor(scene: Scene);
  158843. /**
  158844. * Registers the component in a given scene
  158845. */
  158846. register(): void;
  158847. /**
  158848. * Rebuilds the elements related to this component in case of
  158849. * context lost for instance.
  158850. */
  158851. rebuild(): void;
  158852. /**
  158853. * Disposes the component and the associated ressources
  158854. */
  158855. dispose(): void;
  158856. private _gatherRenderTargets;
  158857. }
  158858. }
  158859. declare module BABYLON {
  158860. /**
  158861. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  158862. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  158863. */
  158864. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  158865. private _scene;
  158866. private _camerasToBeAttached;
  158867. /**
  158868. * ID of the sharpen post process,
  158869. */
  158870. private readonly SharpenPostProcessId;
  158871. /**
  158872. * @ignore
  158873. * ID of the image processing post process;
  158874. */
  158875. readonly ImageProcessingPostProcessId: string;
  158876. /**
  158877. * @ignore
  158878. * ID of the Fast Approximate Anti-Aliasing post process;
  158879. */
  158880. readonly FxaaPostProcessId: string;
  158881. /**
  158882. * ID of the chromatic aberration post process,
  158883. */
  158884. private readonly ChromaticAberrationPostProcessId;
  158885. /**
  158886. * ID of the grain post process
  158887. */
  158888. private readonly GrainPostProcessId;
  158889. /**
  158890. * Sharpen post process which will apply a sharpen convolution to enhance edges
  158891. */
  158892. sharpen: SharpenPostProcess;
  158893. private _sharpenEffect;
  158894. private bloom;
  158895. /**
  158896. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  158897. */
  158898. depthOfField: DepthOfFieldEffect;
  158899. /**
  158900. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  158901. */
  158902. fxaa: FxaaPostProcess;
  158903. /**
  158904. * Image post processing pass used to perform operations such as tone mapping or color grading.
  158905. */
  158906. imageProcessing: ImageProcessingPostProcess;
  158907. /**
  158908. * Chromatic aberration post process which will shift rgb colors in the image
  158909. */
  158910. chromaticAberration: ChromaticAberrationPostProcess;
  158911. private _chromaticAberrationEffect;
  158912. /**
  158913. * Grain post process which add noise to the image
  158914. */
  158915. grain: GrainPostProcess;
  158916. private _grainEffect;
  158917. /**
  158918. * Glow post process which adds a glow to emissive areas of the image
  158919. */
  158920. private _glowLayer;
  158921. /**
  158922. * Animations which can be used to tweak settings over a period of time
  158923. */
  158924. animations: Animation[];
  158925. private _imageProcessingConfigurationObserver;
  158926. private _sharpenEnabled;
  158927. private _bloomEnabled;
  158928. private _depthOfFieldEnabled;
  158929. private _depthOfFieldBlurLevel;
  158930. private _fxaaEnabled;
  158931. private _imageProcessingEnabled;
  158932. private _defaultPipelineTextureType;
  158933. private _bloomScale;
  158934. private _chromaticAberrationEnabled;
  158935. private _grainEnabled;
  158936. private _buildAllowed;
  158937. /**
  158938. * This is triggered each time the pipeline has been built.
  158939. */
  158940. onBuildObservable: Observable<DefaultRenderingPipeline>;
  158941. /**
  158942. * Gets active scene
  158943. */
  158944. get scene(): Scene;
  158945. /**
  158946. * Enable or disable the sharpen process from the pipeline
  158947. */
  158948. set sharpenEnabled(enabled: boolean);
  158949. get sharpenEnabled(): boolean;
  158950. private _resizeObserver;
  158951. private _hardwareScaleLevel;
  158952. private _bloomKernel;
  158953. /**
  158954. * Specifies the size of the bloom blur kernel, relative to the final output size
  158955. */
  158956. get bloomKernel(): number;
  158957. set bloomKernel(value: number);
  158958. /**
  158959. * Specifies the weight of the bloom in the final rendering
  158960. */
  158961. private _bloomWeight;
  158962. /**
  158963. * Specifies the luma threshold for the area that will be blurred by the bloom
  158964. */
  158965. private _bloomThreshold;
  158966. private _hdr;
  158967. /**
  158968. * The strength of the bloom.
  158969. */
  158970. set bloomWeight(value: number);
  158971. get bloomWeight(): number;
  158972. /**
  158973. * The strength of the bloom.
  158974. */
  158975. set bloomThreshold(value: number);
  158976. get bloomThreshold(): number;
  158977. /**
  158978. * The scale of the bloom, lower value will provide better performance.
  158979. */
  158980. set bloomScale(value: number);
  158981. get bloomScale(): number;
  158982. /**
  158983. * Enable or disable the bloom from the pipeline
  158984. */
  158985. set bloomEnabled(enabled: boolean);
  158986. get bloomEnabled(): boolean;
  158987. private _rebuildBloom;
  158988. /**
  158989. * If the depth of field is enabled.
  158990. */
  158991. get depthOfFieldEnabled(): boolean;
  158992. set depthOfFieldEnabled(enabled: boolean);
  158993. /**
  158994. * Blur level of the depth of field effect. (Higher blur will effect performance)
  158995. */
  158996. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  158997. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  158998. /**
  158999. * If the anti aliasing is enabled.
  159000. */
  159001. set fxaaEnabled(enabled: boolean);
  159002. get fxaaEnabled(): boolean;
  159003. private _samples;
  159004. /**
  159005. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  159006. */
  159007. set samples(sampleCount: number);
  159008. get samples(): number;
  159009. /**
  159010. * If image processing is enabled.
  159011. */
  159012. set imageProcessingEnabled(enabled: boolean);
  159013. get imageProcessingEnabled(): boolean;
  159014. /**
  159015. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  159016. */
  159017. set glowLayerEnabled(enabled: boolean);
  159018. get glowLayerEnabled(): boolean;
  159019. /**
  159020. * Gets the glow layer (or null if not defined)
  159021. */
  159022. get glowLayer(): Nullable<GlowLayer>;
  159023. /**
  159024. * Enable or disable the chromaticAberration process from the pipeline
  159025. */
  159026. set chromaticAberrationEnabled(enabled: boolean);
  159027. get chromaticAberrationEnabled(): boolean;
  159028. /**
  159029. * Enable or disable the grain process from the pipeline
  159030. */
  159031. set grainEnabled(enabled: boolean);
  159032. get grainEnabled(): boolean;
  159033. /**
  159034. * @constructor
  159035. * @param name - The rendering pipeline name (default: "")
  159036. * @param hdr - If high dynamic range textures should be used (default: true)
  159037. * @param scene - The scene linked to this pipeline (default: the last created scene)
  159038. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  159039. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  159040. */
  159041. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  159042. /**
  159043. * Get the class name
  159044. * @returns "DefaultRenderingPipeline"
  159045. */
  159046. getClassName(): string;
  159047. /**
  159048. * Force the compilation of the entire pipeline.
  159049. */
  159050. prepare(): void;
  159051. private _hasCleared;
  159052. private _prevPostProcess;
  159053. private _prevPrevPostProcess;
  159054. private _setAutoClearAndTextureSharing;
  159055. private _depthOfFieldSceneObserver;
  159056. private _buildPipeline;
  159057. private _disposePostProcesses;
  159058. /**
  159059. * Adds a camera to the pipeline
  159060. * @param camera the camera to be added
  159061. */
  159062. addCamera(camera: Camera): void;
  159063. /**
  159064. * Removes a camera from the pipeline
  159065. * @param camera the camera to remove
  159066. */
  159067. removeCamera(camera: Camera): void;
  159068. /**
  159069. * Dispose of the pipeline and stop all post processes
  159070. */
  159071. dispose(): void;
  159072. /**
  159073. * Serialize the rendering pipeline (Used when exporting)
  159074. * @returns the serialized object
  159075. */
  159076. serialize(): any;
  159077. /**
  159078. * Parse the serialized pipeline
  159079. * @param source Source pipeline.
  159080. * @param scene The scene to load the pipeline to.
  159081. * @param rootUrl The URL of the serialized pipeline.
  159082. * @returns An instantiated pipeline from the serialized object.
  159083. */
  159084. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  159085. }
  159086. }
  159087. declare module BABYLON {
  159088. /** @hidden */
  159089. export var lensHighlightsPixelShader: {
  159090. name: string;
  159091. shader: string;
  159092. };
  159093. }
  159094. declare module BABYLON {
  159095. /** @hidden */
  159096. export var depthOfFieldPixelShader: {
  159097. name: string;
  159098. shader: string;
  159099. };
  159100. }
  159101. declare module BABYLON {
  159102. /**
  159103. * BABYLON.JS Chromatic Aberration GLSL Shader
  159104. * Author: Olivier Guyot
  159105. * Separates very slightly R, G and B colors on the edges of the screen
  159106. * Inspired by Francois Tarlier & Martins Upitis
  159107. */
  159108. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  159109. /**
  159110. * @ignore
  159111. * The chromatic aberration PostProcess id in the pipeline
  159112. */
  159113. LensChromaticAberrationEffect: string;
  159114. /**
  159115. * @ignore
  159116. * The highlights enhancing PostProcess id in the pipeline
  159117. */
  159118. HighlightsEnhancingEffect: string;
  159119. /**
  159120. * @ignore
  159121. * The depth-of-field PostProcess id in the pipeline
  159122. */
  159123. LensDepthOfFieldEffect: string;
  159124. private _scene;
  159125. private _depthTexture;
  159126. private _grainTexture;
  159127. private _chromaticAberrationPostProcess;
  159128. private _highlightsPostProcess;
  159129. private _depthOfFieldPostProcess;
  159130. private _edgeBlur;
  159131. private _grainAmount;
  159132. private _chromaticAberration;
  159133. private _distortion;
  159134. private _highlightsGain;
  159135. private _highlightsThreshold;
  159136. private _dofDistance;
  159137. private _dofAperture;
  159138. private _dofDarken;
  159139. private _dofPentagon;
  159140. private _blurNoise;
  159141. /**
  159142. * @constructor
  159143. *
  159144. * Effect parameters are as follow:
  159145. * {
  159146. * chromatic_aberration: number; // from 0 to x (1 for realism)
  159147. * edge_blur: number; // from 0 to x (1 for realism)
  159148. * distortion: number; // from 0 to x (1 for realism)
  159149. * grain_amount: number; // from 0 to 1
  159150. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  159151. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  159152. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  159153. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  159154. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  159155. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  159156. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  159157. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  159158. * }
  159159. * Note: if an effect parameter is unset, effect is disabled
  159160. *
  159161. * @param name The rendering pipeline name
  159162. * @param parameters - An object containing all parameters (see above)
  159163. * @param scene The scene linked to this pipeline
  159164. * @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)
  159165. * @param cameras The array of cameras that the rendering pipeline will be attached to
  159166. */
  159167. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  159168. /**
  159169. * Get the class name
  159170. * @returns "LensRenderingPipeline"
  159171. */
  159172. getClassName(): string;
  159173. /**
  159174. * Gets associated scene
  159175. */
  159176. get scene(): Scene;
  159177. /**
  159178. * Gets or sets the edge blur
  159179. */
  159180. get edgeBlur(): number;
  159181. set edgeBlur(value: number);
  159182. /**
  159183. * Gets or sets the grain amount
  159184. */
  159185. get grainAmount(): number;
  159186. set grainAmount(value: number);
  159187. /**
  159188. * Gets or sets the chromatic aberration amount
  159189. */
  159190. get chromaticAberration(): number;
  159191. set chromaticAberration(value: number);
  159192. /**
  159193. * Gets or sets the depth of field aperture
  159194. */
  159195. get dofAperture(): number;
  159196. set dofAperture(value: number);
  159197. /**
  159198. * Gets or sets the edge distortion
  159199. */
  159200. get edgeDistortion(): number;
  159201. set edgeDistortion(value: number);
  159202. /**
  159203. * Gets or sets the depth of field distortion
  159204. */
  159205. get dofDistortion(): number;
  159206. set dofDistortion(value: number);
  159207. /**
  159208. * Gets or sets the darken out of focus amount
  159209. */
  159210. get darkenOutOfFocus(): number;
  159211. set darkenOutOfFocus(value: number);
  159212. /**
  159213. * Gets or sets a boolean indicating if blur noise is enabled
  159214. */
  159215. get blurNoise(): boolean;
  159216. set blurNoise(value: boolean);
  159217. /**
  159218. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  159219. */
  159220. get pentagonBokeh(): boolean;
  159221. set pentagonBokeh(value: boolean);
  159222. /**
  159223. * Gets or sets the highlight grain amount
  159224. */
  159225. get highlightsGain(): number;
  159226. set highlightsGain(value: number);
  159227. /**
  159228. * Gets or sets the highlight threshold
  159229. */
  159230. get highlightsThreshold(): number;
  159231. set highlightsThreshold(value: number);
  159232. /**
  159233. * Sets the amount of blur at the edges
  159234. * @param amount blur amount
  159235. */
  159236. setEdgeBlur(amount: number): void;
  159237. /**
  159238. * Sets edge blur to 0
  159239. */
  159240. disableEdgeBlur(): void;
  159241. /**
  159242. * Sets the amout of grain
  159243. * @param amount Amount of grain
  159244. */
  159245. setGrainAmount(amount: number): void;
  159246. /**
  159247. * Set grain amount to 0
  159248. */
  159249. disableGrain(): void;
  159250. /**
  159251. * Sets the chromatic aberration amount
  159252. * @param amount amount of chromatic aberration
  159253. */
  159254. setChromaticAberration(amount: number): void;
  159255. /**
  159256. * Sets chromatic aberration amount to 0
  159257. */
  159258. disableChromaticAberration(): void;
  159259. /**
  159260. * Sets the EdgeDistortion amount
  159261. * @param amount amount of EdgeDistortion
  159262. */
  159263. setEdgeDistortion(amount: number): void;
  159264. /**
  159265. * Sets edge distortion to 0
  159266. */
  159267. disableEdgeDistortion(): void;
  159268. /**
  159269. * Sets the FocusDistance amount
  159270. * @param amount amount of FocusDistance
  159271. */
  159272. setFocusDistance(amount: number): void;
  159273. /**
  159274. * Disables depth of field
  159275. */
  159276. disableDepthOfField(): void;
  159277. /**
  159278. * Sets the Aperture amount
  159279. * @param amount amount of Aperture
  159280. */
  159281. setAperture(amount: number): void;
  159282. /**
  159283. * Sets the DarkenOutOfFocus amount
  159284. * @param amount amount of DarkenOutOfFocus
  159285. */
  159286. setDarkenOutOfFocus(amount: number): void;
  159287. private _pentagonBokehIsEnabled;
  159288. /**
  159289. * Creates a pentagon bokeh effect
  159290. */
  159291. enablePentagonBokeh(): void;
  159292. /**
  159293. * Disables the pentagon bokeh effect
  159294. */
  159295. disablePentagonBokeh(): void;
  159296. /**
  159297. * Enables noise blur
  159298. */
  159299. enableNoiseBlur(): void;
  159300. /**
  159301. * Disables noise blur
  159302. */
  159303. disableNoiseBlur(): void;
  159304. /**
  159305. * Sets the HighlightsGain amount
  159306. * @param amount amount of HighlightsGain
  159307. */
  159308. setHighlightsGain(amount: number): void;
  159309. /**
  159310. * Sets the HighlightsThreshold amount
  159311. * @param amount amount of HighlightsThreshold
  159312. */
  159313. setHighlightsThreshold(amount: number): void;
  159314. /**
  159315. * Disables highlights
  159316. */
  159317. disableHighlights(): void;
  159318. /**
  159319. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  159320. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  159321. */
  159322. dispose(disableDepthRender?: boolean): void;
  159323. private _createChromaticAberrationPostProcess;
  159324. private _createHighlightsPostProcess;
  159325. private _createDepthOfFieldPostProcess;
  159326. private _createGrainTexture;
  159327. }
  159328. }
  159329. declare module BABYLON {
  159330. /**
  159331. * Contains all parameters needed for the prepass to perform
  159332. * screen space subsurface scattering
  159333. */
  159334. export class SSAO2Configuration implements PrePassEffectConfiguration {
  159335. /**
  159336. * Is subsurface enabled
  159337. */
  159338. enabled: boolean;
  159339. /**
  159340. * Name of the configuration
  159341. */
  159342. name: string;
  159343. /**
  159344. * Textures that should be present in the MRT for this effect to work
  159345. */
  159346. readonly texturesRequired: number[];
  159347. }
  159348. }
  159349. declare module BABYLON {
  159350. /** @hidden */
  159351. export var ssao2PixelShader: {
  159352. name: string;
  159353. shader: string;
  159354. };
  159355. }
  159356. declare module BABYLON {
  159357. /** @hidden */
  159358. export var ssaoCombinePixelShader: {
  159359. name: string;
  159360. shader: string;
  159361. };
  159362. }
  159363. declare module BABYLON {
  159364. /**
  159365. * Render pipeline to produce ssao effect
  159366. */
  159367. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  159368. /**
  159369. * @ignore
  159370. * The PassPostProcess id in the pipeline that contains the original scene color
  159371. */
  159372. SSAOOriginalSceneColorEffect: string;
  159373. /**
  159374. * @ignore
  159375. * The SSAO PostProcess id in the pipeline
  159376. */
  159377. SSAORenderEffect: string;
  159378. /**
  159379. * @ignore
  159380. * The horizontal blur PostProcess id in the pipeline
  159381. */
  159382. SSAOBlurHRenderEffect: string;
  159383. /**
  159384. * @ignore
  159385. * The vertical blur PostProcess id in the pipeline
  159386. */
  159387. SSAOBlurVRenderEffect: string;
  159388. /**
  159389. * @ignore
  159390. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  159391. */
  159392. SSAOCombineRenderEffect: string;
  159393. /**
  159394. * The output strength of the SSAO post-process. Default value is 1.0.
  159395. */
  159396. totalStrength: number;
  159397. /**
  159398. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  159399. */
  159400. maxZ: number;
  159401. /**
  159402. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  159403. */
  159404. minZAspect: number;
  159405. private _samples;
  159406. /**
  159407. * Number of samples used for the SSAO calculations. Default value is 8
  159408. */
  159409. set samples(n: number);
  159410. get samples(): number;
  159411. private _textureSamples;
  159412. /**
  159413. * Number of samples to use for antialiasing
  159414. */
  159415. set textureSamples(n: number);
  159416. get textureSamples(): number;
  159417. /**
  159418. * Force rendering the geometry through geometry buffer
  159419. */
  159420. private _forceGeometryBuffer;
  159421. /**
  159422. * Ratio object used for SSAO ratio and blur ratio
  159423. */
  159424. private _ratio;
  159425. /**
  159426. * Dynamically generated sphere sampler.
  159427. */
  159428. private _sampleSphere;
  159429. /**
  159430. * Blur filter offsets
  159431. */
  159432. private _samplerOffsets;
  159433. private _expensiveBlur;
  159434. /**
  159435. * If bilateral blur should be used
  159436. */
  159437. set expensiveBlur(b: boolean);
  159438. get expensiveBlur(): boolean;
  159439. /**
  159440. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  159441. */
  159442. radius: number;
  159443. /**
  159444. * The base color of the SSAO post-process
  159445. * The final result is "base + ssao" between [0, 1]
  159446. */
  159447. base: number;
  159448. /**
  159449. * Support test.
  159450. */
  159451. static get IsSupported(): boolean;
  159452. private _scene;
  159453. private _randomTexture;
  159454. private _originalColorPostProcess;
  159455. private _ssaoPostProcess;
  159456. private _blurHPostProcess;
  159457. private _blurVPostProcess;
  159458. private _ssaoCombinePostProcess;
  159459. private _prePassRenderer;
  159460. /**
  159461. * Gets active scene
  159462. */
  159463. get scene(): Scene;
  159464. /**
  159465. * @constructor
  159466. * @param name The rendering pipeline name
  159467. * @param scene The scene linked to this pipeline
  159468. * @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 }
  159469. * @param cameras The array of cameras that the rendering pipeline will be attached to
  159470. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  159471. */
  159472. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  159473. /**
  159474. * Get the class name
  159475. * @returns "SSAO2RenderingPipeline"
  159476. */
  159477. getClassName(): string;
  159478. /**
  159479. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  159480. */
  159481. dispose(disableGeometryBufferRenderer?: boolean): void;
  159482. private _createBlurPostProcess;
  159483. /** @hidden */
  159484. _rebuild(): void;
  159485. private _bits;
  159486. private _radicalInverse_VdC;
  159487. private _hammersley;
  159488. private _hemisphereSample_uniform;
  159489. private _generateHemisphere;
  159490. private _getDefinesForSSAO;
  159491. private static readonly ORTHO_DEPTH_PROJECTION;
  159492. private static readonly PERSPECTIVE_DEPTH_PROJECTION;
  159493. private _createSSAOPostProcess;
  159494. private _createSSAOCombinePostProcess;
  159495. private _createRandomTexture;
  159496. /**
  159497. * Serialize the rendering pipeline (Used when exporting)
  159498. * @returns the serialized object
  159499. */
  159500. serialize(): any;
  159501. /**
  159502. * Parse the serialized pipeline
  159503. * @param source Source pipeline.
  159504. * @param scene The scene to load the pipeline to.
  159505. * @param rootUrl The URL of the serialized pipeline.
  159506. * @returns An instantiated pipeline from the serialized object.
  159507. */
  159508. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  159509. }
  159510. }
  159511. declare module BABYLON {
  159512. /** @hidden */
  159513. export var ssaoPixelShader: {
  159514. name: string;
  159515. shader: string;
  159516. };
  159517. }
  159518. declare module BABYLON {
  159519. /**
  159520. * Render pipeline to produce ssao effect
  159521. */
  159522. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  159523. /**
  159524. * @ignore
  159525. * The PassPostProcess id in the pipeline that contains the original scene color
  159526. */
  159527. SSAOOriginalSceneColorEffect: string;
  159528. /**
  159529. * @ignore
  159530. * The SSAO PostProcess id in the pipeline
  159531. */
  159532. SSAORenderEffect: string;
  159533. /**
  159534. * @ignore
  159535. * The horizontal blur PostProcess id in the pipeline
  159536. */
  159537. SSAOBlurHRenderEffect: string;
  159538. /**
  159539. * @ignore
  159540. * The vertical blur PostProcess id in the pipeline
  159541. */
  159542. SSAOBlurVRenderEffect: string;
  159543. /**
  159544. * @ignore
  159545. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  159546. */
  159547. SSAOCombineRenderEffect: string;
  159548. /**
  159549. * The output strength of the SSAO post-process. Default value is 1.0.
  159550. */
  159551. totalStrength: number;
  159552. /**
  159553. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  159554. */
  159555. radius: number;
  159556. /**
  159557. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  159558. * Must not be equal to fallOff and superior to fallOff.
  159559. * Default value is 0.0075
  159560. */
  159561. area: number;
  159562. /**
  159563. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  159564. * Must not be equal to area and inferior to area.
  159565. * Default value is 0.000001
  159566. */
  159567. fallOff: number;
  159568. /**
  159569. * The base color of the SSAO post-process
  159570. * The final result is "base + ssao" between [0, 1]
  159571. */
  159572. base: number;
  159573. private _scene;
  159574. private _depthTexture;
  159575. private _randomTexture;
  159576. private _originalColorPostProcess;
  159577. private _ssaoPostProcess;
  159578. private _blurHPostProcess;
  159579. private _blurVPostProcess;
  159580. private _ssaoCombinePostProcess;
  159581. private _firstUpdate;
  159582. /**
  159583. * Gets active scene
  159584. */
  159585. get scene(): Scene;
  159586. /**
  159587. * @constructor
  159588. * @param name - The rendering pipeline name
  159589. * @param scene - The scene linked to this pipeline
  159590. * @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 }
  159591. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  159592. */
  159593. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  159594. /**
  159595. * Get the class name
  159596. * @returns "SSAORenderingPipeline"
  159597. */
  159598. getClassName(): string;
  159599. /**
  159600. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  159601. */
  159602. dispose(disableDepthRender?: boolean): void;
  159603. private _createBlurPostProcess;
  159604. /** @hidden */
  159605. _rebuild(): void;
  159606. private _createSSAOPostProcess;
  159607. private _createSSAOCombinePostProcess;
  159608. private _createRandomTexture;
  159609. }
  159610. }
  159611. declare module BABYLON {
  159612. /**
  159613. * Contains all parameters needed for the prepass to perform
  159614. * screen space reflections
  159615. */
  159616. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  159617. /**
  159618. * Is ssr enabled
  159619. */
  159620. enabled: boolean;
  159621. /**
  159622. * Name of the configuration
  159623. */
  159624. name: string;
  159625. /**
  159626. * Textures that should be present in the MRT for this effect to work
  159627. */
  159628. readonly texturesRequired: number[];
  159629. }
  159630. }
  159631. declare module BABYLON {
  159632. /** @hidden */
  159633. export var screenSpaceReflectionPixelShader: {
  159634. name: string;
  159635. shader: string;
  159636. };
  159637. }
  159638. declare module BABYLON {
  159639. /**
  159640. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  159641. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  159642. */
  159643. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  159644. /**
  159645. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  159646. */
  159647. threshold: number;
  159648. /**
  159649. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  159650. */
  159651. strength: number;
  159652. /**
  159653. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  159654. */
  159655. reflectionSpecularFalloffExponent: number;
  159656. /**
  159657. * 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]
  159658. */
  159659. step: number;
  159660. /**
  159661. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  159662. */
  159663. roughnessFactor: number;
  159664. private _forceGeometryBuffer;
  159665. private _geometryBufferRenderer;
  159666. private _prePassRenderer;
  159667. private _enableSmoothReflections;
  159668. private _reflectionSamples;
  159669. private _smoothSteps;
  159670. /**
  159671. * Gets a string identifying the name of the class
  159672. * @returns "ScreenSpaceReflectionPostProcess" string
  159673. */
  159674. getClassName(): string;
  159675. /**
  159676. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  159677. * @param name The name of the effect.
  159678. * @param scene The scene containing the objects to calculate reflections.
  159679. * @param options The required width/height ratio to downsize to before computing the render pass.
  159680. * @param camera The camera to apply the render pass to.
  159681. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  159682. * @param engine The engine which the post process will be applied. (default: current engine)
  159683. * @param reusable If the post process can be reused on the same frame. (default: false)
  159684. * @param textureType Type of textures used when performing the post process. (default: 0)
  159685. * @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)
  159686. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  159687. */
  159688. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  159689. /**
  159690. * Gets wether or not smoothing reflections is enabled.
  159691. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  159692. */
  159693. get enableSmoothReflections(): boolean;
  159694. /**
  159695. * Sets wether or not smoothing reflections is enabled.
  159696. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  159697. */
  159698. set enableSmoothReflections(enabled: boolean);
  159699. /**
  159700. * Gets the number of samples taken while computing reflections. More samples count is high,
  159701. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  159702. */
  159703. get reflectionSamples(): number;
  159704. /**
  159705. * Sets the number of samples taken while computing reflections. More samples count is high,
  159706. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  159707. */
  159708. set reflectionSamples(samples: number);
  159709. /**
  159710. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  159711. * more the post-process will require GPU power and can generate a drop in FPS.
  159712. * Default value (5.0) work pretty well in all cases but can be adjusted.
  159713. */
  159714. get smoothSteps(): number;
  159715. set smoothSteps(steps: number);
  159716. private _updateEffectDefines;
  159717. /** @hidden */
  159718. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  159719. }
  159720. }
  159721. declare module BABYLON {
  159722. /** @hidden */
  159723. export var standardPixelShader: {
  159724. name: string;
  159725. shader: string;
  159726. };
  159727. }
  159728. declare module BABYLON {
  159729. /**
  159730. * Standard rendering pipeline
  159731. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  159732. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  159733. */
  159734. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  159735. /**
  159736. * Public members
  159737. */
  159738. /**
  159739. * Post-process which contains the original scene color before the pipeline applies all the effects
  159740. */
  159741. originalPostProcess: Nullable<PostProcess>;
  159742. /**
  159743. * Post-process used to down scale an image x4
  159744. */
  159745. downSampleX4PostProcess: Nullable<PostProcess>;
  159746. /**
  159747. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  159748. */
  159749. brightPassPostProcess: Nullable<PostProcess>;
  159750. /**
  159751. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  159752. */
  159753. blurHPostProcesses: PostProcess[];
  159754. /**
  159755. * Post-process array storing all the vertical blur post-processes used by the pipeline
  159756. */
  159757. blurVPostProcesses: PostProcess[];
  159758. /**
  159759. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  159760. */
  159761. textureAdderPostProcess: Nullable<PostProcess>;
  159762. /**
  159763. * Post-process used to create volumetric lighting effect
  159764. */
  159765. volumetricLightPostProcess: Nullable<PostProcess>;
  159766. /**
  159767. * Post-process used to smooth the previous volumetric light post-process on the X axis
  159768. */
  159769. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  159770. /**
  159771. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  159772. */
  159773. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  159774. /**
  159775. * Post-process used to merge the volumetric light effect and the real scene color
  159776. */
  159777. volumetricLightMergePostProces: Nullable<PostProcess>;
  159778. /**
  159779. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  159780. */
  159781. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  159782. /**
  159783. * Base post-process used to calculate the average luminance of the final image for HDR
  159784. */
  159785. luminancePostProcess: Nullable<PostProcess>;
  159786. /**
  159787. * Post-processes used to create down sample post-processes in order to get
  159788. * the average luminance of the final image for HDR
  159789. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  159790. */
  159791. luminanceDownSamplePostProcesses: PostProcess[];
  159792. /**
  159793. * Post-process used to create a HDR effect (light adaptation)
  159794. */
  159795. hdrPostProcess: Nullable<PostProcess>;
  159796. /**
  159797. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  159798. */
  159799. textureAdderFinalPostProcess: Nullable<PostProcess>;
  159800. /**
  159801. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  159802. */
  159803. lensFlareFinalPostProcess: Nullable<PostProcess>;
  159804. /**
  159805. * Post-process used to merge the final HDR post-process and the real scene color
  159806. */
  159807. hdrFinalPostProcess: Nullable<PostProcess>;
  159808. /**
  159809. * Post-process used to create a lens flare effect
  159810. */
  159811. lensFlarePostProcess: Nullable<PostProcess>;
  159812. /**
  159813. * Post-process that merges the result of the lens flare post-process and the real scene color
  159814. */
  159815. lensFlareComposePostProcess: Nullable<PostProcess>;
  159816. /**
  159817. * Post-process used to create a motion blur effect
  159818. */
  159819. motionBlurPostProcess: Nullable<PostProcess>;
  159820. /**
  159821. * Post-process used to create a depth of field effect
  159822. */
  159823. depthOfFieldPostProcess: Nullable<PostProcess>;
  159824. /**
  159825. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  159826. */
  159827. fxaaPostProcess: Nullable<FxaaPostProcess>;
  159828. /**
  159829. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  159830. */
  159831. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  159832. /**
  159833. * Represents the brightness threshold in order to configure the illuminated surfaces
  159834. */
  159835. brightThreshold: number;
  159836. /**
  159837. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  159838. */
  159839. blurWidth: number;
  159840. /**
  159841. * Sets if the blur for highlighted surfaces must be only horizontal
  159842. */
  159843. horizontalBlur: boolean;
  159844. /**
  159845. * Gets the overall exposure used by the pipeline
  159846. */
  159847. get exposure(): number;
  159848. /**
  159849. * Sets the overall exposure used by the pipeline
  159850. */
  159851. set exposure(value: number);
  159852. /**
  159853. * Texture used typically to simulate "dirty" on camera lens
  159854. */
  159855. lensTexture: Nullable<Texture>;
  159856. /**
  159857. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  159858. */
  159859. volumetricLightCoefficient: number;
  159860. /**
  159861. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  159862. */
  159863. volumetricLightPower: number;
  159864. /**
  159865. * Used the set the blur intensity to smooth the volumetric lights
  159866. */
  159867. volumetricLightBlurScale: number;
  159868. /**
  159869. * Light (spot or directional) used to generate the volumetric lights rays
  159870. * The source light must have a shadow generate so the pipeline can get its
  159871. * depth map
  159872. */
  159873. sourceLight: Nullable<SpotLight | DirectionalLight>;
  159874. /**
  159875. * For eye adaptation, represents the minimum luminance the eye can see
  159876. */
  159877. hdrMinimumLuminance: number;
  159878. /**
  159879. * For eye adaptation, represents the decrease luminance speed
  159880. */
  159881. hdrDecreaseRate: number;
  159882. /**
  159883. * For eye adaptation, represents the increase luminance speed
  159884. */
  159885. hdrIncreaseRate: number;
  159886. /**
  159887. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  159888. */
  159889. get hdrAutoExposure(): boolean;
  159890. /**
  159891. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  159892. */
  159893. set hdrAutoExposure(value: boolean);
  159894. /**
  159895. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  159896. */
  159897. lensColorTexture: Nullable<Texture>;
  159898. /**
  159899. * The overall strengh for the lens flare effect
  159900. */
  159901. lensFlareStrength: number;
  159902. /**
  159903. * Dispersion coefficient for lens flare ghosts
  159904. */
  159905. lensFlareGhostDispersal: number;
  159906. /**
  159907. * Main lens flare halo width
  159908. */
  159909. lensFlareHaloWidth: number;
  159910. /**
  159911. * Based on the lens distortion effect, defines how much the lens flare result
  159912. * is distorted
  159913. */
  159914. lensFlareDistortionStrength: number;
  159915. /**
  159916. * Configures the blur intensity used for for lens flare (halo)
  159917. */
  159918. lensFlareBlurWidth: number;
  159919. /**
  159920. * Lens star texture must be used to simulate rays on the flares and is available
  159921. * in the documentation
  159922. */
  159923. lensStarTexture: Nullable<Texture>;
  159924. /**
  159925. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  159926. * flare effect by taking account of the dirt texture
  159927. */
  159928. lensFlareDirtTexture: Nullable<Texture>;
  159929. /**
  159930. * Represents the focal length for the depth of field effect
  159931. */
  159932. depthOfFieldDistance: number;
  159933. /**
  159934. * Represents the blur intensity for the blurred part of the depth of field effect
  159935. */
  159936. depthOfFieldBlurWidth: number;
  159937. /**
  159938. * Gets how much the image is blurred by the movement while using the motion blur post-process
  159939. */
  159940. get motionStrength(): number;
  159941. /**
  159942. * Sets how much the image is blurred by the movement while using the motion blur post-process
  159943. */
  159944. set motionStrength(strength: number);
  159945. /**
  159946. * Gets wether or not the motion blur post-process is object based or screen based.
  159947. */
  159948. get objectBasedMotionBlur(): boolean;
  159949. /**
  159950. * Sets wether or not the motion blur post-process should be object based or screen based
  159951. */
  159952. set objectBasedMotionBlur(value: boolean);
  159953. /**
  159954. * List of animations for the pipeline (IAnimatable implementation)
  159955. */
  159956. animations: Animation[];
  159957. /**
  159958. * Private members
  159959. */
  159960. private _scene;
  159961. private _currentDepthOfFieldSource;
  159962. private _basePostProcess;
  159963. private _fixedExposure;
  159964. private _currentExposure;
  159965. private _hdrAutoExposure;
  159966. private _hdrCurrentLuminance;
  159967. private _motionStrength;
  159968. private _isObjectBasedMotionBlur;
  159969. private _floatTextureType;
  159970. private _camerasToBeAttached;
  159971. private _ratio;
  159972. private _bloomEnabled;
  159973. private _depthOfFieldEnabled;
  159974. private _vlsEnabled;
  159975. private _lensFlareEnabled;
  159976. private _hdrEnabled;
  159977. private _motionBlurEnabled;
  159978. private _fxaaEnabled;
  159979. private _screenSpaceReflectionsEnabled;
  159980. private _motionBlurSamples;
  159981. private _volumetricLightStepsCount;
  159982. private _samples;
  159983. /**
  159984. * @ignore
  159985. * Specifies if the bloom pipeline is enabled
  159986. */
  159987. get BloomEnabled(): boolean;
  159988. set BloomEnabled(enabled: boolean);
  159989. /**
  159990. * @ignore
  159991. * Specifies if the depth of field pipeline is enabed
  159992. */
  159993. get DepthOfFieldEnabled(): boolean;
  159994. set DepthOfFieldEnabled(enabled: boolean);
  159995. /**
  159996. * @ignore
  159997. * Specifies if the lens flare pipeline is enabed
  159998. */
  159999. get LensFlareEnabled(): boolean;
  160000. set LensFlareEnabled(enabled: boolean);
  160001. /**
  160002. * @ignore
  160003. * Specifies if the HDR pipeline is enabled
  160004. */
  160005. get HDREnabled(): boolean;
  160006. set HDREnabled(enabled: boolean);
  160007. /**
  160008. * @ignore
  160009. * Specifies if the volumetric lights scattering effect is enabled
  160010. */
  160011. get VLSEnabled(): boolean;
  160012. set VLSEnabled(enabled: boolean);
  160013. /**
  160014. * @ignore
  160015. * Specifies if the motion blur effect is enabled
  160016. */
  160017. get MotionBlurEnabled(): boolean;
  160018. set MotionBlurEnabled(enabled: boolean);
  160019. /**
  160020. * Specifies if anti-aliasing is enabled
  160021. */
  160022. get fxaaEnabled(): boolean;
  160023. set fxaaEnabled(enabled: boolean);
  160024. /**
  160025. * Specifies if screen space reflections are enabled.
  160026. */
  160027. get screenSpaceReflectionsEnabled(): boolean;
  160028. set screenSpaceReflectionsEnabled(enabled: boolean);
  160029. /**
  160030. * Specifies the number of steps used to calculate the volumetric lights
  160031. * Typically in interval [50, 200]
  160032. */
  160033. get volumetricLightStepsCount(): number;
  160034. set volumetricLightStepsCount(count: number);
  160035. /**
  160036. * Specifies the number of samples used for the motion blur effect
  160037. * Typically in interval [16, 64]
  160038. */
  160039. get motionBlurSamples(): number;
  160040. set motionBlurSamples(samples: number);
  160041. /**
  160042. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  160043. */
  160044. get samples(): number;
  160045. set samples(sampleCount: number);
  160046. /**
  160047. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  160048. * @constructor
  160049. * @param name The rendering pipeline name
  160050. * @param scene The scene linked to this pipeline
  160051. * @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)
  160052. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  160053. * @param cameras The array of cameras that the rendering pipeline will be attached to
  160054. */
  160055. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  160056. private _buildPipeline;
  160057. private _createDownSampleX4PostProcess;
  160058. private _createBrightPassPostProcess;
  160059. private _createBlurPostProcesses;
  160060. private _createTextureAdderPostProcess;
  160061. private _createVolumetricLightPostProcess;
  160062. private _createLuminancePostProcesses;
  160063. private _createHdrPostProcess;
  160064. private _createLensFlarePostProcess;
  160065. private _createDepthOfFieldPostProcess;
  160066. private _createMotionBlurPostProcess;
  160067. private _getDepthTexture;
  160068. private _disposePostProcesses;
  160069. /**
  160070. * Dispose of the pipeline and stop all post processes
  160071. */
  160072. dispose(): void;
  160073. /**
  160074. * Serialize the rendering pipeline (Used when exporting)
  160075. * @returns the serialized object
  160076. */
  160077. serialize(): any;
  160078. /**
  160079. * Parse the serialized pipeline
  160080. * @param source Source pipeline.
  160081. * @param scene The scene to load the pipeline to.
  160082. * @param rootUrl The URL of the serialized pipeline.
  160083. * @returns An instantiated pipeline from the serialized object.
  160084. */
  160085. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  160086. /**
  160087. * Luminance steps
  160088. */
  160089. static LuminanceSteps: number;
  160090. }
  160091. }
  160092. declare module BABYLON {
  160093. /** @hidden */
  160094. export var stereoscopicInterlacePixelShader: {
  160095. name: string;
  160096. shader: string;
  160097. };
  160098. }
  160099. declare module BABYLON {
  160100. /**
  160101. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  160102. */
  160103. export class StereoscopicInterlacePostProcessI extends PostProcess {
  160104. private _stepSize;
  160105. private _passedProcess;
  160106. /**
  160107. * Gets a string identifying the name of the class
  160108. * @returns "StereoscopicInterlacePostProcessI" string
  160109. */
  160110. getClassName(): string;
  160111. /**
  160112. * Initializes a StereoscopicInterlacePostProcessI
  160113. * @param name The name of the effect.
  160114. * @param rigCameras The rig cameras to be appled to the post process
  160115. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  160116. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  160117. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  160118. * @param engine The engine which the post process will be applied. (default: current engine)
  160119. * @param reusable If the post process can be reused on the same frame. (default: false)
  160120. */
  160121. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  160122. }
  160123. /**
  160124. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  160125. */
  160126. export class StereoscopicInterlacePostProcess extends PostProcess {
  160127. private _stepSize;
  160128. private _passedProcess;
  160129. /**
  160130. * Gets a string identifying the name of the class
  160131. * @returns "StereoscopicInterlacePostProcess" string
  160132. */
  160133. getClassName(): string;
  160134. /**
  160135. * Initializes a StereoscopicInterlacePostProcess
  160136. * @param name The name of the effect.
  160137. * @param rigCameras The rig cameras to be appled to the post process
  160138. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  160139. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  160140. * @param engine The engine which the post process will be applied. (default: current engine)
  160141. * @param reusable If the post process can be reused on the same frame. (default: false)
  160142. */
  160143. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  160144. }
  160145. }
  160146. declare module BABYLON {
  160147. /** @hidden */
  160148. export var tonemapPixelShader: {
  160149. name: string;
  160150. shader: string;
  160151. };
  160152. }
  160153. declare module BABYLON {
  160154. /** Defines operator used for tonemapping */
  160155. export enum TonemappingOperator {
  160156. /** Hable */
  160157. Hable = 0,
  160158. /** Reinhard */
  160159. Reinhard = 1,
  160160. /** HejiDawson */
  160161. HejiDawson = 2,
  160162. /** Photographic */
  160163. Photographic = 3
  160164. }
  160165. /**
  160166. * Defines a post process to apply tone mapping
  160167. */
  160168. export class TonemapPostProcess extends PostProcess {
  160169. private _operator;
  160170. /** Defines the required exposure adjustement */
  160171. exposureAdjustment: number;
  160172. /**
  160173. * Gets a string identifying the name of the class
  160174. * @returns "TonemapPostProcess" string
  160175. */
  160176. getClassName(): string;
  160177. /**
  160178. * Creates a new TonemapPostProcess
  160179. * @param name defines the name of the postprocess
  160180. * @param _operator defines the operator to use
  160181. * @param exposureAdjustment defines the required exposure adjustement
  160182. * @param camera defines the camera to use (can be null)
  160183. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  160184. * @param engine defines the hosting engine (can be ignore if camera is set)
  160185. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  160186. */
  160187. constructor(name: string, _operator: TonemappingOperator,
  160188. /** Defines the required exposure adjustement */
  160189. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  160190. }
  160191. }
  160192. declare module BABYLON {
  160193. /** @hidden */
  160194. export var volumetricLightScatteringPixelShader: {
  160195. name: string;
  160196. shader: string;
  160197. };
  160198. }
  160199. declare module BABYLON {
  160200. /** @hidden */
  160201. export var volumetricLightScatteringPassVertexShader: {
  160202. name: string;
  160203. shader: string;
  160204. };
  160205. }
  160206. declare module BABYLON {
  160207. /** @hidden */
  160208. export var volumetricLightScatteringPassPixelShader: {
  160209. name: string;
  160210. shader: string;
  160211. };
  160212. }
  160213. declare module BABYLON {
  160214. /**
  160215. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  160216. */
  160217. export class VolumetricLightScatteringPostProcess extends PostProcess {
  160218. private _volumetricLightScatteringPass;
  160219. private _volumetricLightScatteringRTT;
  160220. private _viewPort;
  160221. private _screenCoordinates;
  160222. private _cachedDefines;
  160223. /**
  160224. * If not undefined, the mesh position is computed from the attached node position
  160225. */
  160226. attachedNode: {
  160227. position: Vector3;
  160228. };
  160229. /**
  160230. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  160231. */
  160232. customMeshPosition: Vector3;
  160233. /**
  160234. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  160235. */
  160236. useCustomMeshPosition: boolean;
  160237. /**
  160238. * If the post-process should inverse the light scattering direction
  160239. */
  160240. invert: boolean;
  160241. /**
  160242. * The internal mesh used by the post-process
  160243. */
  160244. mesh: Mesh;
  160245. /**
  160246. * @hidden
  160247. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  160248. */
  160249. get useDiffuseColor(): boolean;
  160250. set useDiffuseColor(useDiffuseColor: boolean);
  160251. /**
  160252. * Array containing the excluded meshes not rendered in the internal pass
  160253. */
  160254. excludedMeshes: AbstractMesh[];
  160255. /**
  160256. * Controls the overall intensity of the post-process
  160257. */
  160258. exposure: number;
  160259. /**
  160260. * Dissipates each sample's contribution in range [0, 1]
  160261. */
  160262. decay: number;
  160263. /**
  160264. * Controls the overall intensity of each sample
  160265. */
  160266. weight: number;
  160267. /**
  160268. * Controls the density of each sample
  160269. */
  160270. density: number;
  160271. /**
  160272. * @constructor
  160273. * @param name The post-process name
  160274. * @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)
  160275. * @param camera The camera that the post-process will be attached to
  160276. * @param mesh The mesh used to create the light scattering
  160277. * @param samples The post-process quality, default 100
  160278. * @param samplingModeThe post-process filtering mode
  160279. * @param engine The babylon engine
  160280. * @param reusable If the post-process is reusable
  160281. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  160282. */
  160283. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  160284. /**
  160285. * Returns the string "VolumetricLightScatteringPostProcess"
  160286. * @returns "VolumetricLightScatteringPostProcess"
  160287. */
  160288. getClassName(): string;
  160289. private _isReady;
  160290. /**
  160291. * Sets the new light position for light scattering effect
  160292. * @param position The new custom light position
  160293. */
  160294. setCustomMeshPosition(position: Vector3): void;
  160295. /**
  160296. * Returns the light position for light scattering effect
  160297. * @return Vector3 The custom light position
  160298. */
  160299. getCustomMeshPosition(): Vector3;
  160300. /**
  160301. * Disposes the internal assets and detaches the post-process from the camera
  160302. */
  160303. dispose(camera: Camera): void;
  160304. /**
  160305. * Returns the render target texture used by the post-process
  160306. * @return the render target texture used by the post-process
  160307. */
  160308. getPass(): RenderTargetTexture;
  160309. private _meshExcluded;
  160310. private _createPass;
  160311. private _updateMeshScreenCoordinates;
  160312. /**
  160313. * Creates a default mesh for the Volumeric Light Scattering post-process
  160314. * @param name The mesh name
  160315. * @param scene The scene where to create the mesh
  160316. * @return the default mesh
  160317. */
  160318. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  160319. }
  160320. }
  160321. declare module BABYLON {
  160322. /** @hidden */
  160323. export var screenSpaceCurvaturePixelShader: {
  160324. name: string;
  160325. shader: string;
  160326. };
  160327. }
  160328. declare module BABYLON {
  160329. /**
  160330. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  160331. */
  160332. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  160333. /**
  160334. * Defines how much ridge the curvature effect displays.
  160335. */
  160336. ridge: number;
  160337. /**
  160338. * Defines how much valley the curvature effect displays.
  160339. */
  160340. valley: number;
  160341. private _geometryBufferRenderer;
  160342. /**
  160343. * Gets a string identifying the name of the class
  160344. * @returns "ScreenSpaceCurvaturePostProcess" string
  160345. */
  160346. getClassName(): string;
  160347. /**
  160348. * Creates a new instance ScreenSpaceCurvaturePostProcess
  160349. * @param name The name of the effect.
  160350. * @param scene The scene containing the objects to blur according to their velocity.
  160351. * @param options The required width/height ratio to downsize to before computing the render pass.
  160352. * @param camera The camera to apply the render pass to.
  160353. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  160354. * @param engine The engine which the post process will be applied. (default: current engine)
  160355. * @param reusable If the post process can be reused on the same frame. (default: false)
  160356. * @param textureType Type of textures used when performing the post process. (default: 0)
  160357. * @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)
  160358. */
  160359. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  160360. /**
  160361. * Support test.
  160362. */
  160363. static get IsSupported(): boolean;
  160364. /** @hidden */
  160365. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  160366. }
  160367. }
  160368. declare module BABYLON {
  160369. interface Scene {
  160370. /** @hidden (Backing field) */
  160371. _boundingBoxRenderer: BoundingBoxRenderer;
  160372. /** @hidden (Backing field) */
  160373. _forceShowBoundingBoxes: boolean;
  160374. /**
  160375. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  160376. */
  160377. forceShowBoundingBoxes: boolean;
  160378. /**
  160379. * Gets the bounding box renderer associated with the scene
  160380. * @returns a BoundingBoxRenderer
  160381. */
  160382. getBoundingBoxRenderer(): BoundingBoxRenderer;
  160383. }
  160384. interface AbstractMesh {
  160385. /** @hidden (Backing field) */
  160386. _showBoundingBox: boolean;
  160387. /**
  160388. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  160389. */
  160390. showBoundingBox: boolean;
  160391. }
  160392. /**
  160393. * Component responsible of rendering the bounding box of the meshes in a scene.
  160394. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  160395. */
  160396. export class BoundingBoxRenderer implements ISceneComponent {
  160397. /**
  160398. * The component name helpfull to identify the component in the list of scene components.
  160399. */
  160400. readonly name: string;
  160401. /**
  160402. * The scene the component belongs to.
  160403. */
  160404. scene: Scene;
  160405. /**
  160406. * Color of the bounding box lines placed in front of an object
  160407. */
  160408. frontColor: Color3;
  160409. /**
  160410. * Color of the bounding box lines placed behind an object
  160411. */
  160412. backColor: Color3;
  160413. /**
  160414. * Defines if the renderer should show the back lines or not
  160415. */
  160416. showBackLines: boolean;
  160417. /**
  160418. * Observable raised before rendering a bounding box
  160419. */
  160420. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  160421. /**
  160422. * Observable raised after rendering a bounding box
  160423. */
  160424. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  160425. /**
  160426. * Observable raised after resources are created
  160427. */
  160428. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  160429. /**
  160430. * When false, no bounding boxes will be rendered
  160431. */
  160432. enabled: boolean;
  160433. /**
  160434. * @hidden
  160435. */
  160436. renderList: SmartArray<BoundingBox>;
  160437. private _colorShader;
  160438. private _vertexBuffers;
  160439. private _indexBuffer;
  160440. private _fillIndexBuffer;
  160441. private _fillIndexData;
  160442. /**
  160443. * Instantiates a new bounding box renderer in a scene.
  160444. * @param scene the scene the renderer renders in
  160445. */
  160446. constructor(scene: Scene);
  160447. /**
  160448. * Registers the component in a given scene
  160449. */
  160450. register(): void;
  160451. private _evaluateSubMesh;
  160452. private _preActiveMesh;
  160453. private _prepareResources;
  160454. private _createIndexBuffer;
  160455. /**
  160456. * Rebuilds the elements related to this component in case of
  160457. * context lost for instance.
  160458. */
  160459. rebuild(): void;
  160460. /**
  160461. * @hidden
  160462. */
  160463. reset(): void;
  160464. /**
  160465. * Render the bounding boxes of a specific rendering group
  160466. * @param renderingGroupId defines the rendering group to render
  160467. */
  160468. render(renderingGroupId: number): void;
  160469. /**
  160470. * In case of occlusion queries, we can render the occlusion bounding box through this method
  160471. * @param mesh Define the mesh to render the occlusion bounding box for
  160472. */
  160473. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  160474. /**
  160475. * Dispose and release the resources attached to this renderer.
  160476. */
  160477. dispose(): void;
  160478. }
  160479. }
  160480. declare module BABYLON {
  160481. interface Scene {
  160482. /** @hidden (Backing field) */
  160483. _depthRenderer: {
  160484. [id: string]: DepthRenderer;
  160485. };
  160486. /**
  160487. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  160488. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  160489. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  160490. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  160491. * @returns the created depth renderer
  160492. */
  160493. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  160494. /**
  160495. * Disables a depth renderer for a given camera
  160496. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  160497. */
  160498. disableDepthRenderer(camera?: Nullable<Camera>): void;
  160499. }
  160500. /**
  160501. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  160502. * in several rendering techniques.
  160503. */
  160504. export class DepthRendererSceneComponent implements ISceneComponent {
  160505. /**
  160506. * The component name helpfull to identify the component in the list of scene components.
  160507. */
  160508. readonly name: string;
  160509. /**
  160510. * The scene the component belongs to.
  160511. */
  160512. scene: Scene;
  160513. /**
  160514. * Creates a new instance of the component for the given scene
  160515. * @param scene Defines the scene to register the component in
  160516. */
  160517. constructor(scene: Scene);
  160518. /**
  160519. * Registers the component in a given scene
  160520. */
  160521. register(): void;
  160522. /**
  160523. * Rebuilds the elements related to this component in case of
  160524. * context lost for instance.
  160525. */
  160526. rebuild(): void;
  160527. /**
  160528. * Disposes the component and the associated ressources
  160529. */
  160530. dispose(): void;
  160531. private _gatherRenderTargets;
  160532. private _gatherActiveCameraRenderTargets;
  160533. }
  160534. }
  160535. declare module BABYLON {
  160536. interface AbstractScene {
  160537. /** @hidden (Backing field) */
  160538. _prePassRenderer: Nullable<PrePassRenderer>;
  160539. /**
  160540. * Gets or Sets the current prepass renderer associated to the scene.
  160541. */
  160542. prePassRenderer: Nullable<PrePassRenderer>;
  160543. /**
  160544. * Enables the prepass and associates it with the scene
  160545. * @returns the PrePassRenderer
  160546. */
  160547. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  160548. /**
  160549. * Disables the prepass associated with the scene
  160550. */
  160551. disablePrePassRenderer(): void;
  160552. }
  160553. /**
  160554. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  160555. * in several rendering techniques.
  160556. */
  160557. export class PrePassRendererSceneComponent implements ISceneComponent {
  160558. /**
  160559. * The component name helpful to identify the component in the list of scene components.
  160560. */
  160561. readonly name: string;
  160562. /**
  160563. * The scene the component belongs to.
  160564. */
  160565. scene: Scene;
  160566. /**
  160567. * Creates a new instance of the component for the given scene
  160568. * @param scene Defines the scene to register the component in
  160569. */
  160570. constructor(scene: Scene);
  160571. /**
  160572. * Registers the component in a given scene
  160573. */
  160574. register(): void;
  160575. private _beforeCameraDraw;
  160576. private _afterCameraDraw;
  160577. private _beforeClearStage;
  160578. private _beforeRenderingMeshStage;
  160579. private _afterRenderingMeshStage;
  160580. /**
  160581. * Rebuilds the elements related to this component in case of
  160582. * context lost for instance.
  160583. */
  160584. rebuild(): void;
  160585. /**
  160586. * Disposes the component and the associated ressources
  160587. */
  160588. dispose(): void;
  160589. }
  160590. }
  160591. declare module BABYLON {
  160592. /** @hidden */
  160593. export var fibonacci: {
  160594. name: string;
  160595. shader: string;
  160596. };
  160597. }
  160598. declare module BABYLON {
  160599. /** @hidden */
  160600. export var diffusionProfile: {
  160601. name: string;
  160602. shader: string;
  160603. };
  160604. }
  160605. declare module BABYLON {
  160606. /** @hidden */
  160607. export var subSurfaceScatteringPixelShader: {
  160608. name: string;
  160609. shader: string;
  160610. };
  160611. }
  160612. declare module BABYLON {
  160613. /**
  160614. * Sub surface scattering post process
  160615. */
  160616. export class SubSurfaceScatteringPostProcess extends PostProcess {
  160617. /**
  160618. * Gets a string identifying the name of the class
  160619. * @returns "SubSurfaceScatteringPostProcess" string
  160620. */
  160621. getClassName(): string;
  160622. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  160623. }
  160624. }
  160625. declare module BABYLON {
  160626. /**
  160627. * Contains all parameters needed for the prepass to perform
  160628. * screen space subsurface scattering
  160629. */
  160630. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  160631. /** @hidden */
  160632. static _SceneComponentInitialization: (scene: Scene) => void;
  160633. private _ssDiffusionS;
  160634. private _ssFilterRadii;
  160635. private _ssDiffusionD;
  160636. /**
  160637. * Post process to attach for screen space subsurface scattering
  160638. */
  160639. postProcess: SubSurfaceScatteringPostProcess;
  160640. /**
  160641. * Diffusion profile color for subsurface scattering
  160642. */
  160643. get ssDiffusionS(): number[];
  160644. /**
  160645. * Diffusion profile max color channel value for subsurface scattering
  160646. */
  160647. get ssDiffusionD(): number[];
  160648. /**
  160649. * Diffusion profile filter radius for subsurface scattering
  160650. */
  160651. get ssFilterRadii(): number[];
  160652. /**
  160653. * Is subsurface enabled
  160654. */
  160655. enabled: boolean;
  160656. /**
  160657. * Name of the configuration
  160658. */
  160659. name: string;
  160660. /**
  160661. * Diffusion profile colors for subsurface scattering
  160662. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  160663. * See ...
  160664. * Note that you can only store up to 5 of them
  160665. */
  160666. ssDiffusionProfileColors: Color3[];
  160667. /**
  160668. * Defines the ratio real world => scene units.
  160669. * Used for subsurface scattering
  160670. */
  160671. metersPerUnit: number;
  160672. /**
  160673. * Textures that should be present in the MRT for this effect to work
  160674. */
  160675. readonly texturesRequired: number[];
  160676. private _scene;
  160677. /**
  160678. * Builds a subsurface configuration object
  160679. * @param scene The scene
  160680. */
  160681. constructor(scene: Scene);
  160682. /**
  160683. * Adds a new diffusion profile.
  160684. * Useful for more realistic subsurface scattering on diverse materials.
  160685. * @param color The color of the diffusion profile. Should be the average color of the material.
  160686. * @return The index of the diffusion profile for the material subsurface configuration
  160687. */
  160688. addDiffusionProfile(color: Color3): number;
  160689. /**
  160690. * Creates the sss post process
  160691. * @return The created post process
  160692. */
  160693. createPostProcess(): SubSurfaceScatteringPostProcess;
  160694. /**
  160695. * Deletes all diffusion profiles.
  160696. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  160697. */
  160698. clearAllDiffusionProfiles(): void;
  160699. /**
  160700. * Disposes this object
  160701. */
  160702. dispose(): void;
  160703. /**
  160704. * @hidden
  160705. * https://zero-radiance.github.io/post/sampling-diffusion/
  160706. *
  160707. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  160708. * ------------------------------------------------------------------------------------
  160709. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  160710. * PDF[r, phi, s] = r * R[r, phi, s]
  160711. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  160712. * ------------------------------------------------------------------------------------
  160713. * We importance sample the color channel with the widest scattering distance.
  160714. */
  160715. getDiffusionProfileParameters(color: Color3): number;
  160716. /**
  160717. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  160718. * 'u' is the random number (the value of the CDF): [0, 1).
  160719. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  160720. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  160721. */
  160722. private _sampleBurleyDiffusionProfile;
  160723. }
  160724. }
  160725. declare module BABYLON {
  160726. interface AbstractScene {
  160727. /** @hidden (Backing field) */
  160728. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  160729. /**
  160730. * Gets or Sets the current prepass renderer associated to the scene.
  160731. */
  160732. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  160733. /**
  160734. * Enables the subsurface effect for prepass
  160735. * @returns the SubSurfaceConfiguration
  160736. */
  160737. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  160738. /**
  160739. * Disables the subsurface effect for prepass
  160740. */
  160741. disableSubSurfaceForPrePass(): void;
  160742. }
  160743. /**
  160744. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  160745. * in several rendering techniques.
  160746. */
  160747. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  160748. /**
  160749. * The component name helpful to identify the component in the list of scene components.
  160750. */
  160751. readonly name: string;
  160752. /**
  160753. * The scene the component belongs to.
  160754. */
  160755. scene: Scene;
  160756. /**
  160757. * Creates a new instance of the component for the given scene
  160758. * @param scene Defines the scene to register the component in
  160759. */
  160760. constructor(scene: Scene);
  160761. /**
  160762. * Registers the component in a given scene
  160763. */
  160764. register(): void;
  160765. /**
  160766. * Serializes the component data to the specified json object
  160767. * @param serializationObject The object to serialize to
  160768. */
  160769. serialize(serializationObject: any): void;
  160770. /**
  160771. * Adds all the elements from the container to the scene
  160772. * @param container the container holding the elements
  160773. */
  160774. addFromContainer(container: AbstractScene): void;
  160775. /**
  160776. * Removes all the elements in the container from the scene
  160777. * @param container contains the elements to remove
  160778. * @param dispose if the removed element should be disposed (default: false)
  160779. */
  160780. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  160781. /**
  160782. * Rebuilds the elements related to this component in case of
  160783. * context lost for instance.
  160784. */
  160785. rebuild(): void;
  160786. /**
  160787. * Disposes the component and the associated ressources
  160788. */
  160789. dispose(): void;
  160790. }
  160791. }
  160792. declare module BABYLON {
  160793. /** @hidden */
  160794. export var outlinePixelShader: {
  160795. name: string;
  160796. shader: string;
  160797. };
  160798. }
  160799. declare module BABYLON {
  160800. /** @hidden */
  160801. export var outlineVertexShader: {
  160802. name: string;
  160803. shader: string;
  160804. };
  160805. }
  160806. declare module BABYLON {
  160807. interface Scene {
  160808. /** @hidden */
  160809. _outlineRenderer: OutlineRenderer;
  160810. /**
  160811. * Gets the outline renderer associated with the scene
  160812. * @returns a OutlineRenderer
  160813. */
  160814. getOutlineRenderer(): OutlineRenderer;
  160815. }
  160816. interface AbstractMesh {
  160817. /** @hidden (Backing field) */
  160818. _renderOutline: boolean;
  160819. /**
  160820. * Gets or sets a boolean indicating if the outline must be rendered as well
  160821. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  160822. */
  160823. renderOutline: boolean;
  160824. /** @hidden (Backing field) */
  160825. _renderOverlay: boolean;
  160826. /**
  160827. * Gets or sets a boolean indicating if the overlay must be rendered as well
  160828. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  160829. */
  160830. renderOverlay: boolean;
  160831. }
  160832. /**
  160833. * This class is responsible to draw bothe outline/overlay of meshes.
  160834. * It should not be used directly but through the available method on mesh.
  160835. */
  160836. export class OutlineRenderer implements ISceneComponent {
  160837. /**
  160838. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  160839. */
  160840. private static _StencilReference;
  160841. /**
  160842. * The name of the component. Each component must have a unique name.
  160843. */
  160844. name: string;
  160845. /**
  160846. * The scene the component belongs to.
  160847. */
  160848. scene: Scene;
  160849. /**
  160850. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  160851. */
  160852. zOffset: number;
  160853. private _engine;
  160854. private _effect;
  160855. private _cachedDefines;
  160856. private _savedDepthWrite;
  160857. /**
  160858. * Instantiates a new outline renderer. (There could be only one per scene).
  160859. * @param scene Defines the scene it belongs to
  160860. */
  160861. constructor(scene: Scene);
  160862. /**
  160863. * Register the component to one instance of a scene.
  160864. */
  160865. register(): void;
  160866. /**
  160867. * Rebuilds the elements related to this component in case of
  160868. * context lost for instance.
  160869. */
  160870. rebuild(): void;
  160871. /**
  160872. * Disposes the component and the associated ressources.
  160873. */
  160874. dispose(): void;
  160875. /**
  160876. * Renders the outline in the canvas.
  160877. * @param subMesh Defines the sumesh to render
  160878. * @param batch Defines the batch of meshes in case of instances
  160879. * @param useOverlay Defines if the rendering is for the overlay or the outline
  160880. */
  160881. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  160882. /**
  160883. * Returns whether or not the outline renderer is ready for a given submesh.
  160884. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  160885. * @param subMesh Defines the submesh to check readyness for
  160886. * @param useInstances Defines wheter wee are trying to render instances or not
  160887. * @returns true if ready otherwise false
  160888. */
  160889. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  160890. private _beforeRenderingMesh;
  160891. private _afterRenderingMesh;
  160892. }
  160893. }
  160894. declare module BABYLON {
  160895. /**
  160896. * Defines the basic options interface of a Sprite Frame Source Size.
  160897. */
  160898. export interface ISpriteJSONSpriteSourceSize {
  160899. /**
  160900. * number of the original width of the Frame
  160901. */
  160902. w: number;
  160903. /**
  160904. * number of the original height of the Frame
  160905. */
  160906. h: number;
  160907. }
  160908. /**
  160909. * Defines the basic options interface of a Sprite Frame Data.
  160910. */
  160911. export interface ISpriteJSONSpriteFrameData {
  160912. /**
  160913. * number of the x offset of the Frame
  160914. */
  160915. x: number;
  160916. /**
  160917. * number of the y offset of the Frame
  160918. */
  160919. y: number;
  160920. /**
  160921. * number of the width of the Frame
  160922. */
  160923. w: number;
  160924. /**
  160925. * number of the height of the Frame
  160926. */
  160927. h: number;
  160928. }
  160929. /**
  160930. * Defines the basic options interface of a JSON Sprite.
  160931. */
  160932. export interface ISpriteJSONSprite {
  160933. /**
  160934. * string name of the Frame
  160935. */
  160936. filename: string;
  160937. /**
  160938. * ISpriteJSONSpriteFrame basic object of the frame data
  160939. */
  160940. frame: ISpriteJSONSpriteFrameData;
  160941. /**
  160942. * boolean to flag is the frame was rotated.
  160943. */
  160944. rotated: boolean;
  160945. /**
  160946. * boolean to flag is the frame was trimmed.
  160947. */
  160948. trimmed: boolean;
  160949. /**
  160950. * ISpriteJSONSpriteFrame basic object of the source data
  160951. */
  160952. spriteSourceSize: ISpriteJSONSpriteFrameData;
  160953. /**
  160954. * ISpriteJSONSpriteFrame basic object of the source data
  160955. */
  160956. sourceSize: ISpriteJSONSpriteSourceSize;
  160957. }
  160958. /**
  160959. * Defines the basic options interface of a JSON atlas.
  160960. */
  160961. export interface ISpriteJSONAtlas {
  160962. /**
  160963. * Array of objects that contain the frame data.
  160964. */
  160965. frames: Array<ISpriteJSONSprite>;
  160966. /**
  160967. * object basic object containing the sprite meta data.
  160968. */
  160969. meta?: object;
  160970. }
  160971. }
  160972. declare module BABYLON {
  160973. /** @hidden */
  160974. export var spriteMapPixelShader: {
  160975. name: string;
  160976. shader: string;
  160977. };
  160978. }
  160979. declare module BABYLON {
  160980. /** @hidden */
  160981. export var spriteMapVertexShader: {
  160982. name: string;
  160983. shader: string;
  160984. };
  160985. }
  160986. declare module BABYLON {
  160987. /**
  160988. * Defines the basic options interface of a SpriteMap
  160989. */
  160990. export interface ISpriteMapOptions {
  160991. /**
  160992. * Vector2 of the number of cells in the grid.
  160993. */
  160994. stageSize?: Vector2;
  160995. /**
  160996. * Vector2 of the size of the output plane in World Units.
  160997. */
  160998. outputSize?: Vector2;
  160999. /**
  161000. * Vector3 of the position of the output plane in World Units.
  161001. */
  161002. outputPosition?: Vector3;
  161003. /**
  161004. * Vector3 of the rotation of the output plane.
  161005. */
  161006. outputRotation?: Vector3;
  161007. /**
  161008. * number of layers that the system will reserve in resources.
  161009. */
  161010. layerCount?: number;
  161011. /**
  161012. * number of max animation frames a single cell will reserve in resources.
  161013. */
  161014. maxAnimationFrames?: number;
  161015. /**
  161016. * number cell index of the base tile when the system compiles.
  161017. */
  161018. baseTile?: number;
  161019. /**
  161020. * boolean flip the sprite after its been repositioned by the framing data.
  161021. */
  161022. flipU?: boolean;
  161023. /**
  161024. * Vector3 scalar of the global RGB values of the SpriteMap.
  161025. */
  161026. colorMultiply?: Vector3;
  161027. }
  161028. /**
  161029. * Defines the IDisposable interface in order to be cleanable from resources.
  161030. */
  161031. export interface ISpriteMap extends IDisposable {
  161032. /**
  161033. * String name of the SpriteMap.
  161034. */
  161035. name: string;
  161036. /**
  161037. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  161038. */
  161039. atlasJSON: ISpriteJSONAtlas;
  161040. /**
  161041. * Texture of the SpriteMap.
  161042. */
  161043. spriteSheet: Texture;
  161044. /**
  161045. * The parameters to initialize the SpriteMap with.
  161046. */
  161047. options: ISpriteMapOptions;
  161048. }
  161049. /**
  161050. * Class used to manage a grid restricted sprite deployment on an Output plane.
  161051. */
  161052. export class SpriteMap implements ISpriteMap {
  161053. /** The Name of the spriteMap */
  161054. name: string;
  161055. /** The JSON file with the frame and meta data */
  161056. atlasJSON: ISpriteJSONAtlas;
  161057. /** The systems Sprite Sheet Texture */
  161058. spriteSheet: Texture;
  161059. /** Arguments passed with the Constructor */
  161060. options: ISpriteMapOptions;
  161061. /** Public Sprite Storage array, parsed from atlasJSON */
  161062. sprites: Array<ISpriteJSONSprite>;
  161063. /** Returns the Number of Sprites in the System */
  161064. get spriteCount(): number;
  161065. /** Returns the Position of Output Plane*/
  161066. get position(): Vector3;
  161067. /** Returns the Position of Output Plane*/
  161068. set position(v: Vector3);
  161069. /** Returns the Rotation of Output Plane*/
  161070. get rotation(): Vector3;
  161071. /** Returns the Rotation of Output Plane*/
  161072. set rotation(v: Vector3);
  161073. /** Sets the AnimationMap*/
  161074. get animationMap(): RawTexture;
  161075. /** Sets the AnimationMap*/
  161076. set animationMap(v: RawTexture);
  161077. /** Scene that the SpriteMap was created in */
  161078. private _scene;
  161079. /** Texture Buffer of Float32 that holds tile frame data*/
  161080. private _frameMap;
  161081. /** Texture Buffers of Float32 that holds tileMap data*/
  161082. private _tileMaps;
  161083. /** Texture Buffer of Float32 that holds Animation Data*/
  161084. private _animationMap;
  161085. /** Custom ShaderMaterial Central to the System*/
  161086. private _material;
  161087. /** Custom ShaderMaterial Central to the System*/
  161088. private _output;
  161089. /** Systems Time Ticker*/
  161090. private _time;
  161091. /**
  161092. * Creates a new SpriteMap
  161093. * @param name defines the SpriteMaps Name
  161094. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  161095. * @param spriteSheet is the Texture that the Sprites are on.
  161096. * @param options a basic deployment configuration
  161097. * @param scene The Scene that the map is deployed on
  161098. */
  161099. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  161100. /**
  161101. * Returns tileID location
  161102. * @returns Vector2 the cell position ID
  161103. */
  161104. getTileID(): Vector2;
  161105. /**
  161106. * Gets the UV location of the mouse over the SpriteMap.
  161107. * @returns Vector2 the UV position of the mouse interaction
  161108. */
  161109. getMousePosition(): Vector2;
  161110. /**
  161111. * Creates the "frame" texture Buffer
  161112. * -------------------------------------
  161113. * Structure of frames
  161114. * "filename": "Falling-Water-2.png",
  161115. * "frame": {"x":69,"y":103,"w":24,"h":32},
  161116. * "rotated": true,
  161117. * "trimmed": true,
  161118. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  161119. * "sourceSize": {"w":32,"h":32}
  161120. * @returns RawTexture of the frameMap
  161121. */
  161122. private _createFrameBuffer;
  161123. /**
  161124. * Creates the tileMap texture Buffer
  161125. * @param buffer normally and array of numbers, or a false to generate from scratch
  161126. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  161127. * @returns RawTexture of the tileMap
  161128. */
  161129. private _createTileBuffer;
  161130. /**
  161131. * Modifies the data of the tileMaps
  161132. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  161133. * @param pos is the iVector2 Coordinates of the Tile
  161134. * @param tile The SpriteIndex of the new Tile
  161135. */
  161136. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  161137. /**
  161138. * Creates the animationMap texture Buffer
  161139. * @param buffer normally and array of numbers, or a false to generate from scratch
  161140. * @returns RawTexture of the animationMap
  161141. */
  161142. private _createTileAnimationBuffer;
  161143. /**
  161144. * Modifies the data of the animationMap
  161145. * @param cellID is the Index of the Sprite
  161146. * @param _frame is the target Animation frame
  161147. * @param toCell is the Target Index of the next frame of the animation
  161148. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  161149. * @param speed is a global scalar of the time variable on the map.
  161150. */
  161151. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  161152. /**
  161153. * Exports the .tilemaps file
  161154. */
  161155. saveTileMaps(): void;
  161156. /**
  161157. * Imports the .tilemaps file
  161158. * @param url of the .tilemaps file
  161159. */
  161160. loadTileMaps(url: string): void;
  161161. /**
  161162. * Release associated resources
  161163. */
  161164. dispose(): void;
  161165. }
  161166. }
  161167. declare module BABYLON {
  161168. /**
  161169. * Class used to manage multiple sprites of different sizes on the same spritesheet
  161170. * @see https://doc.babylonjs.com/babylon101/sprites
  161171. */
  161172. export class SpritePackedManager extends SpriteManager {
  161173. /** defines the packed manager's name */
  161174. name: string;
  161175. /**
  161176. * Creates a new sprite manager from a packed sprite sheet
  161177. * @param name defines the manager's name
  161178. * @param imgUrl defines the sprite sheet url
  161179. * @param capacity defines the maximum allowed number of sprites
  161180. * @param scene defines the hosting scene
  161181. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  161182. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  161183. * @param samplingMode defines the smapling mode to use with spritesheet
  161184. * @param fromPacked set to true; do not alter
  161185. */
  161186. constructor(
  161187. /** defines the packed manager's name */
  161188. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  161189. }
  161190. }
  161191. declare module BABYLON {
  161192. /**
  161193. * Defines the list of states available for a task inside a AssetsManager
  161194. */
  161195. export enum AssetTaskState {
  161196. /**
  161197. * Initialization
  161198. */
  161199. INIT = 0,
  161200. /**
  161201. * Running
  161202. */
  161203. RUNNING = 1,
  161204. /**
  161205. * Done
  161206. */
  161207. DONE = 2,
  161208. /**
  161209. * Error
  161210. */
  161211. ERROR = 3
  161212. }
  161213. /**
  161214. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  161215. */
  161216. export abstract class AbstractAssetTask {
  161217. /**
  161218. * Task name
  161219. */ name: string;
  161220. /**
  161221. * Callback called when the task is successful
  161222. */
  161223. onSuccess: (task: any) => void;
  161224. /**
  161225. * Callback called when the task is not successful
  161226. */
  161227. onError: (task: any, message?: string, exception?: any) => void;
  161228. /**
  161229. * Creates a new AssetsManager
  161230. * @param name defines the name of the task
  161231. */
  161232. constructor(
  161233. /**
  161234. * Task name
  161235. */ name: string);
  161236. private _isCompleted;
  161237. private _taskState;
  161238. private _errorObject;
  161239. /**
  161240. * Get if the task is completed
  161241. */
  161242. get isCompleted(): boolean;
  161243. /**
  161244. * Gets the current state of the task
  161245. */
  161246. get taskState(): AssetTaskState;
  161247. /**
  161248. * Gets the current error object (if task is in error)
  161249. */
  161250. get errorObject(): {
  161251. message?: string;
  161252. exception?: any;
  161253. };
  161254. /**
  161255. * Internal only
  161256. * @hidden
  161257. */
  161258. _setErrorObject(message?: string, exception?: any): void;
  161259. /**
  161260. * Execute the current task
  161261. * @param scene defines the scene where you want your assets to be loaded
  161262. * @param onSuccess is a callback called when the task is successfully executed
  161263. * @param onError is a callback called if an error occurs
  161264. */
  161265. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  161266. /**
  161267. * Execute the current task
  161268. * @param scene defines the scene where you want your assets to be loaded
  161269. * @param onSuccess is a callback called when the task is successfully executed
  161270. * @param onError is a callback called if an error occurs
  161271. */
  161272. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  161273. /**
  161274. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  161275. * This can be used with failed tasks that have the reason for failure fixed.
  161276. */
  161277. reset(): void;
  161278. private onErrorCallback;
  161279. private onDoneCallback;
  161280. }
  161281. /**
  161282. * Define the interface used by progress events raised during assets loading
  161283. */
  161284. export interface IAssetsProgressEvent {
  161285. /**
  161286. * Defines the number of remaining tasks to process
  161287. */
  161288. remainingCount: number;
  161289. /**
  161290. * Defines the total number of tasks
  161291. */
  161292. totalCount: number;
  161293. /**
  161294. * Defines the task that was just processed
  161295. */
  161296. task: AbstractAssetTask;
  161297. }
  161298. /**
  161299. * Class used to share progress information about assets loading
  161300. */
  161301. export class AssetsProgressEvent implements IAssetsProgressEvent {
  161302. /**
  161303. * Defines the number of remaining tasks to process
  161304. */
  161305. remainingCount: number;
  161306. /**
  161307. * Defines the total number of tasks
  161308. */
  161309. totalCount: number;
  161310. /**
  161311. * Defines the task that was just processed
  161312. */
  161313. task: AbstractAssetTask;
  161314. /**
  161315. * Creates a AssetsProgressEvent
  161316. * @param remainingCount defines the number of remaining tasks to process
  161317. * @param totalCount defines the total number of tasks
  161318. * @param task defines the task that was just processed
  161319. */
  161320. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  161321. }
  161322. /**
  161323. * Define a task used by AssetsManager to load assets into a container
  161324. */
  161325. export class ContainerAssetTask extends AbstractAssetTask {
  161326. /**
  161327. * Defines the name of the task
  161328. */
  161329. name: string;
  161330. /**
  161331. * Defines the list of mesh's names you want to load
  161332. */
  161333. meshesNames: any;
  161334. /**
  161335. * Defines the root url to use as a base to load your meshes and associated resources
  161336. */
  161337. rootUrl: string;
  161338. /**
  161339. * Defines the filename or File of the scene to load from
  161340. */
  161341. sceneFilename: string | File;
  161342. /**
  161343. * Get the loaded asset container
  161344. */
  161345. loadedContainer: AssetContainer;
  161346. /**
  161347. * Gets the list of loaded meshes
  161348. */
  161349. loadedMeshes: Array<AbstractMesh>;
  161350. /**
  161351. * Gets the list of loaded particle systems
  161352. */
  161353. loadedParticleSystems: Array<IParticleSystem>;
  161354. /**
  161355. * Gets the list of loaded skeletons
  161356. */
  161357. loadedSkeletons: Array<Skeleton>;
  161358. /**
  161359. * Gets the list of loaded animation groups
  161360. */
  161361. loadedAnimationGroups: Array<AnimationGroup>;
  161362. /**
  161363. * Callback called when the task is successful
  161364. */
  161365. onSuccess: (task: ContainerAssetTask) => void;
  161366. /**
  161367. * Callback called when the task is successful
  161368. */
  161369. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  161370. /**
  161371. * Creates a new ContainerAssetTask
  161372. * @param name defines the name of the task
  161373. * @param meshesNames defines the list of mesh's names you want to load
  161374. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  161375. * @param sceneFilename defines the filename or File of the scene to load from
  161376. */
  161377. constructor(
  161378. /**
  161379. * Defines the name of the task
  161380. */
  161381. name: string,
  161382. /**
  161383. * Defines the list of mesh's names you want to load
  161384. */
  161385. meshesNames: any,
  161386. /**
  161387. * Defines the root url to use as a base to load your meshes and associated resources
  161388. */
  161389. rootUrl: string,
  161390. /**
  161391. * Defines the filename or File of the scene to load from
  161392. */
  161393. sceneFilename: string | File);
  161394. /**
  161395. * Execute the current task
  161396. * @param scene defines the scene where you want your assets to be loaded
  161397. * @param onSuccess is a callback called when the task is successfully executed
  161398. * @param onError is a callback called if an error occurs
  161399. */
  161400. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  161401. }
  161402. /**
  161403. * Define a task used by AssetsManager to load meshes
  161404. */
  161405. export class MeshAssetTask extends AbstractAssetTask {
  161406. /**
  161407. * Defines the name of the task
  161408. */
  161409. name: string;
  161410. /**
  161411. * Defines the list of mesh's names you want to load
  161412. */
  161413. meshesNames: any;
  161414. /**
  161415. * Defines the root url to use as a base to load your meshes and associated resources
  161416. */
  161417. rootUrl: string;
  161418. /**
  161419. * Defines the filename or File of the scene to load from
  161420. */
  161421. sceneFilename: string | File;
  161422. /**
  161423. * Gets the list of loaded meshes
  161424. */
  161425. loadedMeshes: Array<AbstractMesh>;
  161426. /**
  161427. * Gets the list of loaded particle systems
  161428. */
  161429. loadedParticleSystems: Array<IParticleSystem>;
  161430. /**
  161431. * Gets the list of loaded skeletons
  161432. */
  161433. loadedSkeletons: Array<Skeleton>;
  161434. /**
  161435. * Gets the list of loaded animation groups
  161436. */
  161437. loadedAnimationGroups: Array<AnimationGroup>;
  161438. /**
  161439. * Callback called when the task is successful
  161440. */
  161441. onSuccess: (task: MeshAssetTask) => void;
  161442. /**
  161443. * Callback called when the task is successful
  161444. */
  161445. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  161446. /**
  161447. * Creates a new MeshAssetTask
  161448. * @param name defines the name of the task
  161449. * @param meshesNames defines the list of mesh's names you want to load
  161450. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  161451. * @param sceneFilename defines the filename or File of the scene to load from
  161452. */
  161453. constructor(
  161454. /**
  161455. * Defines the name of the task
  161456. */
  161457. name: string,
  161458. /**
  161459. * Defines the list of mesh's names you want to load
  161460. */
  161461. meshesNames: any,
  161462. /**
  161463. * Defines the root url to use as a base to load your meshes and associated resources
  161464. */
  161465. rootUrl: string,
  161466. /**
  161467. * Defines the filename or File of the scene to load from
  161468. */
  161469. sceneFilename: string | File);
  161470. /**
  161471. * Execute the current task
  161472. * @param scene defines the scene where you want your assets to be loaded
  161473. * @param onSuccess is a callback called when the task is successfully executed
  161474. * @param onError is a callback called if an error occurs
  161475. */
  161476. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  161477. }
  161478. /**
  161479. * Define a task used by AssetsManager to load text content
  161480. */
  161481. export class TextFileAssetTask extends AbstractAssetTask {
  161482. /**
  161483. * Defines the name of the task
  161484. */
  161485. name: string;
  161486. /**
  161487. * Defines the location of the file to load
  161488. */
  161489. url: string;
  161490. /**
  161491. * Gets the loaded text string
  161492. */
  161493. text: string;
  161494. /**
  161495. * Callback called when the task is successful
  161496. */
  161497. onSuccess: (task: TextFileAssetTask) => void;
  161498. /**
  161499. * Callback called when the task is successful
  161500. */
  161501. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  161502. /**
  161503. * Creates a new TextFileAssetTask object
  161504. * @param name defines the name of the task
  161505. * @param url defines the location of the file to load
  161506. */
  161507. constructor(
  161508. /**
  161509. * Defines the name of the task
  161510. */
  161511. name: string,
  161512. /**
  161513. * Defines the location of the file to load
  161514. */
  161515. url: string);
  161516. /**
  161517. * Execute the current task
  161518. * @param scene defines the scene where you want your assets to be loaded
  161519. * @param onSuccess is a callback called when the task is successfully executed
  161520. * @param onError is a callback called if an error occurs
  161521. */
  161522. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  161523. }
  161524. /**
  161525. * Define a task used by AssetsManager to load binary data
  161526. */
  161527. export class BinaryFileAssetTask extends AbstractAssetTask {
  161528. /**
  161529. * Defines the name of the task
  161530. */
  161531. name: string;
  161532. /**
  161533. * Defines the location of the file to load
  161534. */
  161535. url: string;
  161536. /**
  161537. * Gets the lodaded data (as an array buffer)
  161538. */
  161539. data: ArrayBuffer;
  161540. /**
  161541. * Callback called when the task is successful
  161542. */
  161543. onSuccess: (task: BinaryFileAssetTask) => void;
  161544. /**
  161545. * Callback called when the task is successful
  161546. */
  161547. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  161548. /**
  161549. * Creates a new BinaryFileAssetTask object
  161550. * @param name defines the name of the new task
  161551. * @param url defines the location of the file to load
  161552. */
  161553. constructor(
  161554. /**
  161555. * Defines the name of the task
  161556. */
  161557. name: string,
  161558. /**
  161559. * Defines the location of the file to load
  161560. */
  161561. url: string);
  161562. /**
  161563. * Execute the current task
  161564. * @param scene defines the scene where you want your assets to be loaded
  161565. * @param onSuccess is a callback called when the task is successfully executed
  161566. * @param onError is a callback called if an error occurs
  161567. */
  161568. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  161569. }
  161570. /**
  161571. * Define a task used by AssetsManager to load images
  161572. */
  161573. export class ImageAssetTask extends AbstractAssetTask {
  161574. /**
  161575. * Defines the name of the task
  161576. */
  161577. name: string;
  161578. /**
  161579. * Defines the location of the image to load
  161580. */
  161581. url: string;
  161582. /**
  161583. * Gets the loaded images
  161584. */
  161585. image: HTMLImageElement;
  161586. /**
  161587. * Callback called when the task is successful
  161588. */
  161589. onSuccess: (task: ImageAssetTask) => void;
  161590. /**
  161591. * Callback called when the task is successful
  161592. */
  161593. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  161594. /**
  161595. * Creates a new ImageAssetTask
  161596. * @param name defines the name of the task
  161597. * @param url defines the location of the image to load
  161598. */
  161599. constructor(
  161600. /**
  161601. * Defines the name of the task
  161602. */
  161603. name: string,
  161604. /**
  161605. * Defines the location of the image to load
  161606. */
  161607. url: string);
  161608. /**
  161609. * Execute the current task
  161610. * @param scene defines the scene where you want your assets to be loaded
  161611. * @param onSuccess is a callback called when the task is successfully executed
  161612. * @param onError is a callback called if an error occurs
  161613. */
  161614. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  161615. }
  161616. /**
  161617. * Defines the interface used by texture loading tasks
  161618. */
  161619. export interface ITextureAssetTask<TEX extends BaseTexture> {
  161620. /**
  161621. * Gets the loaded texture
  161622. */
  161623. texture: TEX;
  161624. }
  161625. /**
  161626. * Define a task used by AssetsManager to load 2D textures
  161627. */
  161628. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  161629. /**
  161630. * Defines the name of the task
  161631. */
  161632. name: string;
  161633. /**
  161634. * Defines the location of the file to load
  161635. */
  161636. url: string;
  161637. /**
  161638. * Defines if mipmap should not be generated (default is false)
  161639. */
  161640. noMipmap?: boolean | undefined;
  161641. /**
  161642. * Defines if texture must be inverted on Y axis (default is true)
  161643. */
  161644. invertY: boolean;
  161645. /**
  161646. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  161647. */
  161648. samplingMode: number;
  161649. /**
  161650. * Gets the loaded texture
  161651. */
  161652. texture: Texture;
  161653. /**
  161654. * Callback called when the task is successful
  161655. */
  161656. onSuccess: (task: TextureAssetTask) => void;
  161657. /**
  161658. * Callback called when the task is successful
  161659. */
  161660. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  161661. /**
  161662. * Creates a new TextureAssetTask object
  161663. * @param name defines the name of the task
  161664. * @param url defines the location of the file to load
  161665. * @param noMipmap defines if mipmap should not be generated (default is false)
  161666. * @param invertY defines if texture must be inverted on Y axis (default is true)
  161667. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  161668. */
  161669. constructor(
  161670. /**
  161671. * Defines the name of the task
  161672. */
  161673. name: string,
  161674. /**
  161675. * Defines the location of the file to load
  161676. */
  161677. url: string,
  161678. /**
  161679. * Defines if mipmap should not be generated (default is false)
  161680. */
  161681. noMipmap?: boolean | undefined,
  161682. /**
  161683. * Defines if texture must be inverted on Y axis (default is true)
  161684. */
  161685. invertY?: boolean,
  161686. /**
  161687. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  161688. */
  161689. samplingMode?: number);
  161690. /**
  161691. * Execute the current task
  161692. * @param scene defines the scene where you want your assets to be loaded
  161693. * @param onSuccess is a callback called when the task is successfully executed
  161694. * @param onError is a callback called if an error occurs
  161695. */
  161696. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  161697. }
  161698. /**
  161699. * Define a task used by AssetsManager to load cube textures
  161700. */
  161701. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  161702. /**
  161703. * Defines the name of the task
  161704. */
  161705. name: string;
  161706. /**
  161707. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  161708. */
  161709. url: string;
  161710. /**
  161711. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  161712. */
  161713. extensions?: string[] | undefined;
  161714. /**
  161715. * Defines if mipmaps should not be generated (default is false)
  161716. */
  161717. noMipmap?: boolean | undefined;
  161718. /**
  161719. * Defines the explicit list of files (undefined by default)
  161720. */
  161721. files?: string[] | undefined;
  161722. /**
  161723. * Gets the loaded texture
  161724. */
  161725. texture: CubeTexture;
  161726. /**
  161727. * Callback called when the task is successful
  161728. */
  161729. onSuccess: (task: CubeTextureAssetTask) => void;
  161730. /**
  161731. * Callback called when the task is successful
  161732. */
  161733. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  161734. /**
  161735. * Creates a new CubeTextureAssetTask
  161736. * @param name defines the name of the task
  161737. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  161738. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  161739. * @param noMipmap defines if mipmaps should not be generated (default is false)
  161740. * @param files defines the explicit list of files (undefined by default)
  161741. */
  161742. constructor(
  161743. /**
  161744. * Defines the name of the task
  161745. */
  161746. name: string,
  161747. /**
  161748. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  161749. */
  161750. url: string,
  161751. /**
  161752. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  161753. */
  161754. extensions?: string[] | undefined,
  161755. /**
  161756. * Defines if mipmaps should not be generated (default is false)
  161757. */
  161758. noMipmap?: boolean | undefined,
  161759. /**
  161760. * Defines the explicit list of files (undefined by default)
  161761. */
  161762. files?: string[] | undefined);
  161763. /**
  161764. * Execute the current task
  161765. * @param scene defines the scene where you want your assets to be loaded
  161766. * @param onSuccess is a callback called when the task is successfully executed
  161767. * @param onError is a callback called if an error occurs
  161768. */
  161769. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  161770. }
  161771. /**
  161772. * Define a task used by AssetsManager to load HDR cube textures
  161773. */
  161774. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  161775. /**
  161776. * Defines the name of the task
  161777. */
  161778. name: string;
  161779. /**
  161780. * Defines the location of the file to load
  161781. */
  161782. url: string;
  161783. /**
  161784. * Defines the desired size (the more it increases the longer the generation will be)
  161785. */
  161786. size: number;
  161787. /**
  161788. * Defines if mipmaps should not be generated (default is false)
  161789. */
  161790. noMipmap: boolean;
  161791. /**
  161792. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  161793. */
  161794. generateHarmonics: boolean;
  161795. /**
  161796. * 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)
  161797. */
  161798. gammaSpace: boolean;
  161799. /**
  161800. * Internal Use Only
  161801. */
  161802. reserved: boolean;
  161803. /**
  161804. * Gets the loaded texture
  161805. */
  161806. texture: HDRCubeTexture;
  161807. /**
  161808. * Callback called when the task is successful
  161809. */
  161810. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  161811. /**
  161812. * Callback called when the task is successful
  161813. */
  161814. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  161815. /**
  161816. * Creates a new HDRCubeTextureAssetTask object
  161817. * @param name defines the name of the task
  161818. * @param url defines the location of the file to load
  161819. * @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.
  161820. * @param noMipmap defines if mipmaps should not be generated (default is false)
  161821. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  161822. * @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)
  161823. * @param reserved Internal use only
  161824. */
  161825. constructor(
  161826. /**
  161827. * Defines the name of the task
  161828. */
  161829. name: string,
  161830. /**
  161831. * Defines the location of the file to load
  161832. */
  161833. url: string,
  161834. /**
  161835. * Defines the desired size (the more it increases the longer the generation will be)
  161836. */
  161837. size: number,
  161838. /**
  161839. * Defines if mipmaps should not be generated (default is false)
  161840. */
  161841. noMipmap?: boolean,
  161842. /**
  161843. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  161844. */
  161845. generateHarmonics?: boolean,
  161846. /**
  161847. * 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)
  161848. */
  161849. gammaSpace?: boolean,
  161850. /**
  161851. * Internal Use Only
  161852. */
  161853. reserved?: boolean);
  161854. /**
  161855. * Execute the current task
  161856. * @param scene defines the scene where you want your assets to be loaded
  161857. * @param onSuccess is a callback called when the task is successfully executed
  161858. * @param onError is a callback called if an error occurs
  161859. */
  161860. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  161861. }
  161862. /**
  161863. * Define a task used by AssetsManager to load Equirectangular cube textures
  161864. */
  161865. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  161866. /**
  161867. * Defines the name of the task
  161868. */
  161869. name: string;
  161870. /**
  161871. * Defines the location of the file to load
  161872. */
  161873. url: string;
  161874. /**
  161875. * Defines the desired size (the more it increases the longer the generation will be)
  161876. */
  161877. size: number;
  161878. /**
  161879. * Defines if mipmaps should not be generated (default is false)
  161880. */
  161881. noMipmap: boolean;
  161882. /**
  161883. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  161884. * but the standard material would require them in Gamma space) (default is true)
  161885. */
  161886. gammaSpace: boolean;
  161887. /**
  161888. * Gets the loaded texture
  161889. */
  161890. texture: EquiRectangularCubeTexture;
  161891. /**
  161892. * Callback called when the task is successful
  161893. */
  161894. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  161895. /**
  161896. * Callback called when the task is successful
  161897. */
  161898. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  161899. /**
  161900. * Creates a new EquiRectangularCubeTextureAssetTask object
  161901. * @param name defines the name of the task
  161902. * @param url defines the location of the file to load
  161903. * @param size defines the desired size (the more it increases the longer the generation will be)
  161904. * If the size is omitted this implies you are using a preprocessed cubemap.
  161905. * @param noMipmap defines if mipmaps should not be generated (default is false)
  161906. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  161907. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  161908. * (default is true)
  161909. */
  161910. constructor(
  161911. /**
  161912. * Defines the name of the task
  161913. */
  161914. name: string,
  161915. /**
  161916. * Defines the location of the file to load
  161917. */
  161918. url: string,
  161919. /**
  161920. * Defines the desired size (the more it increases the longer the generation will be)
  161921. */
  161922. size: number,
  161923. /**
  161924. * Defines if mipmaps should not be generated (default is false)
  161925. */
  161926. noMipmap?: boolean,
  161927. /**
  161928. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  161929. * but the standard material would require them in Gamma space) (default is true)
  161930. */
  161931. gammaSpace?: boolean);
  161932. /**
  161933. * Execute the current task
  161934. * @param scene defines the scene where you want your assets to be loaded
  161935. * @param onSuccess is a callback called when the task is successfully executed
  161936. * @param onError is a callback called if an error occurs
  161937. */
  161938. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  161939. }
  161940. /**
  161941. * This class can be used to easily import assets into a scene
  161942. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  161943. */
  161944. export class AssetsManager {
  161945. private _scene;
  161946. private _isLoading;
  161947. protected _tasks: AbstractAssetTask[];
  161948. protected _waitingTasksCount: number;
  161949. protected _totalTasksCount: number;
  161950. /**
  161951. * Callback called when all tasks are processed
  161952. */
  161953. onFinish: (tasks: AbstractAssetTask[]) => void;
  161954. /**
  161955. * Callback called when a task is successful
  161956. */
  161957. onTaskSuccess: (task: AbstractAssetTask) => void;
  161958. /**
  161959. * Callback called when a task had an error
  161960. */
  161961. onTaskError: (task: AbstractAssetTask) => void;
  161962. /**
  161963. * Callback called when a task is done (whatever the result is)
  161964. */
  161965. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  161966. /**
  161967. * Observable called when all tasks are processed
  161968. */
  161969. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  161970. /**
  161971. * Observable called when a task had an error
  161972. */
  161973. onTaskErrorObservable: Observable<AbstractAssetTask>;
  161974. /**
  161975. * Observable called when all tasks were executed
  161976. */
  161977. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  161978. /**
  161979. * Observable called when a task is done (whatever the result is)
  161980. */
  161981. onProgressObservable: Observable<IAssetsProgressEvent>;
  161982. /**
  161983. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  161984. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  161985. */
  161986. useDefaultLoadingScreen: boolean;
  161987. /**
  161988. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  161989. * when all assets have been downloaded.
  161990. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  161991. */
  161992. autoHideLoadingUI: boolean;
  161993. /**
  161994. * Creates a new AssetsManager
  161995. * @param scene defines the scene to work on
  161996. */
  161997. constructor(scene: Scene);
  161998. /**
  161999. * Add a ContainerAssetTask to the list of active tasks
  162000. * @param taskName defines the name of the new task
  162001. * @param meshesNames defines the name of meshes to load
  162002. * @param rootUrl defines the root url to use to locate files
  162003. * @param sceneFilename defines the filename of the scene file
  162004. * @returns a new ContainerAssetTask object
  162005. */
  162006. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  162007. /**
  162008. * Add a MeshAssetTask to the list of active tasks
  162009. * @param taskName defines the name of the new task
  162010. * @param meshesNames defines the name of meshes to load
  162011. * @param rootUrl defines the root url to use to locate files
  162012. * @param sceneFilename defines the filename of the scene file
  162013. * @returns a new MeshAssetTask object
  162014. */
  162015. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  162016. /**
  162017. * Add a TextFileAssetTask 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. * @returns a new TextFileAssetTask object
  162021. */
  162022. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  162023. /**
  162024. * Add a BinaryFileAssetTask to the list of active tasks
  162025. * @param taskName defines the name of the new task
  162026. * @param url defines the url of the file to load
  162027. * @returns a new BinaryFileAssetTask object
  162028. */
  162029. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  162030. /**
  162031. * Add a ImageAssetTask to the list of active tasks
  162032. * @param taskName defines the name of the new task
  162033. * @param url defines the url of the file to load
  162034. * @returns a new ImageAssetTask object
  162035. */
  162036. addImageTask(taskName: string, url: string): ImageAssetTask;
  162037. /**
  162038. * Add a TextureAssetTask to the list of active tasks
  162039. * @param taskName defines the name of the new task
  162040. * @param url defines the url of the file to load
  162041. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  162042. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  162043. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  162044. * @returns a new TextureAssetTask object
  162045. */
  162046. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  162047. /**
  162048. * Add a CubeTextureAssetTask to the list of active tasks
  162049. * @param taskName defines the name of the new task
  162050. * @param url defines the url of the file to load
  162051. * @param extensions defines the extension to use to load the cube map (can be null)
  162052. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  162053. * @param files defines the list of files to load (can be null)
  162054. * @returns a new CubeTextureAssetTask object
  162055. */
  162056. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  162057. /**
  162058. *
  162059. * Add a HDRCubeTextureAssetTask to the list of active tasks
  162060. * @param taskName defines the name of the new task
  162061. * @param url defines the url of the file to load
  162062. * @param size defines the size you want for the cubemap (can be null)
  162063. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  162064. * @param generateHarmonics defines if you want to automatically generate (true by default)
  162065. * @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)
  162066. * @param reserved Internal use only
  162067. * @returns a new HDRCubeTextureAssetTask object
  162068. */
  162069. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  162070. /**
  162071. *
  162072. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  162073. * @param taskName defines the name of the new task
  162074. * @param url defines the url of the file to load
  162075. * @param size defines the size you want for the cubemap (can be null)
  162076. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  162077. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  162078. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  162079. * @returns a new EquiRectangularCubeTextureAssetTask object
  162080. */
  162081. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  162082. /**
  162083. * Remove a task from the assets manager.
  162084. * @param task the task to remove
  162085. */
  162086. removeTask(task: AbstractAssetTask): void;
  162087. private _decreaseWaitingTasksCount;
  162088. private _runTask;
  162089. /**
  162090. * Reset the AssetsManager and remove all tasks
  162091. * @return the current instance of the AssetsManager
  162092. */
  162093. reset(): AssetsManager;
  162094. /**
  162095. * Start the loading process
  162096. * @return the current instance of the AssetsManager
  162097. */
  162098. load(): AssetsManager;
  162099. /**
  162100. * Start the loading process as an async operation
  162101. * @return a promise returning the list of failed tasks
  162102. */
  162103. loadAsync(): Promise<void>;
  162104. }
  162105. }
  162106. declare module BABYLON {
  162107. /**
  162108. * Wrapper class for promise with external resolve and reject.
  162109. */
  162110. export class Deferred<T> {
  162111. /**
  162112. * The promise associated with this deferred object.
  162113. */
  162114. readonly promise: Promise<T>;
  162115. private _resolve;
  162116. private _reject;
  162117. /**
  162118. * The resolve method of the promise associated with this deferred object.
  162119. */
  162120. get resolve(): (value: T | PromiseLike<T>) => void;
  162121. /**
  162122. * The reject method of the promise associated with this deferred object.
  162123. */
  162124. get reject(): (reason?: any) => void;
  162125. /**
  162126. * Constructor for this deferred object.
  162127. */
  162128. constructor();
  162129. }
  162130. }
  162131. declare module BABYLON {
  162132. /**
  162133. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  162134. */
  162135. export class MeshExploder {
  162136. private _centerMesh;
  162137. private _meshes;
  162138. private _meshesOrigins;
  162139. private _toCenterVectors;
  162140. private _scaledDirection;
  162141. private _newPosition;
  162142. private _centerPosition;
  162143. /**
  162144. * Explodes meshes from a center mesh.
  162145. * @param meshes The meshes to explode.
  162146. * @param centerMesh The mesh to be center of explosion.
  162147. */
  162148. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  162149. private _setCenterMesh;
  162150. /**
  162151. * Get class name
  162152. * @returns "MeshExploder"
  162153. */
  162154. getClassName(): string;
  162155. /**
  162156. * "Exploded meshes"
  162157. * @returns Array of meshes with the centerMesh at index 0.
  162158. */
  162159. getMeshes(): Array<Mesh>;
  162160. /**
  162161. * Explodes meshes giving a specific direction
  162162. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  162163. */
  162164. explode(direction?: number): void;
  162165. }
  162166. }
  162167. declare module BABYLON {
  162168. /**
  162169. * Class used to help managing file picking and drag'n'drop
  162170. */
  162171. export class FilesInput {
  162172. /**
  162173. * List of files ready to be loaded
  162174. */
  162175. static get FilesToLoad(): {
  162176. [key: string]: File;
  162177. };
  162178. /**
  162179. * Callback called when a file is processed
  162180. */
  162181. onProcessFileCallback: (file: File, name: string, extension: string, setSceneFileToLoad: (sceneFile: File) => void) => boolean;
  162182. /**
  162183. * Function used when loading the scene file
  162184. */
  162185. loadAsync: (sceneFile: File, onProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>) => Promise<Scene>;
  162186. private _engine;
  162187. private _currentScene;
  162188. private _sceneLoadedCallback;
  162189. private _progressCallback;
  162190. private _additionalRenderLoopLogicCallback;
  162191. private _textureLoadingCallback;
  162192. private _startingProcessingFilesCallback;
  162193. private _onReloadCallback;
  162194. private _errorCallback;
  162195. private _elementToMonitor;
  162196. private _sceneFileToLoad;
  162197. private _filesToLoad;
  162198. /**
  162199. * Creates a new FilesInput
  162200. * @param engine defines the rendering engine
  162201. * @param scene defines the hosting scene
  162202. * @param sceneLoadedCallback callback called when scene is loaded
  162203. * @param progressCallback callback called to track progress
  162204. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  162205. * @param textureLoadingCallback callback called when a texture is loading
  162206. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  162207. * @param onReloadCallback callback called when a reload is requested
  162208. * @param errorCallback callback call if an error occurs
  162209. */
  162210. 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>);
  162211. private _dragEnterHandler;
  162212. private _dragOverHandler;
  162213. private _dropHandler;
  162214. /**
  162215. * Calls this function to listen to drag'n'drop events on a specific DOM element
  162216. * @param elementToMonitor defines the DOM element to track
  162217. */
  162218. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  162219. /** Gets the current list of files to load */
  162220. get filesToLoad(): File[];
  162221. /**
  162222. * Release all associated resources
  162223. */
  162224. dispose(): void;
  162225. private renderFunction;
  162226. private drag;
  162227. private drop;
  162228. private _traverseFolder;
  162229. private _processFiles;
  162230. /**
  162231. * Load files from a drop event
  162232. * @param event defines the drop event to use as source
  162233. */
  162234. loadFiles(event: any): void;
  162235. private _processReload;
  162236. /**
  162237. * Reload the current scene from the loaded files
  162238. */
  162239. reload(): void;
  162240. }
  162241. }
  162242. declare module BABYLON {
  162243. /**
  162244. * Defines the root class used to create scene optimization to use with SceneOptimizer
  162245. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  162246. */
  162247. export class SceneOptimization {
  162248. /**
  162249. * Defines the priority of this optimization (0 by default which means first in the list)
  162250. */
  162251. priority: number;
  162252. /**
  162253. * Gets a string describing the action executed by the current optimization
  162254. * @returns description string
  162255. */
  162256. getDescription(): string;
  162257. /**
  162258. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  162259. * @param scene defines the current scene where to apply this optimization
  162260. * @param optimizer defines the current optimizer
  162261. * @returns true if everything that can be done was applied
  162262. */
  162263. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  162264. /**
  162265. * Creates the SceneOptimization object
  162266. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  162267. * @param desc defines the description associated with the optimization
  162268. */
  162269. constructor(
  162270. /**
  162271. * Defines the priority of this optimization (0 by default which means first in the list)
  162272. */
  162273. priority?: number);
  162274. }
  162275. /**
  162276. * Defines an optimization used to reduce the size of render target textures
  162277. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  162278. */
  162279. export class TextureOptimization extends SceneOptimization {
  162280. /**
  162281. * Defines the priority of this optimization (0 by default which means first in the list)
  162282. */
  162283. priority: number;
  162284. /**
  162285. * 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
  162286. */
  162287. maximumSize: number;
  162288. /**
  162289. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  162290. */
  162291. step: number;
  162292. /**
  162293. * Gets a string describing the action executed by the current optimization
  162294. * @returns description string
  162295. */
  162296. getDescription(): string;
  162297. /**
  162298. * Creates the TextureOptimization object
  162299. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  162300. * @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
  162301. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  162302. */
  162303. constructor(
  162304. /**
  162305. * Defines the priority of this optimization (0 by default which means first in the list)
  162306. */
  162307. priority?: number,
  162308. /**
  162309. * 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
  162310. */
  162311. maximumSize?: number,
  162312. /**
  162313. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  162314. */
  162315. step?: number);
  162316. /**
  162317. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  162318. * @param scene defines the current scene where to apply this optimization
  162319. * @param optimizer defines the current optimizer
  162320. * @returns true if everything that can be done was applied
  162321. */
  162322. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  162323. }
  162324. /**
  162325. * Defines an optimization used to increase or decrease the rendering resolution
  162326. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  162327. */
  162328. export class HardwareScalingOptimization extends SceneOptimization {
  162329. /**
  162330. * Defines the priority of this optimization (0 by default which means first in the list)
  162331. */
  162332. priority: number;
  162333. /**
  162334. * Defines the maximum scale to use (2 by default)
  162335. */
  162336. maximumScale: number;
  162337. /**
  162338. * Defines the step to use between two passes (0.5 by default)
  162339. */
  162340. step: number;
  162341. private _currentScale;
  162342. private _directionOffset;
  162343. /**
  162344. * Gets a string describing the action executed by the current optimization
  162345. * @return description string
  162346. */
  162347. getDescription(): string;
  162348. /**
  162349. * Creates the HardwareScalingOptimization object
  162350. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  162351. * @param maximumScale defines the maximum scale to use (2 by default)
  162352. * @param step defines the step to use between two passes (0.5 by default)
  162353. */
  162354. constructor(
  162355. /**
  162356. * Defines the priority of this optimization (0 by default which means first in the list)
  162357. */
  162358. priority?: number,
  162359. /**
  162360. * Defines the maximum scale to use (2 by default)
  162361. */
  162362. maximumScale?: number,
  162363. /**
  162364. * Defines the step to use between two passes (0.5 by default)
  162365. */
  162366. step?: number);
  162367. /**
  162368. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  162369. * @param scene defines the current scene where to apply this optimization
  162370. * @param optimizer defines the current optimizer
  162371. * @returns true if everything that can be done was applied
  162372. */
  162373. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  162374. }
  162375. /**
  162376. * Defines an optimization used to remove shadows
  162377. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  162378. */
  162379. export class ShadowsOptimization extends SceneOptimization {
  162380. /**
  162381. * Gets a string describing the action executed by the current optimization
  162382. * @return description string
  162383. */
  162384. getDescription(): string;
  162385. /**
  162386. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  162387. * @param scene defines the current scene where to apply this optimization
  162388. * @param optimizer defines the current optimizer
  162389. * @returns true if everything that can be done was applied
  162390. */
  162391. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  162392. }
  162393. /**
  162394. * Defines an optimization used to turn post-processes off
  162395. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  162396. */
  162397. export class PostProcessesOptimization extends SceneOptimization {
  162398. /**
  162399. * Gets a string describing the action executed by the current optimization
  162400. * @return description string
  162401. */
  162402. getDescription(): string;
  162403. /**
  162404. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  162405. * @param scene defines the current scene where to apply this optimization
  162406. * @param optimizer defines the current optimizer
  162407. * @returns true if everything that can be done was applied
  162408. */
  162409. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  162410. }
  162411. /**
  162412. * Defines an optimization used to turn lens flares off
  162413. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  162414. */
  162415. export class LensFlaresOptimization extends SceneOptimization {
  162416. /**
  162417. * Gets a string describing the action executed by the current optimization
  162418. * @return description string
  162419. */
  162420. getDescription(): string;
  162421. /**
  162422. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  162423. * @param scene defines the current scene where to apply this optimization
  162424. * @param optimizer defines the current optimizer
  162425. * @returns true if everything that can be done was applied
  162426. */
  162427. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  162428. }
  162429. /**
  162430. * Defines an optimization based on user defined callback.
  162431. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  162432. */
  162433. export class CustomOptimization extends SceneOptimization {
  162434. /**
  162435. * Callback called to apply the custom optimization.
  162436. */
  162437. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  162438. /**
  162439. * Callback called to get custom description
  162440. */
  162441. onGetDescription: () => string;
  162442. /**
  162443. * Gets a string describing the action executed by the current optimization
  162444. * @returns description string
  162445. */
  162446. getDescription(): string;
  162447. /**
  162448. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  162449. * @param scene defines the current scene where to apply this optimization
  162450. * @param optimizer defines the current optimizer
  162451. * @returns true if everything that can be done was applied
  162452. */
  162453. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  162454. }
  162455. /**
  162456. * Defines an optimization used to turn particles off
  162457. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  162458. */
  162459. export class ParticlesOptimization extends SceneOptimization {
  162460. /**
  162461. * Gets a string describing the action executed by the current optimization
  162462. * @return description string
  162463. */
  162464. getDescription(): string;
  162465. /**
  162466. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  162467. * @param scene defines the current scene where to apply this optimization
  162468. * @param optimizer defines the current optimizer
  162469. * @returns true if everything that can be done was applied
  162470. */
  162471. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  162472. }
  162473. /**
  162474. * Defines an optimization used to turn render targets off
  162475. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  162476. */
  162477. export class RenderTargetsOptimization extends SceneOptimization {
  162478. /**
  162479. * Gets a string describing the action executed by the current optimization
  162480. * @return description string
  162481. */
  162482. getDescription(): string;
  162483. /**
  162484. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  162485. * @param scene defines the current scene where to apply this optimization
  162486. * @param optimizer defines the current optimizer
  162487. * @returns true if everything that can be done was applied
  162488. */
  162489. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  162490. }
  162491. /**
  162492. * Defines an optimization used to merge meshes with compatible materials
  162493. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  162494. */
  162495. export class MergeMeshesOptimization extends SceneOptimization {
  162496. private static _UpdateSelectionTree;
  162497. /**
  162498. * Gets or sets a boolean which defines if optimization octree has to be updated
  162499. */
  162500. static get UpdateSelectionTree(): boolean;
  162501. /**
  162502. * Gets or sets a boolean which defines if optimization octree has to be updated
  162503. */
  162504. static set UpdateSelectionTree(value: boolean);
  162505. /**
  162506. * Gets a string describing the action executed by the current optimization
  162507. * @return description string
  162508. */
  162509. getDescription(): string;
  162510. private _canBeMerged;
  162511. /**
  162512. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  162513. * @param scene defines the current scene where to apply this optimization
  162514. * @param optimizer defines the current optimizer
  162515. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  162516. * @returns true if everything that can be done was applied
  162517. */
  162518. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  162519. }
  162520. /**
  162521. * Defines a list of options used by SceneOptimizer
  162522. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  162523. */
  162524. export class SceneOptimizerOptions {
  162525. /**
  162526. * Defines the target frame rate to reach (60 by default)
  162527. */
  162528. targetFrameRate: number;
  162529. /**
  162530. * Defines the interval between two checkes (2000ms by default)
  162531. */
  162532. trackerDuration: number;
  162533. /**
  162534. * Gets the list of optimizations to apply
  162535. */
  162536. optimizations: SceneOptimization[];
  162537. /**
  162538. * Creates a new list of options used by SceneOptimizer
  162539. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  162540. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  162541. */
  162542. constructor(
  162543. /**
  162544. * Defines the target frame rate to reach (60 by default)
  162545. */
  162546. targetFrameRate?: number,
  162547. /**
  162548. * Defines the interval between two checkes (2000ms by default)
  162549. */
  162550. trackerDuration?: number);
  162551. /**
  162552. * Add a new optimization
  162553. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  162554. * @returns the current SceneOptimizerOptions
  162555. */
  162556. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  162557. /**
  162558. * Add a new custom optimization
  162559. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  162560. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  162561. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  162562. * @returns the current SceneOptimizerOptions
  162563. */
  162564. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  162565. /**
  162566. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  162567. * @param targetFrameRate defines the target frame rate (60 by default)
  162568. * @returns a SceneOptimizerOptions object
  162569. */
  162570. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  162571. /**
  162572. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  162573. * @param targetFrameRate defines the target frame rate (60 by default)
  162574. * @returns a SceneOptimizerOptions object
  162575. */
  162576. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  162577. /**
  162578. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  162579. * @param targetFrameRate defines the target frame rate (60 by default)
  162580. * @returns a SceneOptimizerOptions object
  162581. */
  162582. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  162583. }
  162584. /**
  162585. * Class used to run optimizations in order to reach a target frame rate
  162586. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  162587. */
  162588. export class SceneOptimizer implements IDisposable {
  162589. private _isRunning;
  162590. private _options;
  162591. private _scene;
  162592. private _currentPriorityLevel;
  162593. private _targetFrameRate;
  162594. private _trackerDuration;
  162595. private _currentFrameRate;
  162596. private _sceneDisposeObserver;
  162597. private _improvementMode;
  162598. /**
  162599. * Defines an observable called when the optimizer reaches the target frame rate
  162600. */
  162601. onSuccessObservable: Observable<SceneOptimizer>;
  162602. /**
  162603. * Defines an observable called when the optimizer enables an optimization
  162604. */
  162605. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  162606. /**
  162607. * Defines an observable called when the optimizer is not able to reach the target frame rate
  162608. */
  162609. onFailureObservable: Observable<SceneOptimizer>;
  162610. /**
  162611. * Gets a boolean indicating if the optimizer is in improvement mode
  162612. */
  162613. get isInImprovementMode(): boolean;
  162614. /**
  162615. * Gets the current priority level (0 at start)
  162616. */
  162617. get currentPriorityLevel(): number;
  162618. /**
  162619. * Gets the current frame rate checked by the SceneOptimizer
  162620. */
  162621. get currentFrameRate(): number;
  162622. /**
  162623. * Gets or sets the current target frame rate (60 by default)
  162624. */
  162625. get targetFrameRate(): number;
  162626. /**
  162627. * Gets or sets the current target frame rate (60 by default)
  162628. */
  162629. set targetFrameRate(value: number);
  162630. /**
  162631. * Gets or sets the current interval between two checks (every 2000ms by default)
  162632. */
  162633. get trackerDuration(): number;
  162634. /**
  162635. * Gets or sets the current interval between two checks (every 2000ms by default)
  162636. */
  162637. set trackerDuration(value: number);
  162638. /**
  162639. * Gets the list of active optimizations
  162640. */
  162641. get optimizations(): SceneOptimization[];
  162642. /**
  162643. * Creates a new SceneOptimizer
  162644. * @param scene defines the scene to work on
  162645. * @param options defines the options to use with the SceneOptimizer
  162646. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  162647. * @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)
  162648. */
  162649. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  162650. /**
  162651. * Stops the current optimizer
  162652. */
  162653. stop(): void;
  162654. /**
  162655. * Reset the optimizer to initial step (current priority level = 0)
  162656. */
  162657. reset(): void;
  162658. /**
  162659. * Start the optimizer. By default it will try to reach a specific framerate
  162660. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  162661. */
  162662. start(): void;
  162663. private _checkCurrentState;
  162664. /**
  162665. * Release all resources
  162666. */
  162667. dispose(): void;
  162668. /**
  162669. * Helper function to create a SceneOptimizer with one single line of code
  162670. * @param scene defines the scene to work on
  162671. * @param options defines the options to use with the SceneOptimizer
  162672. * @param onSuccess defines a callback to call on success
  162673. * @param onFailure defines a callback to call on failure
  162674. * @returns the new SceneOptimizer object
  162675. */
  162676. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  162677. }
  162678. }
  162679. declare module BABYLON {
  162680. /**
  162681. * Class used to serialize a scene into a string
  162682. */
  162683. export class SceneSerializer {
  162684. /**
  162685. * Clear cache used by a previous serialization
  162686. */
  162687. static ClearCache(): void;
  162688. /**
  162689. * Serialize a scene into a JSON compatible object
  162690. * @param scene defines the scene to serialize
  162691. * @returns a JSON compatible object
  162692. */
  162693. static Serialize(scene: Scene): any;
  162694. /**
  162695. * Serialize a mesh into a JSON compatible object
  162696. * @param toSerialize defines the mesh to serialize
  162697. * @param withParents defines if parents must be serialized as well
  162698. * @param withChildren defines if children must be serialized as well
  162699. * @returns a JSON compatible object
  162700. */
  162701. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  162702. }
  162703. }
  162704. declare module BABYLON {
  162705. /**
  162706. * This represents the different options available for the video capture.
  162707. */
  162708. export interface VideoRecorderOptions {
  162709. /** Defines the mime type of the video. */
  162710. mimeType: string;
  162711. /** Defines the FPS the video should be recorded at. */
  162712. fps: number;
  162713. /** Defines the chunk size for the recording data. */
  162714. recordChunckSize: number;
  162715. /** The audio tracks to attach to the recording. */
  162716. audioTracks?: MediaStreamTrack[];
  162717. }
  162718. /**
  162719. * This can help with recording videos from BabylonJS.
  162720. * This is based on the available WebRTC functionalities of the browser.
  162721. *
  162722. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  162723. */
  162724. export class VideoRecorder {
  162725. private static readonly _defaultOptions;
  162726. /**
  162727. * Returns whether or not the VideoRecorder is available in your browser.
  162728. * @param engine Defines the Babylon Engine.
  162729. * @returns true if supported otherwise false.
  162730. */
  162731. static IsSupported(engine: Engine): boolean;
  162732. private readonly _options;
  162733. private _canvas;
  162734. private _mediaRecorder;
  162735. private _recordedChunks;
  162736. private _fileName;
  162737. private _resolve;
  162738. private _reject;
  162739. /**
  162740. * True when a recording is already in progress.
  162741. */
  162742. get isRecording(): boolean;
  162743. /**
  162744. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  162745. * @param engine Defines the BabylonJS Engine you wish to record.
  162746. * @param options Defines options that can be used to customize the capture.
  162747. */
  162748. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  162749. /**
  162750. * Stops the current recording before the default capture timeout passed in the startRecording function.
  162751. */
  162752. stopRecording(): void;
  162753. /**
  162754. * Starts recording the canvas for a max duration specified in parameters.
  162755. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  162756. * If null no automatic download will start and you can rely on the promise to get the data back.
  162757. * @param maxDuration Defines the maximum recording time in seconds.
  162758. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  162759. * @return A promise callback at the end of the recording with the video data in Blob.
  162760. */
  162761. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  162762. /**
  162763. * Releases internal resources used during the recording.
  162764. */
  162765. dispose(): void;
  162766. private _handleDataAvailable;
  162767. private _handleError;
  162768. private _handleStop;
  162769. }
  162770. }
  162771. declare module BABYLON {
  162772. /**
  162773. * Class containing a set of static utilities functions for screenshots
  162774. */
  162775. export class ScreenshotTools {
  162776. /**
  162777. * Captures a screenshot of the current rendering
  162778. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  162779. * @param engine defines the rendering engine
  162780. * @param camera defines the source camera
  162781. * @param size This parameter can be set to a single number or to an object with the
  162782. * following (optional) properties: precision, width, height. If a single number is passed,
  162783. * it will be used for both width and height. If an object is passed, the screenshot size
  162784. * will be derived from the parameters. The precision property is a multiplier allowing
  162785. * rendering at a higher or lower resolution
  162786. * @param successCallback defines the callback receives a single parameter which contains the
  162787. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  162788. * src parameter of an <img> to display it
  162789. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  162790. * Check your browser for supported MIME types
  162791. */
  162792. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  162793. /**
  162794. * Captures a screenshot of the current rendering
  162795. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  162796. * @param engine defines the rendering engine
  162797. * @param camera defines the source camera
  162798. * @param size This parameter can be set to a single number or to an object with the
  162799. * following (optional) properties: precision, width, height. If a single number is passed,
  162800. * it will be used for both width and height. If an object is passed, the screenshot size
  162801. * will be derived from the parameters. The precision property is a multiplier allowing
  162802. * rendering at a higher or lower resolution
  162803. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  162804. * Check your browser for supported MIME types
  162805. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  162806. * to the src parameter of an <img> to display it
  162807. */
  162808. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  162809. /**
  162810. * Generates an image screenshot from the specified camera.
  162811. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  162812. * @param engine The engine to use for rendering
  162813. * @param camera The camera to use for rendering
  162814. * @param size This parameter can be set to a single number or to an object with the
  162815. * following (optional) properties: precision, width, height. If a single number is passed,
  162816. * it will be used for both width and height. If an object is passed, the screenshot size
  162817. * will be derived from the parameters. The precision property is a multiplier allowing
  162818. * rendering at a higher or lower resolution
  162819. * @param successCallback The callback receives a single parameter which contains the
  162820. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  162821. * src parameter of an <img> to display it
  162822. * @param mimeType The MIME type of the screenshot image (default: image/png).
  162823. * Check your browser for supported MIME types
  162824. * @param samples Texture samples (default: 1)
  162825. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  162826. * @param fileName A name for for the downloaded file.
  162827. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  162828. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  162829. */
  162830. 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;
  162831. /**
  162832. * Generates an image screenshot from the specified camera.
  162833. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  162834. * @param engine The engine to use for rendering
  162835. * @param camera The camera to use for rendering
  162836. * @param size This parameter can be set to a single number or to an object with the
  162837. * following (optional) properties: precision, width, height. If a single number is passed,
  162838. * it will be used for both width and height. If an object is passed, the screenshot size
  162839. * will be derived from the parameters. The precision property is a multiplier allowing
  162840. * rendering at a higher or lower resolution
  162841. * @param mimeType The MIME type of the screenshot image (default: image/png).
  162842. * Check your browser for supported MIME types
  162843. * @param samples Texture samples (default: 1)
  162844. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  162845. * @param fileName A name for for the downloaded file.
  162846. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  162847. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  162848. * to the src parameter of an <img> to display it
  162849. */
  162850. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  162851. /**
  162852. * Gets height and width for screenshot size
  162853. * @private
  162854. */
  162855. private static _getScreenshotSize;
  162856. }
  162857. }
  162858. declare module BABYLON {
  162859. /**
  162860. * Interface for a data buffer
  162861. */
  162862. export interface IDataBuffer {
  162863. /**
  162864. * Reads bytes from the data buffer.
  162865. * @param byteOffset The byte offset to read
  162866. * @param byteLength The byte length to read
  162867. * @returns A promise that resolves when the bytes are read
  162868. */
  162869. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  162870. /**
  162871. * The byte length of the buffer.
  162872. */
  162873. readonly byteLength: number;
  162874. }
  162875. /**
  162876. * Utility class for reading from a data buffer
  162877. */
  162878. export class DataReader {
  162879. /**
  162880. * The data buffer associated with this data reader.
  162881. */
  162882. readonly buffer: IDataBuffer;
  162883. /**
  162884. * The current byte offset from the beginning of the data buffer.
  162885. */
  162886. byteOffset: number;
  162887. private _dataView;
  162888. private _dataByteOffset;
  162889. /**
  162890. * Constructor
  162891. * @param buffer The buffer to read
  162892. */
  162893. constructor(buffer: IDataBuffer);
  162894. /**
  162895. * Loads the given byte length.
  162896. * @param byteLength The byte length to load
  162897. * @returns A promise that resolves when the load is complete
  162898. */
  162899. loadAsync(byteLength: number): Promise<void>;
  162900. /**
  162901. * Read a unsigned 32-bit integer from the currently loaded data range.
  162902. * @returns The 32-bit integer read
  162903. */
  162904. readUint32(): number;
  162905. /**
  162906. * Read a byte array from the currently loaded data range.
  162907. * @param byteLength The byte length to read
  162908. * @returns The byte array read
  162909. */
  162910. readUint8Array(byteLength: number): Uint8Array;
  162911. /**
  162912. * Read a string from the currently loaded data range.
  162913. * @param byteLength The byte length to read
  162914. * @returns The string read
  162915. */
  162916. readString(byteLength: number): string;
  162917. /**
  162918. * Skips the given byte length the currently loaded data range.
  162919. * @param byteLength The byte length to skip
  162920. */
  162921. skipBytes(byteLength: number): void;
  162922. }
  162923. }
  162924. declare module BABYLON {
  162925. /**
  162926. * Class for storing data to local storage if available or in-memory storage otherwise
  162927. */
  162928. export class DataStorage {
  162929. private static _Storage;
  162930. private static _GetStorage;
  162931. /**
  162932. * Reads a string from the data storage
  162933. * @param key The key to read
  162934. * @param defaultValue The value if the key doesn't exist
  162935. * @returns The string value
  162936. */
  162937. static ReadString(key: string, defaultValue: string): string;
  162938. /**
  162939. * Writes a string to the data storage
  162940. * @param key The key to write
  162941. * @param value The value to write
  162942. */
  162943. static WriteString(key: string, value: string): void;
  162944. /**
  162945. * Reads a boolean from the data storage
  162946. * @param key The key to read
  162947. * @param defaultValue The value if the key doesn't exist
  162948. * @returns The boolean value
  162949. */
  162950. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  162951. /**
  162952. * Writes a boolean to the data storage
  162953. * @param key The key to write
  162954. * @param value The value to write
  162955. */
  162956. static WriteBoolean(key: string, value: boolean): void;
  162957. /**
  162958. * Reads a number from the data storage
  162959. * @param key The key to read
  162960. * @param defaultValue The value if the key doesn't exist
  162961. * @returns The number value
  162962. */
  162963. static ReadNumber(key: string, defaultValue: number): number;
  162964. /**
  162965. * Writes a number to the data storage
  162966. * @param key The key to write
  162967. * @param value The value to write
  162968. */
  162969. static WriteNumber(key: string, value: number): void;
  162970. }
  162971. }
  162972. declare module BABYLON {
  162973. /**
  162974. * Class used to record delta files between 2 scene states
  162975. */
  162976. export class SceneRecorder {
  162977. private _trackedScene;
  162978. private _savedJSON;
  162979. /**
  162980. * Track a given scene. This means the current scene state will be considered the original state
  162981. * @param scene defines the scene to track
  162982. */
  162983. track(scene: Scene): void;
  162984. /**
  162985. * Get the delta between current state and original state
  162986. * @returns a string containing the delta
  162987. */
  162988. getDelta(): any;
  162989. private _compareArray;
  162990. private _compareObjects;
  162991. private _compareCollections;
  162992. private static GetShadowGeneratorById;
  162993. /**
  162994. * Apply a given delta to a given scene
  162995. * @param deltaJSON defines the JSON containing the delta
  162996. * @param scene defines the scene to apply the delta to
  162997. */
  162998. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  162999. private static _ApplyPropertiesToEntity;
  163000. private static _ApplyDeltaForEntity;
  163001. }
  163002. }
  163003. declare module BABYLON {
  163004. /**
  163005. * A 3D trajectory consisting of an order list of vectors describing a
  163006. * path of motion through 3D space.
  163007. */
  163008. export class Trajectory {
  163009. private _points;
  163010. private readonly _segmentLength;
  163011. /**
  163012. * Serialize to JSON.
  163013. * @returns serialized JSON string
  163014. */
  163015. serialize(): string;
  163016. /**
  163017. * Deserialize from JSON.
  163018. * @param json serialized JSON string
  163019. * @returns deserialized Trajectory
  163020. */
  163021. static Deserialize(json: string): Trajectory;
  163022. /**
  163023. * Create a new empty Trajectory.
  163024. * @param segmentLength radius of discretization for Trajectory points
  163025. */
  163026. constructor(segmentLength?: number);
  163027. /**
  163028. * Get the length of the Trajectory.
  163029. * @returns length of the Trajectory
  163030. */
  163031. getLength(): number;
  163032. /**
  163033. * Append a new point to the Trajectory.
  163034. * NOTE: This implementation has many allocations.
  163035. * @param point point to append to the Trajectory
  163036. */
  163037. add(point: DeepImmutable<Vector3>): void;
  163038. /**
  163039. * Create a new Trajectory with a segment length chosen to make it
  163040. * probable that the new Trajectory will have a specified number of
  163041. * segments. This operation is imprecise.
  163042. * @param targetResolution number of segments desired
  163043. * @returns new Trajectory with approximately the requested number of segments
  163044. */
  163045. resampleAtTargetResolution(targetResolution: number): Trajectory;
  163046. /**
  163047. * Convert Trajectory segments into tokenized representation. This
  163048. * representation is an array of numbers where each nth number is the
  163049. * index of the token which is most similar to the nth segment of the
  163050. * Trajectory.
  163051. * @param tokens list of vectors which serve as discrete tokens
  163052. * @returns list of indices of most similar token per segment
  163053. */
  163054. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  163055. private static _forwardDir;
  163056. private static _inverseFromVec;
  163057. private static _upDir;
  163058. private static _fromToVec;
  163059. private static _lookMatrix;
  163060. /**
  163061. * Transform the rotation (i.e., direction) of a segment to isolate
  163062. * the relative transformation represented by the segment. This operation
  163063. * may or may not succeed due to singularities in the equations that define
  163064. * motion relativity in this context.
  163065. * @param priorVec the origin of the prior segment
  163066. * @param fromVec the origin of the current segment
  163067. * @param toVec the destination of the current segment
  163068. * @param result reference to output variable
  163069. * @returns whether or not transformation was successful
  163070. */
  163071. private static _transformSegmentDirToRef;
  163072. private static _bestMatch;
  163073. private static _score;
  163074. private static _bestScore;
  163075. /**
  163076. * Determine which token vector is most similar to the
  163077. * segment vector.
  163078. * @param segment segment vector
  163079. * @param tokens token vector list
  163080. * @returns index of the most similar token to the segment
  163081. */
  163082. private static _tokenizeSegment;
  163083. }
  163084. /**
  163085. * Class representing a set of known, named trajectories to which Trajectories can be
  163086. * added and using which Trajectories can be recognized.
  163087. */
  163088. export class TrajectoryClassifier {
  163089. private _maximumAllowableMatchCost;
  163090. private _vector3Alphabet;
  163091. private _levenshteinAlphabet;
  163092. private _nameToDescribedTrajectory;
  163093. /**
  163094. * Serialize to JSON.
  163095. * @returns JSON serialization
  163096. */
  163097. serialize(): string;
  163098. /**
  163099. * Deserialize from JSON.
  163100. * @param json JSON serialization
  163101. * @returns deserialized TrajectorySet
  163102. */
  163103. static Deserialize(json: string): TrajectoryClassifier;
  163104. /**
  163105. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  163106. * VERY naive, need to be generating these things from known
  163107. * sets. Better version later, probably eliminating this one.
  163108. * @returns auto-generated TrajectorySet
  163109. */
  163110. static Generate(): TrajectoryClassifier;
  163111. private constructor();
  163112. /**
  163113. * Add a new Trajectory to the set with a given name.
  163114. * @param trajectory new Trajectory to be added
  163115. * @param classification name to which to add the Trajectory
  163116. */
  163117. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  163118. /**
  163119. * Remove a known named trajectory and all Trajectories associated with it.
  163120. * @param classification name to remove
  163121. * @returns whether anything was removed
  163122. */
  163123. deleteClassification(classification: string): boolean;
  163124. /**
  163125. * Attempt to recognize a Trajectory from among all the classifications
  163126. * already known to the classifier.
  163127. * @param trajectory Trajectory to be recognized
  163128. * @returns classification of Trajectory if recognized, null otherwise
  163129. */
  163130. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  163131. }
  163132. }
  163133. declare module BABYLON {
  163134. /**
  163135. * An interface for all Hit test features
  163136. */
  163137. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  163138. /**
  163139. * Triggered when new babylon (transformed) hit test results are available
  163140. */
  163141. onHitTestResultObservable: Observable<T[]>;
  163142. }
  163143. /**
  163144. * Options used for hit testing
  163145. */
  163146. export interface IWebXRLegacyHitTestOptions {
  163147. /**
  163148. * Only test when user interacted with the scene. Default - hit test every frame
  163149. */
  163150. testOnPointerDownOnly?: boolean;
  163151. /**
  163152. * The node to use to transform the local results to world coordinates
  163153. */
  163154. worldParentNode?: TransformNode;
  163155. }
  163156. /**
  163157. * Interface defining the babylon result of raycasting/hit-test
  163158. */
  163159. export interface IWebXRLegacyHitResult {
  163160. /**
  163161. * Transformation matrix that can be applied to a node that will put it in the hit point location
  163162. */
  163163. transformationMatrix: Matrix;
  163164. /**
  163165. * The native hit test result
  163166. */
  163167. xrHitResult: XRHitResult | XRHitTestResult;
  163168. }
  163169. /**
  163170. * The currently-working hit-test module.
  163171. * Hit test (or Ray-casting) is used to interact with the real world.
  163172. * For further information read here - https://github.com/immersive-web/hit-test
  163173. */
  163174. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  163175. /**
  163176. * options to use when constructing this feature
  163177. */
  163178. readonly options: IWebXRLegacyHitTestOptions;
  163179. private _direction;
  163180. private _mat;
  163181. private _onSelectEnabled;
  163182. private _origin;
  163183. /**
  163184. * The module's name
  163185. */
  163186. static readonly Name: string;
  163187. /**
  163188. * The (Babylon) version of this module.
  163189. * This is an integer representing the implementation version.
  163190. * This number does not correspond to the WebXR specs version
  163191. */
  163192. static readonly Version: number;
  163193. /**
  163194. * Populated with the last native XR Hit Results
  163195. */
  163196. lastNativeXRHitResults: XRHitResult[];
  163197. /**
  163198. * Triggered when new babylon (transformed) hit test results are available
  163199. */
  163200. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  163201. /**
  163202. * Creates a new instance of the (legacy version) hit test feature
  163203. * @param _xrSessionManager an instance of WebXRSessionManager
  163204. * @param options options to use when constructing this feature
  163205. */
  163206. constructor(_xrSessionManager: WebXRSessionManager,
  163207. /**
  163208. * options to use when constructing this feature
  163209. */
  163210. options?: IWebXRLegacyHitTestOptions);
  163211. /**
  163212. * execute a hit test with an XR Ray
  163213. *
  163214. * @param xrSession a native xrSession that will execute this hit test
  163215. * @param xrRay the ray (position and direction) to use for ray-casting
  163216. * @param referenceSpace native XR reference space to use for the hit-test
  163217. * @param filter filter function that will filter the results
  163218. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  163219. */
  163220. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  163221. /**
  163222. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  163223. * @param event the (select) event to use to select with
  163224. * @param referenceSpace the reference space to use for this hit test
  163225. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  163226. */
  163227. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  163228. /**
  163229. * attach this feature
  163230. * Will usually be called by the features manager
  163231. *
  163232. * @returns true if successful.
  163233. */
  163234. attach(): boolean;
  163235. /**
  163236. * detach this feature.
  163237. * Will usually be called by the features manager
  163238. *
  163239. * @returns true if successful.
  163240. */
  163241. detach(): boolean;
  163242. /**
  163243. * Dispose this feature and all of the resources attached
  163244. */
  163245. dispose(): void;
  163246. protected _onXRFrame(frame: XRFrame): void;
  163247. private _onHitTestResults;
  163248. private _onSelect;
  163249. }
  163250. }
  163251. declare module BABYLON {
  163252. /**
  163253. * Options used for hit testing (version 2)
  163254. */
  163255. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  163256. /**
  163257. * Do not create a permanent hit test. Will usually be used when only
  163258. * transient inputs are needed.
  163259. */
  163260. disablePermanentHitTest?: boolean;
  163261. /**
  163262. * Enable transient (for example touch-based) hit test inspections
  163263. */
  163264. enableTransientHitTest?: boolean;
  163265. /**
  163266. * Offset ray for the permanent hit test
  163267. */
  163268. offsetRay?: Vector3;
  163269. /**
  163270. * Offset ray for the transient hit test
  163271. */
  163272. transientOffsetRay?: Vector3;
  163273. /**
  163274. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  163275. */
  163276. useReferenceSpace?: boolean;
  163277. /**
  163278. * Override the default entity type(s) of the hit-test result
  163279. */
  163280. entityTypes?: XRHitTestTrackableType[];
  163281. }
  163282. /**
  163283. * Interface defining the babylon result of hit-test
  163284. */
  163285. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  163286. /**
  163287. * The input source that generated this hit test (if transient)
  163288. */
  163289. inputSource?: XRInputSource;
  163290. /**
  163291. * Is this a transient hit test
  163292. */
  163293. isTransient?: boolean;
  163294. /**
  163295. * Position of the hit test result
  163296. */
  163297. position: Vector3;
  163298. /**
  163299. * Rotation of the hit test result
  163300. */
  163301. rotationQuaternion: Quaternion;
  163302. /**
  163303. * The native hit test result
  163304. */
  163305. xrHitResult: XRHitTestResult;
  163306. }
  163307. /**
  163308. * The currently-working hit-test module.
  163309. * Hit test (or Ray-casting) is used to interact with the real world.
  163310. * For further information read here - https://github.com/immersive-web/hit-test
  163311. *
  163312. * Tested on chrome (mobile) 80.
  163313. */
  163314. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  163315. /**
  163316. * options to use when constructing this feature
  163317. */
  163318. readonly options: IWebXRHitTestOptions;
  163319. private _tmpMat;
  163320. private _tmpPos;
  163321. private _tmpQuat;
  163322. private _transientXrHitTestSource;
  163323. private _xrHitTestSource;
  163324. private initHitTestSource;
  163325. /**
  163326. * The module's name
  163327. */
  163328. static readonly Name: string;
  163329. /**
  163330. * The (Babylon) version of this module.
  163331. * This is an integer representing the implementation version.
  163332. * This number does not correspond to the WebXR specs version
  163333. */
  163334. static readonly Version: number;
  163335. /**
  163336. * When set to true, each hit test will have its own position/rotation objects
  163337. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  163338. * the developers will clone them or copy them as they see fit.
  163339. */
  163340. autoCloneTransformation: boolean;
  163341. /**
  163342. * Triggered when new babylon (transformed) hit test results are available
  163343. * Note - this will be called when results come back from the device. It can be an empty array!!
  163344. */
  163345. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  163346. /**
  163347. * Use this to temporarily pause hit test checks.
  163348. */
  163349. paused: boolean;
  163350. /**
  163351. * Creates a new instance of the hit test feature
  163352. * @param _xrSessionManager an instance of WebXRSessionManager
  163353. * @param options options to use when constructing this feature
  163354. */
  163355. constructor(_xrSessionManager: WebXRSessionManager,
  163356. /**
  163357. * options to use when constructing this feature
  163358. */
  163359. options?: IWebXRHitTestOptions);
  163360. /**
  163361. * attach this feature
  163362. * Will usually be called by the features manager
  163363. *
  163364. * @returns true if successful.
  163365. */
  163366. attach(): boolean;
  163367. /**
  163368. * detach this feature.
  163369. * Will usually be called by the features manager
  163370. *
  163371. * @returns true if successful.
  163372. */
  163373. detach(): boolean;
  163374. /**
  163375. * Dispose this feature and all of the resources attached
  163376. */
  163377. dispose(): void;
  163378. protected _onXRFrame(frame: XRFrame): void;
  163379. private _processWebXRHitTestResult;
  163380. }
  163381. }
  163382. declare module BABYLON {
  163383. /**
  163384. * Configuration options of the anchor system
  163385. */
  163386. export interface IWebXRAnchorSystemOptions {
  163387. /**
  163388. * a node that will be used to convert local to world coordinates
  163389. */
  163390. worldParentNode?: TransformNode;
  163391. /**
  163392. * If set to true a reference of the created anchors will be kept until the next session starts
  163393. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  163394. */
  163395. doNotRemoveAnchorsOnSessionEnded?: boolean;
  163396. }
  163397. /**
  163398. * A babylon container for an XR Anchor
  163399. */
  163400. export interface IWebXRAnchor {
  163401. /**
  163402. * A babylon-assigned ID for this anchor
  163403. */
  163404. id: number;
  163405. /**
  163406. * Transformation matrix to apply to an object attached to this anchor
  163407. */
  163408. transformationMatrix: Matrix;
  163409. /**
  163410. * The native anchor object
  163411. */
  163412. xrAnchor: XRAnchor;
  163413. /**
  163414. * if defined, this object will be constantly updated by the anchor's position and rotation
  163415. */
  163416. attachedNode?: TransformNode;
  163417. /**
  163418. * Remove this anchor from the scene
  163419. */
  163420. remove(): void;
  163421. }
  163422. /**
  163423. * An implementation of the anchor system for WebXR.
  163424. * For further information see https://github.com/immersive-web/anchors/
  163425. */
  163426. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  163427. private _options;
  163428. private _lastFrameDetected;
  163429. private _trackedAnchors;
  163430. private _referenceSpaceForFrameAnchors;
  163431. private _futureAnchors;
  163432. /**
  163433. * The module's name
  163434. */
  163435. static readonly Name: string;
  163436. /**
  163437. * The (Babylon) version of this module.
  163438. * This is an integer representing the implementation version.
  163439. * This number does not correspond to the WebXR specs version
  163440. */
  163441. static readonly Version: number;
  163442. /**
  163443. * Observers registered here will be executed when a new anchor was added to the session
  163444. */
  163445. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  163446. /**
  163447. * Observers registered here will be executed when an anchor was removed from the session
  163448. */
  163449. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  163450. /**
  163451. * Observers registered here will be executed when an existing anchor updates
  163452. * This can execute N times every frame
  163453. */
  163454. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  163455. /**
  163456. * Set the reference space to use for anchor creation, when not using a hit test.
  163457. * Will default to the session's reference space if not defined
  163458. */
  163459. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  163460. /**
  163461. * constructs a new anchor system
  163462. * @param _xrSessionManager an instance of WebXRSessionManager
  163463. * @param _options configuration object for this feature
  163464. */
  163465. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  163466. private _tmpVector;
  163467. private _tmpQuaternion;
  163468. private _populateTmpTransformation;
  163469. /**
  163470. * Create a new anchor point using a hit test result at a specific point in the scene
  163471. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  163472. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  163473. *
  163474. * @param hitTestResult The hit test result to use for this anchor creation
  163475. * @param position an optional position offset for this anchor
  163476. * @param rotationQuaternion an optional rotation offset for this anchor
  163477. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  163478. */
  163479. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  163480. /**
  163481. * Add a new anchor at a specific position and rotation
  163482. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  163483. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  163484. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  163485. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  163486. *
  163487. * @param position the position in which to add an anchor
  163488. * @param rotationQuaternion an optional rotation for the anchor transformation
  163489. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  163490. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  163491. */
  163492. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  163493. /**
  163494. * Get the list of anchors currently being tracked by the system
  163495. */
  163496. get anchors(): IWebXRAnchor[];
  163497. /**
  163498. * detach this feature.
  163499. * Will usually be called by the features manager
  163500. *
  163501. * @returns true if successful.
  163502. */
  163503. detach(): boolean;
  163504. /**
  163505. * Dispose this feature and all of the resources attached
  163506. */
  163507. dispose(): void;
  163508. protected _onXRFrame(frame: XRFrame): void;
  163509. /**
  163510. * avoiding using Array.find for global support.
  163511. * @param xrAnchor the plane to find in the array
  163512. */
  163513. private _findIndexInAnchorArray;
  163514. private _updateAnchorWithXRFrame;
  163515. private _createAnchorAtTransformation;
  163516. }
  163517. }
  163518. declare module BABYLON {
  163519. /**
  163520. * Options used in the plane detector module
  163521. */
  163522. export interface IWebXRPlaneDetectorOptions {
  163523. /**
  163524. * The node to use to transform the local results to world coordinates
  163525. */
  163526. worldParentNode?: TransformNode;
  163527. /**
  163528. * If set to true a reference of the created planes will be kept until the next session starts
  163529. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  163530. */
  163531. doNotRemovePlanesOnSessionEnded?: boolean;
  163532. /**
  163533. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  163534. */
  163535. preferredDetectorOptions?: XRGeometryDetectorOptions;
  163536. }
  163537. /**
  163538. * A babylon interface for a WebXR plane.
  163539. * A Plane is actually a polygon, built from N points in space
  163540. *
  163541. * Supported in chrome 79, not supported in canary 81 ATM
  163542. */
  163543. export interface IWebXRPlane {
  163544. /**
  163545. * a babylon-assigned ID for this polygon
  163546. */
  163547. id: number;
  163548. /**
  163549. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  163550. */
  163551. polygonDefinition: Array<Vector3>;
  163552. /**
  163553. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  163554. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  163555. */
  163556. transformationMatrix: Matrix;
  163557. /**
  163558. * the native xr-plane object
  163559. */
  163560. xrPlane: XRPlane;
  163561. }
  163562. /**
  163563. * The plane detector is used to detect planes in the real world when in AR
  163564. * For more information see https://github.com/immersive-web/real-world-geometry/
  163565. */
  163566. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  163567. private _options;
  163568. private _detectedPlanes;
  163569. private _enabled;
  163570. private _lastFrameDetected;
  163571. /**
  163572. * The module's name
  163573. */
  163574. static readonly Name: string;
  163575. /**
  163576. * The (Babylon) version of this module.
  163577. * This is an integer representing the implementation version.
  163578. * This number does not correspond to the WebXR specs version
  163579. */
  163580. static readonly Version: number;
  163581. /**
  163582. * Observers registered here will be executed when a new plane was added to the session
  163583. */
  163584. onPlaneAddedObservable: Observable<IWebXRPlane>;
  163585. /**
  163586. * Observers registered here will be executed when a plane is no longer detected in the session
  163587. */
  163588. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  163589. /**
  163590. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  163591. * This can execute N times every frame
  163592. */
  163593. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  163594. /**
  163595. * construct a new Plane Detector
  163596. * @param _xrSessionManager an instance of xr Session manager
  163597. * @param _options configuration to use when constructing this feature
  163598. */
  163599. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  163600. /**
  163601. * detach this feature.
  163602. * Will usually be called by the features manager
  163603. *
  163604. * @returns true if successful.
  163605. */
  163606. detach(): boolean;
  163607. /**
  163608. * Dispose this feature and all of the resources attached
  163609. */
  163610. dispose(): void;
  163611. /**
  163612. * Check if the needed objects are defined.
  163613. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  163614. */
  163615. isCompatible(): boolean;
  163616. protected _onXRFrame(frame: XRFrame): void;
  163617. private _init;
  163618. private _updatePlaneWithXRPlane;
  163619. /**
  163620. * avoiding using Array.find for global support.
  163621. * @param xrPlane the plane to find in the array
  163622. */
  163623. private _findIndexInPlaneArray;
  163624. }
  163625. }
  163626. declare module BABYLON {
  163627. /**
  163628. * Options interface for the background remover plugin
  163629. */
  163630. export interface IWebXRBackgroundRemoverOptions {
  163631. /**
  163632. * Further background meshes to disable when entering AR
  163633. */
  163634. backgroundMeshes?: AbstractMesh[];
  163635. /**
  163636. * flags to configure the removal of the environment helper.
  163637. * If not set, the entire background will be removed. If set, flags should be set as well.
  163638. */
  163639. environmentHelperRemovalFlags?: {
  163640. /**
  163641. * Should the skybox be removed (default false)
  163642. */
  163643. skyBox?: boolean;
  163644. /**
  163645. * Should the ground be removed (default false)
  163646. */
  163647. ground?: boolean;
  163648. };
  163649. /**
  163650. * don't disable the environment helper
  163651. */
  163652. ignoreEnvironmentHelper?: boolean;
  163653. }
  163654. /**
  163655. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  163656. */
  163657. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  163658. /**
  163659. * read-only options to be used in this module
  163660. */
  163661. readonly options: IWebXRBackgroundRemoverOptions;
  163662. /**
  163663. * The module's name
  163664. */
  163665. static readonly Name: string;
  163666. /**
  163667. * The (Babylon) version of this module.
  163668. * This is an integer representing the implementation version.
  163669. * This number does not correspond to the WebXR specs version
  163670. */
  163671. static readonly Version: number;
  163672. /**
  163673. * registered observers will be triggered when the background state changes
  163674. */
  163675. onBackgroundStateChangedObservable: Observable<boolean>;
  163676. /**
  163677. * constructs a new background remover module
  163678. * @param _xrSessionManager the session manager for this module
  163679. * @param options read-only options to be used in this module
  163680. */
  163681. constructor(_xrSessionManager: WebXRSessionManager,
  163682. /**
  163683. * read-only options to be used in this module
  163684. */
  163685. options?: IWebXRBackgroundRemoverOptions);
  163686. /**
  163687. * attach this feature
  163688. * Will usually be called by the features manager
  163689. *
  163690. * @returns true if successful.
  163691. */
  163692. attach(): boolean;
  163693. /**
  163694. * detach this feature.
  163695. * Will usually be called by the features manager
  163696. *
  163697. * @returns true if successful.
  163698. */
  163699. detach(): boolean;
  163700. /**
  163701. * Dispose this feature and all of the resources attached
  163702. */
  163703. dispose(): void;
  163704. protected _onXRFrame(_xrFrame: XRFrame): void;
  163705. private _setBackgroundState;
  163706. }
  163707. }
  163708. declare module BABYLON {
  163709. /**
  163710. * Options for the controller physics feature
  163711. */
  163712. export class IWebXRControllerPhysicsOptions {
  163713. /**
  163714. * Should the headset get its own impostor
  163715. */
  163716. enableHeadsetImpostor?: boolean;
  163717. /**
  163718. * Optional parameters for the headset impostor
  163719. */
  163720. headsetImpostorParams?: {
  163721. /**
  163722. * The type of impostor to create. Default is sphere
  163723. */
  163724. impostorType: number;
  163725. /**
  163726. * the size of the impostor. Defaults to 10cm
  163727. */
  163728. impostorSize?: number | {
  163729. width: number;
  163730. height: number;
  163731. depth: number;
  163732. };
  163733. /**
  163734. * Friction definitions
  163735. */
  163736. friction?: number;
  163737. /**
  163738. * Restitution
  163739. */
  163740. restitution?: number;
  163741. };
  163742. /**
  163743. * The physics properties of the future impostors
  163744. */
  163745. physicsProperties?: {
  163746. /**
  163747. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  163748. * Note that this requires a physics engine that supports mesh impostors!
  163749. */
  163750. useControllerMesh?: boolean;
  163751. /**
  163752. * The type of impostor to create. Default is sphere
  163753. */
  163754. impostorType?: number;
  163755. /**
  163756. * the size of the impostor. Defaults to 10cm
  163757. */
  163758. impostorSize?: number | {
  163759. width: number;
  163760. height: number;
  163761. depth: number;
  163762. };
  163763. /**
  163764. * Friction definitions
  163765. */
  163766. friction?: number;
  163767. /**
  163768. * Restitution
  163769. */
  163770. restitution?: number;
  163771. };
  163772. /**
  163773. * the xr input to use with this pointer selection
  163774. */
  163775. xrInput: WebXRInput;
  163776. }
  163777. /**
  163778. * Add physics impostor to your webxr controllers,
  163779. * including naive calculation of their linear and angular velocity
  163780. */
  163781. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  163782. private readonly _options;
  163783. private _attachController;
  163784. private _controllers;
  163785. private _debugMode;
  163786. private _delta;
  163787. private _headsetImpostor?;
  163788. private _headsetMesh?;
  163789. private _lastTimestamp;
  163790. private _tmpQuaternion;
  163791. private _tmpVector;
  163792. /**
  163793. * The module's name
  163794. */
  163795. static readonly Name: string;
  163796. /**
  163797. * The (Babylon) version of this module.
  163798. * This is an integer representing the implementation version.
  163799. * This number does not correspond to the webxr specs version
  163800. */
  163801. static readonly Version: number;
  163802. /**
  163803. * Construct a new Controller Physics Feature
  163804. * @param _xrSessionManager the corresponding xr session manager
  163805. * @param _options options to create this feature with
  163806. */
  163807. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  163808. /**
  163809. * @hidden
  163810. * enable debugging - will show console outputs and the impostor mesh
  163811. */
  163812. _enablePhysicsDebug(): void;
  163813. /**
  163814. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  163815. * @param xrController the controller to add
  163816. */
  163817. addController(xrController: WebXRInputSource): void;
  163818. /**
  163819. * attach this feature
  163820. * Will usually be called by the features manager
  163821. *
  163822. * @returns true if successful.
  163823. */
  163824. attach(): boolean;
  163825. /**
  163826. * detach this feature.
  163827. * Will usually be called by the features manager
  163828. *
  163829. * @returns true if successful.
  163830. */
  163831. detach(): boolean;
  163832. /**
  163833. * Get the headset impostor, if enabled
  163834. * @returns the impostor
  163835. */
  163836. getHeadsetImpostor(): PhysicsImpostor | undefined;
  163837. /**
  163838. * Get the physics impostor of a specific controller.
  163839. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  163840. * @param controller the controller or the controller id of which to get the impostor
  163841. * @returns the impostor or null
  163842. */
  163843. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  163844. /**
  163845. * Update the physics properties provided in the constructor
  163846. * @param newProperties the new properties object
  163847. */
  163848. setPhysicsProperties(newProperties: {
  163849. impostorType?: number;
  163850. impostorSize?: number | {
  163851. width: number;
  163852. height: number;
  163853. depth: number;
  163854. };
  163855. friction?: number;
  163856. restitution?: number;
  163857. }): void;
  163858. protected _onXRFrame(_xrFrame: any): void;
  163859. private _detachController;
  163860. }
  163861. }
  163862. declare module BABYLON {
  163863. /**
  163864. * A babylon interface for a "WebXR" feature point.
  163865. * Represents the position and confidence value of a given feature point.
  163866. */
  163867. export interface IWebXRFeaturePoint {
  163868. /**
  163869. * Represents the position of the feature point in world space.
  163870. */
  163871. position: Vector3;
  163872. /**
  163873. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  163874. */
  163875. confidenceValue: number;
  163876. }
  163877. /**
  163878. * The feature point system is used to detect feature points from real world geometry.
  163879. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  163880. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  163881. */
  163882. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  163883. private _enabled;
  163884. private _featurePointCloud;
  163885. /**
  163886. * The module's name
  163887. */
  163888. static readonly Name: string;
  163889. /**
  163890. * The (Babylon) version of this module.
  163891. * This is an integer representing the implementation version.
  163892. * This number does not correspond to the WebXR specs version
  163893. */
  163894. static readonly Version: number;
  163895. /**
  163896. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  163897. * Will notify the observers about which feature points have been added.
  163898. */
  163899. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  163900. /**
  163901. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  163902. * Will notify the observers about which feature points have been updated.
  163903. */
  163904. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  163905. /**
  163906. * The current feature point cloud maintained across frames.
  163907. */
  163908. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  163909. /**
  163910. * construct the feature point system
  163911. * @param _xrSessionManager an instance of xr Session manager
  163912. */
  163913. constructor(_xrSessionManager: WebXRSessionManager);
  163914. /**
  163915. * Detach this feature.
  163916. * Will usually be called by the features manager
  163917. *
  163918. * @returns true if successful.
  163919. */
  163920. detach(): boolean;
  163921. /**
  163922. * Dispose this feature and all of the resources attached
  163923. */
  163924. dispose(): void;
  163925. /**
  163926. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  163927. */
  163928. protected _onXRFrame(frame: XRFrame): void;
  163929. /**
  163930. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  163931. */
  163932. private _init;
  163933. }
  163934. }
  163935. declare module BABYLON {
  163936. /**
  163937. * Configuration interface for the hand tracking feature
  163938. */
  163939. export interface IWebXRHandTrackingOptions {
  163940. /**
  163941. * The xrInput that will be used as source for new hands
  163942. */
  163943. xrInput: WebXRInput;
  163944. /**
  163945. * Configuration object for the joint meshes
  163946. */
  163947. jointMeshes?: {
  163948. /**
  163949. * Should the meshes created be invisible (defaults to false)
  163950. */
  163951. invisible?: boolean;
  163952. /**
  163953. * A source mesh to be used to create instances. Defaults to a sphere.
  163954. * This mesh will be the source for all other (25) meshes.
  163955. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  163956. */
  163957. sourceMesh?: Mesh;
  163958. /**
  163959. * This function will be called after a mesh was created for a specific joint.
  163960. * Using this function you can either manipulate the instance or return a new mesh.
  163961. * When returning a new mesh the instance created before will be disposed
  163962. */
  163963. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  163964. /**
  163965. * Should the source mesh stay visible. Defaults to false
  163966. */
  163967. keepOriginalVisible?: boolean;
  163968. /**
  163969. * Scale factor for all instances (defaults to 2)
  163970. */
  163971. scaleFactor?: number;
  163972. /**
  163973. * Should each instance have its own physics impostor
  163974. */
  163975. enablePhysics?: boolean;
  163976. /**
  163977. * If enabled, override default physics properties
  163978. */
  163979. physicsProps?: {
  163980. friction?: number;
  163981. restitution?: number;
  163982. impostorType?: number;
  163983. };
  163984. /**
  163985. * Should the default hand mesh be disabled. In this case, the spheres will be visible (unless set invisible).
  163986. */
  163987. disableDefaultHandMesh?: boolean;
  163988. /**
  163989. * a rigged hand-mesh that will be updated according to the XRHand data provided. This will override the default hand mesh
  163990. */
  163991. handMeshes?: {
  163992. right: AbstractMesh;
  163993. left: AbstractMesh;
  163994. };
  163995. /**
  163996. * If a hand mesh was provided, this array will define what axis will update which node. This will override the default hand mesh
  163997. */
  163998. rigMapping?: {
  163999. right: string[];
  164000. left: string[];
  164001. };
  164002. };
  164003. }
  164004. /**
  164005. * Parts of the hands divided to writs and finger names
  164006. */
  164007. export const enum HandPart {
  164008. /**
  164009. * HandPart - Wrist
  164010. */
  164011. WRIST = "wrist",
  164012. /**
  164013. * HandPart - The THumb
  164014. */
  164015. THUMB = "thumb",
  164016. /**
  164017. * HandPart - Index finger
  164018. */
  164019. INDEX = "index",
  164020. /**
  164021. * HandPart - Middle finger
  164022. */
  164023. MIDDLE = "middle",
  164024. /**
  164025. * HandPart - Ring finger
  164026. */
  164027. RING = "ring",
  164028. /**
  164029. * HandPart - Little finger
  164030. */
  164031. LITTLE = "little"
  164032. }
  164033. /**
  164034. * Representing a single hand (with its corresponding native XRHand object)
  164035. */
  164036. export class WebXRHand implements IDisposable {
  164037. /** the controller to which the hand correlates */
  164038. readonly xrController: WebXRInputSource;
  164039. /** the meshes to be used to track the hand joints */
  164040. readonly trackedMeshes: AbstractMesh[];
  164041. private _handMesh?;
  164042. private _rigMapping?;
  164043. private _scene;
  164044. private _defaultHandMesh;
  164045. private _transformNodeMapping;
  164046. /**
  164047. * Hand-parts definition (key is HandPart)
  164048. */
  164049. handPartsDefinition: {
  164050. [key: string]: number[];
  164051. };
  164052. /**
  164053. * Observers will be triggered when the mesh for this hand was initialized.
  164054. */
  164055. onHandMeshReadyObservable: Observable<WebXRHand>;
  164056. /**
  164057. * Populate the HandPartsDefinition object.
  164058. * This is called as a side effect since certain browsers don't have XRHand defined.
  164059. */
  164060. private generateHandPartsDefinition;
  164061. /**
  164062. * Construct a new hand object
  164063. * @param xrController the controller to which the hand correlates
  164064. * @param trackedMeshes the meshes to be used to track the hand joints
  164065. * @param _handMesh an optional hand mesh. if not provided, ours will be used
  164066. * @param _rigMapping an optional rig mapping for the hand mesh. if not provided, ours will be used
  164067. * @param disableDefaultHandMesh should the default mesh creation be disabled
  164068. */
  164069. constructor(
  164070. /** the controller to which the hand correlates */
  164071. xrController: WebXRInputSource,
  164072. /** the meshes to be used to track the hand joints */
  164073. trackedMeshes: AbstractMesh[], _handMesh?: AbstractMesh | undefined, _rigMapping?: string[] | undefined, disableDefaultHandMesh?: boolean);
  164074. /**
  164075. * Get the hand mesh. It is possible that the hand mesh is not yet ready!
  164076. */
  164077. get handMesh(): AbstractMesh | undefined;
  164078. /**
  164079. * Update this hand from the latest xr frame
  164080. * @param xrFrame xrFrame to update from
  164081. * @param referenceSpace The current viewer reference space
  164082. * @param scaleFactor optional scale factor for the meshes
  164083. */
  164084. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  164085. /**
  164086. * Get meshes of part of the hand
  164087. * @param part the part of hand to get
  164088. * @returns An array of meshes that correlate to the hand part requested
  164089. */
  164090. getHandPartMeshes(part: HandPart): AbstractMesh[];
  164091. /**
  164092. * Dispose this Hand object
  164093. */
  164094. dispose(): void;
  164095. private _generateDefaultHandMesh;
  164096. }
  164097. /**
  164098. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  164099. */
  164100. export class WebXRHandTracking extends WebXRAbstractFeature {
  164101. /**
  164102. * options to use when constructing this feature
  164103. */
  164104. readonly options: IWebXRHandTrackingOptions;
  164105. private static _idCounter;
  164106. /**
  164107. * The module's name
  164108. */
  164109. static readonly Name: string;
  164110. /**
  164111. * The (Babylon) version of this module.
  164112. * This is an integer representing the implementation version.
  164113. * This number does not correspond to the WebXR specs version
  164114. */
  164115. static readonly Version: number;
  164116. /**
  164117. * This observable will notify registered observers when a new hand object was added and initialized
  164118. */
  164119. onHandAddedObservable: Observable<WebXRHand>;
  164120. /**
  164121. * This observable will notify its observers right before the hand object is disposed
  164122. */
  164123. onHandRemovedObservable: Observable<WebXRHand>;
  164124. private _hands;
  164125. /**
  164126. * Creates a new instance of the hit test feature
  164127. * @param _xrSessionManager an instance of WebXRSessionManager
  164128. * @param options options to use when constructing this feature
  164129. */
  164130. constructor(_xrSessionManager: WebXRSessionManager,
  164131. /**
  164132. * options to use when constructing this feature
  164133. */
  164134. options: IWebXRHandTrackingOptions);
  164135. /**
  164136. * Check if the needed objects are defined.
  164137. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  164138. */
  164139. isCompatible(): boolean;
  164140. /**
  164141. * attach this feature
  164142. * Will usually be called by the features manager
  164143. *
  164144. * @returns true if successful.
  164145. */
  164146. attach(): boolean;
  164147. /**
  164148. * detach this feature.
  164149. * Will usually be called by the features manager
  164150. *
  164151. * @returns true if successful.
  164152. */
  164153. detach(): boolean;
  164154. /**
  164155. * Dispose this feature and all of the resources attached
  164156. */
  164157. dispose(): void;
  164158. /**
  164159. * Get the hand object according to the controller id
  164160. * @param controllerId the controller id to which we want to get the hand
  164161. * @returns null if not found or the WebXRHand object if found
  164162. */
  164163. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  164164. /**
  164165. * Get a hand object according to the requested handedness
  164166. * @param handedness the handedness to request
  164167. * @returns null if not found or the WebXRHand object if found
  164168. */
  164169. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  164170. protected _onXRFrame(_xrFrame: XRFrame): void;
  164171. private _attachHand;
  164172. private _detachHand;
  164173. }
  164174. }
  164175. declare module BABYLON {
  164176. /**
  164177. * Options used in the mesh detector module
  164178. */
  164179. export interface IWebXRMeshDetectorOptions {
  164180. /**
  164181. * The node to use to transform the local results to world coordinates
  164182. */
  164183. worldParentNode?: TransformNode;
  164184. /**
  164185. * If set to true a reference of the created meshes will be kept until the next session starts
  164186. * If not defined, meshes will be removed from the array when the feature is detached or the session ended.
  164187. */
  164188. doNotRemoveMeshesOnSessionEnded?: boolean;
  164189. /**
  164190. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  164191. */
  164192. preferredDetectorOptions?: XRGeometryDetectorOptions;
  164193. /**
  164194. * If set to true, WebXRMeshDetector will convert coordinate systems for meshes.
  164195. * If not defined, mesh conversions from right handed to left handed coordinate systems won't be conducted.
  164196. * Right handed mesh data will be available through IWebXRVertexData.xrMesh.
  164197. */
  164198. convertCoordinateSystems?: boolean;
  164199. }
  164200. /**
  164201. * A babylon interface for a XR mesh's vertex data.
  164202. *
  164203. * Currently not supported by WebXR, available only with BabylonNative
  164204. */
  164205. export interface IWebXRVertexData {
  164206. /**
  164207. * A babylon-assigned ID for this mesh
  164208. */
  164209. id: number;
  164210. /**
  164211. * Data required for constructing a mesh in Babylon.js.
  164212. */
  164213. xrMesh: XRMesh;
  164214. /**
  164215. * The node to use to transform the local results to world coordinates.
  164216. * WorldParentNode will only exist if it was declared in the IWebXRMeshDetectorOptions.
  164217. */
  164218. worldParentNode?: TransformNode;
  164219. /**
  164220. * An array of vertex positions in babylon space. right/left hand system is taken into account.
  164221. * Positions will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  164222. */
  164223. positions?: Float32Array;
  164224. /**
  164225. * An array of indices in babylon space. right/left hand system is taken into account.
  164226. * Indices will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  164227. */
  164228. indices?: Uint32Array;
  164229. /**
  164230. * An array of vertex normals in babylon space. right/left hand system is taken into account.
  164231. * Normals will not be calculated if convertCoordinateSystems is undefined in the IWebXRMeshDetectorOptions.
  164232. * Different platforms may or may not support mesh normals when convertCoordinateSystems is set to true.
  164233. */
  164234. normals?: Float32Array;
  164235. /**
  164236. * A transformation matrix to apply on the mesh that will be built using the meshDefinition.
  164237. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module.
  164238. * TransformationMatrix will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  164239. */
  164240. transformationMatrix?: Matrix;
  164241. }
  164242. /**
  164243. * The mesh detector is used to detect meshes in the real world when in AR
  164244. */
  164245. export class WebXRMeshDetector extends WebXRAbstractFeature {
  164246. private _options;
  164247. private _detectedMeshes;
  164248. /**
  164249. * The module's name
  164250. */
  164251. static readonly Name: string;
  164252. /**
  164253. * The (Babylon) version of this module.
  164254. * This is an integer representing the implementation version.
  164255. * This number does not correspond to the WebXR specs version
  164256. */
  164257. static readonly Version: number;
  164258. /**
  164259. * Observers registered here will be executed when a new mesh was added to the session
  164260. */
  164261. onMeshAddedObservable: Observable<IWebXRVertexData>;
  164262. /**
  164263. * Observers registered here will be executed when a mesh is no longer detected in the session
  164264. */
  164265. onMeshRemovedObservable: Observable<IWebXRVertexData>;
  164266. /**
  164267. * Observers registered here will be executed when an existing mesh updates
  164268. */
  164269. onMeshUpdatedObservable: Observable<IWebXRVertexData>;
  164270. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRMeshDetectorOptions);
  164271. detach(): boolean;
  164272. dispose(): void;
  164273. protected _onXRFrame(frame: XRFrame): void;
  164274. private _init;
  164275. private _updateVertexDataWithXRMesh;
  164276. }
  164277. }
  164278. declare module BABYLON {
  164279. /**
  164280. * The motion controller class for all microsoft mixed reality controllers
  164281. */
  164282. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  164283. protected readonly _mapping: {
  164284. defaultButton: {
  164285. valueNodeName: string;
  164286. unpressedNodeName: string;
  164287. pressedNodeName: string;
  164288. };
  164289. defaultAxis: {
  164290. valueNodeName: string;
  164291. minNodeName: string;
  164292. maxNodeName: string;
  164293. };
  164294. buttons: {
  164295. "xr-standard-trigger": {
  164296. rootNodeName: string;
  164297. componentProperty: string;
  164298. states: string[];
  164299. };
  164300. "xr-standard-squeeze": {
  164301. rootNodeName: string;
  164302. componentProperty: string;
  164303. states: string[];
  164304. };
  164305. "xr-standard-touchpad": {
  164306. rootNodeName: string;
  164307. labelAnchorNodeName: string;
  164308. touchPointNodeName: string;
  164309. };
  164310. "xr-standard-thumbstick": {
  164311. rootNodeName: string;
  164312. componentProperty: string;
  164313. states: string[];
  164314. };
  164315. };
  164316. axes: {
  164317. "xr-standard-touchpad": {
  164318. "x-axis": {
  164319. rootNodeName: string;
  164320. };
  164321. "y-axis": {
  164322. rootNodeName: string;
  164323. };
  164324. };
  164325. "xr-standard-thumbstick": {
  164326. "x-axis": {
  164327. rootNodeName: string;
  164328. };
  164329. "y-axis": {
  164330. rootNodeName: string;
  164331. };
  164332. };
  164333. };
  164334. };
  164335. /**
  164336. * The base url used to load the left and right controller models
  164337. */
  164338. static MODEL_BASE_URL: string;
  164339. /**
  164340. * The name of the left controller model file
  164341. */
  164342. static MODEL_LEFT_FILENAME: string;
  164343. /**
  164344. * The name of the right controller model file
  164345. */
  164346. static MODEL_RIGHT_FILENAME: string;
  164347. profileId: string;
  164348. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  164349. protected _getFilenameAndPath(): {
  164350. filename: string;
  164351. path: string;
  164352. };
  164353. protected _getModelLoadingConstraints(): boolean;
  164354. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  164355. protected _setRootMesh(meshes: AbstractMesh[]): void;
  164356. protected _updateModel(): void;
  164357. }
  164358. }
  164359. declare module BABYLON {
  164360. /**
  164361. * The motion controller class for oculus touch (quest, rift).
  164362. * This class supports legacy mapping as well the standard xr mapping
  164363. */
  164364. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  164365. private _forceLegacyControllers;
  164366. private _modelRootNode;
  164367. /**
  164368. * The base url used to load the left and right controller models
  164369. */
  164370. static MODEL_BASE_URL: string;
  164371. /**
  164372. * The name of the left controller model file
  164373. */
  164374. static MODEL_LEFT_FILENAME: string;
  164375. /**
  164376. * The name of the right controller model file
  164377. */
  164378. static MODEL_RIGHT_FILENAME: string;
  164379. /**
  164380. * Base Url for the Quest controller model.
  164381. */
  164382. static QUEST_MODEL_BASE_URL: string;
  164383. profileId: string;
  164384. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  164385. protected _getFilenameAndPath(): {
  164386. filename: string;
  164387. path: string;
  164388. };
  164389. protected _getModelLoadingConstraints(): boolean;
  164390. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  164391. protected _setRootMesh(meshes: AbstractMesh[]): void;
  164392. protected _updateModel(): void;
  164393. /**
  164394. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  164395. * between the touch and touch 2.
  164396. */
  164397. private _isQuest;
  164398. }
  164399. }
  164400. declare module BABYLON {
  164401. /**
  164402. * The motion controller class for the standard HTC-Vive controllers
  164403. */
  164404. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  164405. private _modelRootNode;
  164406. /**
  164407. * The base url used to load the left and right controller models
  164408. */
  164409. static MODEL_BASE_URL: string;
  164410. /**
  164411. * File name for the controller model.
  164412. */
  164413. static MODEL_FILENAME: string;
  164414. profileId: string;
  164415. /**
  164416. * Create a new Vive motion controller object
  164417. * @param scene the scene to use to create this controller
  164418. * @param gamepadObject the corresponding gamepad object
  164419. * @param handedness the handedness of the controller
  164420. */
  164421. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  164422. protected _getFilenameAndPath(): {
  164423. filename: string;
  164424. path: string;
  164425. };
  164426. protected _getModelLoadingConstraints(): boolean;
  164427. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  164428. protected _setRootMesh(meshes: AbstractMesh[]): void;
  164429. protected _updateModel(): void;
  164430. }
  164431. }
  164432. declare module BABYLON {
  164433. /**
  164434. * A cursor which tracks a point on a path
  164435. */
  164436. export class PathCursor {
  164437. private path;
  164438. /**
  164439. * Stores path cursor callbacks for when an onchange event is triggered
  164440. */
  164441. private _onchange;
  164442. /**
  164443. * The value of the path cursor
  164444. */
  164445. value: number;
  164446. /**
  164447. * The animation array of the path cursor
  164448. */
  164449. animations: Animation[];
  164450. /**
  164451. * Initializes the path cursor
  164452. * @param path The path to track
  164453. */
  164454. constructor(path: Path2);
  164455. /**
  164456. * Gets the cursor point on the path
  164457. * @returns A point on the path cursor at the cursor location
  164458. */
  164459. getPoint(): Vector3;
  164460. /**
  164461. * Moves the cursor ahead by the step amount
  164462. * @param step The amount to move the cursor forward
  164463. * @returns This path cursor
  164464. */
  164465. moveAhead(step?: number): PathCursor;
  164466. /**
  164467. * Moves the cursor behind by the step amount
  164468. * @param step The amount to move the cursor back
  164469. * @returns This path cursor
  164470. */
  164471. moveBack(step?: number): PathCursor;
  164472. /**
  164473. * Moves the cursor by the step amount
  164474. * If the step amount is greater than one, an exception is thrown
  164475. * @param step The amount to move the cursor
  164476. * @returns This path cursor
  164477. */
  164478. move(step: number): PathCursor;
  164479. /**
  164480. * Ensures that the value is limited between zero and one
  164481. * @returns This path cursor
  164482. */
  164483. private ensureLimits;
  164484. /**
  164485. * Runs onchange callbacks on change (used by the animation engine)
  164486. * @returns This path cursor
  164487. */
  164488. private raiseOnChange;
  164489. /**
  164490. * Executes a function on change
  164491. * @param f A path cursor onchange callback
  164492. * @returns This path cursor
  164493. */
  164494. onchange(f: (cursor: PathCursor) => void): PathCursor;
  164495. }
  164496. }
  164497. declare module BABYLON {
  164498. /** @hidden */
  164499. export var blurPixelShader: {
  164500. name: string;
  164501. shader: string;
  164502. };
  164503. }
  164504. declare module BABYLON {
  164505. /** @hidden */
  164506. export var pointCloudVertexDeclaration: {
  164507. name: string;
  164508. shader: string;
  164509. };
  164510. }
  164511. // Mixins
  164512. interface Window {
  164513. mozIndexedDB: IDBFactory;
  164514. webkitIndexedDB: IDBFactory;
  164515. msIndexedDB: IDBFactory;
  164516. webkitURL: typeof URL;
  164517. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  164518. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  164519. WebGLRenderingContext: WebGLRenderingContext;
  164520. MSGesture: MSGesture;
  164521. CANNON: any;
  164522. AudioContext: AudioContext;
  164523. webkitAudioContext: AudioContext;
  164524. PointerEvent: any;
  164525. Math: Math;
  164526. Uint8Array: Uint8ArrayConstructor;
  164527. Float32Array: Float32ArrayConstructor;
  164528. mozURL: typeof URL;
  164529. msURL: typeof URL;
  164530. VRFrameData: any; // WebVR, from specs 1.1
  164531. DracoDecoderModule: any;
  164532. setImmediate(handler: (...args: any[]) => void): number;
  164533. }
  164534. interface HTMLCanvasElement {
  164535. requestPointerLock(): void;
  164536. msRequestPointerLock?(): void;
  164537. mozRequestPointerLock?(): void;
  164538. webkitRequestPointerLock?(): void;
  164539. /** Track wether a record is in progress */
  164540. isRecording: boolean;
  164541. /** Capture Stream method defined by some browsers */
  164542. captureStream(fps?: number): MediaStream;
  164543. }
  164544. interface CanvasRenderingContext2D {
  164545. msImageSmoothingEnabled: boolean;
  164546. }
  164547. interface MouseEvent {
  164548. mozMovementX: number;
  164549. mozMovementY: number;
  164550. webkitMovementX: number;
  164551. webkitMovementY: number;
  164552. msMovementX: number;
  164553. msMovementY: number;
  164554. }
  164555. interface Navigator {
  164556. mozGetVRDevices: (any: any) => any;
  164557. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  164558. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  164559. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  164560. webkitGetGamepads(): Gamepad[];
  164561. msGetGamepads(): Gamepad[];
  164562. webkitGamepads(): Gamepad[];
  164563. }
  164564. interface HTMLVideoElement {
  164565. mozSrcObject: any;
  164566. }
  164567. interface Math {
  164568. fround(x: number): number;
  164569. imul(a: number, b: number): number;
  164570. log2(x: number): number;
  164571. }
  164572. interface WebGLRenderingContext {
  164573. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  164574. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  164575. vertexAttribDivisor(index: number, divisor: number): void;
  164576. createVertexArray(): any;
  164577. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  164578. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  164579. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  164580. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  164581. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  164582. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  164583. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  164584. // Queries
  164585. createQuery(): WebGLQuery;
  164586. deleteQuery(query: WebGLQuery): void;
  164587. beginQuery(target: number, query: WebGLQuery): void;
  164588. endQuery(target: number): void;
  164589. getQueryParameter(query: WebGLQuery, pname: number): any;
  164590. getQuery(target: number, pname: number): any;
  164591. MAX_SAMPLES: number;
  164592. RGBA8: number;
  164593. READ_FRAMEBUFFER: number;
  164594. DRAW_FRAMEBUFFER: number;
  164595. UNIFORM_BUFFER: number;
  164596. HALF_FLOAT_OES: number;
  164597. RGBA16F: number;
  164598. RGBA32F: number;
  164599. R32F: number;
  164600. RG32F: number;
  164601. RGB32F: number;
  164602. R16F: number;
  164603. RG16F: number;
  164604. RGB16F: number;
  164605. RED: number;
  164606. RG: number;
  164607. R8: number;
  164608. RG8: number;
  164609. UNSIGNED_INT_24_8: number;
  164610. DEPTH24_STENCIL8: number;
  164611. MIN: number;
  164612. MAX: number;
  164613. /* Multiple Render Targets */
  164614. drawBuffers(buffers: number[]): void;
  164615. readBuffer(src: number): void;
  164616. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  164617. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  164618. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  164619. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  164620. // Occlusion Query
  164621. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  164622. ANY_SAMPLES_PASSED: number;
  164623. QUERY_RESULT_AVAILABLE: number;
  164624. QUERY_RESULT: number;
  164625. }
  164626. interface WebGLProgram {
  164627. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  164628. }
  164629. interface EXT_disjoint_timer_query {
  164630. QUERY_COUNTER_BITS_EXT: number;
  164631. TIME_ELAPSED_EXT: number;
  164632. TIMESTAMP_EXT: number;
  164633. GPU_DISJOINT_EXT: number;
  164634. QUERY_RESULT_EXT: number;
  164635. QUERY_RESULT_AVAILABLE_EXT: number;
  164636. queryCounterEXT(query: WebGLQuery, target: number): void;
  164637. createQueryEXT(): WebGLQuery;
  164638. beginQueryEXT(target: number, query: WebGLQuery): void;
  164639. endQueryEXT(target: number): void;
  164640. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  164641. deleteQueryEXT(query: WebGLQuery): void;
  164642. }
  164643. interface WebGLUniformLocation {
  164644. _currentState: any;
  164645. }
  164646. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  164647. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  164648. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  164649. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  164650. interface WebGLRenderingContext {
  164651. readonly RASTERIZER_DISCARD: number;
  164652. readonly DEPTH_COMPONENT24: number;
  164653. readonly TEXTURE_3D: number;
  164654. readonly TEXTURE_2D_ARRAY: number;
  164655. readonly TEXTURE_COMPARE_FUNC: number;
  164656. readonly TEXTURE_COMPARE_MODE: number;
  164657. readonly COMPARE_REF_TO_TEXTURE: number;
  164658. readonly TEXTURE_WRAP_R: number;
  164659. readonly HALF_FLOAT: number;
  164660. readonly RGB8: number;
  164661. readonly RED_INTEGER: number;
  164662. readonly RG_INTEGER: number;
  164663. readonly RGB_INTEGER: number;
  164664. readonly RGBA_INTEGER: number;
  164665. readonly R8_SNORM: number;
  164666. readonly RG8_SNORM: number;
  164667. readonly RGB8_SNORM: number;
  164668. readonly RGBA8_SNORM: number;
  164669. readonly R8I: number;
  164670. readonly RG8I: number;
  164671. readonly RGB8I: number;
  164672. readonly RGBA8I: number;
  164673. readonly R8UI: number;
  164674. readonly RG8UI: number;
  164675. readonly RGB8UI: number;
  164676. readonly RGBA8UI: number;
  164677. readonly R16I: number;
  164678. readonly RG16I: number;
  164679. readonly RGB16I: number;
  164680. readonly RGBA16I: number;
  164681. readonly R16UI: number;
  164682. readonly RG16UI: number;
  164683. readonly RGB16UI: number;
  164684. readonly RGBA16UI: number;
  164685. readonly R32I: number;
  164686. readonly RG32I: number;
  164687. readonly RGB32I: number;
  164688. readonly RGBA32I: number;
  164689. readonly R32UI: number;
  164690. readonly RG32UI: number;
  164691. readonly RGB32UI: number;
  164692. readonly RGBA32UI: number;
  164693. readonly RGB10_A2UI: number;
  164694. readonly R11F_G11F_B10F: number;
  164695. readonly RGB9_E5: number;
  164696. readonly RGB10_A2: number;
  164697. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  164698. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  164699. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  164700. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  164701. readonly DEPTH_COMPONENT32F: number;
  164702. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  164703. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  164704. 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;
  164705. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  164706. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  164707. readonly TRANSFORM_FEEDBACK: number;
  164708. readonly INTERLEAVED_ATTRIBS: number;
  164709. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  164710. createTransformFeedback(): WebGLTransformFeedback;
  164711. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  164712. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  164713. beginTransformFeedback(primitiveMode: number): void;
  164714. endTransformFeedback(): void;
  164715. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  164716. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  164717. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  164718. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  164719. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  164720. }
  164721. interface ImageBitmap {
  164722. readonly width: number;
  164723. readonly height: number;
  164724. close(): void;
  164725. }
  164726. interface WebGLQuery extends WebGLObject {
  164727. }
  164728. declare var WebGLQuery: {
  164729. prototype: WebGLQuery;
  164730. new(): WebGLQuery;
  164731. };
  164732. interface WebGLSampler extends WebGLObject {
  164733. }
  164734. declare var WebGLSampler: {
  164735. prototype: WebGLSampler;
  164736. new(): WebGLSampler;
  164737. };
  164738. interface WebGLSync extends WebGLObject {
  164739. }
  164740. declare var WebGLSync: {
  164741. prototype: WebGLSync;
  164742. new(): WebGLSync;
  164743. };
  164744. interface WebGLTransformFeedback extends WebGLObject {
  164745. }
  164746. declare var WebGLTransformFeedback: {
  164747. prototype: WebGLTransformFeedback;
  164748. new(): WebGLTransformFeedback;
  164749. };
  164750. interface WebGLVertexArrayObject extends WebGLObject {
  164751. }
  164752. declare var WebGLVertexArrayObject: {
  164753. prototype: WebGLVertexArrayObject;
  164754. new(): WebGLVertexArrayObject;
  164755. };
  164756. interface Navigator {
  164757. readonly gpu: GPU | undefined;
  164758. }
  164759. interface GPUColorDict {
  164760. a: number;
  164761. b: number;
  164762. g: number;
  164763. r: number;
  164764. }
  164765. type GPUColor = [number, number, number, number] | GPUColorDict;
  164766. interface GPUOrigin2DDict {
  164767. x?: number;
  164768. y?: number;
  164769. }
  164770. type GPUOrigin2D = [number, number] | GPUOrigin2DDict;
  164771. interface GPUOrigin3DDict {
  164772. x?: number;
  164773. y?: number;
  164774. z?: number;
  164775. }
  164776. type GPUOrigin3D = [number, number, number] | GPUOrigin3DDict;
  164777. interface GPUExtent3DDict {
  164778. width: number;
  164779. height: number;
  164780. depth: number;
  164781. }
  164782. type GPUExtent3D = [number, number, number] | GPUExtent3DDict;
  164783. type GPUBindingResource =
  164784. | GPUSampler
  164785. | GPUTextureView
  164786. | GPUBufferBinding;
  164787. type GPUExtensionName =
  164788. | "texture-compression-bc"
  164789. | "timestamp-query"
  164790. | "pipeline-statistics-query"
  164791. | "depth-clamping"
  164792. | "depth24unorm-stencil8"
  164793. | "depth32float-stencil8";
  164794. type GPUAddressMode = "clamp-to-edge" | "repeat" | "mirror-repeat";
  164795. type GPUBindingType =
  164796. | "uniform-buffer"
  164797. | "storage-buffer"
  164798. | "readonly-storage-buffer"
  164799. | "sampler"
  164800. | "comparison-sampler"
  164801. | "sampled-texture"
  164802. | "readonly-storage-texture"
  164803. | "writeonly-storage-texture";
  164804. type GPUBlendFactor =
  164805. | "zero"
  164806. | "one"
  164807. | "src-color"
  164808. | "one-minus-src-color"
  164809. | "src-alpha"
  164810. | "one-minus-src-alpha"
  164811. | "dst-color"
  164812. | "one-minus-dst-color"
  164813. | "dst-alpha"
  164814. | "one-minus-dst-alpha"
  164815. | "src-alpha-saturated"
  164816. | "blend-color"
  164817. | "one-minus-blend-color";
  164818. type GPUBlendOperation =
  164819. | "add"
  164820. | "subtract"
  164821. | "reverse-subtract"
  164822. | "min"
  164823. | "max";
  164824. type GPUCompareFunction =
  164825. | "never"
  164826. | "less"
  164827. | "equal"
  164828. | "less-equal"
  164829. | "greater"
  164830. | "not-equal"
  164831. | "greater-equal"
  164832. | "always";
  164833. type GPUCullMode = "none" | "front" | "back";
  164834. type GPUFilterMode = "nearest" | "linear";
  164835. type GPUFrontFace = "ccw" | "cw";
  164836. type GPUIndexFormat = "uint16" | "uint32";
  164837. type GPUInputStepMode = "vertex" | "instance";
  164838. type GPULoadOp = "load";
  164839. type GPUPrimitiveTopology =
  164840. | "point-list"
  164841. | "line-list"
  164842. | "line-strip"
  164843. | "triangle-list"
  164844. | "triangle-strip";
  164845. type GPUStencilOperation =
  164846. | "keep"
  164847. | "zero"
  164848. | "replace"
  164849. | "invert"
  164850. | "increment-clamp"
  164851. | "decrement-clamp"
  164852. | "increment-wrap"
  164853. | "decrement-wrap";
  164854. type GPUStoreOp = "store" | "clear";
  164855. type GPUTextureDimension = "1d" | "2d" | "3d";
  164856. type GPUTextureFormat =
  164857. | "r8unorm"
  164858. | "r8snorm"
  164859. | "r8uint"
  164860. | "r8sint"
  164861. | "r16uint"
  164862. | "r16sint"
  164863. | "r16float"
  164864. | "rg8unorm"
  164865. | "rg8snorm"
  164866. | "rg8uint"
  164867. | "rg8sint"
  164868. | "r32uint"
  164869. | "r32sint"
  164870. | "r32float"
  164871. | "rg16uint"
  164872. | "rg16sint"
  164873. | "rg16float"
  164874. | "rgba8unorm"
  164875. | "rgba8unorm-srgb"
  164876. | "rgba8snorm"
  164877. | "rgba8uint"
  164878. | "rgba8sint"
  164879. | "bgra8unorm"
  164880. | "bgra8unorm-srgb"
  164881. | "rgb9e5ufloat"
  164882. | "rgb10a2unorm"
  164883. | "rg11b10ufloat"
  164884. | "rg32uint"
  164885. | "rg32sint"
  164886. | "rg32float"
  164887. | "rgba16uint"
  164888. | "rgba16sint"
  164889. | "rgba16float"
  164890. | "rgba32uint"
  164891. | "rgba32sint"
  164892. | "rgba32float"
  164893. | "stencil8"
  164894. | "depth16unorm"
  164895. | "depth24plus"
  164896. | "depth24plus-stencil8"
  164897. | "depth32float"
  164898. | "bc1-rgba-unorm"
  164899. | "bc1-rgba-unorm-srgb"
  164900. | "bc2-rgba-unorm"
  164901. | "bc2-rgba-unorm-srgb"
  164902. | "bc3-rgba-unorm"
  164903. | "bc3-rgba-unorm-srgb"
  164904. | "bc4-r-unorm"
  164905. | "bc4-r-snorm"
  164906. | "bc5-rg-unorm"
  164907. | "bc5-rg-snorm"
  164908. | "bc6h-rgb-ufloat"
  164909. | "bc6h-rgb-float"
  164910. | "bc7-rgba-unorm"
  164911. | "bc7-rgba-unorm-srgb"
  164912. | "depth24unorm-stencil8"
  164913. | "depth32float-stencil8";
  164914. type GPUTextureComponentType = "float" | "sint" | "uint" | "depth-comparison";
  164915. type GPUTextureViewDimension =
  164916. | "1d"
  164917. | "2d"
  164918. | "2d-array"
  164919. | "cube"
  164920. | "cube-array"
  164921. | "3d";
  164922. type GPUVertexFormat =
  164923. | "uchar2"
  164924. | "uchar4"
  164925. | "char2"
  164926. | "char4"
  164927. | "uchar2norm"
  164928. | "uchar4norm"
  164929. | "char2norm"
  164930. | "char4norm"
  164931. | "ushort2"
  164932. | "ushort4"
  164933. | "short2"
  164934. | "short4"
  164935. | "ushort2norm"
  164936. | "ushort4norm"
  164937. | "short2norm"
  164938. | "short4norm"
  164939. | "half2"
  164940. | "half4"
  164941. | "float"
  164942. | "float2"
  164943. | "float3"
  164944. | "float4"
  164945. | "uint"
  164946. | "uint2"
  164947. | "uint3"
  164948. | "uint4"
  164949. | "int"
  164950. | "int2"
  164951. | "int3"
  164952. | "int4";
  164953. type GPUTextureAspect = "all" | "stencil-only" | "depth-only";
  164954. type GPUBufferUsageFlags = number;
  164955. type GPUColorWriteFlags = number;
  164956. type GPUShaderStageFlags = number;
  164957. type GPUTextureUsageFlags = number;
  164958. type GPUMapModeFlags = number;
  164959. interface GPUBindGroupEntry {
  164960. binding: number;
  164961. resource: GPUBindingResource;
  164962. }
  164963. interface GPUBindGroupDescriptor extends GPUObjectDescriptorBase {
  164964. layout: GPUBindGroupLayout;
  164965. entries: Iterable<GPUBindGroupEntry>;
  164966. }
  164967. interface GPUBindGroupLayoutEntry {
  164968. binding: number;
  164969. visibility: GPUShaderStageFlags;
  164970. type: GPUBindingType;
  164971. hasDynamicOffset?: boolean;
  164972. minBufferBindingSize?: number;
  164973. viewDimension?: GPUTextureViewDimension;
  164974. textureComponentType?: GPUTextureComponentType;
  164975. storageTextureFormat?: GPUTextureFormat;
  164976. }
  164977. interface GPUBindGroupLayoutDescriptor
  164978. extends GPUObjectDescriptorBase {
  164979. entries: Iterable<GPUBindGroupLayoutEntry>;
  164980. }
  164981. interface GPUBlendDescriptor {
  164982. dstFactor?: GPUBlendFactor;
  164983. operation?: GPUBlendOperation;
  164984. srcFactor?: GPUBlendFactor;
  164985. }
  164986. interface GPUColorStateDescriptor {
  164987. format: GPUTextureFormat;
  164988. alphaBlend?: GPUBlendDescriptor;
  164989. colorBlend?: GPUBlendDescriptor;
  164990. writeMask?: GPUColorWriteFlags;
  164991. }
  164992. interface GPUBufferBinding {
  164993. buffer: GPUBuffer;
  164994. offset?: number;
  164995. size?: number;
  164996. }
  164997. interface GPUTextureDataLayout {
  164998. offset?: number;
  164999. bytesPerRow: number;
  165000. rowsPerImage?: number;
  165001. }
  165002. interface GPUBufferCopyView extends GPUTextureDataLayout {
  165003. buffer: GPUBuffer;
  165004. }
  165005. interface GPUTextureCopyView {
  165006. texture: GPUTexture;
  165007. mipLevel?: number;
  165008. origin?: GPUOrigin3D;
  165009. }
  165010. interface GPUImageBitmapCopyView {
  165011. imageBitmap: ImageBitmap;
  165012. origin?: GPUOrigin2D;
  165013. }
  165014. interface GPUBufferDescriptor extends GPUObjectDescriptorBase {
  165015. size: number;
  165016. usage: GPUBufferUsageFlags;
  165017. mappedAtCreation?: boolean;
  165018. }
  165019. interface GPUCommandEncoderDescriptor extends GPUObjectDescriptorBase {
  165020. label?: string;
  165021. measureExecutionTime?: boolean;
  165022. }
  165023. interface GPUComputePipelineDescriptor
  165024. extends GPUPipelineDescriptorBase {
  165025. computeStage: GPUProgrammableStageDescriptor;
  165026. }
  165027. interface GPUDepthStencilStateDescriptor {
  165028. format: GPUTextureFormat;
  165029. depthWriteEnabled?: boolean;
  165030. depthCompare?: GPUCompareFunction;
  165031. stencilFront?: GPUStencilStateFaceDescriptor;
  165032. stencilBack?: GPUStencilStateFaceDescriptor;
  165033. stencilReadMask?: number;
  165034. stencilWriteMask?: number;
  165035. }
  165036. interface GPUDeviceDescriptor extends GPUObjectDescriptorBase {
  165037. extensions?: Iterable<GPUExtensionName>;
  165038. limits?: GPULimits;
  165039. }
  165040. interface GPUFenceDescriptor extends GPUObjectDescriptorBase {
  165041. initialValue?: number;
  165042. label?: string;
  165043. signalQueue?: GPUQueue;
  165044. }
  165045. interface GPUVertexAttributeDescriptor {
  165046. format: GPUVertexFormat;
  165047. offset: number;
  165048. shaderLocation: number;
  165049. }
  165050. interface GPUVertexBufferLayoutDescriptor {
  165051. arrayStride: number;
  165052. stepMode?: GPUInputStepMode;
  165053. attributes: Iterable<GPUVertexAttributeDescriptor>;
  165054. }
  165055. interface GPUVertexStateDescriptor {
  165056. indexFormat?: GPUIndexFormat;
  165057. vertexBuffers?: Iterable<GPUVertexBufferLayoutDescriptor>;
  165058. }
  165059. interface GPULimits {
  165060. maxBindGroups?: number;
  165061. maxDynamicUniformBuffersPerPipelineLayout?: number;
  165062. maxDynamicStorageBuffersPerPipelineLayout?: number;
  165063. maxSampledTexturesPerShaderStage?: number;
  165064. maxSamplersPerShaderStage?: number;
  165065. maxStorageBuffersPerShaderStage?: number;
  165066. maxStorageTexturesPerShaderStage?: number;
  165067. maxUniformBuffersPerShaderStage?: number;
  165068. maxUniformBufferBindingSize?: number;
  165069. }
  165070. interface GPUPipelineDescriptorBase {
  165071. label?: string;
  165072. layout?: GPUPipelineLayout;
  165073. }
  165074. interface GPUPipelineLayoutDescriptor extends GPUObjectDescriptorBase {
  165075. bindGroupLayouts: Iterable<GPUBindGroupLayout>;
  165076. }
  165077. interface GPUProgrammableStageDescriptor {
  165078. module: GPUShaderModule;
  165079. entryPoint: string;
  165080. }
  165081. interface GPURasterizationStateDescriptor {
  165082. frontFace?: GPUFrontFace;
  165083. cullMode?: GPUCullMode;
  165084. clampDepth?: boolean;
  165085. depthBias?: number;
  165086. depthBiasSlopeScale?: number;
  165087. depthBiasClamp?: number;
  165088. }
  165089. interface GPURenderPassColorAttachmentDescriptor {
  165090. attachment: GPUTextureView;
  165091. resolveTarget?: GPUTextureView;
  165092. loadValue: GPULoadOp | GPUColor;
  165093. storeOp?: GPUStoreOp;
  165094. }
  165095. interface GPURenderPassDepthStencilAttachmentDescriptor {
  165096. attachment: GPUTextureView;
  165097. depthLoadValue: GPULoadOp | number;
  165098. depthStoreOp: GPUStoreOp;
  165099. depthReadOnly?: boolean;
  165100. stencilLoadValue: GPULoadOp | number;
  165101. stencilStoreOp: GPUStoreOp;
  165102. stencilReadOnly?: boolean;
  165103. }
  165104. interface GPURenderPassDescriptor extends GPUObjectDescriptorBase {
  165105. colorAttachments: Iterable<GPURenderPassColorAttachmentDescriptor>;
  165106. depthStencilAttachment?: GPURenderPassDepthStencilAttachmentDescriptor;
  165107. }
  165108. interface GPURenderPipelineDescriptor
  165109. extends GPUPipelineDescriptorBase {
  165110. vertexStage: GPUProgrammableStageDescriptor;
  165111. fragmentStage?: GPUProgrammableStageDescriptor;
  165112. primitiveTopology: GPUPrimitiveTopology;
  165113. rasterizationState?: GPURasterizationStateDescriptor;
  165114. colorStates: Iterable<GPUColorStateDescriptor>;
  165115. depthStencilState?: GPUDepthStencilStateDescriptor;
  165116. vertexState?: GPUVertexStateDescriptor;
  165117. sampleCount?: number;
  165118. sampleMask?: number;
  165119. alphaToCoverageEnabled?: boolean;
  165120. }
  165121. interface GPUSamplerDescriptor extends GPUObjectDescriptorBase {
  165122. addressModeU?: GPUAddressMode;
  165123. addressModeV?: GPUAddressMode;
  165124. addressModeW?: GPUAddressMode;
  165125. magFilter?: GPUFilterMode;
  165126. minFilter?: GPUFilterMode;
  165127. mipmapFilter?: GPUFilterMode;
  165128. lodMinClamp?: number;
  165129. lodMaxClamp?: number;
  165130. compare?: GPUCompareFunction;
  165131. maxAnisotropy?: number;
  165132. }
  165133. interface GPUShaderModuleDescriptor extends GPUObjectDescriptorBase {
  165134. code: Uint32Array | string;
  165135. label?: string;
  165136. sourceMap?: object;
  165137. }
  165138. interface GPUStencilStateFaceDescriptor {
  165139. compare?: GPUCompareFunction;
  165140. depthFailOp?: GPUStencilOperation;
  165141. passOp?: GPUStencilOperation;
  165142. failOp?: GPUStencilOperation;
  165143. }
  165144. interface GPUSwapChainDescriptor extends GPUObjectDescriptorBase {
  165145. device: GPUDevice;
  165146. format: GPUTextureFormat;
  165147. usage?: GPUTextureUsageFlags;
  165148. }
  165149. interface GPUTextureDescriptor extends GPUObjectDescriptorBase {
  165150. size: GPUExtent3D;
  165151. mipLevelCount?: number;
  165152. sampleCount?: number;
  165153. dimension?: GPUTextureDimension;
  165154. format: GPUTextureFormat;
  165155. usage: GPUTextureUsageFlags;
  165156. }
  165157. interface GPUTextureViewDescriptor extends GPUObjectDescriptorBase {
  165158. format?: GPUTextureFormat;
  165159. dimension?: GPUTextureViewDimension;
  165160. aspect?: GPUTextureAspect;
  165161. baseArrayLayer?: number;
  165162. baseMipLevel?: number;
  165163. arrayLayerCount?: number;
  165164. mipLevelCount?: number;
  165165. }
  165166. declare class GPUAdapter {
  165167. // https://michalzalecki.com/nominal-typing-in-typescript/#approach-1-class-with-a-private-property
  165168. private __brand: void;
  165169. readonly name: string;
  165170. readonly extensions: GPUExtensionName[];
  165171. readonly limits: Required<GPULimits>;
  165172. requestDevice(descriptor?: GPUDeviceDescriptor): Promise<GPUDevice | null>;
  165173. }
  165174. declare class GPUBindGroup implements GPUObjectBase {
  165175. private __brand: void;
  165176. label: string | undefined;
  165177. }
  165178. declare class GPUBindGroupLayout implements GPUObjectBase {
  165179. private __brand: void;
  165180. label: string | undefined;
  165181. }
  165182. declare class GPUBuffer implements GPUObjectBase {
  165183. private __brand: void;
  165184. label: string | undefined;
  165185. destroy(): void;
  165186. unmap(): void;
  165187. mapAsync(mode: GPUMapModeFlags, offset?: number, size?: number): Promise<void>;
  165188. getMappedRange(offset?: number, size?: number): ArrayBuffer;
  165189. }
  165190. declare class GPUCommandBuffer implements GPUObjectBase {
  165191. private __brand: void;
  165192. label: string | undefined;
  165193. readonly executionTime: Promise<number>;
  165194. }
  165195. interface GPUCommandBufferDescriptor extends GPUObjectDescriptorBase { }
  165196. declare class GPUCommandEncoder implements GPUObjectBase {
  165197. private __brand: void;
  165198. label: string | undefined;
  165199. beginComputePass(
  165200. descriptor?: GPUComputePassDescriptor
  165201. ): GPUComputePassEncoder;
  165202. beginRenderPass(descriptor: GPURenderPassDescriptor): GPURenderPassEncoder;
  165203. copyBufferToBuffer(
  165204. source: GPUBuffer,
  165205. sourceOffset: number,
  165206. destination: GPUBuffer,
  165207. destinationOffset: number,
  165208. size: number
  165209. ): void;
  165210. copyBufferToTexture(
  165211. source: GPUBufferCopyView,
  165212. destination: GPUTextureCopyView,
  165213. copySize: GPUExtent3D
  165214. ): void;
  165215. copyTextureToBuffer(
  165216. source: GPUTextureCopyView,
  165217. destination: GPUBufferCopyView,
  165218. copySize: GPUExtent3D
  165219. ): void;
  165220. copyTextureToTexture(
  165221. source: GPUTextureCopyView,
  165222. destination: GPUTextureCopyView,
  165223. copySize: GPUExtent3D
  165224. ): void;
  165225. finish(descriptor?: GPUCommandBufferDescriptor): GPUCommandBuffer;
  165226. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  165227. popDebugGroup(): void;
  165228. pushDebugGroup(groupLabel: string): void;
  165229. insertDebugMarker(markerLabel: string): void;
  165230. }
  165231. interface GPUComputePassDescriptor extends GPUObjectDescriptorBase { }
  165232. declare class GPUComputePassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder {
  165233. private __brand: void;
  165234. label: string | undefined;
  165235. setBindGroup(
  165236. index: number,
  165237. bindGroup: GPUBindGroup,
  165238. dynamicOffsets?: Iterable<number>
  165239. ): void;
  165240. popDebugGroup(): void;
  165241. pushDebugGroup(groupLabel: string): void;
  165242. insertDebugMarker(markerLabel: string): void;
  165243. setPipeline(pipeline: GPUComputePipeline): void;
  165244. dispatch(x: number, y?: number, z?: number): void;
  165245. dispatchIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  165246. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  165247. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  165248. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  165249. endPass(): void;
  165250. }
  165251. declare class GPUComputePipeline implements GPUPipelineBase {
  165252. private __brand: void;
  165253. label: string | undefined;
  165254. getBindGroupLayout(index: number): GPUBindGroupLayout;
  165255. }
  165256. interface GPUObjectBase {
  165257. label: string | undefined;
  165258. }
  165259. interface GPUObjectDescriptorBase {
  165260. label?: string;
  165261. }
  165262. // SwapChain / CanvasContext
  165263. declare class GPUCanvasContext {
  165264. private __brand: void;
  165265. configureSwapChain(descriptor: GPUSwapChainDescriptor): GPUSwapChain;
  165266. getSwapChainPreferredFormat(device: GPUDevice): Promise<GPUTextureFormat>;
  165267. }
  165268. declare class GPUDevice extends EventTarget implements GPUObjectBase {
  165269. private __brand: void;
  165270. label: string | undefined;
  165271. readonly adapter: GPUAdapter;
  165272. readonly extensions: GPUExtensionName[];
  165273. readonly limits: Required<GPULimits>;
  165274. createBindGroup(descriptor: GPUBindGroupDescriptor): GPUBindGroup;
  165275. createBindGroupLayout(
  165276. descriptor: GPUBindGroupLayoutDescriptor
  165277. ): GPUBindGroupLayout;
  165278. createBuffer(descriptor: GPUBufferDescriptor): GPUBuffer;
  165279. createPipelineLayout(
  165280. descriptor: GPUPipelineLayoutDescriptor
  165281. ): GPUPipelineLayout;
  165282. createSampler(descriptor?: GPUSamplerDescriptor): GPUSampler;
  165283. createShaderModule(descriptor: GPUShaderModuleDescriptor): GPUShaderModule;
  165284. createTexture(descriptor: GPUTextureDescriptor): GPUTexture;
  165285. createComputePipeline(
  165286. descriptor: GPUComputePipelineDescriptor
  165287. ): GPUComputePipeline;
  165288. createRenderPipeline(
  165289. descriptor: GPURenderPipelineDescriptor
  165290. ): GPURenderPipeline;
  165291. createReadyComputePipeline(
  165292. descriptor: GPUComputePipelineDescriptor
  165293. ): Promise<GPUComputePipeline>;
  165294. createReadyRenderPipeline(
  165295. descriptor: GPURenderPipelineDescriptor
  165296. ): Promise<GPURenderPipeline>;
  165297. createCommandEncoder(
  165298. descriptor?: GPUCommandEncoderDescriptor
  165299. ): GPUCommandEncoder;
  165300. createRenderBundleEncoder(
  165301. descriptor: GPURenderBundleEncoderDescriptor
  165302. ): GPURenderBundleEncoder;
  165303. createQuerySet(descriptor: GPUQuerySetDescriptor): GPUQuerySet;
  165304. defaultQueue: GPUQueue;
  165305. pushErrorScope(filter: GPUErrorFilter): void;
  165306. popErrorScope(): Promise<GPUError | null>;
  165307. onuncapturederror: Event | undefined;
  165308. readonly lost: Promise<GPUDeviceLostInfo>;
  165309. }
  165310. declare class GPUFence implements GPUObjectBase {
  165311. private __brand: void;
  165312. label: string | undefined;
  165313. getCompletedValue(): number;
  165314. onCompletion(completionValue: number): Promise<void>;
  165315. }
  165316. interface GPUPipelineBase extends GPUObjectBase {
  165317. getBindGroupLayout(index: number): GPUBindGroupLayout;
  165318. }
  165319. declare class GPUPipelineLayout implements GPUObjectBase {
  165320. private __brand: void;
  165321. label: string | undefined;
  165322. }
  165323. interface GPUProgrammablePassEncoder {
  165324. setBindGroup(
  165325. index: number,
  165326. bindGroup: GPUBindGroup,
  165327. dynamicOffsets?: Iterable<number>
  165328. ): void;
  165329. popDebugGroup(): void;
  165330. pushDebugGroup(groupLabel: string): void;
  165331. insertDebugMarker(markerLabel: string): void;
  165332. }
  165333. declare class GPUQueue implements GPUObjectBase {
  165334. private __brand: void;
  165335. label: string | undefined;
  165336. signal(fence: GPUFence, signalValue: number): void;
  165337. submit(commandBuffers: Iterable<GPUCommandBuffer>): void;
  165338. createFence(descriptor?: GPUFenceDescriptor): GPUFence;
  165339. writeBuffer(buffer: GPUBuffer,
  165340. bufferOffset: number,
  165341. data: BufferSource | ArrayBuffer,
  165342. dataOffset?: number,
  165343. size?: number): void;
  165344. writeTexture(destination: GPUTextureCopyView,
  165345. data: BufferSource | ArrayBuffer,
  165346. dataLayout: GPUTextureDataLayout,
  165347. size: GPUExtent3D): void;
  165348. copyImageBitmapToTexture(
  165349. source: GPUImageBitmapCopyView,
  165350. destination: GPUTextureCopyView,
  165351. copySize: GPUExtent3D
  165352. ): void;
  165353. }
  165354. type GPUQueryType =
  165355. | "occlusion"
  165356. | "timestamp"
  165357. | "pipeline-statistics";
  165358. type GPUPipelineStatisticName =
  165359. | "vertex-shader-invocations"
  165360. | "clipper-invocations"
  165361. | "clipper-primitives-out"
  165362. | "fragment-shader-invocations"
  165363. | "compute-shader-invocations";
  165364. interface GPUQuerySetDescriptor extends GPUObjectDescriptorBase {
  165365. type: GPUQueryType;
  165366. count: number;
  165367. pipelineStatistics?: Iterable<GPUPipelineStatisticName>;
  165368. }
  165369. declare class GPUQuerySet implements GPUObjectBase {
  165370. private __brand: void;
  165371. label: string | undefined;
  165372. destroy(): void;
  165373. }
  165374. interface GPURenderEncoderBase {
  165375. setPipeline(pipeline: GPURenderPipeline): void;
  165376. setIndexBuffer(buffer: GPUBuffer, offset?: number, size?: number): void;
  165377. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  165378. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number, size?: number): void;
  165379. draw(
  165380. vertexCount: number,
  165381. instanceCount?: number,
  165382. firstVertex?: number,
  165383. firstInstance?: number
  165384. ): void;
  165385. drawIndexed(
  165386. indexCount: number,
  165387. instanceCount?: number,
  165388. firstIndex?: number,
  165389. baseVertex?: number,
  165390. firstInstance?: number
  165391. ): void;
  165392. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  165393. drawIndexedIndirect(
  165394. indirectBuffer: GPUBuffer,
  165395. indirectOffset: number
  165396. ): void;
  165397. }
  165398. declare class GPURenderPassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder, GPURenderEncoderBase {
  165399. private __brand: void;
  165400. label: string | undefined;
  165401. setBindGroup(
  165402. index: number,
  165403. bindGroup: GPUBindGroup,
  165404. dynamicOffsets?: Iterable<number>
  165405. ): void;
  165406. popDebugGroup(): void;
  165407. pushDebugGroup(groupLabel: string): void;
  165408. insertDebugMarker(markerLabel: string): void;
  165409. setPipeline(pipeline: GPURenderPipeline): void;
  165410. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  165411. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  165412. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  165413. draw(
  165414. vertexCount: number,
  165415. instanceCount?: number,
  165416. firstVertex?: number,
  165417. firstInstance?: number
  165418. ): void;
  165419. drawIndexed(
  165420. indexCount: number,
  165421. instanceCount?: number,
  165422. firstIndex?: number,
  165423. baseVertex?: number,
  165424. firstInstance?: number
  165425. ): void;
  165426. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  165427. drawIndexedIndirect(
  165428. indirectBuffer: GPUBuffer,
  165429. indirectOffset: number
  165430. ): void;
  165431. setViewport(
  165432. x: number,
  165433. y: number,
  165434. width: number,
  165435. height: number,
  165436. minDepth: number,
  165437. maxDepth: number
  165438. ): void;
  165439. setScissorRect(x: number, y: number, width: number, height: number): void;
  165440. setBlendColor(color: GPUColor): void;
  165441. setStencilReference(reference: number): void;
  165442. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  165443. beginOcclusionQuery(queryIndex: number): void;
  165444. endOcclusionQuery(): void;
  165445. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  165446. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  165447. executeBundles(bundles: Iterable<GPURenderBundle>): void;
  165448. endPass(): void;
  165449. }
  165450. interface GPURenderBundleDescriptor extends GPUObjectDescriptorBase { }
  165451. declare class GPURenderBundle implements GPUObjectBase {
  165452. private __brand: void;
  165453. label: string | undefined;
  165454. }
  165455. declare class GPURenderBundleEncoder implements GPURenderEncoderBase {
  165456. private __brand: void;
  165457. label: string | undefined;
  165458. setBindGroup(
  165459. index: number,
  165460. bindGroup: GPUBindGroup,
  165461. dynamicOffsets?: Iterable<number>
  165462. ): void;
  165463. popDebugGroup(): void;
  165464. pushDebugGroup(groupLabel: string): void;
  165465. insertDebugMarker(markerLabel: string): void;
  165466. setPipeline(pipeline: GPURenderPipeline): void;
  165467. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  165468. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  165469. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  165470. draw(
  165471. vertexCount: number,
  165472. instanceCount?: number,
  165473. firstVertex?: number,
  165474. firstInstance?: number
  165475. ): void;
  165476. drawIndexed(
  165477. indexCount: number,
  165478. instanceCount?: number,
  165479. firstIndex?: number,
  165480. baseVertex?: number,
  165481. firstInstance?: number
  165482. ): void;
  165483. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  165484. drawIndexedIndirect(
  165485. indirectBuffer: GPUBuffer,
  165486. indirectOffset: number
  165487. ): void;
  165488. finish(descriptor?: GPURenderBundleDescriptor): GPURenderBundle;
  165489. }
  165490. interface GPURenderBundleEncoderDescriptor
  165491. extends GPUObjectDescriptorBase {
  165492. colorFormats: Iterable<GPUTextureFormat>;
  165493. depthStencilFormat?: GPUTextureFormat;
  165494. sampleCount?: number;
  165495. }
  165496. declare class GPURenderPipeline implements GPUPipelineBase {
  165497. private __brand: void;
  165498. label: string | undefined;
  165499. getBindGroupLayout(index: number): GPUBindGroupLayout;
  165500. }
  165501. declare class GPUSampler implements GPUObjectBase {
  165502. private __brand: void;
  165503. label: string | undefined;
  165504. }
  165505. type GPUCompilationMessageType =
  165506. | "error"
  165507. | "warning"
  165508. | "info";
  165509. interface GPUCompilationMessage {
  165510. readonly message: string;
  165511. readonly type: GPUCompilationMessageType;
  165512. readonly lineNum: number;
  165513. readonly linePos: number;
  165514. }
  165515. interface GPUCompilationInfo {
  165516. readonly messages: readonly GPUCompilationMessage[];
  165517. }
  165518. declare class GPUShaderModule implements GPUObjectBase {
  165519. private __brand: void;
  165520. label: string | undefined;
  165521. compilationInfo(): Promise<GPUCompilationInfo>;
  165522. }
  165523. declare class GPUSwapChain implements GPUObjectBase {
  165524. private __brand: void;
  165525. label: string | undefined;
  165526. getCurrentTexture(): GPUTexture;
  165527. }
  165528. declare class GPUTexture implements GPUObjectBase {
  165529. private __brand: void;
  165530. label: string | undefined;
  165531. createView(descriptor?: GPUTextureViewDescriptor): GPUTextureView;
  165532. destroy(): void;
  165533. }
  165534. declare class GPUTextureView implements GPUObjectBase {
  165535. private __brand: void;
  165536. label: string | undefined;
  165537. }
  165538. type GPUPowerPreference = "low-power" | "high-performance";
  165539. interface GPURequestAdapterOptions {
  165540. powerPreference?: GPUPowerPreference;
  165541. }
  165542. declare class GPU {
  165543. private __brand: void;
  165544. requestAdapter(options?: GPURequestAdapterOptions): Promise<GPUAdapter | null>;
  165545. }
  165546. // ****************************************************************************
  165547. // ERROR SCOPES
  165548. // ****************************************************************************
  165549. type GPUErrorFilter = "out-of-memory" | "validation";
  165550. declare class GPUOutOfMemoryError {
  165551. private __brand: void;
  165552. constructor();
  165553. }
  165554. declare class GPUValidationError {
  165555. private __brand: void;
  165556. constructor(message: string);
  165557. readonly message: string;
  165558. }
  165559. type GPUError = GPUOutOfMemoryError | GPUValidationError;
  165560. // ****************************************************************************
  165561. // TELEMETRY
  165562. // ****************************************************************************
  165563. declare class GPUUncapturedErrorEvent extends Event {
  165564. private __brand: void;
  165565. constructor(
  165566. type: string,
  165567. gpuUncapturedErrorEventInitDict: GPUUncapturedErrorEventInit
  165568. );
  165569. readonly error: GPUError;
  165570. }
  165571. interface GPUUncapturedErrorEventInit extends EventInit {
  165572. error: GPUError;
  165573. }
  165574. declare class GPUDeviceLostInfo {
  165575. private __brand: void;
  165576. readonly message: string;
  165577. }
  165578. // Type definitions for WebVR API
  165579. // Project: https://w3c.github.io/webvr/
  165580. // Definitions by: six a <https://github.com/lostfictions>
  165581. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  165582. interface VRDisplay extends EventTarget {
  165583. /**
  165584. * Dictionary of capabilities describing the VRDisplay.
  165585. */
  165586. readonly capabilities: VRDisplayCapabilities;
  165587. /**
  165588. * z-depth defining the far plane of the eye view frustum
  165589. * enables mapping of values in the render target depth
  165590. * attachment to scene coordinates. Initially set to 10000.0.
  165591. */
  165592. depthFar: number;
  165593. /**
  165594. * z-depth defining the near plane of the eye view frustum
  165595. * enables mapping of values in the render target depth
  165596. * attachment to scene coordinates. Initially set to 0.01.
  165597. */
  165598. depthNear: number;
  165599. /**
  165600. * An identifier for this distinct VRDisplay. Used as an
  165601. * association point in the Gamepad API.
  165602. */
  165603. readonly displayId: number;
  165604. /**
  165605. * A display name, a user-readable name identifying it.
  165606. */
  165607. readonly displayName: string;
  165608. readonly isConnected: boolean;
  165609. readonly isPresenting: boolean;
  165610. /**
  165611. * If this VRDisplay supports room-scale experiences, the optional
  165612. * stage attribute contains details on the room-scale parameters.
  165613. */
  165614. readonly stageParameters: VRStageParameters | null;
  165615. /**
  165616. * Passing the value returned by `requestAnimationFrame` to
  165617. * `cancelAnimationFrame` will unregister the callback.
  165618. * @param handle Define the hanle of the request to cancel
  165619. */
  165620. cancelAnimationFrame(handle: number): void;
  165621. /**
  165622. * Stops presenting to the VRDisplay.
  165623. * @returns a promise to know when it stopped
  165624. */
  165625. exitPresent(): Promise<void>;
  165626. /**
  165627. * Return the current VREyeParameters for the given eye.
  165628. * @param whichEye Define the eye we want the parameter for
  165629. * @returns the eye parameters
  165630. */
  165631. getEyeParameters(whichEye: string): VREyeParameters;
  165632. /**
  165633. * Populates the passed VRFrameData with the information required to render
  165634. * the current frame.
  165635. * @param frameData Define the data structure to populate
  165636. * @returns true if ok otherwise false
  165637. */
  165638. getFrameData(frameData: VRFrameData): boolean;
  165639. /**
  165640. * Get the layers currently being presented.
  165641. * @returns the list of VR layers
  165642. */
  165643. getLayers(): VRLayer[];
  165644. /**
  165645. * Return a VRPose containing the future predicted pose of the VRDisplay
  165646. * when the current frame will be presented. The value returned will not
  165647. * change until JavaScript has returned control to the browser.
  165648. *
  165649. * The VRPose will contain the position, orientation, velocity,
  165650. * and acceleration of each of these properties.
  165651. * @returns the pose object
  165652. */
  165653. getPose(): VRPose;
  165654. /**
  165655. * Return the current instantaneous pose of the VRDisplay, with no
  165656. * prediction applied.
  165657. * @returns the current instantaneous pose
  165658. */
  165659. getImmediatePose(): VRPose;
  165660. /**
  165661. * The callback passed to `requestAnimationFrame` will be called
  165662. * any time a new frame should be rendered. When the VRDisplay is
  165663. * presenting the callback will be called at the native refresh
  165664. * rate of the HMD. When not presenting this function acts
  165665. * identically to how window.requestAnimationFrame acts. Content should
  165666. * make no assumptions of frame rate or vsync behavior as the HMD runs
  165667. * asynchronously from other displays and at differing refresh rates.
  165668. * @param callback Define the eaction to run next frame
  165669. * @returns the request handle it
  165670. */
  165671. requestAnimationFrame(callback: FrameRequestCallback): number;
  165672. /**
  165673. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  165674. * Repeat calls while already presenting will update the VRLayers being displayed.
  165675. * @param layers Define the list of layer to present
  165676. * @returns a promise to know when the request has been fulfilled
  165677. */
  165678. requestPresent(layers: VRLayer[]): Promise<void>;
  165679. /**
  165680. * Reset the pose for this display, treating its current position and
  165681. * orientation as the "origin/zero" values. VRPose.position,
  165682. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  165683. * updated when calling resetPose(). This should be called in only
  165684. * sitting-space experiences.
  165685. */
  165686. resetPose(): void;
  165687. /**
  165688. * The VRLayer provided to the VRDisplay will be captured and presented
  165689. * in the HMD. Calling this function has the same effect on the source
  165690. * canvas as any other operation that uses its source image, and canvases
  165691. * created without preserveDrawingBuffer set to true will be cleared.
  165692. * @param pose Define the pose to submit
  165693. */
  165694. submitFrame(pose?: VRPose): void;
  165695. }
  165696. declare var VRDisplay: {
  165697. prototype: VRDisplay;
  165698. new(): VRDisplay;
  165699. };
  165700. interface VRLayer {
  165701. leftBounds?: number[] | Float32Array | null;
  165702. rightBounds?: number[] | Float32Array | null;
  165703. source?: HTMLCanvasElement | null;
  165704. }
  165705. interface VRDisplayCapabilities {
  165706. readonly canPresent: boolean;
  165707. readonly hasExternalDisplay: boolean;
  165708. readonly hasOrientation: boolean;
  165709. readonly hasPosition: boolean;
  165710. readonly maxLayers: number;
  165711. }
  165712. interface VREyeParameters {
  165713. /** @deprecated */
  165714. readonly fieldOfView: VRFieldOfView;
  165715. readonly offset: Float32Array;
  165716. readonly renderHeight: number;
  165717. readonly renderWidth: number;
  165718. }
  165719. interface VRFieldOfView {
  165720. readonly downDegrees: number;
  165721. readonly leftDegrees: number;
  165722. readonly rightDegrees: number;
  165723. readonly upDegrees: number;
  165724. }
  165725. interface VRFrameData {
  165726. readonly leftProjectionMatrix: Float32Array;
  165727. readonly leftViewMatrix: Float32Array;
  165728. readonly pose: VRPose;
  165729. readonly rightProjectionMatrix: Float32Array;
  165730. readonly rightViewMatrix: Float32Array;
  165731. readonly timestamp: number;
  165732. }
  165733. interface VRPose {
  165734. readonly angularAcceleration: Float32Array | null;
  165735. readonly angularVelocity: Float32Array | null;
  165736. readonly linearAcceleration: Float32Array | null;
  165737. readonly linearVelocity: Float32Array | null;
  165738. readonly orientation: Float32Array | null;
  165739. readonly position: Float32Array | null;
  165740. readonly timestamp: number;
  165741. }
  165742. interface VRStageParameters {
  165743. sittingToStandingTransform?: Float32Array;
  165744. sizeX?: number;
  165745. sizeY?: number;
  165746. }
  165747. interface Navigator {
  165748. getVRDisplays(): Promise<VRDisplay[]>;
  165749. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  165750. }
  165751. interface Window {
  165752. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  165753. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  165754. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  165755. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  165756. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  165757. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  165758. }
  165759. interface Gamepad {
  165760. readonly displayId: number;
  165761. }
  165762. /**
  165763. * Available session modes
  165764. */
  165765. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  165766. /**
  165767. * Reference space types
  165768. */
  165769. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  165770. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  165771. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  165772. /**
  165773. * Handedness types
  165774. */
  165775. type XRHandedness = "none" | "left" | "right";
  165776. /**
  165777. * InputSource target ray modes
  165778. */
  165779. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  165780. /**
  165781. * Eye types
  165782. */
  165783. type XREye = "none" | "left" | "right";
  165784. /**
  165785. * Type of XR events available
  165786. */
  165787. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  165788. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  165789. type XRPlaneSet = Set<XRPlane>;
  165790. type XRAnchorSet = Set<XRAnchor>;
  165791. type XREventHandler = (callback: any) => void;
  165792. interface XRLayer extends EventTarget {}
  165793. interface XRSessionInit {
  165794. optionalFeatures?: string[];
  165795. requiredFeatures?: string[];
  165796. }
  165797. interface XRSessionEvent extends Event {
  165798. readonly session: XRSession;
  165799. }
  165800. interface XRSystem {
  165801. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  165802. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  165803. }
  165804. interface XRViewport {
  165805. readonly x: number;
  165806. readonly y: number;
  165807. readonly width: number;
  165808. readonly height: number;
  165809. }
  165810. interface XRWebGLLayerInit {
  165811. antialias?: boolean;
  165812. depth?: boolean;
  165813. stencil?: boolean;
  165814. alpha?: boolean;
  165815. multiview?: boolean;
  165816. framebufferScaleFactor?: number;
  165817. }
  165818. declare class XRWebGLLayer {
  165819. static getNativeFramebufferScaleFactor(session: XRSession): number;
  165820. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  165821. readonly antialias: boolean;
  165822. readonly framebuffer: WebGLFramebuffer;
  165823. readonly framebufferWidth: number;
  165824. readonly framebufferHeight: number;
  165825. readonly ignoreDepthValues: boolean;
  165826. getViewport: (view: XRView) => XRViewport;
  165827. }
  165828. // tslint:disable-next-line no-empty-interface
  165829. interface XRSpace extends EventTarget {}
  165830. interface XRRenderState {
  165831. readonly baseLayer?: XRWebGLLayer;
  165832. readonly depthFar: number;
  165833. readonly depthNear: number;
  165834. readonly inlineVerticalFieldOfView?: number;
  165835. }
  165836. interface XRRenderStateInit extends XRRenderState {
  165837. baseLayer: XRWebGLLayer;
  165838. depthFar: number;
  165839. depthNear: number;
  165840. inlineVerticalFieldOfView?: number;
  165841. layers?: XRLayer[];
  165842. }
  165843. interface XRReferenceSpace extends XRSpace {
  165844. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  165845. onreset: XREventHandler;
  165846. }
  165847. interface XRBoundedReferenceSpace extends XRSpace {
  165848. readonly boundsGeometry: DOMPointReadOnly[];
  165849. }
  165850. interface XRInputSource {
  165851. readonly handedness: XRHandedness;
  165852. readonly targetRayMode: XRTargetRayMode;
  165853. readonly targetRaySpace: XRSpace;
  165854. readonly gripSpace?: XRSpace;
  165855. readonly gamepad?: Gamepad;
  165856. readonly profiles: Array<string>;
  165857. readonly hand?: XRHand;
  165858. }
  165859. interface XRPose {
  165860. readonly transform: XRRigidTransform;
  165861. readonly emulatedPosition: boolean;
  165862. }
  165863. interface XRWorldInformation {
  165864. detectedPlanes?: XRPlaneSet;
  165865. }
  165866. interface XRFrame {
  165867. readonly session: XRSession;
  165868. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  165869. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  165870. // AR
  165871. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  165872. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  165873. // Anchors
  165874. trackedAnchors?: XRAnchorSet;
  165875. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  165876. // World geometries
  165877. worldInformation?: XRWorldInformation;
  165878. // Hand tracking
  165879. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  165880. }
  165881. interface XRInputSourceEvent extends Event {
  165882. readonly frame: XRFrame;
  165883. readonly inputSource: XRInputSource;
  165884. }
  165885. type XRInputSourceArray = XRInputSource[];
  165886. interface XRSession {
  165887. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  165888. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  165889. /**
  165890. * Returns a list of this session's XRInputSources, each representing an input device
  165891. * used to control the camera and/or scene.
  165892. */
  165893. readonly inputSources: Array<XRInputSource>;
  165894. /**
  165895. * object which contains options affecting how the imagery is rendered.
  165896. * This includes things such as the near and far clipping planes
  165897. */
  165898. readonly renderState: XRRenderState;
  165899. readonly visibilityState: XRVisibilityState;
  165900. /**
  165901. * Removes a callback from the animation frame painting callback from
  165902. * XRSession's set of animation frame rendering callbacks, given the
  165903. * identifying handle returned by a previous call to requestAnimationFrame().
  165904. */
  165905. cancelAnimationFrame: (handle: number) => void;
  165906. /**
  165907. * Ends the WebXR session. Returns a promise which resolves when the
  165908. * session has been shut down.
  165909. */
  165910. end(): Promise<void>;
  165911. /**
  165912. * Schedules the specified method to be called the next time the user agent
  165913. * is working on rendering an animation frame for the WebXR device. Returns an
  165914. * integer value which can be used to identify the request for the purposes of
  165915. * canceling the callback using cancelAnimationFrame(). This method is comparable
  165916. * to the Window.requestAnimationFrame() method.
  165917. */
  165918. requestAnimationFrame: XRFrameRequestCallback;
  165919. /**
  165920. * Requests that a new XRReferenceSpace of the specified type be created.
  165921. * Returns a promise which resolves with the XRReferenceSpace or
  165922. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  165923. * the requested space type isn't supported by the device.
  165924. */
  165925. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  165926. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  165927. onend: XREventHandler;
  165928. oninputsourceschange: XREventHandler;
  165929. onselect: XREventHandler;
  165930. onselectstart: XREventHandler;
  165931. onselectend: XREventHandler;
  165932. onsqueeze: XREventHandler;
  165933. onsqueezestart: XREventHandler;
  165934. onsqueezeend: XREventHandler;
  165935. onvisibilitychange: XREventHandler;
  165936. // hit test
  165937. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  165938. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  165939. // legacy AR hit test
  165940. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  165941. // legacy plane detection
  165942. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  165943. }
  165944. interface XRViewerPose extends XRPose {
  165945. readonly views: Array<XRView>;
  165946. }
  165947. declare class XRRigidTransform {
  165948. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  165949. position: DOMPointReadOnly;
  165950. orientation: DOMPointReadOnly;
  165951. matrix: Float32Array;
  165952. inverse: XRRigidTransform;
  165953. }
  165954. interface XRView {
  165955. readonly eye: XREye;
  165956. readonly projectionMatrix: Float32Array;
  165957. readonly transform: XRRigidTransform;
  165958. readonly recommendedViewportScale?: number;
  165959. requestViewportScale(scale: number): void;
  165960. }
  165961. interface XRInputSourceChangeEvent extends Event {
  165962. session: XRSession;
  165963. removed: Array<XRInputSource>;
  165964. added: Array<XRInputSource>;
  165965. }
  165966. // Experimental/Draft features
  165967. declare class XRRay {
  165968. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  165969. origin: DOMPointReadOnly;
  165970. direction: DOMPointReadOnly;
  165971. matrix: Float32Array;
  165972. }
  165973. declare enum XRHitTestTrackableType {
  165974. "point",
  165975. "plane",
  165976. "mesh",
  165977. }
  165978. interface XRHitResult {
  165979. hitMatrix: Float32Array;
  165980. }
  165981. interface XRTransientInputHitTestResult {
  165982. readonly inputSource: XRInputSource;
  165983. readonly results: Array<XRHitTestResult>;
  165984. }
  165985. interface XRHitTestResult {
  165986. getPose(baseSpace: XRSpace): XRPose | undefined;
  165987. // When anchor system is enabled
  165988. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  165989. }
  165990. interface XRHitTestSource {
  165991. cancel(): void;
  165992. }
  165993. interface XRTransientInputHitTestSource {
  165994. cancel(): void;
  165995. }
  165996. interface XRHitTestOptionsInit {
  165997. space: XRSpace;
  165998. entityTypes?: Array<XRHitTestTrackableType>;
  165999. offsetRay?: XRRay;
  166000. }
  166001. interface XRTransientInputHitTestOptionsInit {
  166002. profile: string;
  166003. entityTypes?: Array<XRHitTestTrackableType>;
  166004. offsetRay?: XRRay;
  166005. }
  166006. interface XRAnchor {
  166007. anchorSpace: XRSpace;
  166008. delete(): void;
  166009. }
  166010. interface XRPlane {
  166011. orientation: "Horizontal" | "Vertical";
  166012. planeSpace: XRSpace;
  166013. polygon: Array<DOMPointReadOnly>;
  166014. lastChangedTime: number;
  166015. }
  166016. interface XRJointSpace extends XRSpace {}
  166017. interface XRJointPose extends XRPose {
  166018. radius: number | undefined;
  166019. }
  166020. interface XRHand extends Iterable<XRJointSpace> {
  166021. readonly length: number;
  166022. [index: number]: XRJointSpace;
  166023. readonly WRIST: number;
  166024. readonly THUMB_METACARPAL: number;
  166025. readonly THUMB_PHALANX_PROXIMAL: number;
  166026. readonly THUMB_PHALANX_DISTAL: number;
  166027. readonly THUMB_PHALANX_TIP: number;
  166028. readonly INDEX_METACARPAL: number;
  166029. readonly INDEX_PHALANX_PROXIMAL: number;
  166030. readonly INDEX_PHALANX_INTERMEDIATE: number;
  166031. readonly INDEX_PHALANX_DISTAL: number;
  166032. readonly INDEX_PHALANX_TIP: number;
  166033. readonly MIDDLE_METACARPAL: number;
  166034. readonly MIDDLE_PHALANX_PROXIMAL: number;
  166035. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  166036. readonly MIDDLE_PHALANX_DISTAL: number;
  166037. readonly MIDDLE_PHALANX_TIP: number;
  166038. readonly RING_METACARPAL: number;
  166039. readonly RING_PHALANX_PROXIMAL: number;
  166040. readonly RING_PHALANX_INTERMEDIATE: number;
  166041. readonly RING_PHALANX_DISTAL: number;
  166042. readonly RING_PHALANX_TIP: number;
  166043. readonly LITTLE_METACARPAL: number;
  166044. readonly LITTLE_PHALANX_PROXIMAL: number;
  166045. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  166046. readonly LITTLE_PHALANX_DISTAL: number;
  166047. readonly LITTLE_PHALANX_TIP: number;
  166048. }
  166049. // This file contains native only extensions for WebXR. These APIs are not supported in the browser yet.
  166050. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  166051. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  166052. type XRSceneObjectType = "unknown" | "background" | "wall" | "floor" | "ceiling" | "platform";
  166053. interface XRSceneObject {
  166054. type: XRSceneObjectType;
  166055. }
  166056. interface XRFieldOfView {
  166057. angleLeft: number;
  166058. angleRight: number;
  166059. angleUp: number;
  166060. angleDown: number;
  166061. }
  166062. interface XRFrustum {
  166063. position: DOMPointReadOnly;
  166064. orientation: DOMPointReadOnly;
  166065. fieldOfView: XRFieldOfView;
  166066. farDistance: number;
  166067. }
  166068. interface XRPlane {
  166069. parentSceneObject?: XRSceneObject;
  166070. }
  166071. interface XRMesh {
  166072. meshSpace: XRSpace;
  166073. positions: Float32Array;
  166074. indices: Uint32Array;
  166075. normals?: Float32Array;
  166076. lastChangedTime: number;
  166077. parentSceneObject?: XRSceneObject;
  166078. }
  166079. interface XRFrustumDetectionBoundary {
  166080. type: "frustum";
  166081. frustum: XRFrustum;
  166082. }
  166083. interface XRSphereDetectionBoundary {
  166084. type: "sphere";
  166085. radius: number;
  166086. }
  166087. interface XRBoxDetectionBoundary {
  166088. type: "box";
  166089. extent: DOMPointReadOnly;
  166090. }
  166091. type XRDetectionBoundary = XRFrustumDetectionBoundary | XRSphereDetectionBoundary | XRBoxDetectionBoundary;
  166092. interface XRGeometryDetectorOptions {
  166093. detectionBoundary?: XRDetectionBoundary;
  166094. updateInterval?: number;
  166095. }
  166096. interface XRSession {
  166097. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  166098. trySetPreferredPlaneDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  166099. trySetMeshDetectorEnabled(enabled: boolean): boolean;
  166100. trySetPreferredMeshDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  166101. }
  166102. interface XRFrame {
  166103. featurePointCloud?: Array<number>;
  166104. }
  166105. type XRMeshSet = Set<XRMesh>;
  166106. interface XRWorldInformation {
  166107. detectedMeshes?: XRMeshSet;
  166108. }